+
+Theory of operation:
+
+After power-up, the firmware sets up the CPU and powers it down,
+waiting for a long button press. In this condition the system
+takes about 8uA from the 9V battery. So a typical 500 mAh 9V battery
+would last about 2604 days in this mode.
+
+When the button is pressed for a sufficiently long time, the CPU
+wakes up, switches the status LED on (providing visual feedback),
+and starts blinking.
+
+The firmware main loop is timed by ADC interrupt. It continuously measures
+the voltage on R55 feedback resistor, and adjusts the PWM value on OC1B
+to match the expected current through the LED string. Occasionally
+the ADC is switched to the battery voltage sensing, and the battery
+voltage is read. If the battery is critically low, the system
+is switched to the power-saving light pattern (see below).
+
+The step-up converter has four target values of current (2 mA,
+6 mA, 12 mA, and 20 mA as of this writing, see pwmled.c). The blinking pattern
+is adjusted separately from the target value in the firmware.
+
+The firmware recognizes short and long button presses. The short one
+cycles through all blinking modes, the long one switches the system off and on.
+
+The status LED has two blinking modes:
+- in the normal one, it is off by default, and uses a series of
+ short switch-on blinks to display the battery voltage
+ (the number of blinks is voltage above 7V in 0.5V steps).
+- when an error occurs, the status LED stays on by default, and displays
+ the error condition as a series of short switch-off blinks:
+ - one blink is a "power low" condition
+ - three blinks is "step-up error" (a LED string disconnected,
+ for example).
+- when the long (-enough) button press is detected, i.e. when powering on
+ or off, the LED is switched on to provide a visual feedback
+ of long-enough button press.
+
+The blinking modes and patterns are currently set up as follows:
+1. power-saving minimal mode
+ - a single short blink at minimum current
+2. blinking mode 1
+ - 2 and 3 blinks at the second-lowest current
+3. blinking mode 2
+ - 2 and 3 blinks at the third-lowest current
+4. blinking mode 3
+ - 2 and 3 blinks at the highest current
+5. steady light at the minimum current
+6. steady light at the second-lowest current
+7. steady light at the third-lowest current
+8. steady light at the highest current
+
+The system starts up set to mode 3, and switches to mode 1 when
+the power is critically low. Other modes can be chosen via short
+button press.
+