diff --git a/esp/cpp/07_lcd-panel/main/display.cpp b/esp/cpp/07_lcd-panel/main/display.cpp index 7c4b5aa..38bd976 100644 --- a/esp/cpp/07_lcd-panel/main/display.cpp +++ b/esp/cpp/07_lcd-panel/main/display.cpp @@ -1,13 +1,13 @@ -#include "display.h" -#include "ssd1306.h" - #include #include #include +#include "display.h" +#include "ssd1306.h" + // LVGL library is not thread-safe, this example calls LVGL APIs from tasks. // We must use a mutex to protect it. _lock_t Display::ScopedLock::lv_lock_; @@ -30,11 +30,9 @@ Display::Display(IPanelDevice &device) : lv_display_set_user_data(lv_display_, panel_.esp_panel_); register_draw_buffer(); - register_lvgl_tick_timer(); - // TODO: What is this - ESP_LOGI(TAG, "Create LVGL task"); + ESP_LOGI(TAG, "Create LVGL FreeRTOS task"); xTaskCreate(Display::lvgl_port_task, "LVGL", LVGL_TASK_STACK_SIZE, nullptr, LVGL_TASK_PRIORITY, nullptr); } diff --git a/esp/cpp/07_lcd-panel/main/display.h b/esp/cpp/07_lcd-panel/main/display.h index cd9f13a..62971fd 100644 --- a/esp/cpp/07_lcd-panel/main/display.h +++ b/esp/cpp/07_lcd-panel/main/display.h @@ -1,10 +1,11 @@ #ifndef DISPLAY_H #define DISPLAY_H +#include + #include #include -#include #include #include "panel.h" @@ -51,7 +52,7 @@ class Display { return &managed_timers_.at(name); } - TimerHandle operator[](const char * name) { return get_handle(name); } + TimerHandle operator[](const char *name) { return get_handle(name); } TimerHandle create_timer(esp_timer_create_args_t args) { @@ -144,7 +145,7 @@ public: private: void register_draw_buffer(); - void register_lvgl_tick_timer(); + static void register_lvgl_tick_timer(); Panel panel_; diff --git a/esp/cpp/07_lcd-panel/main/ssd1306.cpp b/esp/cpp/07_lcd-panel/main/ssd1306.cpp index ed06643..75dab2e 100644 --- a/esp/cpp/07_lcd-panel/main/ssd1306.cpp +++ b/esp/cpp/07_lcd-panel/main/ssd1306.cpp @@ -4,7 +4,7 @@ // To use LV_COLOR_FORMAT_I1 we need an extra buffer to hold the converted data. uint8_t SSD1306::oled_buffer_[LCD_H_RES * LCD_V_RES / 8]; -SSD1306::SSD1306(I2C& i2c, +SSD1306::SSD1306(I2C &i2c, esp_lcd_panel_ssd1306_config_t config, int width, int height) : @@ -14,11 +14,10 @@ SSD1306::SSD1306(I2C& i2c, .control_phase_bytes = 1, .dc_bit_offset = 6, .lcd_cmd_bits = LCD_CMD_BITS, - .lcd_param_bits = LCD_CMD_BITS, + .lcd_param_bits = LCD_PARAM_BITS, .scl_speed_hz = LCD_PIXEL_CLOCK_HZ, }, width, height ), - ssd1306_config_(config) -{ } + ssd1306_config_(config) { } diff --git a/esp/cpp/07_lcd-panel/main/ssd1306.h b/esp/cpp/07_lcd-panel/main/ssd1306.h index 9548406..5c75eab 100644 --- a/esp/cpp/07_lcd-panel/main/ssd1306.h +++ b/esp/cpp/07_lcd-panel/main/ssd1306.h @@ -20,17 +20,17 @@ // According to SSD1306 datasheet // https://www.digikey.com/en/products/detail/winstar-display/WEA012864DWPP3N00003/20533255 -// Bit number used to represent command and parameter #define SCREEN_WIDTH 128 // OLED display width, in pixels. #define SCREEN_HEIGHT 64 // OLED display height, in pixels. #define LCD_H_RES SCREEN_WIDTH #define LCD_V_RES SCREEN_HEIGHT #define I2C_HW_ADDR 0x3C #define LCD_PIXEL_CLOCK_HZ (400 * 1000) +// Bit number used to represent command and parameter #define LCD_CMD_BITS 8 #define LCD_PARAM_BITS 8 -class SSD1306 : public IPanelDevice { +class SSD1306 final : public IPanelDevice { public: // Constructors allow overriding ssd1306 config. explicit SSD1306(I2C &i2c) : @@ -42,7 +42,7 @@ public: int height = SCREEN_HEIGHT ); - virtual ~SSD1306() = default; + ~SSD1306() final = default; void *vendor_config() override {