mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
CI: add astyle pre-commit hook
This commit is contained in:
@@ -32,7 +32,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief adc button configuration
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
adc_channel_t adc_channel; /**< Channel of ADC */
|
||||
@@ -43,9 +43,9 @@ typedef struct {
|
||||
|
||||
/**
|
||||
* @brief Initialize gpio button
|
||||
*
|
||||
*
|
||||
* @param config pointer of configuration struct
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is NULL.
|
||||
@@ -56,10 +56,10 @@ esp_err_t button_adc_init(const button_adc_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize gpio button
|
||||
*
|
||||
*
|
||||
* @param channel ADC channel
|
||||
* @param button_index Button index on the channel
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid.
|
||||
@@ -68,10 +68,10 @@ esp_err_t button_adc_deinit(adc_channel_t channel, int button_index);
|
||||
|
||||
/**
|
||||
* @brief Get the adc button level
|
||||
*
|
||||
*
|
||||
* @param button_index It is compressed by ADC channel and button index, use the macro ADC_BUTTON_COMBINE to generate. It will be treated as a uint32_t variable.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
* - 0 Not pressed
|
||||
* - 1 Pressed
|
||||
*/
|
||||
|
||||
@@ -22,18 +22,18 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief gpio button configuration
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t gpio_num; /**< num of gpio */
|
||||
uint8_t active_level; /**< gpio level when press down */
|
||||
int32_t gpio_num; /**< num of gpio */
|
||||
uint8_t active_level; /**< gpio level when press down */
|
||||
} button_gpio_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize gpio button
|
||||
*
|
||||
*
|
||||
* @param config pointer of configuration struct
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is NULL.
|
||||
@@ -42,18 +42,18 @@ esp_err_t button_gpio_init(const button_gpio_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize gpio button
|
||||
*
|
||||
*
|
||||
* @param gpio_num gpio number of button
|
||||
*
|
||||
*
|
||||
* @return Always return ESP_OK
|
||||
*/
|
||||
esp_err_t button_gpio_deinit(int gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Get current level on button gpio
|
||||
*
|
||||
*
|
||||
* @param gpio_num gpio number of button, it will be treated as a uint32_t variable.
|
||||
*
|
||||
*
|
||||
* @return Level on gpio
|
||||
*/
|
||||
uint8_t button_gpio_get_key_level(void *gpio_num);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#define LED_CHANNEL 0 /* RMT_CHANNEL_0 */
|
||||
#define BUTTON_GPIO_PIN GPIO_NUM_9
|
||||
|
||||
|
||||
led_driver_config_t led_driver_get_config()
|
||||
{
|
||||
led_driver_config_t config = {
|
||||
|
||||
@@ -83,7 +83,8 @@ const HS_color_t temp_table[] = {
|
||||
{0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10},
|
||||
{227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16},
|
||||
{223, 16}, {223, 17}, {223, 17}, {223, 17}, {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19},
|
||||
{222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21}};
|
||||
{222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21}
|
||||
};
|
||||
|
||||
void temp_to_hs(uint32_t temperature, HS_color_t *HS)
|
||||
{
|
||||
@@ -107,10 +108,10 @@ void xy_to_rgb(XY_color_t XY, uint8_t brightness, RGB_color_t *RGB)
|
||||
float x = (float)XY.x / 65536.0f;
|
||||
float y = (float)XY.y / 65536.0f;
|
||||
float z = 1.0f - x - y;
|
||||
|
||||
|
||||
// Convert brightness (0-255) to Y value (0.0-1.0)
|
||||
float Y = (float)brightness / 255.0f;
|
||||
|
||||
|
||||
// Convert from xy to XYZ
|
||||
float X, Z;
|
||||
if (y > 0.0f) {
|
||||
@@ -120,39 +121,51 @@ void xy_to_rgb(XY_color_t XY, uint8_t brightness, RGB_color_t *RGB)
|
||||
X = 0.0f;
|
||||
Z = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
// Convert XYZ to RGB using D65 white point matrix
|
||||
float r = X * 3.240479f - Y * 1.537150f - Z * 0.498535f;
|
||||
float g = -X * 0.969256f + Y * 1.875992f + Z * 0.041556f;
|
||||
float b = X * 0.055648f - Y * 0.204043f + Z * 1.057311f;
|
||||
|
||||
|
||||
// Apply reverse gamma correction
|
||||
if (r <= 0.0031308f) {
|
||||
r = 12.92f * r;
|
||||
} else {
|
||||
r = (1.0f + 0.055f) * powf(r, (1.0f / 2.4f)) - 0.055f;
|
||||
}
|
||||
|
||||
|
||||
if (g <= 0.0031308f) {
|
||||
g = 12.92f * g;
|
||||
} else {
|
||||
g = (1.0f + 0.055f) * powf(g, (1.0f / 2.4f)) - 0.055f;
|
||||
}
|
||||
|
||||
|
||||
if (b <= 0.0031308f) {
|
||||
b = 12.92f * b;
|
||||
} else {
|
||||
b = (1.0f + 0.055f) * powf(b, (1.0f / 2.4f)) - 0.055f;
|
||||
}
|
||||
|
||||
|
||||
// Clamp values to [0, 1] range
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
if (r > 1.0f) r = 1.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
if (g > 1.0f) g = 1.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
if (b > 1.0f) b = 1.0f;
|
||||
|
||||
if (r < 0.0f) {
|
||||
r = 0.0f;
|
||||
}
|
||||
if (r > 1.0f) {
|
||||
r = 1.0f;
|
||||
}
|
||||
if (g < 0.0f) {
|
||||
g = 0.0f;
|
||||
}
|
||||
if (g > 1.0f) {
|
||||
g = 1.0f;
|
||||
}
|
||||
if (b < 0.0f) {
|
||||
b = 0.0f;
|
||||
}
|
||||
if (b > 1.0f) {
|
||||
b = 1.0f;
|
||||
}
|
||||
|
||||
// Convert to 0-255 range
|
||||
RGB->red = (uint8_t)(r * 255.0f);
|
||||
RGB->green = (uint8_t)(g * 255.0f);
|
||||
|
||||
@@ -61,7 +61,7 @@ static void SetupBrightnessControl(led_driver_config_t *config)
|
||||
static void SetDisplayBrightness(uint8_t brightness)
|
||||
{
|
||||
if (ledc_set_duty(LEDC_HIGH_SPEED_MODE, led_driver_channel, brightness) ||
|
||||
ledc_update_duty(LEDC_HIGH_SPEED_MODE, led_driver_channel)) {
|
||||
ledc_update_duty(LEDC_HIGH_SPEED_MODE, led_driver_channel)) {
|
||||
ESP_LOGE(TAG, "Failed to set display brightness...");
|
||||
}
|
||||
}
|
||||
@@ -155,8 +155,12 @@ esp_err_t led_driver_set_power(led_driver_handle_t handle, bool power)
|
||||
esp_err_t led_driver_set_RGB(led_driver_handle_t handle)
|
||||
{
|
||||
TFT_fillWindow(TFT_BLACK);
|
||||
TFT_fillCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t){mRGB.red, mRGB.green, mRGB.blue});
|
||||
TFT_drawCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t){255, 255, 255});
|
||||
TFT_fillCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t) {
|
||||
mRGB.red, mRGB.green, mRGB.blue
|
||||
});
|
||||
TFT_drawCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t) {
|
||||
255, 255, 255
|
||||
});
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user