Skip to content

Commit 6c4ac59

Browse files
committed
Space reduction: Remove iostream include in speed_calc, replace ints
1 parent 1cf5d43 commit 6c4ac59

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

include/speed_calc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ void startSpeedCalculation();
1919
// Starts speed (RPM and MPH) calculations at specified interval
2020
extern volatile float rpm;
2121
extern volatile float mph;
22-
extern volatile unsigned int previousPulses[ARRAY_SIZE];
22+
extern volatile uint8_t previousPulses[ARRAY_SIZE];
2323

2424
#endif

src/speed_calc.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "speed_calc.h"
2-
#include <iostream>
32

4-
volatile int speedPulses = 0;
3+
volatile uint8_t speedPulses = 0;
54
volatile float rpm = 0;
65
volatile float mph = 0;
76

8-
volatile unsigned int previousPulses[ARRAY_SIZE];
7+
volatile uint8_t previousPulses[ARRAY_SIZE];
98

109
STM32TimerInterrupt speedCalcTimer(TIM1);
1110

@@ -15,8 +14,8 @@ void increment() {
1514

1615
void calculateSpeed(){
1716
// 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;
2019

2120
// Replaces oldest pulse in pulse counter array with a new one
2221
calculationCounter = (calculationCounter + 1) % ARRAY_SIZE;

0 commit comments

Comments
 (0)