diff --git a/main.c b/main.c index 4a9287d..1132cd4 100644 --- a/main.c +++ b/main.c @@ -42,6 +42,9 @@ static volatile uint16_t shake_count = 0; // number of time counts (+1 @ 488 Hz) static volatile uint32_t time_count = 0; +// time after last shake to go to sleep, in seconds +#define REST_TIME (5 * 60U) + // blocking wait (in 10 us steps, up to UINT32_MAX / 10) static void wait_10us(uint32_t us10) { @@ -254,9 +257,10 @@ void main(void) puts("\r\n"); shake_count = 0; // reset count } - if (time_count > 488 * 10) { - puts("10s\r\n"); + if (time_count > 488UL * REST_TIME) { + puts("rest\r\n"); time_count = 0; // reset counter + LED_UV_PORT->ODR.reg &= ~LED_UV_PIN; // switch UV LED off led_red(0); // ensure LED is off led_green(0); // ensure LED is off led_blue(0); // ensure LED is off @@ -283,7 +287,7 @@ void shake_isr(void) __interrupt(SHAKE_IRQ) shake_count++; // register vibration } -// time counter +// system time counter void time_isr(void) __interrupt(IRQ_TIM4) { TIM4->SR.fields.UIF = 0; // clear flag