add shake stay awake time
This commit is contained in:
parent
9b16b17628
commit
c7f6a3ae38
7
main.c
7
main.c
|
@ -44,6 +44,8 @@
|
|||
static volatile uint16_t shake_count = 0;
|
||||
// number of time counts (+1 @ 488 Hz)
|
||||
static volatile uint32_t time_count = 0;
|
||||
// last time the badge was shook
|
||||
static volatile uint32_t time_shake = 0;
|
||||
|
||||
// time after last shake to go to sleep, in seconds
|
||||
#define REST_TIME (5 * 60U)
|
||||
|
@ -420,6 +422,7 @@ void main(void)
|
|||
puts("vibrations: ");
|
||||
puth(shake_count);
|
||||
puts("\r\n");
|
||||
time_shake = time_count; // remember time to stay awake
|
||||
shake_count = 0; // reset count
|
||||
}
|
||||
if (nec_flag) {
|
||||
|
@ -488,9 +491,7 @@ void main(void)
|
|||
putc('m');
|
||||
action = true; // redo main loop
|
||||
}
|
||||
if (time_count > 488UL * REST_TIME && !master) {
|
||||
puts("rest\r\n");
|
||||
time_count = 0; // reset counter
|
||||
if (time_count > time_shake + 488UL * REST_TIME && !master) {
|
||||
LED_UV_PORT->ODR.reg &= ~LED_UV_PIN; // switch UV LED off
|
||||
IRM_ON_PORT->ODR.reg &= ~IRM_ON_PIN; // switch IR demodulator off
|
||||
led_red(0); // ensure LED is off
|
||||
|
|
Loading…
Reference in New Issue