Light Controller Exported Functions

group Light_Controller_Exported_Functions

Exported functions for the light controller module.

Functions

bool light_controller_init(void)

Initializes the light controller.

返回值:
  • true -- Initialization successful.

  • false -- Initialization failed. Ensure that the platform types are correctly defined and the initialization conditions are met.

返回:

The operation result.

void light_controller_deinit(void)

Deinitializes the light controller.

void light_set_lightness_linear(light_t *light, uint16_t lightness, uint32_t time, light_change_done_cb cb)

Sets lightness gradual change for a light channel.

参数:
  • light -- [in] Pointer to the light channel.

  • lightness -- [in] Target lightness. Value range is 0-65535.

  • time -- [in] Gradual change time in milliseconds.

  • cb -- [in] Callback function invoked upon light change completion.

void light_blink(light_t *light, uint16_t lightness_begin, uint16_t lightness_end, uint32_t interval, uint8_t begin_duty, uint32_t times, light_change_done_cb cb)

Causes the light to blink.

参数:
  • light -- [in] Pointer to the light channel.

  • lightness_begin -- [in] Blink start lightness. Value range is 0-65535.

  • lightness_end -- [in] Blink end lightness. Value range is 0-65535.

  • interval -- [in] Blink interval in milliseconds.

  • begin_duty -- [in] Start lightness duty cycle in total interval, value range is 0-100. For example, if interval is 1000ms, and duty is set to 60, then start lightness will last for 600ms.

  • cb -- [in] Callback function called when light change is done.

  • times -- [in] Number of blink cycles.

void light_breath(light_t *light, uint16_t lightness_begin, uint16_t lightness_end, uint32_t interval, uint8_t forward_duty, uint32_t times, bool half_breath_end, light_change_done_cb cb)

Causes the light to breathe.

参数:
  • light -- [in] Pointer to the light channel.

  • lightness_begin -- [in] Breath start lightness. Value range is 0-65535.

  • lightness_end -- [in] Breath end lightness. Value range is 0-65535.

  • interval -- [in] Breath cycle time, in milliseconds.

  • forward_duty -- [in] Start lightness duty in total interval, value range is 0-100. For example, if interval is 1000ms, duty is 60, then start lightness will last for 600ms.

  • times -- [in] Number of breath cycles.

  • half_breath_end -- [in] Indicates if the last breath is half or not. If true, lightness will remain at lightness_end. Default is false.

  • cb -- [in] Callback function invoked upon breath completion.

void light_stop(light_t *light)

Stops the current action on a light channel.

参数:

light -- [in] Pointer to the light channel to stop the action.

bool is_light_controller_busy(void)

Checks whether the light controller is busy or not.

返回值:
  • true -- Controller is currently busy.

  • false -- Controller is currently idle. Check for pending operations or errors.

返回:

The operation result.

bool is_light_busy(const light_t *light)

Checks whether a specific light is busy or not.

参数:

light -- [in] Pointer to the light channel to check.

返回值:
  • true -- The specified light is busy.

  • false -- The specified light is idle. Ensure light operations are properly initiated if expected take action.

返回:

The operation result.