Light Tower 3.0 - display mode 0 + Precision LED blinking +Advanced AVR time management Nixie tube
A led (the Dot led on a 7-segment) is used to display a number from 0-5 by the numbers of blinks. This is a simple idea, but can be very complicated to code, but with TM3, this is more than a piece of cake. 4Hz is picked for the blinking frequency because this is more easier for a human to read/count; so a 5 blinks at 4Hz is exactly 5*(1/4)*2=2.5 seconds, and to add a 1 second as blank, it requires 3.5 seconds to achieve such idea. 1 blink takes 1*(1/4)=0.25 second, so the maximum timing interval can not be fixed at 3.5 second, or the blanking period for 1 blink would be too long. Final challenge is to have these timing synchronize, so that the LED blinks at exactly the time frame at exactly the frequency.
Therefore this simple idea is simple, but is actually very complicated, and TM3 makes it easy again. The key here is to use few variables incrementing at the same time, but at different rate. Same time is not exactly the same nano second, but within 100us is more than sufficient. A synchronized counter incrementing at 500ms is needed with a range of 3.5*2=7 or (0-6);
0: OFF
1: 250ms-ON; 250ms-off; Off-1S = 1.5s
2: 2x[250ms-ON; 250ms-off;] Off-1S = 2s
3: 3x[250ms-ON; 250ms-off;] Off-1S = 2.5s
4: 4x[250ms-ON; 250ms-off;] Off-1S = 3s
5: 5x[250ms-ON; 250ms-off;] Off-1S = 3.5s
The absolutely beautiful line of code to achieve this complicated task is:
if( delaySec.ccx==num+2){delaySec.ccx=0;} //num is a number from 0-5; delaySec.ccx is a 500ms counter;
The LED will only blink after the counter is more than 1 or 2-7; Here the 1 second off period is placed on the first 2 numbers; What this code does is increasing the timing required for more blinks. If num is a 1, then it only requires 1.5s or when delaySec.ccx == 3; and this is the essence of Advanced AVR 3.0 time management.
PS. I am trying to use 1x 7-segment led display to display 2 numbers with the blinking dot led, but this will be one of the many sub-modes.