This is a page that is being worked on to help modify the BLF-VLD code. This is just a DRAFT.

The code is written without any brownout detection. In other words, the program has no idea how long the light has been off. Because the program has no warning when you will turn off the light, it has to store information in permanent memory as it goes. The "watchdog" monitors what is going on every 250 milliseconds. So at first it writes down that the light has only been on for an instant (in case the light is turned off immediately thereafter). Then after the light has been on for a second, it records that the light has been left on for a long dash (this is important programming the light), and once the light has been on for more than 2 seconds, any attempt at programming is abandoned and the mode the light is currently in is memorized.

Once the light is turned back on, the program checks to see if it was on for more than 2 seconds last time, and if so, comes on in the stored mode. If it was on for less than 2 seconds, a couple of things could happen. First, you could be in programming mode. So it checks to see if variables have been stored that indicate that is the case. If that is not the case, then you are probably changing modes, so it will go ahead and change modes, and store the value of the new mode in case you do another blink and change modes again.

Strobe, SOS, Alpine, and Fade are all functions that are run by the software, as opposed to simple output levels.

Variables

mode index of last mode used
target_mode index of slot to be reprogrammed
chosen_mode index of chosen mode-line to be stored ???(what are mode-lines?)
prog_stage keep track of programming stages
extended keeps track of whether to use standard or extended modes
ext_mode current mode-line in extended mode
click number of clicks (short taps) so far
click_cell index of currently used cell for click detection ??? (what are cells?)
last_click type of last click (short, long, or none)
mode_arr array holding offsets to the mode lines for the configured modes