From 6f8a80b149c587afb4161f6dd2137549ae11f98a Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sat, 17 Jun 2023 19:54:34 -0400 Subject: [PATCH] Slow breathing animation on two wires, finally working --- tron-bag/main.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/tron-bag/main.c b/tron-bag/main.c index 55b10ab..4dc4390 100644 --- a/tron-bag/main.c +++ b/tron-bag/main.c @@ -2,24 +2,10 @@ #include #include -/* -#include -AVR_MCU(F_CPU, "attiny85"); - -const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = { - { AVR_MCU_VCD_SYMBOL("GTCCR"), .what = (void *)>CCR, }, - { AVR_MCU_VCD_SYMBOL("TCCR0A"), .what = (void *)&TCCR0A, }, - { AVR_MCU_VCD_SYMBOL("TCCR0B"), .what = (void *)&TCCR0B, }, - { AVR_MCU_VCD_SYMBOL("PORTB"), .what = (void *)&PORTB, }, - { AVR_MCU_VCD_SYMBOL("TCNT0"), .what = (void *)&TCNT0, }, -}; -*/ - #define FPS 10 #define FPS_MS 1000 / FPS #define MULT 5 -/* typedef struct { uint8_t value; int8_t inc; @@ -39,26 +25,26 @@ void counter_update(counter_t *self) { self->value = value; } } -*/ int main(void) { DDRB = 0xff; PORTB = 0; + GTCCR = 0; TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00); TCCR0B = _BV(CS00); - uint8_t brightness = 1; - - GTCCR = 0; + counter_t red = (counter_t){ .value = 128, .inc = 1 }; + counter_t blue = (counter_t){ .value = 0, .inc = 1 }; while(1) { - OCR0A = brightness; - OCR0B = brightness; + OCR0A = red.value; + OCR0B = blue.value; - _delay_ms(100); + _delay_ms(10); - brightness += 1; + counter_update(&red); + counter_update(&blue); } return 0;