Fixed several buffer overflow issues

This commit is contained in:
2024-08-25 12:06:52 -04:00
parent a59a6657e8
commit 4d47b68600
6 changed files with 142 additions and 103 deletions

View File

@@ -90,6 +90,7 @@ template<uint32_t NUM_STACKS>
void BoardDriver<NUM_STACKS>::Init(){
for(uint32_t i = 0; i < NUM_STACKS; i++){
pinMode(this->stacks[i].ledPin, OUTPUT);
filteredReadings[i] = 0;
}
// begin doesn't really do anything besides setting the pinmode
@@ -159,7 +160,6 @@ uint32_t BoardDriver<NUM_STACKS>::GetNumberCubes(uint32_t stackIndex){
(static_cast<float>(this->filteredReadings[stackIndex]) * 0.9)
+ (static_cast<float>(value) * 0.1)
);
// temporary definitions to define value ranges:
uint16_t zeroCubesHigh = 4095;
uint16_t zeroCubesLow = 3400;
@@ -182,5 +182,6 @@ uint32_t BoardDriver<NUM_STACKS>::GetNumberCubes(uint32_t stackIndex){
stackHeight = 3;
}
this->filteredReadings[stackIndex] = lowPassADCRead;
return stackHeight;
}