~toykeeper/flashlight-firmware/fsm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
From off:

  Ramp shortcuts:
  * 1 click: memorized level
  * Hold: lowest level then ramp up
  * 2 clicks: highest ramp level
  * Click, hold: highest level then ramp down

  Blinkies:
  * 3 clicks: specials (battcheck, goodnight, beacon, tempcheck)
  * Click, click, hold: strobes
    (candle mode, bike flasher, party strobe, tactical strobe,
     lightning storm mode)
    (remembers which you last used)

  Other:
  * 4 clicks: lock-out
  * 5 clicks: momentary mode (disconnect power to exit)
  * 6 clicks: muggle mode
  * On hardware with an indicator LED...
    * 7 clicks: Change aux LED mode used in "off" mode.
                (the modes are usually off/low/high/blinking)
    * 7 clicks (but hold the last click):
        Change aux LED color used in "off" mode.

In steady / ramping mode:
  * 1 click: off
  * Hold: ramp up
  * Click, hold: ramp down
  * 2 clicks: to/from turbo (actual turbo, not just highest ramp level)
  * 3 clicks: toggle smooth vs discrete ramping
  * 4 clicks: configure current ramp
  * 5 clicks: activate manual memory and save current brightness
  * 5 clicks (but hold the last click): go back to automatic memory

Smooth ramp config mode:
  * Setting 1: low end
    (click N times to set ramp floor to level N)
  * Setting 2: high end
    (click N times to set ramp ceiling to level "151 - N")

Discrete ramp config mode:
  * Setting 1: low end
    (click N times to set ramp floor to level N)
  * Setting 2: high end
    (click N times to set ramp ceiling to level "151 - N")
  * Setting 3: number of levels in discrete ramp
    (click N times to make discrete mode have N stair-steps)
    (minimum 2, maximum 150)

"Strobe" group modes:

  Candle mode:
    * 1 click: off
    * 2 clicks: next "strobe" group mode
    * 3 clicks: add 30 minutes to the timer
                (light will shut off when timer expires)
                (default is no timer)
    * Hold: brighter
    * Click, hold: dimmer

  Bike flasher:
    * 1 click: off
    * 2 clicks: next "strobe" group mode
    * Hold: brighter
    * Click, hold: dimmer

  Party / Tactical strobe modes:
    * 1 click: off
    * Hold: change speed (faster)
    * Click, hold: change speed (slower)
    * 2 clicks: next "strobe" group mode
      (TODO: random/police strobe?)

  Lightning storm mode:
    * 1 click: off
    * 2 clicks: next "strobe" group mode

"Blinky" group modes:

  Battcheck mode:
    * 1 click: off
    * 2 clicks: goodnight mode

  Goodnight mode:
    * 1 click: off
    * 2 clicks: beacon mode

  Beacon mode:
    * 1 click: off
    * 2 clicks: tempcheck mode
    * 4 clicks: configure time between pulses

    Beacon config mode:
      * At buzz, click N times to set beacon frequency to N seconds.

  Tempcheck mode:
    * 1 click: off
    * 2 clicks: battcheck mode
    * 4 clicks: thermal config mode

    Thermal config mode:
      * Setting 1: calibrate sensor:
        At buzz, click N times for N degrees C.  For example, if the light 
        is current at "room temperature" of 22 C, click 22 times.  Is 
        intended to only be done once upon initial setup, or not at all.
      * Setting 2: temperature limit:
        At buzz, click N times to set thermal limit to roughly 30 C + N.

Lockout mode:
  * Hold: momentary moon (current ramp floor)
  * Click, Hold: momentary moon (other ramp floor)
  * 4 clicks: exit lockout (return to regular "off" mode)
  * On hardware with an indicator LED...
    * 3 clicks: Change aux LED brightness used in lockout mode.
                (the modes are usually off/low/high/blinking)
    * 3 clicks (but hold the last click):
        Change aux LED color used in lockout mode.

Momentary mode:
  * Press button: Light on (at memorized mode/level).
    (uses either a steady mode or a strobe-group mode)
  * Release button: Light off.
  * To exit, disconnect power.  (loosen/tighten the tailcap)

Muggle mode:
  * 1 click: On / off.
  * Hold: Ramp up / down.
  * 6 clicks: Exit muggle mode.

Indicator LED / aux LED support:

  The indicator LED (button LED), if there is one, tracks the brightness 
  of the main LED(s) during use.  It'll be off, low, or high depending 
  on whether the main emitter is off, using only the first power 
  channel, or using a higher level.

  If front-facing aux LEDs are present, they stay off while the main 
  light is on.  They only turn on when the main emitters are off.

  The indicator LED can stay on when the light is in the "off" state or 
  "lockout" state.  These modes can have different settings, to make it 
  easier to see which one the light is in.  To configure it:

    1. Go to the standby mode you want to configure.  This is either 
       "off" or "lockout".
    2. In "off" mode, click 7 times to switch to the next aux LED mode.
       Or in "lockout" mode, click 3 times.
    3. Repeat step 2 until the desired mode is reached.

  The available aux LED / indicator LED modes vary depending on the type 
  of light, but they typically have the following modes:

    - Off
    - Low
    - High
    - Blinking

  If the aux LEDs can change color, the user can configure the color 
  using exactly the same method...  except hold the last click until the 
  desired color is reached.


TODO:
  - change 6C to 6H for exiting muggle mode?
  - move muggle mode from 6C to ... 8C or something?
  - add 4H from lockout to turn light on and start ramping up?
  - move config modes to 5C instead of 4C, and move manual memory to 4C?
  - remove beacon config mode, and use a hold to set timing instead?
  - rewrite muggle mode to split it into on and off states
  * save settings in eeprom
  * decide on "hold until hot" or "click N times" for thermal config mode
  * test thermal regulation on an actual light
  * improve thermal regulation
  - a way to blink out the firmware version?
  * indicator LED support
  * a way to configure indicator LED behavior
    * Go to lockout mode, then click three times.  Hold the third click 
      to change regular "off" brightness, or make it a fast click to 
      change lockout mode brightness.
  * add goodnight mode?
  * add lightning mode?
  * muggle mode: smooth ramp
  * refactor to make config modes smaller
  * move all config menus to four clicks
  * candle mode timer, with three clicks to add 30 minutes
  * diagram updates for 3-click special actions
  * add a toggle for memory (manual vs automatic memory)
  - candle mode: smoother adjustments?
  - make sunset mode timer and brightness configurable?
  - make beacon mode actually sleep between pulses