class::hal::Led

class hal::Led
  : public hal::Device

The LED Class is used to control LEDs based on the standard LED driver.

Summary

Led()

int disable(

bool high_impedance
) const

int enable(

u32 duty,
u32 period
) const

int enable() const

int enable(

float brightness
) const

int flash(

float duty_cycle,
float period
)

int get_info(

led_info_t & info
) const

enum led_flags

Members

Led()

int disable(

bool high_impedance
) const

Disables the LED.

Parameters

  • high_impedance True to set the off state to float

Returns

Zero on success

For the pin to be set to float, the driver must support the FLAG_IS_HIGH_IMPEDANCE flag.


int enable(

u32 duty,
u32 period
) const

Enables the LED with the specified duty cycle and period.

Parameters

  • duty The duty cycle (in microseconds) to be on

  • period The period in microseconds

This method can be used to both set the brightness and flash the LED. To use as brightness control, set the period to a small value.

Returns

Zero on success


int enable() const

Turns the LED on.

Returns

Zero on success


int enable(

float brightness
) const

Enables the LED with the specified brightness.

Parameters

  • brightness Brightness from 0.0 to 1.0

Returns

Zero on success


int flash(

float duty_cycle,
float period
)

Flashes the LED.

Parameters

  • duty_cycle The duty cycle in seconds

  • period The period in seconds

Returns

Zero on success


int get_info(

led_info_t & info
) const

Gets the info for the LED.

Parameters

  • info A reference to the destination information

Returns

Zero on success

After this method is called, the info.o_flags value will indicate what flags are supported by the driver. If FLAG_IS_DUTY_CYCLE is set, then the driver supports brightness control and flashing. Otherwise, the driver can simple enable and disable the LED.


enum led_flags
  • IS_HIGH_IMPEDANCE See LED_FLAG_IS_HIGH_IMPEDANCE
  • IS_DUTY_CYCLE See LED_FLAG_IS_DUTY_CYCLE
  • ENABLE See LED_FLAG_ENABLE
  • DISABLE See LED_FLAG_DISABLE

X

Thanks for Coming!

Subscribe to news and updates