LED Indicator

[中文]

As one of the simplest output peripherals, LED indicators can indicate the current operating state of the system by blinking in different types. ESP-IoT-Solution provides an LED indicator component with the following features:

  • Can define multiple groups of different blink types

  • Can define the priority of blink types

  • Can set up multiple indicators

Instructions

API Reference

Header File

Functions

led_indicator_handle_t led_indicator_create(int io_num, const led_indicator_config_t *config)

create a led indicator instance with gpio number and configuration

Return

led_indicator_handle_t handle of the led indicator, NULL if create failed.

Parameters
  • io_num: gpio number of the led

  • config: configuration of the led, eg. gpio level when led off

led_indicator_handle_t led_indicator_get_handle(int io_num)

get the handle of created led_indicator with gpio number

Return

led_indicator_handle_t handle of the created led indicator, NULL if not created

Parameters
  • io_num: gpio number of the led

esp_err_t led_indicator_delete(led_indicator_handle_t *p_handle)

delete the led indicator and release resource

Return

esp_err_t

  • ESP_ERR_INVALID_ARG if parameter is invalid

  • ESP_FAIL Fail

  • ESP_OK Success

Parameters
  • p_handle: pointer to led indicator handle

start a new blink_type on the led indicator. if mutiple blink_type started simultaneously, it will be executed according to priority.

Return

esp_err_t

  • ESP_ERR_INVALID_ARG if parameter is invalid

  • ESP_ERR_NOT_FOUND no predefined blink_type found

  • ESP_OK Success

Parameters
  • handle: led indicator handle

  • blink_type: predefined blink type

stop a blink_type. you can stop a blink_type at any time, no matter it is executing or waiting to be executed.

Return

esp_err_t

  • ESP_ERR_INVALID_ARG if parameter is invalid

  • ESP_ERR_NOT_FOUND no predefined blink_type found

  • ESP_OK Success

Parameters
  • handle: led indicator handle

  • blink_type: predefined blink type

Structures

one blink step, a meaningful signal consists of a group of steps

Public Members

action type in this step

hold on or off, set NULL if not LED_BLINK_HOLD

hold time(ms), set NULL if not LED_BLINK_HOLD,

struct led_indicator_config_t

led indicator specified configurations, as a arg when create a new indicator

Public Members

bool off_level

gpio level of turn off. 0 if attach led positive side to esp32 gpio pin, 1 if attach led negative side

led_indicator_mode_t mode

led work mode, eg. gpio or pwm mode

Type Definitions

typedef void *led_indicator_handle_t

led indicator operation handle

Enumerations

led on-off state

Values:

LED_STATE_OFF = 0

turn off the led

LED_STATE_ON = 1

turn on the led

actions in this type

Values:

stop the blink

hold the on-off state

loop from first step

enum led_indicator_mode_t

led indicator blink mode, as a member of led_indicator_config_t

Values:

LED_GPIO_MODE

blink with max brightness

The blink type with smaller index has the higher priority eg. BLINK_FACTORY_RESET priority is higher than BLINK_UPDATING.

Values:

restoring factory settings

updating software

connected to AP (or Cloud) succeed

provision done

connecting to AP (or Cloud)

reconnecting to AP (or Cloud), if lose connection

provisioning

INVALIED type