FIX: do not overrun daily history
This commit is contained in:
parent
036f5c9bf4
commit
ba91310389
@ -196,6 +196,10 @@ int main(void) {
|
||||
io::RelayChannel tankPump(OCHAN0_GPIO_Port, OCHAN0_Pin, true, io::RelayChannel::state::OFF);
|
||||
io::RelayChannel refillPump(OCHAN1_GPIO_Port, OCHAN1_Pin, false, io::RelayChannel::state::OFF);
|
||||
|
||||
//Initially switch relays off by forcing a refresh
|
||||
tankPump.forceRefresh();
|
||||
refillPump.forceRefresh();
|
||||
|
||||
uint32_t last_menu_retrigger = 0;
|
||||
uint32_t last_backlight_retrigger = 0;
|
||||
|
||||
@ -214,6 +218,7 @@ int main(void) {
|
||||
|
||||
static uint16_t old_minute_counter = minute_counter;
|
||||
|
||||
|
||||
SendUartString(&huart1, "Hello from FloatPUMP Controller");
|
||||
SendUartString(&huart1, {"Revision: " GIT_HASH});
|
||||
|
||||
@ -288,6 +293,12 @@ int main(void) {
|
||||
last_menu_retrigger = HAL_GetTick();
|
||||
while (true) {
|
||||
//Display menu until timeout
|
||||
tankPump.switchRelay(floatpump::io::RelayChannel::state::OFF);
|
||||
refillPump.switchRelay(floatpump::io::RelayChannel::state::OFF);
|
||||
//Force refresh
|
||||
tankPump.forceRefresh();
|
||||
refillPump.forceRefresh();
|
||||
|
||||
controller.execute();
|
||||
if (rot_button) {
|
||||
rot_button = false;
|
||||
@ -330,6 +341,9 @@ int main(void) {
|
||||
|
||||
if (HAL_GetTick() > last_menu_retrigger + 10000) {
|
||||
display.LCDClearDisplay();
|
||||
//Force relay refresh to apply inverted outputs immediately
|
||||
tankPump.forceRefresh();
|
||||
refillPump.forceRefresh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -354,7 +368,7 @@ int main(void) {
|
||||
//Calculate diff to value 1h ago -> minute_counter+1's entry is always 60mins ago !
|
||||
diff_hist_hour = history_h[minute_counter % 60] - history_h[(minute_counter + 1) % 60];
|
||||
//Same here for daily history
|
||||
diff_hist_day = history_d[minute_counter / 60] - history_d[(minute_counter + 60) / 60];
|
||||
diff_hist_day = history_d[(minute_counter / 60) % 24] - history_d[((minute_counter + 60) / 60) % 24];
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||
|
Loading…
Reference in New Issue
Block a user