Tweak backlight dimming

This commit is contained in:
fvanroie 2021-02-20 01:53:59 +01:00
parent 5951214138
commit 94842f7036
5 changed files with 14 additions and 22 deletions

View File

@ -43,7 +43,10 @@ extern "C" {
void monitor_init(void);
void monitor_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p);
void monitor_flush2(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p);
// HASP Customized functions
void monitor_backlight(uint8_t level);
void monitor_title(const char* title);
/**********************
* MACROS

View File

@ -42,7 +42,7 @@ const char* Esp32Device::get_display_driver()
void Esp32Device::set_backlight_pin(uint8_t pin)
{
Esp32Device::_backlight_pin = pin;
_backlight_pin = pin;
/* Setup Backlight Control Pin */
if(pin < GPIO_NUM_MAX) {
@ -81,7 +81,7 @@ bool Esp32Device::get_backlight_power()
void Esp32Device::update_backlight()
{
if(pin < GPIO_NUM_MAX) {
if(_backlight_pin < GPIO_NUM_MAX) {
uint32_t duty = _backlight_power ? map(_backlight_level, 0, 100, 0, 4095) : 0;
ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value
}

View File

@ -40,9 +40,13 @@ void Win32Device::set_backlight_pin(uint8_t pin)
void Win32Device::set_backlight_level(uint8_t level)
{
_backlight_level = level >= 0 ? level : 0;
_backlight_level = _backlight_level <= 100 ? _backlight_level : 100;
update_backlight();
uint8_t new_level = level >= 0 ? level : 0;
new_level = new_level <= 100 ? new_level : 100;
if(_backlight_level != new_level) {
_backlight_level = new_level;
update_backlight();
}
}
uint8_t Win32Device::get_backlight_level()

View File

@ -897,32 +897,20 @@ void dispatch_output_statusupdate(const char*, const char*)
{
char buffer[128];
printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout);
haspGetVersion(buffer, sizeof(buffer));
snprintf_P(data, sizeof(data),
PSTR("{\"node\":\"%s\",\"status\":\"available\",\"version\":\"%s\",\"uptime\":%lu,"),
haspDevice.get_hostname(), buffer, long(millis() / 1000));
printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout);
#if HASP_USE_WIFI > 0
network_get_statusupdate(buffer, sizeof(buffer));
strcat(data, buffer);
#endif
printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout);
snprintf_P(buffer, sizeof(buffer), PSTR("\"heapFree\":%u,\"heapFrag\":%u,\"espCore\":\"%s\","),
haspDevice.get_free_heap(), haspDevice.get_heap_fragmentation(), haspDevice.get_core_version());
strcat(data, buffer);
printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout);
snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u,"),
haspGetPage(), (HASP_NUM_PAGES));
strcat(data, buffer);
@ -932,9 +920,6 @@ void dispatch_output_statusupdate(const char*, const char*)
strcat(data, buffer);
#endif
printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout);
snprintf_P(buffer, sizeof(buffer), PSTR("\"tftDriver\":\"%s\",\"tftWidth\":%u,\"tftHeight\":%u}"),
haspDevice.get_display_driver(), (TFT_WIDTH), (TFT_HEIGHT));
strcat(data, buffer);
@ -1019,7 +1004,7 @@ void dispatchSetup()
void dispatchLoop()
{
// Not used
lv_task_handler(); // process animations
}
#if 1 || ARDUINO

View File

@ -205,6 +205,7 @@ void guiSetup(void)
/* Setup Backlight Control Pin */
haspDevice.set_backlight_pin(gui_settings.backlight_pin);
// if(gui_settings.backlight_pin >= 0) {
// LOG_VERBOSE(TAG_GUI, F("Backlight : Pin %d"), gui_settings.backlight_pin);
@ -290,7 +291,6 @@ void guiLoop(void)
// tick.update();
#endif
lv_task_handler(); // process animations
#if !defined(WINDOWS)
drv_touch_loop(); // update touch
#endif