Robot Control Library
led.h
Go to the documentation of this file.
1/**
2 * <rc/led.h>
3 *
4 * @brief Control the LEDs on Robotics Cape and BeagleBone Blue.
5 *
6 * @author James Strawson
7 * @date 1/31/2018
8 *
9 * @addtogroup LED
10 * @{
11 */
12
13#ifndef RC_LED_H
14#define RC_LED_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/**
21 * @brief Availabe LEDs on the BeagleBone platform.
22 *
23 * This list may expand for future boards. Note that the WIFI and USR LEDs are
24 * normally controlled by separate processes. They can be controlled, but may
25 * conflict as other processes continue to try to write to them simultaneously.
26 *
27 * The BAT LED's are controlled by the rc_battery_monitor service. If you want
28 * to control these LEDs yourself please stop the service first.
29 *
30 * ```bash
31 * sudo systemctl stop rc_battery_monitor
32 * sudo systemctl disable rc_battery_monitor
33 * ```
34 */
35typedef enum rc_led_t{
48
49
50/**
51 * @brief sets the state of an LED
52 *
53 * @param[in] led rc_led_t enum
54 * @param[in] value 0 for OFF, non-zero for ON
55 *
56 * @return 0 on success, -1 on failure
57 */
58int rc_led_set(rc_led_t led, int value);
59
60
61/**
62 * @brief closes file descriptors to all opened LEDs
63 *
64 * This does NOT turn off the LEDs, it is up to the user to leave the LEDs in
65 * the desired state before closing.
66 */
67void rc_led_cleanup(void);
68
69
70/**
71 * @brief gets the current state of an LED
72 *
73 * @param[in] led rc_led_t enum
74 *
75 * @return 0 if off, 1 if on, -1 on error
76 */
78
79
80/**
81 * @brief blinks an led at specified frequency and duration.
82 *
83 * This is a blocking function call, it does not return until either the
84 * specified duration has completed or rc_led_stop_blink has been called from
85 * another thread.
86 *
87 * @param[in] led rc_led_t enum
88 * @param[in] hz blink frequency in HZ
89 * @param[in] duration blink duration in seconds
90 *
91 * @return 0 on success, -1 on error, 1 if function exited prematurely.
92 */
93int rc_led_blink(rc_led_t led, float hz, float duration);
94
95
96/**
97 * @brief Stops an LED from blinking.
98 *
99 * Since rc_led_blink is a blocking function, it's obviously necessary to call
100 * rc_led_stop_blink from a separate thread or signal handler. This will cause
101 * rc_led_blink to return 1 if blinking was stopped mid-way. Also see
102 * rc_led_stop_blink_all
103 *
104 * @param[in] led rc_led_t enum
105 */
107
108
109/**
110 * @brief stops all LEDs from blinking
111 *
112 * Since rc_led_blink is a blocking function, it's obviously necessary to call
113 * rc_led_stop_blink from a separate thread or signal handler. This will cause
114 * rc_led_blink to return 1 if blinking was stopped mid-way.
115 */
117
118
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif // RC_LED_H
125
126/** @} end group LED */
int rc_led_set(rc_led_t led, int value)
sets the state of an LED
rc_led_t
Availabe LEDs on the BeagleBone platform.
Definition: led.h:35
void rc_led_stop_blink(rc_led_t led)
Stops an LED from blinking.
int rc_led_get(rc_led_t led)
gets the current state of an LED
void rc_led_stop_blink_all(void)
stops all LEDs from blinking
int rc_led_blink(rc_led_t led, float hz, float duration)
blinks an led at specified frequency and duration.
void rc_led_cleanup(void)
closes file descriptors to all opened LEDs
@ RC_LED_BAT25
Definition: led.h:42
@ RC_LED_GREEN
Definition: led.h:36
@ RC_LED_USR2
Definition: led.h:40
@ RC_LED_USR3
Definition: led.h:41
@ RC_LED_BAT100
Definition: led.h:45
@ RC_LED_WIFI
Definition: led.h:46
@ RC_LED_USR1
Definition: led.h:39
@ RC_LED_BAT75
Definition: led.h:44
@ RC_LED_BAT50
Definition: led.h:43
@ RC_LED_RED
Definition: led.h:37
@ RC_LED_USR0
Definition: led.h:38