diff --git a/include/zh_ac_dimmer.h b/include/zh_ac_dimmer.h index 318d7d9..2b33191 100644 --- a/include/zh_ac_dimmer.h +++ b/include/zh_ac_dimmer.h @@ -76,6 +76,15 @@ extern "C" */ esp_err_t zh_ac_dimmer_set(uint8_t value); + /** + * @brief Get AC dimmer dimming value. + * + * @param[out] value Pointer to dimming value. + * + * @return ESP_OK if success or an error code otherwise. + */ + esp_err_t zh_ac_dimmer_get(uint8_t *value); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/version.txt b/version.txt index 8cfbc90..867e524 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.1 \ No newline at end of file +1.2.0 \ No newline at end of file diff --git a/zh_ac_dimmer.c b/zh_ac_dimmer.c index e47c4fb..c4ec561 100755 --- a/zh_ac_dimmer.c +++ b/zh_ac_dimmer.c @@ -109,6 +109,16 @@ esp_err_t zh_ac_dimmer_set(uint8_t value) return ESP_OK; } +esp_err_t zh_ac_dimmer_get(uint8_t *value) +{ + ZH_LOGI("AC dimmer getting status begin."); + ZH_ERROR_CHECK(value != NULL, ESP_ERR_INVALID_ARG, NULL, "AC dimmer getting status failed. Value is NULL."); + ZH_ERROR_CHECK(_is_initialized == true, ESP_ERR_INVALID_STATE, NULL, "AC dimmer getting status failed. AC dimmer is not initialized."); + *value = _dimmer_value; + ZH_LOGI("AC dimmer getting status completed successfully."); + return ESP_OK; +} + static esp_err_t _zh_ac_dimmer_validate_config(const zh_ac_dimmer_init_config_t *config) { ZH_ERROR_CHECK(config != NULL, ESP_ERR_INVALID_ARG, NULL, "Initial config is NULL.");