From 8aaed133e8da85987817a726e297bdaed435d2b4 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Fri, 14 Feb 2025 15:56:15 -0500 Subject: [PATCH] Update Display getters. --- esp/cpp/07_lcd-panel/main/display.h | 9 +++++++-- esp/cpp/07_lcd-panel/main/main.cpp | 12 +++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/esp/cpp/07_lcd-panel/main/display.h b/esp/cpp/07_lcd-panel/main/display.h index e98d290..12f12b9 100644 --- a/esp/cpp/07_lcd-panel/main/display.h +++ b/esp/cpp/07_lcd-panel/main/display.h @@ -46,9 +46,14 @@ public: ~Display() = default; - [[nodiscard]] const lv_display_t *get_display() const { return display_; } - [[nodiscard]] lv_display_t *get_display() { return display_; } + [[nodiscard]] inline const lv_display_t *get() const { return display_; } + + [[nodiscard]] inline lv_display_t *get() { return display_; } + + [[nodiscard]] inline const lv_display_t *operator*() const { return get(); } + + [[nodiscard]] inline lv_display_t *operator*() { return get(); } static bool lvgl_flush_ready(esp_lcd_panel_io_handle_t panel, esp_lcd_panel_io_event_data_t *data, diff --git a/esp/cpp/07_lcd-panel/main/main.cpp b/esp/cpp/07_lcd-panel/main/main.cpp index 93c30cf..93bf35b 100644 --- a/esp/cpp/07_lcd-panel/main/main.cpp +++ b/esp/cpp/07_lcd-panel/main/main.cpp @@ -13,17 +13,15 @@ void setup() ScopedLock lock(Display::lvgl_api_lock_); ESP_LOGI(TAG, "Display LVGL Scroll Text"); - lv_obj_t *scr = lv_display_get_screen_active(d.get_display()); + lv_obj_t *scr = lv_display_get_screen_active(d.get()); lv_obj_t *label = lv_label_create(scr); // Circular scroll - lv_label_set_long_mode(label, - LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_label_set_text(label, - "Hello hello hello hello hello hello hello hello."); + lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_label_set_text(label, "Hello hello hello hello hello hello hello."); + // Size of the screen // if you use rotation 90 or 270 use lv_display_get_vertical_resolution - lv_obj_set_width(label, - lv_display_get_horizontal_resolution(d.get_display())); + lv_obj_set_width(label, lv_display_get_horizontal_resolution(*d)); lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0); } }