You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: include/ERG_Mode.h
+48-30Lines changed: 48 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -14,29 +14,11 @@
14
14
#defineERG_MODE_LOG_CSV_TAG"ERG_Mode_CSV"
15
15
#definePOWERTABLE_LOG_TAG"PowTab"
16
16
#defineERG_MODE_DELAY700
17
-
#defineRETURN_ERROR -99
17
+
#defineRETURN_ERROR-99
18
18
19
19
extern TaskHandle_t ErgTask;
20
20
voidsetupERG();
21
-
voidergTaskLoop(void *pvParameters);
22
-
23
-
classErgMode {
24
-
public:
25
-
voidcomputErg(int newSetpoint);
26
-
void_writeLogHeader();
27
-
void_writeLog(int cycles, float currentIncline, float newIncline, int currentSetPoint, int newSetPoint, int currentWatts, int newWatts, int currentCadence, int newCadence);
28
-
29
-
private:
30
-
bool engineStopped = false;
31
-
bool initialized = false;
32
-
int setPoint = 0;
33
-
int cycles = 0;
34
-
int offsetMultiplier = 0;
35
-
Measurement watts = Measurement(0);
36
-
int cadence = 0;
37
-
38
-
bool_userIsSpinning(int cadence, float incline);
39
-
};
21
+
voidergTaskLoop(void* pvParameters);
40
22
41
23
classPowerEntry {
42
24
public:
@@ -46,15 +28,15 @@ class PowerEntry {
46
28
int readings;
47
29
48
30
PowerEntry() {
49
-
this->watts = 0;
31
+
this->watts= 0;
50
32
this->targetPosition = 0;
51
-
this->cad = 0;
52
-
this->readings = 0;
33
+
this->cad= 0;
34
+
this->readings= 0;
53
35
}
54
36
};
55
37
56
38
classPowerBuffer {
57
-
public:
39
+
public:
58
40
PowerEntry powerEntry[POWER_SAMPLES];
59
41
voidset(int);
60
42
voidreset();
@@ -63,19 +45,55 @@ class PowerBuffer {
63
45
classPowerTable {
64
46
public:
65
47
PowerEntry powerEntry[POWERTABLE_SIZE];
66
-
48
+
49
+
// Pick up new power value and put them into the power table
50
+
voidprocessPowerValue(PowerBuffer& powerBuffer, int cadence, Measurement watts);
51
+
52
+
// Sets stepper min/max value from power table
53
+
voidsetStepperMinMax();
54
+
67
55
// Catalogs a new entry into the power table.
68
-
voidnewEntry(PowerBuffer powerBuffer);
69
-
56
+
voidnewEntry(PowerBuffer& powerBuffer);
57
+
70
58
// returns incline for wattTarget. Null if not found.
void_writeLog(int cycles, float currentIncline, float newIncline, int currentSetPoint, int newSetPoint, int currentWatts, int newWatts, int currentCadence, int newCadence);
77
+
78
+
private:
79
+
bool engineStopped = false;
80
+
bool initialized = false;
81
+
int setPoint = 0;
82
+
int cycle = 0;
83
+
int offsetMultiplier = 0;
84
+
Measurement watts = Measurement(0);
85
+
int cadence = 0;
86
+
PowerTable* powerTable;
87
+
88
+
// check if user is spinning, reset incline if user stops spinning
89
+
bool_userIsSpinning(int cadence, float incline);
90
+
91
+
// calculate incline if setpoint (from Zwift) changes
92
+
void_setPointChangeState(int newSetPoint, int newCadence, Measurement& newWatts, float currentIncline);
93
+
94
+
// calculate incline if setpoint is unchanged
95
+
void_inSetpointState(int newSetPoint, int newCadence, Measurement& newWatts, float currentIncline);
96
+
97
+
// update localvalues + incline, creates a log
98
+
void_updateValues(int newSetPoint, int newCadence, Measurement& newWatts, float currentIncline, float newIncline);
0 commit comments