Fixed stupid mistakes.
This commit is contained in:
parent
3d65b42a63
commit
8f90ed463a
@ -72,7 +72,7 @@ uint64_t old_time_ms = 0;
|
|||||||
// ms Counter Func
|
// ms Counter Func
|
||||||
ISR(TIM1_CAPT_vect)
|
ISR(TIM1_CAPT_vect)
|
||||||
{
|
{
|
||||||
ms += 100;
|
ms += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NeoPixel Funcs
|
// NeoPixel Funcs
|
||||||
@ -132,41 +132,52 @@ 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 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;
|
||||||
|
|
||||||
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] = ms + LED0_MS;
|
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);
|
||||||
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[1])
|
if (ms >= led_ms_update[1])
|
||||||
{
|
{
|
||||||
led_ms_update[1] = ms + LED1_MS;
|
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);
|
||||||
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[2])
|
if (ms >= led_ms_update[2])
|
||||||
{
|
{
|
||||||
led_ms_update[2] = ms + LED2_MS;
|
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);
|
||||||
|
show = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms > led_ms_update[0])
|
if (ms >= led_ms_update[3])
|
||||||
{
|
{
|
||||||
led_ms_update[3] = ms + LED3_MS;
|
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);
|
||||||
|
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)
|
||||||
@ -413,7 +424,7 @@ inline void send_byte(uint8_t byte, uint8_t led)
|
|||||||
byte <<= 1;
|
byte <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
cli();
|
||||||
@ -447,9 +458,9 @@ void init()
|
|||||||
init_display();
|
init_display();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TIM1 init - prescaler 64
|
// TIM1 init - CTC - prescaler 8 - 10ms interrupt
|
||||||
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS11) | (1 << CS10);
|
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS11);
|
||||||
ICR1 = (F_CPU / 64 / 100) - 1;
|
ICR1 = (F_CPU / 8 / 100) - 1;
|
||||||
TIMSK1 = (1 << ICIE1);
|
TIMSK1 = (1 << ICIE1);
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user