diff options
| author | Selene ToyKeeper | 2020-03-16 03:17:14 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-03-16 03:17:14 -0600 |
| commit | 84f9a0c9daf991b23d665a5dffdb3b76e6753491 (patch) | |
| tree | 40828ea70c3b3a34f276de4d3f5537f64275ed6a /spaghetti-monster | |
| parent | deleted commented-out WDT code from previous revision (diff) | |
| download | anduril-84f9a0c9daf991b23d665a5dffdb3b76e6753491.tar.gz anduril-84f9a0c9daf991b23d665a5dffdb3b76e6753491.tar.bz2 anduril-84f9a0c9daf991b23d665a5dffdb3b76e6753491.zip | |
increased blink speed slightly, and added a library function to blink out 16-bit numbers
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/fsm-misc.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 8da7b5b..152f047 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -46,19 +46,41 @@ uint8_t blink_digit(uint8_t num) { //StatePtr old_state = current_state; // "zero" digit gets a single short blink - uint8_t ontime = BLINK_SPEED * 2 / 10; + uint8_t ontime = BLINK_SPEED * 2 / 12; if (!num) { ontime = 8; num ++; } for (; num>0; num--) { set_level(BLINK_BRIGHTNESS); nice_delay_ms(ontime); set_level(0); - nice_delay_ms(BLINK_SPEED * 3 / 10); + nice_delay_ms(BLINK_SPEED * 3 / 12); } - return nice_delay_ms(BLINK_SPEED * 5 / 10); + return nice_delay_ms(BLINK_SPEED * 8 / 12); } #endif +#ifdef USE_BLINK_BIG_NUM +uint8_t blink_big_num(uint16_t num) { + uint16_t digits[] = { 10000, 1000, 100, 10, 1 }; + uint8_t started = 0; + for (uint8_t digit=0; digit<sizeof(digits)/sizeof(uint16_t); digit++) { + uint16_t scale = digits[digit]; + if (num >= scale) { + started = 1; + } + if (started) { + uint8_t digit = 0; + while (num >= scale) { + num -= scale; + digit ++; + } + if (! blink_digit(digit)) return 0; + } + } + + return nice_delay_ms(1000); +} +#endif #ifdef USE_BLINK_NUM uint8_t blink_num(uint8_t num) { //StatePtr old_state = current_state; |
