diff options
| author | jacqueline <me@jacqueline.id.au> | 2025-01-10 02:17:11 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-01-10 02:17:11 +0000 |
| commit | 94c30b759192231b8172bbb7d81125c8181261a1 (patch) | |
| tree | 3000ddfd33ddb3598f0f8546b94550bad500ec88 /src/drivers/display.cpp | |
| parent | 90118996194d90449e7e7d1fbeb08da587b10642 (diff) | |
| download | tangara-fw-94c30b759192231b8172bbb7d81125c8181261a1.tar.gz | |
Isolate the SD card from the SPI bus when talking to the display (#176)
This should help significantly with https://codeberg.org/cool-tech-zone/tangara-fw/issues/121, which seems to be caused by some SD cards being very picky about being the only SPI device on their bus.
Co-authored-by: ailurux <ailuruxx@gmail.com>
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/176
Co-authored-by: jacqueline <me@jacqueline.id.au>
Co-committed-by: jacqueline <me@jacqueline.id.au>
Diffstat (limited to 'src/drivers/display.cpp')
| -rw-r--r-- | src/drivers/display.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp index 15cd6c62..2fcb9dc0 100644 --- a/src/drivers/display.cpp +++ b/src/drivers/display.cpp @@ -179,6 +179,9 @@ auto Display::SetDisplayOn(bool enabled) -> void { return; } + spi_device_acquire_bus(handle_, portMAX_DELAY); + gpio_.SdMuxEnable(false); + if (display_on_) { SendCommandWithData(displays::ST77XX_DISPON, nullptr, 0); vTaskDelay(pdMS_TO_TICKS(100)); @@ -191,6 +194,9 @@ auto Display::SetDisplayOn(bool enabled) -> void { vTaskDelay(pdMS_TO_TICKS(100)); SendCommandWithData(displays::ST77XX_DISPOFF, nullptr, 0); } + + gpio_.SdMuxEnable(true); + spi_device_release_bus(handle_); } auto Display::SetBrightness(uint_fast8_t percent) -> void { @@ -222,6 +228,7 @@ void Display::SendInitialisationSequence(const uint8_t* data) { // finished may be increased by doing this, but a short boot with no feedback // feels worse than a longer boot that doesn't tell you anything. spi_device_acquire_bus(handle_, portMAX_DELAY); + gpio_.SdMuxEnable(false); // First byte of the data is the number of commands. for (int i = *(data++); i > 0; i--) { @@ -243,6 +250,7 @@ void Display::SendInitialisationSequence(const uint8_t* data) { } } + gpio_.SdMuxEnable(true); spi_device_release_bus(handle_); } @@ -250,24 +258,14 @@ IRAM_ATTR void Display::SendCommandWithData(uint8_t command, const uint8_t* data, size_t length) { - SendCmd(&command, 1); - SendData(data, length); -} - -IRAM_ATTR -void Display::SendCmd(const uint8_t* data, size_t length) { - SendTransaction(COMMAND, data, length); -} - -IRAM_ATTR -void Display::SendData(const uint8_t* data, size_t length) { + SendTransaction(COMMAND, &command, 1); SendTransaction(DATA, data, length); } IRAM_ATTR void Display::SendTransaction(TransactionType type, - const uint8_t* data, - size_t length) { + const uint8_t* data, + size_t length) { // TODO(jacqueline): What's sending this? if (length == 0) { return; @@ -306,6 +304,7 @@ void Display::OnLvglFlush(const lv_area_t* area, uint8_t* color_map) { lv_draw_sw_rgb565_swap(color_map, size); spi_device_acquire_bus(handle_, portMAX_DELAY); + gpio_.SdMuxEnable(false); // First we need to specify the rectangle of the display we're writing into. uint16_t data[2] = {0, 0}; @@ -324,6 +323,7 @@ void Display::OnLvglFlush(const lv_area_t* area, uint8_t* color_map) { SendCommandWithData(displays::ST77XX_RAMWR, reinterpret_cast<uint8_t*>(color_map), size * 2); + gpio_.SdMuxEnable(true); spi_device_release_bus(handle_); if (!first_flush_finished_ && lv_disp_flush_is_last(display_)) { |
