uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
leds.h
Go to the documentation of this file.
1 
4 /*
5  * Copyright 2015 Sebastian Neuser
6  *
7  * This file is part of the uMIDI firmware.
8  *
9  * the uMIDI firmware is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * the uMIDI firmware is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with the uMIDI firmware. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef _LEDS_H
24 #define _LEDS_H
25 
26 
27 //---------------- includes ----------------//
28 #include <stdbool.h>
29 #include <avr/io.h>
30 
31 #include "gpio.h"
32 
33 
34 //---------------- constants ----------------//
35 
37 extern struct led* led_red;
38 
40 extern struct led* led_green;
41 
43 #define LED_GREEN led_green
44 
46 #define LED_RED led_red
47 
48 
49 //---------------- data types ----------------//
53 {
57 };
58 
62 struct led_state
63 {
64  bool active;
65  enum led_mode mode;
66  uint8_t prescaler;
67  uint8_t counter;
68 };
69 
72 struct led
73 {
74  const struct gpio_pin* const pin;
75  struct led_state state;
76 };
77 
78 
79 //---------------- functions and procedures ----------------//
82 void init_leds_module(void);
83 
84 
88 void register_led(struct led * const);
89 
99 void blink_led(struct led* led, uint8_t prescaler);
100 
105 void flash_led(struct led* led);
106 
113 void flash_led_multiple(struct led* led, uint8_t count);
114 
121 void set_led(struct led* led, bool enable);
122 
127 void toggle_led(struct led* led);
128 
133 void update_leds(void);
134 
135 
136 //---------------- EOF ----------------//
137 #endif // _LEDS_H
struct led * led_red
The green onboard LED.
Definition: leds.c:69
void register_led(struct led *const)
Add an LED to the cyclic processed LEDs.
Definition: leds.c:123
uint8_t prescaler
Prescaler for the counter in blinking mode.
Definition: leds.h:66
void flash_led(struct led *led)
Briefly flashes an LED.
Definition: leds.c:145
led_mode
Enumeration for the LED mode.
Definition: leds.h:52
GPIO configuration and service functions.
The LED blinks once per second.
Definition: leds.h:56
void init_leds_module(void)
Module initialization procedure.
Definition: leds.c:116
uint8_t counter
Counter for the blinking interval.
Definition: leds.h:67
void flash_led_multiple(struct led *led, uint8_t count)
Briefly flashes an LED.
Definition: leds.c:151
The LED flashes briefly and remains off.
Definition: leds.h:55
The LED can be turned on/off manually.
Definition: leds.h:54
Enumeration for the on-board LEDs.
Definition: leds.h:72
enum led_mode mode
The mode of the LED.
Definition: leds.h:65
void update_leds(void)
State machine task that updates the LEDs.
Definition: leds.c:195
Internal state of an LED.
Definition: leds.h:62
bool active
When the LED is on, this reads true
Definition: leds.h:64
struct led * led_green
The green onboard LED.
Definition: leds.c:67
Configuration of a single GPIO pin.
Definition: gpio.h:57
void toggle_led(struct led *led)
Toggles an LED.
Definition: leds.c:163
void blink_led(struct led *led, uint8_t prescaler)
Lets an LED blink in a fixed interval.
Definition: leds.c:139
const struct gpio_pin *const pin
Gpio pin connected to an LED.
Definition: leds.h:74
void set_led(struct led *led, bool enable)
Enables or disables an LED.
Definition: leds.c:157