-
Notifications
You must be signed in to change notification settings - Fork 0
/
slave_flasher.cpp
52 lines (43 loc) · 1.18 KB
/
slave_flasher.cpp
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
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <util/delay.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/sleep.h>
#include "avr_tlc5940.hpp"
#include "avr_rtc.hpp"
#include "avr_led.hpp"
int main (void)
{
avr_led::setup();
avr_rtc::setup();
avr_tlc5940::setup();
for (;;)
{
uint32_t ms = avr_rtc::t_ms;
uint32_t sec = ms/1000;
ms -= sec*1000;
if ((ms & 0x10) == 0)
{
if (sec & 1)
avr_tlc5940::set_channel(15, ms);
else
avr_tlc5940::set_channel(15, 1000-ms);
unsigned val;
if (ms<512)
val = 1023 - 2*ms;
else
val = 0;
switch(sec % 4)
{
case 0: for (unsigned ch=0; ch<14; ch++) avr_tlc5940::set_channel(ch, val); break;
case 1: for (unsigned ch=0; ch<14; ch+=3) avr_tlc5940::set_channel(ch, val); break;
case 2: for (unsigned ch=1; ch<14; ch+=3) avr_tlc5940::set_channel(ch, val); break;
case 3: for (unsigned ch=2; ch<14; ch+=3) avr_tlc5940::set_channel(ch, val); break;
}
avr_tlc5940::output_gsdata();
}
sleep_mode();
}
}