~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/misc.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
// misc.c: Misc extra functions 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 "misc.h"
 
8
 
 
9
/* no longer used
 
10
void blink_confirm(uint8_t num) {
 
11
    uint8_t brightness = actual_level;
 
12
    uint8_t bump = actual_level + BLINK_BRIGHTNESS;
 
13
    if (bump > MAX_LEVEL) bump = 0;
 
14
    for (; num>0; num--) {
 
15
        set_level(bump);
 
16
        delay_4ms(10/4);
 
17
        set_level(brightness);
 
18
        if (num > 1) { delay_4ms(100/4); }
 
19
    }
 
20
}
 
21
*/
 
22
 
 
23
// make a short, visible pulse
 
24
// (either brighter or darker, depending on current brightness)
 
25
void blink_once() {
 
26
    uint8_t brightness = actual_level;
 
27
    uint8_t bump = brightness + BLINK_BRIGHTNESS;
 
28
    if (bump > MAX_LEVEL) bump = 0;
 
29
 
 
30
    set_level(bump);
 
31
    delay_4ms(BLINK_ONCE_TIME/4);
 
32
    set_level(brightness);
 
33
}
 
34
 
 
35
// Just go dark for a moment to indicate to user that something happened
 
36
void blip() {
 
37
    uint8_t temp = actual_level;
 
38
    set_level(0);
 
39
    delay_4ms(3);
 
40
    set_level(temp);
 
41
}
 
42