From eed54353350694d75f38ae27868e2cb98b0562fb Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Thu, 30 Jul 2020 21:41:50 +0200 Subject: [PATCH] fw: Implement main loop scheduler --- firmware/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index e25f14b..8c94a35 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -83,6 +83,7 @@ void lcd_title(const char *msg1, const char *msg2) int main() { char *post_msg; + uint8_t sched = 0; MCUSR &= ~(1 << WDRF); WDTCSR = (1 << WDCE); @@ -108,8 +109,20 @@ int main() while (1) { if (!spi_proc()) { - timer_proc(); - input_proc(); + switch (sched) { + case 0: + timer_proc(); + break; + case 1: + input_proc(); + break; + } + } + sched = sched + 1; + if (sched == 4) { + sched = 0; + if (batmon_proc()) + reset(); } } return 0;