Disable the buttons on the lantern

uart
Savanni D'Gerinel 2022-08-06 14:18:14 -04:00
parent 11436eeb28
commit 78cd1908a7
1 changed files with 18 additions and 16 deletions

View File

@ -29,15 +29,17 @@ You should have received a copy of the GNU General Public License along with thi
uint8_t status_light_value = 0;
dio_t status_light = { .ddr = &DDRC, .port = &PORTC, .pin = &PINC, .addr = 7 };
/*
dio_t buttons[4] = {
{ .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 5 },
{ .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 6 },
{ .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 7 },
{ .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 6 },
};
*/
typedef struct {
int button_press[4];
// int button_press[4];
bool frame_timeout;
} status_flags_t;
@ -47,16 +49,13 @@ ISR(TIMER1_COMPA_vect) {
status_flags.frame_timeout = true;
}
/*
ISR(INT2_vect) {
for (int i = 0; i < 4; i++) {
status_flags.button_press[i] = dio_read(&buttons[i]);
}
}
typedef struct {
bool on;
int timeout;
} power_pulse_t;
*/
void setup_fps_timer(void) {
// WGM = 0100: CTC with OCR1nA top
@ -76,9 +75,11 @@ int main(void) {
EIMSK = 1 << INT2;
EICRA |= 1 << ISC21 | 1 << ISC20;
/*
for (int i = 0; i < 4; i++) {
status_flags.button_press[i] = false;
}
*/
status_flags.frame_timeout = false;
dio_set_direction(&status_light, LINE_OUT);
@ -87,9 +88,6 @@ int main(void) {
PRR0 = _BV(7) | _BV(5) | _BV(2);
PRR1 = _BV(7) | _BV(4) | _BV(3) | _BV(0);
dio_t power_pulse = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 0 };
dio_set_direction(&power_pulse, LINE_OUT);
display_t display = {
.reg = {
.output = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 7 },
@ -102,13 +100,15 @@ int main(void) {
display_write_message(&display, "ready");
_delay_ms(1000);
/*
for (int i = 0; i < 4; i++) {
dio_set_direction(&buttons[i], LINE_IN);
}
*/
sk9822_t lights = {
.data_pin = { .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 1 },
.clock_pin = { .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 0 }
.clock_pin = { .ddr = &DDRC, .port = &PORTC, .pin = &PINC, .addr = 7 },
.data_pin = { .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 6 }
};
rgb_t colors[LIGHT_COUNT];
@ -123,6 +123,12 @@ int main(void) {
set_sleep_mode(SLEEP_MODE_IDLE);
while(1) {
if (status_flags.frame_timeout) {
status_flags.frame_timeout = false;
lantern_step(&lantern, colors);
sk9822_send(&lights, colors, LIGHT_COUNT);
}
/*
if (status_flags.button_press[0]) {
status_flags.button_press[0] = false;
lantern_set_mode(&lantern, normal);
@ -132,11 +138,7 @@ int main(void) {
} else if (status_flags.button_press[2]) {
status_flags.button_press[2] = false;
lantern_set_mode(&lantern, eerie);
} else if (status_flags.frame_timeout) {
status_flags.frame_timeout = false;
lantern_step(&lantern, colors);
sk9822_send(&lights, colors, LIGHT_COUNT);
}
*/
sei();
sleep_mode();