From b8be7983e8ab14b3324c1da147cb3119046229e2 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 23 Jun 2012 09:27:26 +0200 Subject: src/binwatch: make unwanted time setting harder --- src/binwatch/binwatch.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/binwatch/binwatch.c b/src/binwatch/binwatch.c index 049c8b3..08b0740 100644 --- a/src/binwatch/binwatch.c +++ b/src/binwatch/binwatch.c @@ -31,6 +31,8 @@ #define BINWATCH_ANIM_SPEED (LED_100MS / 2) #define BINWATCH_UI_SPEED (LED_1S / 2) +#define BINWATCH_SET_TIME_STEPS 3 + /** Format time in leds format. */ static uint16_t binwatch_format_time (uint8_t hour, uint8_t minute) @@ -128,19 +130,36 @@ main (void) led_display (time, BINWATCH_TIME_DISPLAY_DUR); } /* Wait user press to display time. */ + uint8_t set_time_step = 0; while (1) { uint16_t press_ms = button_wait (); if (press_ms < 5000) { + /* Short press, display time. */ time = binwatch_get_time (); led_animate (time, LED_ANIMATION_TRACE_CCW, BINWATCH_ANIM_SPEED); led_display (time, BINWATCH_TIME_DISPLAY_DUR); + set_time_step = 0; + } + else if (press_ms < 10000) + { + /* Long press, if done several time in a row, set time. + * This is done to avoid unwanted set time. */ + set_time_step++; + if (set_time_step >= BINWATCH_SET_TIME_STEPS) + { + binwatch_set_time_ui (); + set_time_step = 0; + } + else + led_display (0x3c0, BINWATCH_UI_SPEED); } else { - binwatch_set_time_ui (); + /* Very long press, must be unintended. */ + set_time_step = 0; } } } -- cgit v1.2.3