Skip to content

Commit da184c6

Browse files
committed
Fix backlight duty validation and update error messages for CST816S touch controller
1 parent fd3628c commit da184c6

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/esp32_smartdisplay.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ void smartdisplay_lcd_set_backlight(float duty)
5151
{
5252
log_v("duty:%2f", duty);
5353

54-
if (duty > 1.0f)
55-
duty = 1.0f;
56-
if (duty < 0.0f)
57-
duty = 0.0f;
54+
if (duty < 0.0f || duty > 1.0f || isnan(duty))
55+
{
56+
log_e("Invalid duty value: %f", duty);
57+
return;
58+
}
59+
5860
#if ESP_ARDUINO_VERSION_MAJOR >= 3
5961
ledcWrite(DISPLAY_BCKL, duty * PWM_MAX_BCKL);
6062
#else

src/esp_touch_cst816s.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
268268
// Reset controller
269269
if ((res = cst816s_reset(th)) != ESP_OK)
270270
{
271-
log_e("GT911 reset failed");
271+
log_e("CST826S reset failed");
272272
cst816s_del(th);
273273
return res;
274274
}
275275

276276
// Read type and resolution
277277
if ((res = cst816s_read_info(th)) != ESP_OK)
278278
{
279-
log_e("GT911 read info failed");
279+
log_e("CST826S read info failed");
280280
cst816s_del(th);
281281
return res;
282282
}

0 commit comments

Comments
 (0)