/*
* Master Firmware: Status and Error LED Handler
*
* This file is part of OpenTrack.
*
* OpenTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenTrack. If not, see <http://www.gnu.org/licenses/>.
*
* Ethan Zonca
* Matthew Kanning
* Kyle Ripperger
* Matthew Kroening
*
*/
#ifndef LED_H_
#define LED_H_
#include <avr/io.h>
#include <stdbool.h>
enum leds {
LED_ACT0 = 0,
LED_ACT1,
LED_ACT2,
LED_ACT3,
LED_POWER,
LED_STATUS,
LED_ERROR,
LED_SIDEBOARD,
LED_ACTIVITY,
LED_CYCLE,
LED_HEAT,
LED_BUZZ,
};
typedef struct {volatile uint8_t* direction; volatile uint8_t* port; uint8_t pin;} led_t;
// Match order of leds enum
static led_t ledList[] = {
{&DDRA, &PORTA, PA1}, // ACT0
{&DDRA, &PORTA, PA2}, // ACT1
{&DDRA, &PORTA, PA3}, // ACT2
{&DDRA, &PORTA, PA4}, // ACT3
{&DDRB, &PORTB, PB4}, // POWER
{&DDRB, &PORTB, PB3}, // STATUS
{&DDRB, &PORTB, PB2}, // ERROR
{&DDRD, &PORTD, PD6}, // SIDEBOARD
{&DDRD, &PORTD, PD5}, // ACTIVITY
{&DDRD, &PORTD, PD4}, // CYCLE
{&DDRA, &PORTA, PA6}, // HEAT
{&DDRA, &PORTA, PA7}, // BUZZER
};
#define NUM_LEDS 12
void led_setup();
void led_power_toggle();
void led_on(uint8_t led);
void led_off(uint8_t led);
void led_toggle(uint8_t led);
void led_blackout();
bool led_isBlackout();
void led_errorcode(uint8_t code);
void led_spin();
void led_alert();
#endif /* LED_H_ */