diff --git a/components/display/include/display.hpp b/components/display/include/display.hpp index bf4e967d9..05529aad9 100644 --- a/components/display/include/display.hpp +++ b/components/display/include/display.hpp @@ -14,16 +14,16 @@ namespace espp { - /** - * @brief Possible orientations of the display. - */ - enum class DisplayRotation : uint8_t { LANDSCAPE, PORTRAIT, LANDSCAPE_INVERTED, PORTRAIT_INVERTED }; +/** + * @brief Possible orientations of the display. + */ +enum class DisplayRotation : uint8_t { LANDSCAPE, PORTRAIT, LANDSCAPE_INVERTED, PORTRAIT_INVERTED }; - /** - * @brief Signals used by LVGL to let the post_transfer_callback know - * whether or not to call lv_disp_flush_ready. - */ - enum class DisplaySignal : uint32_t { NONE, FLUSH }; +/** + * @brief Signals used by LVGL to let the post_transfer_callback know + * whether or not to call lv_disp_flush_ready. + */ +enum class DisplaySignal : uint32_t { NONE, FLUSH }; /** * @brief Wrapper class around LVGL display buffer and display driver. @@ -36,8 +36,8 @@ namespace espp { * For more information, see * https://docs.lvgl.io/9.1/porting/display.html#display-interface * - * @tparam Pixel The pixel format to be used for the display. This allows the class to be used with displays - * of different color depths and formats. + * @tparam Pixel The pixel format to be used for the display. This allows the class to be used with + * displays of different color depths and formats. */ template class Display : public BaseComponent { public: @@ -61,7 +61,8 @@ template class Display : public BaseComponent { size_t height; /**< Height of the display, in pixels. */ size_t pixel_buffer_size; /**< Size of the display buffer in pixels. */ flush_fn flush_callback; /**< Function provided to LVGL for it to flush data to the display. */ - rotation_fn rotation_callback{nullptr}; /**< Function used to configure display with new rotation setting. */ + rotation_fn rotation_callback{ + nullptr}; /**< Function used to configure display with new rotation setting. */ gpio_num_t backlight_pin; /**< GPIO pin for the backlight. */ bool backlight_on_value{ true}; /**< Value to write to the backlight pin to turn the backlight on. */ @@ -76,7 +77,8 @@ template class Display : public BaseComponent { uint32_t allocation_flags{ MALLOC_CAP_8BIT | MALLOC_CAP_DMA}; /**< For configuring how the display buffer is allocated*/ - DisplayRotation rotation{DisplayRotation::LANDSCAPE}; /**< Default / Initial rotation of the display. */ + DisplayRotation rotation{ + DisplayRotation::LANDSCAPE}; /**< Default / Initial rotation of the display. */ bool software_rotation_enabled{ true}; /**< Enable LVGL software display rotation, incurs additional overhead. */ Logger::Verbosity log_level{Logger::Verbosity::WARN}; /**< Verbosity for the Display logger_. */ @@ -94,7 +96,8 @@ template class Display : public BaseComponent { size_t height; /**< Height of the display, in pixels. */ size_t pixel_buffer_size; /**< Size of the display buffer in pixels. */ flush_fn flush_callback; /**< Function provided to LVGL for it to flush data to the display. */ - rotation_fn rotation_callback{nullptr}; /**< Function used to configure display with new rotation setting. */ + rotation_fn rotation_callback{ + nullptr}; /**< Function used to configure display with new rotation setting. */ gpio_num_t backlight_pin; /**< GPIO pin for the backlight. */ bool backlight_on_value{ true}; /**< Value to write to the backlight pin to turn the backlight on. */ @@ -103,8 +106,9 @@ template class Display : public BaseComponent { .priority = 20, .core_id = 0}; /**< Task configuration. */ std::chrono::duration update_period{ - 0.01}; /**< How frequently to run the update function. */ - DisplayRotation rotation{DisplayRotation::LANDSCAPE}; /**< Default / Initial rotation of the display. */ + 0.01}; /**< How frequently to run the update function. */ + DisplayRotation rotation{ + DisplayRotation::LANDSCAPE}; /**< Default / Initial rotation of the display. */ bool software_rotation_enabled{ true}; /**< Enable LVGL software display rotation, incurs additional overhead. */ Logger::Verbosity log_level{Logger::Verbosity::WARN}; /**< Verbosity for the Display logger_. */ @@ -140,8 +144,7 @@ template class Display : public BaseComponent { assert(vram_1_ != NULL); } created_vram_ = true; - init(config.flush_callback, config.rotation_callback, config.rotation, - config.task_config); + init(config.flush_callback, config.rotation_callback, config.rotation, config.task_config); set_brightness(1.0f); } @@ -168,8 +171,7 @@ template class Display : public BaseComponent { .duty_resolution = LEDC_TIMER_10_BIT}) , update_period_(config.update_period) { logger_.debug("Initializing with non-allocating config!"); - init(config.flush_callback, config.rotation_callback, config.rotation, - config.task_config); + init(config.flush_callback, config.rotation_callback, config.rotation, config.task_config); } /** @@ -271,7 +273,7 @@ template class Display : public BaseComponent { * @brief LVGL event handler. */ static void event_cb(lv_event_t *event) { - if(event->code == LV_EVENT_RESOLUTION_CHANGED) { + if (event->code == LV_EVENT_RESOLUTION_CHANGED) { auto rotation = lv_display_get_rotation(lv_display_get_default()); auto rotation_callback = reinterpret_cast(lv_event_get_user_data(event)); if (rotation_callback != nullptr) { @@ -289,7 +291,8 @@ template class Display : public BaseComponent { * @param rotation Default / initial rotation of the display. * @param task_config Configuration for the task that runs the lvgl tick */ - void init(flush_fn flush_callback, rotation_fn rotation_callback, DisplayRotation rotation, const Task::BaseConfig &task_config) { + void init(flush_fn flush_callback, rotation_fn rotation_callback, DisplayRotation rotation, + const Task::BaseConfig &task_config) { lv_init(); display_ = lv_display_create(width_, height_); diff --git a/components/display_drivers/example/main/display_drivers_example.cpp b/components/display_drivers/example/main/display_drivers_example.cpp index 961fc800f..98062cd9b 100644 --- a/components/display_drivers/example/main/display_drivers_example.cpp +++ b/components/display_drivers/example/main/display_drivers_example.cpp @@ -131,9 +131,9 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat trans[0].tx_data[0] = (uint8_t)espp::Gc9a01::Command::caset; #endif trans[1].tx_data[0] = (xs) >> 8; - trans[1].tx_data[1] = (xs) & 0xff; + trans[1].tx_data[1] = (xs)&0xff; trans[1].tx_data[2] = (xe) >> 8; - trans[1].tx_data[3] = (xe) & 0xff; + trans[1].tx_data[3] = (xe)&0xff; #if CONFIG_HARDWARE_WROVER_KIT trans[2].tx_data[0] = (uint8_t)espp::Ili9341::Command::raset; #elif CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX @@ -142,9 +142,9 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat trans[2].tx_data[0] = (uint8_t)espp::Gc9a01::Command::raset; #endif trans[3].tx_data[0] = (ys) >> 8; - trans[3].tx_data[1] = (ys) & 0xff; + trans[3].tx_data[1] = (ys)&0xff; trans[3].tx_data[2] = (ye) >> 8; - trans[3].tx_data[3] = (ye) & 0xff; + trans[3].tx_data[3] = (ye)&0xff; #if CONFIG_HARDWARE_WROVER_KIT trans[4].tx_data[0] = (uint8_t)espp::Ili9341::Command::ramwr; #elif CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX diff --git a/components/display_drivers/include/gc9a01.hpp b/components/display_drivers/include/gc9a01.hpp index 89e0421d2..d38120c08 100644 --- a/components/display_drivers/include/gc9a01.hpp +++ b/components/display_drivers/include/gc9a01.hpp @@ -395,7 +395,7 @@ class Gc9a01 { static gpio_num_t dc_pin_; static int offset_x_; static int offset_y_; - static inline bool swap_xy_ = false; - static inline std::mutex spi_mutex_{}; + static bool swap_xy_; + static std::mutex spi_mutex_; }; } // namespace espp diff --git a/components/display_drivers/include/ili9341.hpp b/components/display_drivers/include/ili9341.hpp index 4599ae430..44e5722af 100644 --- a/components/display_drivers/include/ili9341.hpp +++ b/components/display_drivers/include/ili9341.hpp @@ -325,7 +325,7 @@ class Ili9341 { static gpio_num_t dc_pin_; static int offset_x_; static int offset_y_; - static inline bool swap_xy_ = false; - static inline std::mutex spi_mutex_{}; + static bool swap_xy_; + static std::mutex spi_mutex_; }; } // namespace espp diff --git a/components/display_drivers/include/st7789.hpp b/components/display_drivers/include/st7789.hpp index 05dd08811..5ec2c60e6 100644 --- a/components/display_drivers/include/st7789.hpp +++ b/components/display_drivers/include/st7789.hpp @@ -394,7 +394,7 @@ class St7789 { static gpio_num_t dc_pin_; static int offset_x_; static int offset_y_; - static inline bool swap_xy_ = false; - static inline std::mutex spi_mutex_{}; + static bool swap_xy_; + static std::mutex spi_mutex_; }; } // namespace espp diff --git a/components/display_drivers/src/gc9a01.cpp b/components/display_drivers/src/gc9a01.cpp index 29ccb49e1..f99bd9882 100644 --- a/components/display_drivers/src/gc9a01.cpp +++ b/components/display_drivers/src/gc9a01.cpp @@ -6,3 +6,5 @@ gpio_num_t espp::Gc9a01::reset_pin_; gpio_num_t espp::Gc9a01::dc_pin_; int espp::Gc9a01::offset_x_; int espp::Gc9a01::offset_y_; +bool espp::Gc9a01::swap_xy_ = false; +std::mutex espp::Gc9a01::spi_mutex_; diff --git a/components/display_drivers/src/ili9341.cpp b/components/display_drivers/src/ili9341.cpp index a8c4ad577..92b6d3150 100644 --- a/components/display_drivers/src/ili9341.cpp +++ b/components/display_drivers/src/ili9341.cpp @@ -6,3 +6,5 @@ gpio_num_t espp::Ili9341::reset_pin_; gpio_num_t espp::Ili9341::dc_pin_; int espp::Ili9341::offset_x_; int espp::Ili9341::offset_y_; +bool espp::Ili9341::swap_xy_ = false; +std::mutex espp::Ili9341::spi_mutex_; diff --git a/components/display_drivers/src/st7789.cpp b/components/display_drivers/src/st7789.cpp index 660c2df0d..af59782e8 100644 --- a/components/display_drivers/src/st7789.cpp +++ b/components/display_drivers/src/st7789.cpp @@ -6,3 +6,5 @@ gpio_num_t espp::St7789::reset_pin_; gpio_num_t espp::St7789::dc_pin_; int espp::St7789::offset_x_; int espp::St7789::offset_y_; +bool espp::St7789::swap_xy_ = false; +std::mutex espp::St7789::spi_mutex_; diff --git a/components/esp-box/include/esp-box.hpp b/components/esp-box/include/esp-box.hpp index 880d75a32..ee4f6d51e 100644 --- a/components/esp-box/include/esp-box.hpp +++ b/components/esp-box/include/esp-box.hpp @@ -302,7 +302,7 @@ class EspBox : public BaseComponent { static constexpr auto touch_interrupt_level = espp::Interrupt::ActiveLevel::HIGH; static constexpr auto touch_interrupt_type = espp::Interrupt::Type::RISING_EDGE; static constexpr auto touch_interrupt_pullup_enabled = false; - }; // struct box3 + }; // struct box3 // box: struct box { @@ -384,15 +384,13 @@ class EspBox : public BaseComponent { // NOTE: the active level, interrupt type, and pullup configuration is set by // detect(), since it depends on the box type - espp::Interrupt::PinConfig touch_interrupt_pin_{ - .gpio_num = touch_interrupt, - .callback = - [this](const auto &event) { - update_touch(); - if (touch_callback_) { - touch_callback_(touchpad_data()); - } - }}; + espp::Interrupt::PinConfig touch_interrupt_pin_{.gpio_num = touch_interrupt, + .callback = [this](const auto &event) { + update_touch(); + if (touch_callback_) { + touch_callback_(touchpad_data()); + } + }}; // we'll only add each interrupt pin if the initialize method is called espp::Interrupt interrupts_{ diff --git a/components/esp-box/src/esp-box.cpp b/components/esp-box/src/esp-box.cpp index d096d138d..af5336899 100644 --- a/components/esp-box/src/esp-box.cpp +++ b/components/esp-box/src/esp-box.cpp @@ -310,7 +310,7 @@ bool EspBox::initialize_display(size_t pixel_buffer_size) { } // initialize the display / lvgl using namespace std::chrono_literals; - display_ = std::make_shared>(espp::Display::AllocatingConfig{ + display_ = std::make_shared>(espp::Display::AllocatingConfig{ .width = lcd_width_, .height = lcd_height_, .pixel_buffer_size = pixel_buffer_size, diff --git a/components/matouch-rotary-display/example/main/matouch_rotary_display_example.cpp b/components/matouch-rotary-display/example/main/matouch_rotary_display_example.cpp index 033f86c79..c6b94903f 100644 --- a/components/matouch-rotary-display/example/main/matouch_rotary_display_example.cpp +++ b/components/matouch-rotary-display/example/main/matouch_rotary_display_example.cpp @@ -116,8 +116,9 @@ extern "C" void app_main(void) { { std::lock_guard lock(lvgl_mutex); int encoder_count = mt_display.encoder_value(); - lv_label_set_text_fmt( - label, "Touch the screen!\nPress the button to clear circles.\nEncoder: %d", encoder_count); + lv_label_set_text_fmt(label, + "Touch the screen!\nPress the button to clear circles.\nEncoder: %d", + encoder_count); } // sleep for the remaining time auto end = esp_timer_get_time(); diff --git a/components/matouch-rotary-display/src/matouch-rotary-display.cpp b/components/matouch-rotary-display/src/matouch-rotary-display.cpp index 31f60b851..e069ca8d3 100644 --- a/components/matouch-rotary-display/src/matouch-rotary-display.cpp +++ b/components/matouch-rotary-display/src/matouch-rotary-display.cpp @@ -305,7 +305,9 @@ bool MatouchRotaryDisplay::initialize_display(size_t pixel_buffer_size) { return true; } -std::shared_ptr> MatouchRotaryDisplay::display() const { return display_; } +std::shared_ptr> MatouchRotaryDisplay::display() const { + return display_; +} void IRAM_ATTR MatouchRotaryDisplay::lcd_wait_lines() { spi_transaction_t *rtrans;