~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/version-check-mode.c

  • Committer: Selene ToyKeeper
  • Date: 2023-11-04 15:09:10 UTC
  • mfrom: (483.1.175 anduril2)
  • Revision ID: bzr@toykeeper.net-20231104150910-ddd3afw4nhfvof2l
merged anduril2 branch -> fsm, with *years* of changes
(this also means this code is now Anduril 2 instead of Anduril 1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// version-check-mode.c: Version check mode for Anduril.
 
2
// Copyright (C) 2017-2023 Selene ToyKeeper
 
3
// SPDX-License-Identifier: GPL-3.0-or-later
 
4
 
 
5
#pragma once
 
6
 
 
7
#include "version-check-mode.h"
 
8
 
 
9
// empty state; logic is handled in FSM loop() instead
 
10
uint8_t version_check_state(Event event, uint16_t arg) {
 
11
    return EVENT_NOT_HANDLED;
 
12
}
 
13
 
 
14
// this happens in FSM loop()
 
15
inline void version_check_iter() {
 
16
    for (uint8_t i=0; i<sizeof(version_number)-1; i++) {
 
17
        uint8_t digit = pgm_read_byte(version_number + i) - '0';
 
18
        if (digit < 10) blink_digit(digit);
 
19
        else {  // "buzz" for non-numeric characters
 
20
            for(uint8_t frame=0; frame<25; frame++) {
 
21
                set_level((frame&1) << 5);
 
22
                nice_delay_ms(16);
 
23
            }
 
24
            nice_delay_ms(BLINK_SPEED * 8 / 12);
 
25
        }
 
26
        nice_delay_ms(300);
 
27
    }
 
28
 
 
29
    set_state_deferred(off_state, 0);
 
30
}
 
31