Skip to content

Commit

Permalink
uint
Browse files Browse the repository at this point in the history
  • Loading branch information
Benhalor committed Mar 28, 2024
1 parent 7888eb5 commit cf7b33d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
Empty file modified flash.sh
100644 → 100755
Empty file.
26 changes: 13 additions & 13 deletions includes/pressure_valve.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class PressureValve {
PressureValve(HardwareTimer* p_hardwareTimer,
uint16_t p_timerChannel,
uint16_t p_valvePin,
uint16_t p_openApertureAngle,
uint16_t p_closeApertureAngle);
int16_t p_openApertureAngle,
int16_t p_closeApertureAngle);
/**
* Initialize this valve
*
Expand All @@ -68,7 +68,7 @@ class PressureValve {
*
* @param p_command The angle in degree
*/
void open(uint16_t p_command);
void open(int16_t p_command);

/**
* Request opening of the Pressure Valve with a given angle with linearization
Expand All @@ -87,35 +87,35 @@ class PressureValve {
*/
void execute();
void openSection(int32_t p_sectionMultiplyBy100);
uint16_t openLinear(uint16_t p_command);
int16_t openLinear(int16_t p_command);

/// Minimum valve aperture angle in degrees
inline uint16_t minAperture() const { return minApertureAngle; }
inline int16_t minAperture() const { return minApertureAngle; }

/// Maximum valve aperture angle in degrees
inline uint16_t maxAperture() const { return maxApertureAngle; }
inline int16_t maxAperture() const { return maxApertureAngle; }

/// Value of the requested aperture
uint16_t command;
int16_t command;

/// Current aperture
uint16_t position;
int16_t position;

/// Current aperture linear
uint16_t positionLinear;
int16_t positionLinear;

private:
/// Minimum valve aperture angle in degrees
uint16_t minApertureAngle;
int16_t minApertureAngle;

/// Maximum valve aperture angle in degrees
uint16_t maxApertureAngle;
int16_t maxApertureAngle;

/// Open aperture angle in degrees
uint16_t openApertureAngle;
int16_t openApertureAngle;

/// Close aperture angle in degrees
uint16_t closeApertureAngle;
int16_t closeApertureAngle;

/// Hardware time for this valve
HardwareTimer* actuator;
Expand Down
20 changes: 10 additions & 10 deletions srcs/pressure_valve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ PressureValve::PressureValve() {}
PressureValve::PressureValve(HardwareTimer* p_hardwareTimer,
uint16_t p_timerChannel,
uint16_t p_valvePin,
uint16_t p_openApertureAngle,
uint16_t p_closeApertureAngle) {
int16_t p_openApertureAngle,
int16_t p_closeApertureAngle) {
actuator = p_hardwareTimer;
timerChannel = p_timerChannel;
valvePin = p_valvePin;
Expand All @@ -65,10 +65,10 @@ void PressureValve::setup() {


// Linearization has been made experimentaly
uint16_t PressureValve::openLinear(uint16_t p_command) {
uint16_t cappedCommand =
int16_t PressureValve::openLinear(int16_t p_command) {
int16_t cappedCommand =
// cppcheck-suppress misra-c2012-12.3 ; cppcheck error
min(max(uint16_t(minApertureAngle), p_command), uint16_t(maxApertureAngle));
min(max(int16_t(minApertureAngle), p_command), int16_t(maxApertureAngle));

positionLinear = cappedCommand;
// The cappedCommand is in [ 0 ; 125 ], but the valve is only effective in [30; 100]
Expand Down Expand Up @@ -108,7 +108,7 @@ uint16_t PressureValve::openLinear(uint16_t p_command) {
Then when made an order 3 regression between correctedOpenningValue and openningValue. This
is the relation below:
*/
command = (uint16_t)(
command = (int16_t)(
(((76u * intermediateValue) / 10u)
- (((985u * intermediateValue) * intermediateValue) / 100000u)
+ (((((44u * intermediateValue) * intermediateValue) / 1000u) * intermediateValue)
Expand All @@ -117,7 +117,7 @@ uint16_t PressureValve::openLinear(uint16_t p_command) {
/ 10u);

// cppcheck-suppress misra-c2012-12.3 ; cppcheck error
command = min(max(uint16_t(minApertureAngle), command), uint16_t(maxApertureAngle));
command = min(max(int16_t(minApertureAngle), command), int16_t(maxApertureAngle));

return command;
}
Expand Down Expand Up @@ -145,10 +145,10 @@ void PressureValve::openSection(int32_t p_sectionMultiplyBy100) {
}

void PressureValve::execute() {

// Position milieu - les deux vannes sont ouvertes
int Pos_dxl_valve_open = 2048 ;
// Position vanne expiratoire fermée
// Position vanne expiratoire fermée
int Pos_dxl_exp_valve_closed = 2300;
// Position vanne insipratoire fermée
int Pos_dxl_insp_valve_closed = 1800;
Expand All @@ -173,7 +173,7 @@ void PressureValve::open() { command = openApertureAngle; }

void PressureValve::close() { command = closeApertureAngle; }

void PressureValve::open(uint16_t p_command) { command = p_command; }
void PressureValve::open(int16_t p_command) { command = p_command; }



Expand Down

0 comments on commit cf7b33d

Please sign in to comment.