Slow breathing animation on two wires, finally working

This commit is contained in:
Savanni D'Gerinel 2023-06-17 19:54:34 -04:00
parent 9e3787b314
commit 6f8a80b149
1 changed files with 8 additions and 22 deletions

View File

@ -2,24 +2,10 @@
#include <avr/sleep.h>
#include <dio.h>
/*
#include <simavr/avr/avr_mcu_section.h>
AVR_MCU(F_CPU, "attiny85");
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
{ AVR_MCU_VCD_SYMBOL("GTCCR"), .what = (void *)&GTCCR, },
{ 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;