mraa  1.8.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Functions | Typedefs
led.h File Reference

API Description

LED is the Light Emitting Diode interface to libmraa. It is used to access the on board LED's via sysfs.

/* initialize LED */
led = mraa_led_init(USER_LED);
if (led == NULL) {
fprintf(stderr, "Failed to initialize LED\n");
return EXIT_FAILURE;
}
/* read maximum brightness */
fprintf(stdout, "maximum brightness value for LED is: %d\n", val);
if (val >= 1) {
val = 0;
} else {
/* never reached mostly */
val = 1;
}
/* turn LED on/off depending on max_brightness value */
status = mraa_led_set_brightness(led, val);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "unable to set LED brightness\n");
goto err_exit;
}
/* sleep for 5 seconds */
sleep(5);
/* set LED trigger to heartbeat */
status = mraa_led_set_trigger(led, LED_TRIGGER);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "unable to set LED trigger to: heartbeat\n");
goto err_exit;
}
fprintf(stdout, "LED trigger set to: heartbeat\n");
/* close LED */

Go to the source code of this file.

Functions

mraa_led_context mraa_led_init (const char *led)
 
mraa_result_t mraa_led_set_brightness (mraa_led_context dev, int value)
 
int mraa_led_read_brightness (mraa_led_context dev)
 
int mraa_led_read_max_brightness (mraa_led_context dev)
 
mraa_result_t mraa_led_set_trigger (mraa_led_context dev, const char *trigger)
 
mraa_result_t mraa_led_clear_trigger (mraa_led_context dev)
 
mraa_result_t mraa_led_close (mraa_led_context dev)
 

Typedefs

typedef struct _led * mraa_led_context
 

Function Documentation

mraa_led_context mraa_led_init ( const char *  led)

Initialise led_context, based on led function name. The structure of LED entry in sysfs is "devicename:colour:function" This api expects only one unique LED identifier which would be "function" name most often. For instance, mraa_led_init("user4");

Parameters
ledName of the LED
Returns
LED context or NULL

Here is the caller graph for this function:

mraa_result_t mraa_led_set_brightness ( mraa_led_context  dev,
int  value 
)

Set LED brightness

Parameters
devLED context
valueInteger value to write
Returns
Result of operation

Here is the caller graph for this function:

int mraa_led_read_brightness ( mraa_led_context  dev)

Read LED brightness

Parameters
devLED context
Returns
Brightness value

Here is the caller graph for this function:

int mraa_led_read_max_brightness ( mraa_led_context  dev)

Read LED maximum brightness

Parameters
devLED context
Returns
Maximum brightness value

Here is the caller graph for this function:

mraa_result_t mraa_led_set_trigger ( mraa_led_context  dev,
const char *  trigger 
)

Set LED trigger

Parameters
devLED context
triggerType of trigger to set
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_led_clear_trigger ( mraa_led_context  dev)

Clear active LED trigger

Parameters
devLED context
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_led_close ( mraa_led_context  dev)

Close LED file descriptors and free the context memory

Parameters
devLED context
Returns
Result of operation

Here is the caller graph for this function:

Typedef Documentation

typedef struct _led* mraa_led_context

Opaque pointer definition to the internal struct _led

Include dependency graph for led.h: