Wrappers to simplify the use of LEDs.
- Green LEDs are numbered 0 to NUM_GREEN_LEDS-1.
- Only color LED 0 is used.
- The color LED has three components R, G, B that can be set independently to mix to a color.
LEDs can be used in three modes:
- on/off mode for all green LEDs and all color LEDs
- PWM mode for green LEDs (PWM0..PWM3 are rounted to green LEDs 0..3)
- PWM mode for color LED 0 (PWM0..PWM3 are routed to color LED 0)
An example of how to use this library.
int main (void)
{
return EXIT_SUCCESS;
}
void gpio_reset(void)
Reset all GPIO pins.
void leds_init_onoff(void)
Initialize the green LEDs for on/off use.
void green_led_off(const int led)
Same as green_led_onoff(led, LED_OFF). Works in all modes.
void green_led_on(const int led)
Same as green_led_onoff(led, LED_ON). Works in all modes.
void sleep_msec(int msec)
Wait for msec milliseconds.
void pynq_destroy(void)
Reset and destroy the switchbox and GPIO of the PYNQ.
LEDs can also be used through GPIO (see gpio.h and pinmap.h). Note that GPIO numbering (SWB_LD0..SWB_LD3) is then used instead of 0..NUM_GREEN_LEDS-1 (LED0..LED3). In the PWM mode for color LED 0, SWB_PWM0..SWB_PWM3 are routed to color LED 0 (GPIO SWB_LD4R, SWB_LD4G, SWB_LD4B).
◆ LED_OFF
◆ LED_ON
◆ NUM_LED_COLORS
#define NUM_LED_COLORS 3 /* # colors per color LED (RGB) */ |
◆ NUM_LEDS
◆ color_led_index_t
Enum of color LEDs. Functions for color LEDs use a led number from 0..NUM_COLOR_LEDS-1. Alternatively, you can use COLOR_LEDi instead of just i if you find that clearer.
Enumerator |
---|
COLOR_LED0 | |
COLOR_LED1 | |
NUM_COLOR_LEDS | |
Definition at line 94 of file leds.h.
◆ green_led_index_t
Enum of green LEDs. Functions for green LEDs use a led number from 0..NUM_GREEN_LEDS-1. Alternatively, you can use LEDi instead of just i if you find that clearer.
Enumerator |
---|
LED0 | |
LED1 | |
LED2 | |
LED3 | |
NUM_GREEN_LEDS | |
Definition at line 80 of file leds.h.
◆ color_led_blue_onoff()
void color_led_blue_onoff |
( |
const int |
onoff | ) |
|
Switches on/off the blue component of color LED 0.
- Parameters
-
onoff | If the LEDs are in onoff mode then onoff must be either LED_ON or LED_OFF. If the LEDs are in one of the PWM modes then onoff must be 0.255. |
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 195 of file leds.c.
◆ color_led_green_onoff()
void color_led_green_onoff |
( |
const int |
onoff | ) |
|
Switches on/off the green component of color LED 0.
- Parameters
-
onoff | If the LEDs are in onoff mode then onoff must be either LED_ON or LED_OFF. If the LEDs are in one of the PWM modes then onoff must be 0.255. |
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 172 of file leds.c.
◆ color_led_off()
void color_led_off |
( |
void |
| ) |
|
Set color LED 0 to black. Same as color_led_onoff(LED_OFF, LED_OFF,
LED_OFF).
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 226 of file leds.c.
◆ color_led_on()
void color_led_on |
( |
void |
| ) |
|
Set color LED 0 to white. Same as color_led_onoff(LED_ON, LED_ON,
LED_ON).
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 225 of file leds.c.
◆ color_led_onoff()
void color_led_onoff |
( |
const int |
red_onoff, |
|
|
const int |
green_onoff, |
|
|
const int |
blue_onoff |
|
) |
| |
Switches on/off the red/green/blue components of color LED 0.
- Parameters
-
onoff | If the LEDs are in onoff mode then *_onoff must be either LED_ON or LED_OFF. If the LEDs are in one of the PWM modes then *_onoff must be 0.255. |
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 218 of file leds.c.
◆ color_led_red_onoff()
void color_led_red_onoff |
( |
const int |
onoff | ) |
|
Switches on/off the red component of color LED 0.
- Parameters
-
onoff | If the LEDs are in onoff mode then onoff must be either LED_ON or LED_OFF. If the LEDs are in one of the PWM modes then onoff must be 0.255. |
- Warning
- Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 148 of file leds.c.
◆ color_leds_init_pwm()
void color_leds_init_pwm |
( |
void |
| ) |
|
Initialize the color LEDs for use with variable intensity. The LED intensity can range from 0.255.
- Warning
- Fails with program exit when LEDs have already been to another mode.
Definition at line 79 of file leds.c.
◆ green_led_off()
void green_led_off |
( |
const int |
led | ) |
|
Same as green_led_onoff(led, LED_OFF). Works in all modes.
- Parameters
-
- Warning
- Fails with program exit when led is outside valid range.
-
Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 147 of file leds.c.
◆ green_led_on()
void green_led_on |
( |
const int |
led | ) |
|
Same as green_led_onoff(led, LED_ON). Works in all modes.
- Parameters
-
- Warning
- Fails with program exit when led is outside valid range.
-
Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 146 of file leds.c.
◆ green_led_onoff()
void green_led_onoff |
( |
const int |
led, |
|
|
const int |
onoff |
|
) |
| |
- Parameters
-
led | The green LED. |
onoff | If the LEDs are in onoff mode then onoff must be either LED_ON or LED_OFF. If the LEDs are in one of the PWM modes then onoff must be 0.255. |
- Warning
- Fails with program exit when led is outside valid range.
-
Fails with program exit when LEDs were not initialized with the correct mode.
Definition at line 117 of file leds.c.
◆ green_leds_init_pwm()
void green_leds_init_pwm |
( |
void |
| ) |
|
Initialize the green LEDs for use with variable intensity. The LED intensity can range from 0.255.
- Warning
- Fails with program exit when LEDs have already been to another mode.
Definition at line 58 of file leds.c.
◆ leds_destroy()
void leds_destroy |
( |
void |
| ) |
|
Unitialize the LEDs, such that the mode of the LEDs can be changed. Switch all lEDs off.
Definition at line 96 of file leds.c.
◆ leds_init_onoff()
void leds_init_onoff |
( |
void |
| ) |
|
Initialize the green LEDs for on/off use.
- Warning
- Fails with program exit when LEDs have already been to another mode.
Definition at line 37 of file leds.c.