Provides inline Functions for controlling the LEDs.
- Copyright
- Copyright (C) 2013 Robert Loos http://www.loosweb.de
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Eight LEDs are possible via a cheap shift register controlled by the SPI bus. It is really cheap, especially cheaper than choosing the next larger controller. For additional ~20 cents you could add even eight LEDs more...
They indicate normal operation states as well as error conditions. The color is defined as follows:
-
RED means DANGER and is reserved for error messages or critical states of the cirquit. If you see a red LED, the circuit is experiencing problems and you should consider immediate shutdown to avoid damage if it is not already too late.
-
Green generally means O.K.
-
Yellow indicates something but also is an O.K. situation.
-
Blue is meant to be the same as yellow but may be used to easily distinguish it from a yellow LED even if the circuit is a few meters away. Additional colors are possible of course... nowadays you can get turquoise or violet LEDs as well as different shades of green, yellow or orange...
The LEDs are set within the SPI interrupt sequence and show any changes without noticeable delay. led_state can be changed any time according to the situation and will be reflected within the next SPI interrupt cycle.
Each LED normally is controlled via 10ms timer callback and generates a repetitive blinking sequence. This can be up to 32 bits long, just as you typedef the LED_BLINK_t.
uint8_t seems enough to generate three different blink rates (plus 'off') but if you want to send debug blink codes uint16_t seems the minimum (you need a recognizable pause at the end of each code!)
This behavior can be disabled by commenting out the definition of LED_USE_TIMER. You can then switch the LED on or off via the inline functions LEDRedOn() and LEDRedOff().