diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp index b981ec33..56bd6e60 100644 --- a/src/drivers/display.cpp +++ b/src/drivers/display.cpp @@ -20,6 +20,7 @@ #include "display_init.hpp" #include "gpio_expander.hpp" +#include "soc/soc.h" static const char* kTag = "DISPLAY"; @@ -67,31 +68,19 @@ auto Display::create(GpioExpander* expander, gpio_config_t dr_config{ .pin_bit_mask = 1ULL << kDisplayDr, .mode = GPIO_MODE_OUTPUT, - .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_up_en = GPIO_PULLUP_ENABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE, .intr_type = GPIO_INTR_DISABLE, }; gpio_config(&dr_config); gpio_set_level(kDisplayDr, 0); - /* - gpio_config_t cs_config{ - .pin_bit_mask = 1ULL << kDisplayCs, - .mode = GPIO_MODE_OUTPUT, - .pull_up_en = GPIO_PULLUP_DISABLE, - .pull_down_en = GPIO_PULLDOWN_DISABLE, - .intr_type = GPIO_INTR_DISABLE, - }; - gpio_config(&cs_config); - gpio_set_level(kDisplayCs, 1); - */ - // TODO: use pwm for the backlight. gpio_config_t led_config{ .pin_bit_mask = 1ULL << kDisplayLedEn, .mode = GPIO_MODE_OUTPUT, .pull_up_en = GPIO_PULLUP_ENABLE, - .pull_down_en = GPIO_PULLDOWN_ENABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, .intr_type = GPIO_INTR_DISABLE, }; gpio_config(&led_config); @@ -154,18 +143,9 @@ Display::Display(GpioExpander* gpio, spi_device_handle_t handle) Display::~Display() {} void Display::SendInitialisationSequence(const uint8_t* data) { - // Reset the display manually to get it into a predictable state. - gpio_->set_pin(GpioExpander::DISPLAY_RESET, false); - gpio_->Write(); - vTaskDelay(pdMS_TO_TICKS(1)); - gpio_->set_pin(GpioExpander::DISPLAY_RESET, true); - gpio_->Write(); - vTaskDelay(pdMS_TO_TICKS(1)); - // Hold onto the bus for the entire sequence so that we're not interrupted // part way through. spi_device_acquire_bus(handle_, portMAX_DELAY); - // gpio_set_level(kDisplayCs, 0); // First byte of the data is the number of commands. for (int i = *(data++); i > 0; i--) { @@ -184,15 +164,12 @@ void Display::SendInitialisationSequence(const uint8_t* data) { } // Avoid hanging on to the bus whilst delaying. - // gpio_set_level(kDisplayCs, 1); spi_device_release_bus(handle_); vTaskDelay(pdMS_TO_TICKS(sleep_duration_ms)); spi_device_acquire_bus(handle_, portMAX_DELAY); - // gpio_set_level(kDisplayCs, 0); } } - // gpio_set_level(kDisplayCs, 1); spi_device_release_bus(handle_); } @@ -251,7 +228,6 @@ void Display::OnLvglFlush(lv_disp_drv_t* disp_drv, // 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); - // gpio_set_level(kDisplayCs, 0); // First we need to specify the rectangle of the display we're writing into. uint16_t data[2] = {0, 0}; @@ -271,7 +247,6 @@ void Display::OnLvglFlush(lv_disp_drv_t* disp_drv, SendCommandWithData(displays::ST77XX_RAMWR, reinterpret_cast(color_map), size * 2); - // gpio_set_level(kDisplayCs, 1); spi_device_release_bus(handle_); lv_disp_flush_ready(&driver_); diff --git a/src/drivers/include/gpio_expander.hpp b/src/drivers/include/gpio_expander.hpp index d53a1982..cd3719a0 100644 --- a/src/drivers/include/gpio_expander.hpp +++ b/src/drivers/include/gpio_expander.hpp @@ -44,7 +44,7 @@ class GpioExpander { // 6 - NC // 7 - sd card power (active low) // Default to SD card off, inputs high. - static const uint8_t kPortADefault = 0b10011110; + static const uint8_t kPortADefault = 0b10111110; // Port B: // 0 - trs output enable diff --git a/src/drivers/touchwheel.cpp b/src/drivers/touchwheel.cpp index 9e0d99af..d5382b3d 100644 --- a/src/drivers/touchwheel.cpp +++ b/src/drivers/touchwheel.cpp @@ -18,10 +18,17 @@ namespace drivers { static const char* kTag = "TOUCHWHEEL"; static const uint8_t kTouchWheelAddress = 0x1C; +static const gpio_num_t kIntPin = GPIO_NUM_25; TouchWheel::TouchWheel() { - gpio_set_direction(GPIO_NUM_25, GPIO_MODE_INPUT); - gpio_set_pull_mode(GPIO_NUM_25, GPIO_PULLUP_ONLY); + gpio_config_t int_config{ + .pin_bit_mask = 1ULL << kIntPin, + .mode = GPIO_MODE_INPUT, + .pull_up_en = GPIO_PULLUP_ENABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&int_config); WriteRegister(Register::RESET, 1); // TODO(daniel): do we need this? how long does reset take?