Compare commits
8 Commits
8aace49723
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c8ecf6744d | |||
| 9312665dfa | |||
| 2c6865643e | |||
|
|
256ea53a2f | ||
|
|
8f90ed463a | ||
|
|
3d65b42a63 | ||
|
|
3cca26fe67 | ||
|
|
c94669f834 |
@@ -12,6 +12,10 @@
|
|||||||
// Port A7 -> Enable Output
|
// Port A7 -> Enable Output
|
||||||
// Port B2 -> Button Input (Pulled-Up)
|
// Port B2 -> Button Input (Pulled-Up)
|
||||||
|
|
||||||
|
// Button Press Times
|
||||||
|
#define BTN_LONG_PRESS_MS 1000
|
||||||
|
#define BTN_DEBOUNCE_MS 50
|
||||||
|
|
||||||
// Size of each strip
|
// Size of each strip
|
||||||
#define LED0_COUNT 12
|
#define LED0_COUNT 12
|
||||||
#define LED1_COUNT 12
|
#define LED1_COUNT 12
|
||||||
@@ -22,7 +26,7 @@
|
|||||||
#define LED0_MS 500
|
#define LED0_MS 500
|
||||||
#define LED1_MS 500
|
#define LED1_MS 500
|
||||||
#define LED2_MS 500
|
#define LED2_MS 500
|
||||||
#define LED3_MS 500
|
#define LED3_MS 400
|
||||||
|
|
||||||
// ms offset
|
// ms offset
|
||||||
#define LED0_MS_OFFSET 0
|
#define LED0_MS_OFFSET 0
|
||||||
@@ -52,27 +56,6 @@
|
|||||||
#define NS_PER_CYCLE ( NS_PER_SEC / CYCLES_PER_SEC )
|
#define NS_PER_CYCLE ( NS_PER_SEC / CYCLES_PER_SEC )
|
||||||
#define NS_TO_CYCLES(n) ( (n) / NS_PER_CYCLE )
|
#define NS_TO_CYCLES(n) ( (n) / NS_PER_CYCLE )
|
||||||
|
|
||||||
// Simple RGB Colour Correction
|
|
||||||
const uint8_t PROGMEM gamma8[] =
|
|
||||||
{
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
|
|
||||||
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
|
|
||||||
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
|
|
||||||
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
|
|
||||||
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
|
|
||||||
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
|
|
||||||
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
|
|
||||||
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
|
|
||||||
90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 109, 110, 112, 114,
|
|
||||||
115, 117, 119, 120, 122, 124, 126, 127, 129, 131, 133, 135, 137, 138, 140, 142,
|
|
||||||
144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 167, 169, 171, 173, 175,
|
|
||||||
177, 180, 182, 184, 186, 189, 191, 193, 196, 198, 200, 203, 205, 208, 210, 213,
|
|
||||||
215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255
|
|
||||||
};
|
|
||||||
|
|
||||||
// ms counter
|
// ms counter
|
||||||
uint64_t ms = 0;
|
uint64_t ms = 0;
|
||||||
|
|
||||||
@@ -93,7 +76,7 @@ uint64_t old_time_ms = 0;
|
|||||||
// ms Counter Func
|
// ms Counter Func
|
||||||
ISR(TIM1_CAPT_vect)
|
ISR(TIM1_CAPT_vect)
|
||||||
{
|
{
|
||||||
++ms;
|
ms += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NeoPixel Funcs
|
// NeoPixel Funcs
|
||||||
@@ -108,6 +91,9 @@ void show_leds();
|
|||||||
// Hardware Init
|
// Hardware Init
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
// Function to switch states
|
||||||
|
void state_switch(uint8_t is_onoff);
|
||||||
|
|
||||||
#ifdef ENABLE_OLED
|
#ifdef ENABLE_OLED
|
||||||
// I2C Display Funcs
|
// I2C Display Funcs
|
||||||
void init_display();
|
void init_display();
|
||||||
@@ -120,14 +106,13 @@ void draw_digit(uint8_t pos, uint8_t digit);
|
|||||||
|
|
||||||
// Call function to show a frame and prepare idx for next frame
|
// Call function to show a frame and prepare idx for next frame
|
||||||
void sun_and_moon(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
void sun_and_moon(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
||||||
void clock_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
|
||||||
void clock_no_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
void clock_no_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
||||||
void loading(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
void loading(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
||||||
void off(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
void off(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led);
|
||||||
|
|
||||||
void (*func_list[5])(uint8_t, uint8_t*, uint8_t, uint8_t) =
|
void (*func_list[4])(uint8_t, uint8_t*, uint8_t, uint8_t) =
|
||||||
{
|
{
|
||||||
sun_and_moon, clock_bg, clock_no_bg, loading, off
|
sun_and_moon, clock_no_bg, loading, off
|
||||||
};
|
};
|
||||||
|
|
||||||
void (*send_ptr[4])(uint8_t) =
|
void (*send_ptr[4])(uint8_t) =
|
||||||
@@ -138,13 +123,10 @@ void (*send_ptr[4])(uint8_t) =
|
|||||||
enum states
|
enum states
|
||||||
{
|
{
|
||||||
STATE_SUN_MOON = 0,
|
STATE_SUN_MOON = 0,
|
||||||
STATE_CLOCK_BG1,
|
|
||||||
STATE_CLOCK_BG2,
|
|
||||||
STATE_CLOCK_NO1,
|
STATE_CLOCK_NO1,
|
||||||
STATE_CLOCK_NO2,
|
STATE_CLOCK_NO2,
|
||||||
STATE_LOADING,
|
STATE_LOADING,
|
||||||
STATE_PC,
|
STATE_PC
|
||||||
STATE_OFF
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t led0_idx = 0;
|
uint8_t led0_idx = 0;
|
||||||
@@ -153,41 +135,54 @@ uint8_t led2_idx = 0;
|
|||||||
uint8_t led3_idx = 0;
|
uint8_t led3_idx = 0;
|
||||||
uint8_t colour = 0;
|
uint8_t colour = 0;
|
||||||
uint8_t func_idx = 0;
|
uint8_t func_idx = 0;
|
||||||
uint8_t btn_old_state = 1;
|
uint8_t backup_func_idx = sizeof(func_list) / sizeof(func_list[0]) - 1;
|
||||||
|
uint8_t btn_old_state = 0;
|
||||||
uint8_t colour_state = STATE_SUN_MOON;
|
uint8_t colour_state = STATE_SUN_MOON;
|
||||||
uint8_t current_state;
|
uint8_t current_state;
|
||||||
|
uint64_t btn_down = -1;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
uint8_t show;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
// Main loop
|
// Main loop
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if (ms > led_ms_update[0])
|
show = 0;
|
||||||
|
|
||||||
|
if (ms >= led_ms_update[0])
|
||||||
{
|
{
|
||||||
|
led_ms_update[0] += LED0_MS;
|
||||||
func_list[func_idx](LED0_COUNT, &led0_idx, colour, 0);
|
func_list[func_idx](LED0_COUNT, &led0_idx, colour, 0);
|
||||||
led_ms_update[0] = ms + LED0_MS;
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[1])
|
if (ms >= led_ms_update[1])
|
||||||
{
|
{
|
||||||
|
led_ms_update[1] += LED1_MS;
|
||||||
func_list[func_idx](LED1_COUNT, &led1_idx, colour, 1);
|
func_list[func_idx](LED1_COUNT, &led1_idx, colour, 1);
|
||||||
led_ms_update[1] = ms + LED1_MS;
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[2])
|
if (ms >= led_ms_update[2])
|
||||||
{
|
{
|
||||||
|
led_ms_update[2] += LED2_MS;
|
||||||
func_list[func_idx](LED2_COUNT, &led2_idx, colour, 2);
|
func_list[func_idx](LED2_COUNT, &led2_idx, colour, 2);
|
||||||
led_ms_update[2] = ms + LED2_MS;
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[0])
|
if (ms >= led_ms_update[3])
|
||||||
{
|
{
|
||||||
|
led_ms_update[3] += LED3_MS;
|
||||||
func_list[func_idx](LED3_COUNT, &led3_idx, colour, 3);
|
func_list[func_idx](LED3_COUNT, &led3_idx, colour, 3);
|
||||||
led_ms_update[3] = ms + LED3_MS;
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
show_leds();
|
if (show)
|
||||||
|
{
|
||||||
|
show_leds();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_OLED
|
#ifdef ENABLE_OLED
|
||||||
if (ms - 1000 >= old_time_ms)
|
if (ms - 1000 >= old_time_ms)
|
||||||
@@ -201,54 +196,26 @@ while(1)
|
|||||||
current_state = PINB & 0x04;
|
current_state = PINB & 0x04;
|
||||||
if (btn_old_state && !current_state)
|
if (btn_old_state && !current_state)
|
||||||
{
|
{
|
||||||
switch (colour_state)
|
btn_down = ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Button Unpress
|
||||||
|
if (!btn_old_state && current_state)
|
||||||
|
{
|
||||||
|
if (ms - BTN_DEBOUNCE_MS >= btn_down)
|
||||||
{
|
{
|
||||||
case STATE_SUN_MOON:
|
btn_down = -1;
|
||||||
func_idx = 1;
|
state_switch(0);
|
||||||
colour_state = STATE_CLOCK_BG1;
|
|
||||||
colour = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_CLOCK_BG1:
|
|
||||||
colour_state = STATE_CLOCK_BG2;
|
|
||||||
colour = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_CLOCK_BG2:
|
|
||||||
func_idx = 2;
|
|
||||||
colour_state = STATE_CLOCK_NO1;
|
|
||||||
colour = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_CLOCK_NO1:
|
|
||||||
colour_state = STATE_CLOCK_NO2;
|
|
||||||
colour = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_CLOCK_NO2:
|
|
||||||
func_idx = 3;
|
|
||||||
colour_state = STATE_LOADING;
|
|
||||||
colour = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_LOADING:
|
|
||||||
func_idx = 4;
|
|
||||||
PORTA ^= 0x20;
|
|
||||||
colour_state = STATE_PC;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_PC:
|
|
||||||
PORTA ^= 0x20;
|
|
||||||
colour_state = STATE_OFF;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_OFF:
|
|
||||||
func_idx = 0;
|
|
||||||
colour_state = STATE_SUN_MOON;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btn_old_state = current_state;
|
btn_old_state = current_state;
|
||||||
|
|
||||||
|
// Long Press Time Has Passed
|
||||||
|
if (ms - BTN_LONG_PRESS_MS >= btn_down)
|
||||||
|
{
|
||||||
|
btn_down = -1;
|
||||||
|
state_switch(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,9 +400,11 @@ inline void send_byte(uint8_t byte, uint8_t led)
|
|||||||
|
|
||||||
inline void send_pixel(uint8_t r, uint8_t g, uint8_t b, uint8_t led)
|
inline void send_pixel(uint8_t r, uint8_t g, uint8_t b, uint8_t led)
|
||||||
{
|
{
|
||||||
|
cli();
|
||||||
send_byte(g, led);
|
send_byte(g, led);
|
||||||
send_byte(r, led);
|
send_byte(r, led);
|
||||||
send_byte(b, led);
|
send_byte(b, led);
|
||||||
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_leds()
|
void show_leds()
|
||||||
@@ -462,127 +431,122 @@ void init()
|
|||||||
init_display();
|
init_display();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TIM1 init
|
// TIM1 init - CTC - prescaler 8 - 10ms interrupt
|
||||||
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);
|
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS11);
|
||||||
ICR1 = (F_CPU / 1000) - 1;
|
ICR1 = (F_CPU / 8 / 100) - 1;
|
||||||
TIMSK1 = (1 << ICIE1);
|
TIMSK1 = (1 << ICIE1);
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void state_switch(uint8_t is_onoff)
|
||||||
|
{
|
||||||
|
uint8_t tmp_func_idx;
|
||||||
|
|
||||||
|
if (is_onoff == 0)
|
||||||
|
{
|
||||||
|
// If we're off don't change anything
|
||||||
|
if (func_idx == sizeof(func_list) / sizeof(func_list[0]) - 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (colour_state)
|
||||||
|
{
|
||||||
|
case STATE_SUN_MOON:
|
||||||
|
func_idx = 1;
|
||||||
|
colour_state = STATE_CLOCK_NO1;
|
||||||
|
colour = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_CLOCK_NO1:
|
||||||
|
colour_state = STATE_CLOCK_NO2;
|
||||||
|
colour = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_CLOCK_NO2:
|
||||||
|
func_idx = 2;
|
||||||
|
colour_state = STATE_LOADING;
|
||||||
|
colour = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_LOADING:
|
||||||
|
func_idx = 0;
|
||||||
|
PORTA ^= 0x20;
|
||||||
|
colour_state = STATE_PC;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_PC:
|
||||||
|
PORTA ^= 0x20;
|
||||||
|
colour_state = STATE_SUN_MOON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp_func_idx = backup_func_idx;
|
||||||
|
backup_func_idx = func_idx;
|
||||||
|
func_idx = tmp_func_idx;
|
||||||
|
}
|
||||||
|
led0_idx = 0;
|
||||||
|
led1_idx = 0;
|
||||||
|
led2_idx = 0;
|
||||||
|
led3_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void sun_and_moon(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
void sun_and_moon(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t colour1[3] =
|
uint8_t colour1[3] = {0xFF, 0x80, 0x00};
|
||||||
{
|
uint8_t colour2[3] = {0x00, 0x80, 0xFF};
|
||||||
pgm_read_byte(&gamma8[0xFF]),
|
uint8_t min;
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
uint8_t max;
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
uint8_t colour2[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0xFF])
|
|
||||||
};
|
|
||||||
|
|
||||||
if (*idx <= count / 2)
|
if (*idx <= count / 2)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
min = *idx;
|
||||||
|
max = *idx + count / 2;
|
||||||
|
|
||||||
|
for (i = 0; i < min; ++i)
|
||||||
{
|
{
|
||||||
if ((i < *idx) || (i >= *idx + count / 2))
|
send_pixel(colour1[0], colour1[1], colour1[2], led);
|
||||||
{
|
}
|
||||||
send_pixel(colour1[0], colour1[1], colour1[2], led);
|
for (i = min; i < max; ++i)
|
||||||
}
|
{
|
||||||
else
|
send_pixel(colour2[0], colour2[1], colour2[2], led);
|
||||||
{
|
}
|
||||||
send_pixel(colour2[0], colour2[1], colour2[2], led);
|
for (i = max; i < count; ++i)
|
||||||
}
|
{
|
||||||
|
send_pixel(colour1[0], colour1[1], colour1[2], led);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
min = *idx - count / 2;
|
||||||
|
max = *idx;
|
||||||
|
|
||||||
|
for (i = 0; i < min; ++i)
|
||||||
{
|
{
|
||||||
if ((i < *idx) && (i >= *idx - count / 2))
|
send_pixel(colour2[0], colour2[1], colour2[2], led);
|
||||||
{
|
}
|
||||||
send_pixel(colour1[0], colour1[1], colour1[2], led);
|
for (i = min; i < max; ++i)
|
||||||
}
|
{
|
||||||
else
|
send_pixel(colour1[0], colour1[1], colour1[2], led);
|
||||||
{
|
}
|
||||||
send_pixel(colour2[0], colour2[1], colour2[2], led);
|
for (i = max; i < count; ++i)
|
||||||
}
|
{
|
||||||
|
send_pixel(colour2[0], colour2[1], colour2[2], led);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*idx++;
|
(*idx)++;
|
||||||
*idx %= count;
|
(*idx) %= count;
|
||||||
}
|
|
||||||
|
|
||||||
void clock_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t colour1[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0xFF]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
uint8_t colour2[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0xFF])
|
|
||||||
};
|
|
||||||
uint8_t* main_colour;
|
|
||||||
uint8_t* bg_colour;
|
|
||||||
|
|
||||||
if (0 == colour)
|
|
||||||
{
|
|
||||||
main_colour = colour1;
|
|
||||||
bg_colour = colour2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
main_colour = colour2;
|
|
||||||
bg_colour = colour1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
if (i == *idx)
|
|
||||||
{
|
|
||||||
send_pixel(main_colour[0], main_colour[1], main_colour[2], led);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
send_pixel(bg_colour[0], bg_colour[1], bg_colour[2], led);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*idx++;
|
|
||||||
*idx %= count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clock_no_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
void clock_no_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t colour1[3] =
|
uint8_t colour1[3] = {0xFF, 0x80, 0x00};
|
||||||
{
|
uint8_t colour2[3] = {0x00, 0x80, 0xFF};
|
||||||
pgm_read_byte(&gamma8[0xFF]),
|
uint8_t black[3] = {0x00, 0x00, 0x00};
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
uint8_t colour2[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0xFF])
|
|
||||||
};
|
|
||||||
uint8_t black[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
uint8_t* main_colour;
|
uint8_t* main_colour;
|
||||||
|
|
||||||
if (0 == colour)
|
if (0 == colour)
|
||||||
@@ -606,25 +570,15 @@ void clock_no_bg(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*idx++;
|
(*idx)++;
|
||||||
*idx %= count;
|
(*idx) %= count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loading(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
void loading(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t colour1[3] =
|
uint8_t colour1[3] = {0xFF, 0x80, 0x00};
|
||||||
{
|
uint8_t colour2[3] = {0x00, 0x80, 0xFF};
|
||||||
pgm_read_byte(&gamma8[0xFF]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
uint8_t colour2[3] =
|
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x80]),
|
|
||||||
pgm_read_byte(&gamma8[0xFF])
|
|
||||||
};
|
|
||||||
|
|
||||||
if (*idx < count)
|
if (*idx < count)
|
||||||
{
|
{
|
||||||
@@ -655,20 +609,15 @@ void loading(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*idx++;
|
(*idx)++;
|
||||||
*idx %= count * 2;
|
(*idx) %= count * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void off(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
void off(uint8_t count, uint8_t* idx, uint8_t colour, uint8_t led)
|
||||||
{
|
{
|
||||||
uint8_t black[3] =
|
uint8_t black[3] = {0x00, 0x00, 0x00};
|
||||||
{
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x00]),
|
|
||||||
pgm_read_byte(&gamma8[0x00])
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (uint8_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
send_pixel(black[0], black[1], black[2], led);
|
send_pixel(black[0], black[1], black[2], led);
|
||||||
}
|
}
|
||||||
|
|||||||
12
Makefile
12
Makefile
@@ -1,2 +1,12 @@
|
|||||||
controller: ATtiny84_LED_PC.c i2c_master.c
|
all:
|
||||||
|
make build
|
||||||
|
make program
|
||||||
|
|
||||||
|
build:
|
||||||
avr-gcc ATtiny84_LED_PC.c i2c_master.c -o controller -DF_CPU=16000000 -mmcu=attiny84
|
avr-gcc ATtiny84_LED_PC.c i2c_master.c -o controller -DF_CPU=16000000 -mmcu=attiny84
|
||||||
|
|
||||||
|
program:
|
||||||
|
avrdude -p attiny84 -c usbtiny -U flash:w:controller
|
||||||
|
|
||||||
|
fuse:
|
||||||
|
avrdude -p attyin84 -c usbtiny -U lfuse:w:0xee:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
|
||||||
|
|||||||
Reference in New Issue
Block a user