File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,6 @@ void startSpeedCalculation();
19
19
// Starts speed (RPM and MPH) calculations at specified interval
20
20
extern volatile float rpm ;
21
21
extern volatile float mph ;
22
- extern volatile unsigned int previousPulses [ARRAY_SIZE ];
22
+ extern volatile uint8_t previousPulses [ARRAY_SIZE ];
23
23
24
24
#endif
Original file line number Diff line number Diff line change 1
1
#include " speed_calc.h"
2
- #include < iostream>
3
2
4
- volatile int speedPulses = 0 ;
3
+ volatile uint8_t speedPulses = 0 ;
5
4
volatile float rpm = 0 ;
6
5
volatile float mph = 0 ;
7
6
8
- volatile unsigned int previousPulses[ARRAY_SIZE];
7
+ volatile uint8_t previousPulses[ARRAY_SIZE];
9
8
10
9
STM32TimerInterrupt speedCalcTimer (TIM1);
11
10
@@ -15,8 +14,8 @@ void increment() {
15
14
16
15
void calculateSpeed (){
17
16
// Variable to track array update position
18
- static int calculationCounter = 0 ;
19
- static unsigned int runningSum = 0 ;
17
+ static uint8_t calculationCounter = 0 ;
18
+ static uint16_t runningSum = 0 ;
20
19
21
20
// Replaces oldest pulse in pulse counter array with a new one
22
21
calculationCounter = (calculationCounter + 1 ) % ARRAY_SIZE;
You can’t perform that action at this time.
0 commit comments