From 8a2a2d226558d099243eea0aa9ae22b2791e0e0e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 6 Jun 2023 10:20:46 +1000 Subject: Get basic audio playback going again --- src/drivers/display.cpp | 58 ++++++++++++++++------------------ src/drivers/include/relative_wheel.hpp | 8 +++-- src/drivers/relative_wheel.cpp | 15 ++++----- 3 files changed, 40 insertions(+), 41 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp index 0c9e56b3..af439def 100644 --- a/src/drivers/display.cpp +++ b/src/drivers/display.cpp @@ -97,8 +97,8 @@ auto Display::Create(GpioExpander* expander, gpio_config(&dr_config); gpio_set_level(kDisplayDr, 0); - ledc_timer_config_t led_config { - .speed_mode = LEDC_LOW_SPEED_MODE, + ledc_timer_config_t led_config{ + .speed_mode = LEDC_LOW_SPEED_MODE, .duty_resolution = LEDC_TIMER_13_BIT, .timer_num = LEDC_TIMER_0, .freq_hz = 5000, @@ -106,14 +106,12 @@ auto Display::Create(GpioExpander* expander, }; ledc_timer_config(&led_config); - ledc_channel_config_t led_channel { - .gpio_num = kDisplayLedEn, - .speed_mode = LEDC_LOW_SPEED_MODE, - .channel = LEDC_CHANNEL_0, - .timer_sel = LEDC_TIMER_0, - .duty = 4095, - .hpoint = 0 - }; + ledc_channel_config_t led_channel{.gpio_num = kDisplayLedEn, + .speed_mode = LEDC_LOW_SPEED_MODE, + .channel = LEDC_CHANNEL_0, + .timer_sel = LEDC_TIMER_0, + .duty = 4095, + .hpoint = 0}; ledc_channel_config(&led_channel); // Next, init the SPI device @@ -260,32 +258,32 @@ void Display::OnLvglFlush(lv_disp_drv_t* disp_drv, // area is stack-allocated, so it isn't safe to reference from the flush // thread. lv_area_t area_copy = *area; - //worker_task_->Dispatch([=, this]() { - // Ideally we want to complete a single flush as quickly as possible, so - // grab the bus for this entire transaction sequence. - spi_device_acquire_bus(handle_, portMAX_DELAY); + // worker_task_->Dispatch([=, this]() { + // Ideally we want to complete a single flush as quickly as possible, so + // grab the bus for this entire transaction sequence. + spi_device_acquire_bus(handle_, portMAX_DELAY); - // First we need to specify the rectangle of the display we're writing into. - uint16_t data[2] = {0, 0}; + // First we need to specify the rectangle of the display we're writing into. + uint16_t data[2] = {0, 0}; - data[0] = SPI_SWAP_DATA_TX(area_copy.x1, 16); - data[1] = SPI_SWAP_DATA_TX(area_copy.x2, 16); - SendCommandWithData(displays::ST77XX_CASET, - reinterpret_cast(data), 4); + data[0] = SPI_SWAP_DATA_TX(area_copy.x1, 16); + data[1] = SPI_SWAP_DATA_TX(area_copy.x2, 16); + SendCommandWithData(displays::ST77XX_CASET, reinterpret_cast(data), + 4); - data[0] = SPI_SWAP_DATA_TX(area_copy.y1, 16); - data[1] = SPI_SWAP_DATA_TX(area_copy.y2, 16); - SendCommandWithData(displays::ST77XX_RASET, - reinterpret_cast(data), 4); + data[0] = SPI_SWAP_DATA_TX(area_copy.y1, 16); + data[1] = SPI_SWAP_DATA_TX(area_copy.y2, 16); + SendCommandWithData(displays::ST77XX_RASET, reinterpret_cast(data), + 4); - // Now send the pixels for this region. - uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); - SendCommandWithData(displays::ST77XX_RAMWR, - reinterpret_cast(color_map), size * 2); + // Now send the pixels for this region. + uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); + SendCommandWithData(displays::ST77XX_RAMWR, + reinterpret_cast(color_map), size * 2); - spi_device_release_bus(handle_); + spi_device_release_bus(handle_); - lv_disp_flush_ready(&driver_); + lv_disp_flush_ready(&driver_); //}); } diff --git a/src/drivers/include/relative_wheel.hpp b/src/drivers/include/relative_wheel.hpp index 3ff64b70..da4f9e3d 100644 --- a/src/drivers/include/relative_wheel.hpp +++ b/src/drivers/include/relative_wheel.hpp @@ -20,9 +20,11 @@ namespace drivers { class RelativeWheel { public: - static auto Create(TouchWheel *touch) -> RelativeWheel* { return new RelativeWheel(touch); } + static auto Create(TouchWheel* touch) -> RelativeWheel* { + return new RelativeWheel(touch); + } - explicit RelativeWheel(TouchWheel *touch); + explicit RelativeWheel(TouchWheel* touch); // Not copyable or movable. RelativeWheel(const RelativeWheel&) = delete; @@ -34,7 +36,7 @@ class RelativeWheel { auto ticks() -> std::int_fast16_t; private: - TouchWheel *touch_; + TouchWheel* touch_; bool is_pressed_; bool is_first_read_; std::int_fast16_t ticks_; diff --git a/src/drivers/relative_wheel.cpp b/src/drivers/relative_wheel.cpp index f64d213d..4c9e19bb 100644 --- a/src/drivers/relative_wheel.cpp +++ b/src/drivers/relative_wheel.cpp @@ -13,12 +13,12 @@ namespace drivers { -RelativeWheel::RelativeWheel(TouchWheel *touch) - :touch_(touch), - is_pressed_(false), - is_first_read_(true), - ticks_(0), - last_angle_(0) {} +RelativeWheel::RelativeWheel(TouchWheel* touch) + : touch_(touch), + is_pressed_(false), + is_first_read_(true), + ticks_(0), + last_angle_(0) {} auto RelativeWheel::Update() -> void { touch_->Update(); @@ -68,11 +68,10 @@ auto RelativeWheel::is_pressed() -> bool { auto RelativeWheel::ticks() -> std::int_fast16_t { int_fast16_t t = ticks_; if (t != 0) { - ESP_LOGI("teeks", "ticks %d", t); + ESP_LOGI("teeks", "ticks %d", t); } ticks_ = 0; return t; } - } // namespace drivers -- cgit v1.2.3