Skip to content

Commit

Permalink
Merge pull request #141 from nlesc-recruit/fix-all-sensors-inactive
Browse files Browse the repository at this point in the history
Do not update display when all sensors are inactive to avoid infinite loop
  • Loading branch information
loostrum authored Jul 28, 2023
2 parents 69386dc + da85087 commit 2e52ebe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion device/PowerSensor/PowerSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ bool sendData = false;
bool streamValues = false;
bool sendSingleValue = false;
bool sendMarkerNext = false;
bool allSensorsInactive = false;

// include device-specific code for setting up the ADC and DMA
#if defined STM32F401xC || defined STM32F411xE
Expand Down Expand Up @@ -302,6 +303,14 @@ void configureDevice() {
LL_ADC_Enable(ADC2);
#endif
LL_ADC_REG_StartConversionSWStart(ADC1);
checkActiveSensors();
}

void checkActiveSensors() {
allSensorsInactive = true;
for (int pair=0; pair < PAIRS; pair++) {
allSensorsInactive &= !(eeprom.sensors[2 * pair].inUse & eeprom.sensors[2 * pair + 1].inUse);
}
}


Expand Down Expand Up @@ -382,7 +391,7 @@ void loop() {
serialEvent();
// update display if enabled
#ifndef NODISPLAY
if (!displayPaused) {
if (!displayPaused && !allSensorsInactive) {
updateDisplay();
}
#endif
Expand Down

0 comments on commit 2e52ebe

Please sign in to comment.