Robot Control Library
LED

Description

Control the LEDs on Robotics Cape and BeagleBone Blue.

<rc/led.h>

Author
James Strawson
Date
1/31/2018

Typedefs

typedef enum rc_led_t rc_led_t
 Availabe LEDs on the BeagleBone platform. More...
 

Functions

int rc_led_set (rc_led_t led, int value)
 sets the state of an LED More...
 
void rc_led_cleanup (void)
 closes file descriptors to all opened LEDs More...
 
int rc_led_get (rc_led_t led)
 gets the current state of an LED More...
 
int rc_led_blink (rc_led_t led, float hz, float duration)
 blinks an led at specified frequency and duration. More...
 
void rc_led_stop_blink (rc_led_t led)
 Stops an LED from blinking. More...
 
void rc_led_stop_blink_all (void)
 stops all LEDs from blinking More...
 

Enumeration Type Documentation

◆ rc_led_t

enum rc_led_t

Availabe LEDs on the BeagleBone platform.

This list may expand for future boards. Note that the WIFI and USR LEDs are normally controlled by separate processes. They can be controlled, but may conflict as other processes continue to try to write to them simultaneously.

The BAT LED's are controlled by the rc_battery_monitor service. If you want to control these LEDs yourself please stop the service first.

sudo systemctl stop rc_battery_monitor
sudo systemctl disable rc_battery_monitor
Enumerator
RC_LED_GREEN 
RC_LED_RED 
RC_LED_USR0 
RC_LED_USR1 
RC_LED_USR2 
RC_LED_USR3 
RC_LED_BAT25 
RC_LED_BAT50 
RC_LED_BAT75 
RC_LED_BAT100 
RC_LED_WIFI 

Function Documentation

◆ rc_led_set()

int rc_led_set ( rc_led_t  led,
int  value 
)

sets the state of an LED

Parameters
[in]ledrc_led_t enum
[in]value0 for OFF, non-zero for ON
Returns
0 on success, -1 on failure
Examples:
rc_balance.c, rc_blink.c, and rc_test_leds.c.

◆ rc_led_cleanup()

void rc_led_cleanup ( void  )

closes file descriptors to all opened LEDs

This does NOT turn off the LEDs, it is up to the user to leave the LEDs in the desired state before closing.

Examples:
rc_balance.c, rc_blink.c, and rc_test_leds.c.

◆ rc_led_get()

int rc_led_get ( rc_led_t  led)

gets the current state of an LED

Parameters
[in]ledrc_led_t enum
Returns
0 if off, 1 if on, -1 on error

◆ rc_led_blink()

int rc_led_blink ( rc_led_t  led,
float  hz,
float  duration 
)

blinks an led at specified frequency and duration.

This is a blocking function call, it does not return until either the specified duration has completed or rc_led_stop_blink has been called from another thread.

Parameters
[in]ledrc_led_t enum
[in]hzblink frequency in HZ
[in]durationblink duration in seconds
Returns
0 on success, -1 on error, 1 if function exited prematurely.
Examples:
rc_balance.c.

◆ rc_led_stop_blink()

void rc_led_stop_blink ( rc_led_t  led)

Stops an LED from blinking.

Since rc_led_blink is a blocking function, it's obviously necessary to call rc_led_stop_blink from a separate thread or signal handler. This will cause rc_led_blink to return 1 if blinking was stopped mid-way. Also see rc_led_stop_blink_all

Parameters
[in]ledrc_led_t enum

◆ rc_led_stop_blink_all()

void rc_led_stop_blink_all ( void  )

stops all LEDs from blinking

Since rc_led_blink is a blocking function, it's obviously necessary to call rc_led_stop_blink from a separate thread or signal handler. This will cause rc_led_blink to return 1 if blinking was stopped mid-way.