显示服务

[English]

显示服务 (display service) 在 display_pattern_t 中定义了一些常用的显示样式枚举值,帮助用户设置 LED 或者 LED 灯条的对应样式。

已经支持的 LED 驱动芯片有 AW2013、WS2812、IS31x。

应用示例

以下示例展示了该 API 的实现方式。

Header File

Functions

display_service_handle_t display_service_create(display_service_config_t *cfg)
esp_err_t display_service_set_pattern(void *handle, int disp_pattern, int value)
esp_err_t display_destroy(display_service_handle_t handle)

Structures

struct display_service_config_t

Display service configurations.

Public Members

periph_service_config_t based_cfg

Peripheral service configuration

void *instance

Sub-instance

Type Definitions

typedef struct display_service_impl *display_service_handle_t

Enumerations

enum display_pattern_t

Values:

DISPLAY_PATTERN_UNKNOWN = 0
DISPLAY_PATTERN_WIFI_SETTING = 1
DISPLAY_PATTERN_WIFI_CONNECTTING = 2
DISPLAY_PATTERN_WIFI_CONNECTED = 3
DISPLAY_PATTERN_WIFI_DISCONNECTED = 4
DISPLAY_PATTERN_WIFI_SETTING_FINISHED = 5
DISPLAY_PATTERN_BT_CONNECTTING = 6
DISPLAY_PATTERN_BT_CONNECTED = 7
DISPLAY_PATTERN_BT_DISCONNECTED = 8
DISPLAY_PATTERN_RECORDING_START = 9
DISPLAY_PATTERN_RECORDING_STOP = 10
DISPLAY_PATTERN_RECOGNITION_START = 11
DISPLAY_PATTERN_RECOGNITION_STOP = 12
DISPLAY_PATTERN_WAKEUP_ON = 13
DISPLAY_PATTERN_WAKEUP_FINISHED = 14
DISPLAY_PATTERN_MUSIC_ON = 15
DISPLAY_PATTERN_MUSIC_FINISHED = 16
DISPLAY_PATTERN_VOLUME = 17
DISPLAY_PATTERN_MUTE_ON = 18
DISPLAY_PATTERN_MUTE_OFF = 19
DISPLAY_PATTERN_TURN_ON = 20
DISPLAY_PATTERN_TURN_OFF = 21
DISPLAY_PATTERN_BATTERY_LOW = 22
DISPLAY_PATTERN_BATTERY_CHARGING = 23
DISPLAY_PATTERN_BATTERY_FULL = 24
DISPLAY_PATTERN_POWERON_INIT = 25
DISPLAY_PATTERN_WIFI_NO_CFG = 26
DISPLAY_PATTERN_SPEECH_BEGIN = 27
DISPLAY_PATTERN_SPEECH_OVER = 28
DISPLAY_PATTERN_MAX

Header File

Functions

void aw2013_led_bar_task(void *parameters)
esp_periph_handle_t led_bar_aw2013_init(void)

Initialize led bar instance.

Return

  • NULL Error

  • others Success

esp_err_t led_bar_aw2013_pattern(void *handle, int pat, int value)

Set led bar display pattern.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led bar instance

  • pat: display pattern

  • value: value of pattern

Set blinking period and times.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led bar instance

  • time: times of blink

  • period: period of blink

void led_bar_aw2013_deinit(esp_periph_handle_t handle)

Destroy esp_periph_handle_t instance.

Parameters
  • handle: led bar instance

Header File

Functions

esp_periph_handle_t led_bar_is31x_init()

Initialize esp_periph_handle_t instance.

Return

  • NULL, Fail

  • Others, Success

esp_err_t led_bar_is31x_pattern(void *handle, int pat, int value)

Set led bar display pattern.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led bar instance

  • pat: display pattern

  • value: value of pattern

void led_bar_is31x_deinit(esp_periph_handle_t handle)

Destroy esp_periph_handle_t instance.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led bar instance

Header File

Functions

led_bar_ws2812_handle_t led_bar_ws2812_init(gpio_num_t gpio_num, int led_num)

Initialize led_bar_ws2812_handle_t instance.

Return

  • led_bar_ws2812_handle_t

Parameters
  • gpio_num: The GPIO number of ws2812

  • led_num: The number of all ws2812

esp_err_t led_bar_ws2812_pattern(void *handle, int pat, int value)

Set ws2812 pattern.

Return

  • ESP_OK, success

  • Others, fail

Parameters
  • handle: ws2812 indicator instance

  • pat: display pattern

  • value: value of pattern

esp_err_t led_bar_ws2812_deinit(led_bar_ws2812_handle_t handle)

Destroy led_bar_ws2812_handle_t instance.

Return

Return

  • ESP_OK, success

  • Others, fail

Parameters
  • handle: ws2812 indicator instance

Type Definitions

typedef struct led_bar_ws2812_impl *led_bar_ws2812_handle_t

Header File

Functions

led_indicator_handle_t led_indicator_init(gpio_num_t num)

Initialize led_indicator_handle_t instance.

Return

  • NULL, Fail

  • Others, Success

Parameters
  • num: led gpio number

esp_err_t led_indicator_pattern(void *handle, int pat, int value)

Set led indicator display pattern.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led indicator instance

  • pat: display pattern

  • value: value of pattern

void led_indicator_deinit(led_indicator_handle_t handle)

Destroy led_indicator_handle_t instance.

Return

  • ESP_OK

  • ESP_FAIL

Parameters
  • handle: led indicator instance

Type Definitions

typedef struct led_indicator_impl *led_indicator_handle_t