~toykeeper/flashlight-firmware/trunk

248 by Selene Scriven
imported "rampinglight" firmware from SammysHP
1
# Firmware for ATtiny13-based flashlights
2
3
This firmware is compatible with the driver commonly found in Convoy flashlights like the S2+ or C8+. More specifically it expects an ATtiny13 microcontroller, single PWM output on PB1, (optionally) voltage devider on PB2 and a single on/off switch. The microcontroller must run at 4.8 MHz (fuses H:FF L:75).
4
5
6
## Features
7
8
- Two modes of operation: ramping and fixed levels
9
- Turbo mode: immediately switch to maximum output
10
- Battery check: one to four flashes
11
- Low voltage protection: flicker every 15 seconds if the voltage is low and turn off if the voltage is critical
12
- Mode memory: start with last frozen ramp value or with last fixed level (off-time memory)
13
- Stop at ramp end: in ramping UI, stop if ramping reaches minimum or maximum output
14
- Start at high: after the flashlight was off, start with the highest output (and go from high to low)
15
- Beacon mode: low background light with regular flashes
16
- Tactical strobe: if enabled, always start with fast strobe mode
17
- Runtime configuration: options can be toggled via configuration menu
18
19
20
## Operation
21
22
### Configuration menu
23
24
1. Turn the light on
25
1. Shortly tap the switch 10+ times, the light will turn off
26
1. The light starts counting via flashes, each group followed by a short burst of flashes. Turn off the light during the burst to toggle the option. Options are:
27
    1. Start with strobe
28
    1. Ramping or fixed levels
29
    1. Mode memory on or off
30
    1. Freeze on ramp end
31
    1. Start on high
32
    1. Stealth beacon mode
33
    1. Slow beacon mode
34
35
The default is: no strobe, ramping UI, no mode memory, do not freeze on ramp end, start on low, no stealth beacon, no slow beacon
36
37
38
### Ramping UI
39
40
Turn the light on and it will start ramping up and down. Short tap the switch to freeze the current brightness. Tap again to resume ramping. The direction of ramping will be reset after one second in fixed state.
41
42
The default is to ramp down from the current level, except if set to "start on high". Or in other words: It will ramp into the direction of the initial brightness. This also means that it will ramp up if "start on high" is not set because it is already at the floor (and vice versa if "start on high" is set).
43
44
Tap three times to go into turbo mode. There is no timer, so make sure to monitor the temperature. Tap again to go back to ramping.
45
46
If "start on high" is enabled, the light starts with the highest level and ramps down.
47
48
Enable "freeze on ramp end" to stop ramping when reaching the lowest or highest level.
49
50
51
### Fixed level UI
52
53
There are four brightness levels in the fixed mode:
54
55
1. Low
56
1. Medium
57
1. High
58
1. Turbo
59
60
Turn the light on, it starts with a fixed output level. Tap the button to switch to next level. After the highest level it will start with the lowest level again. If "start on high" is enabled, the light starts with the highest level and the order of levels is reversed.
61
62
63
### Battery check
64
65
Tap six times to enter battery check mode. The flashlight starts blinking one to four times. The number of flashes corresponds to the remaining capacity / current voltage:
66
67
- 4 flashes: above 4.0 V (75%)
68
- 3 flashes: above 3.8 V (50%)
69
- 2 flashes: above 3.5 V (25%)
70
- 1 flashes: below 3.5 V
71
72
Tap again to return to normal flashlight mode.
73
74
75
### Beacon mode
76
77
Tap five times to enter beacon mode. In this mode the flashlights runs at low intensity and flashes every second. Tap again to return to normal flashlight mode.
78
79
There are two options to change this behavior: Stealth beacon which turns off the light completely inbetween the flashes and slow mode that flashes only every two seconds.
80
81
82
### Strobe mode
83
84
If users want a strobe mode, they usually want it for defence purposes. Thus it should be possible to enter it as fast as possible.
85
86
If strobe is enabled in the preferences, the flashlight always starts in a fast strobe mode. Then a single press of the power switch enters normal flashlight mode.
87
88
89
### Low voltage protection
90
91
If the voltage is below 3.2 V the flashlight will flicker for half a second every 15 seconds. If the voltage is below 2.7 V the light will turn off and flash regularly to notify the operator that the light is still turned on but the battery is empty.
92
93
94
## Development
95
96
TODO
97
98
99
## License and acknowledgments
100
101
Thanks to ToyKeeper who was a great inspiration while writing this code. Her [flashlight firmware repository](https://launchpad.net/flashlight-firmware) contains a huge collection of flashlight firmwares.
102
103
Copyright (c) 2018 Sven Karsten Greiner  
104
This code is licensed under GPL 3 or any later version, see COPYING for details.