From 6efa5cfb3fd013defbfd293b2fc2b3bacb8b5348 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 17 Apr 2025 20:01:20 +0100 Subject: [PATCH] Inky73: Use a GPIO for busy wait. --- drivers/inky73/inky73.cpp | 17 ++++++++++++++--- drivers/inky73/inky73.hpp | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/inky73/inky73.cpp b/drivers/inky73/inky73.cpp index aca9048d..f2991c64 100644 --- a/drivers/inky73/inky73.cpp +++ b/drivers/inky73/inky73.cpp @@ -44,7 +44,7 @@ namespace pimoroni { }; bool Inky73::is_busy() { - return !(sr.read() & 128); + return !gpio_get(BUSY); } void Inky73::busy_wait(uint timeout_ms) { @@ -75,6 +75,10 @@ namespace pimoroni { gpio_set_dir(RESET, GPIO_OUT); gpio_put(RESET, 1); + gpio_set_function(BUSY, GPIO_FUNC_SIO); + gpio_set_dir(BUSY, GPIO_IN); + gpio_set_pulls(BUSY, true, false); + gpio_set_function(SCK, GPIO_FUNC_SPI); gpio_set_function(MOSI, GPIO_FUNC_SPI); }; @@ -164,6 +168,12 @@ namespace pimoroni { gpio_put(CS, 0); spi_write_blocking(spi, (const uint8_t*)graphics->frame_buffer, graphics->bounds.w * graphics->bounds.h / 2); gpio_put(CS, 1); + } else if (graphics->pen_type == PicoGraphics::PEN_3BIT) { + graphics->frame_convert(PicoGraphics::PEN_P4, [this](void *buf, size_t length) { + if (length > 0) { + spi_write_blocking(spi, (const uint8_t*)buf, length); + } + }); } else { graphics->frame_convert(PicoGraphics::PEN_INKY7, [this, &totalLength](void *buf, size_t length) { if (length > 0) { @@ -175,7 +185,7 @@ namespace pimoroni { }); } - gpio_put(DC, 0); // data mode + gpio_put(DC, 0); // command mode gpio_put(CS, 1); @@ -194,7 +204,8 @@ namespace pimoroni { } bool Inky73::is_pressed(Button button) { - return sr.read() & button; + //return sr.read() & button; + return false; } } diff --git a/drivers/inky73/inky73.hpp b/drivers/inky73/inky73.hpp index bed9ee75..868182bb 100644 --- a/drivers/inky73/inky73.hpp +++ b/drivers/inky73/inky73.hpp @@ -25,6 +25,7 @@ namespace pimoroni { uint SCK = SPI_DEFAULT_SCK; uint MOSI = SPI_DEFAULT_MOSI; uint RESET = 27; //25; + uint BUSY = 6; uint SR_CLOCK = 8; uint SR_LATCH = 9; @@ -32,7 +33,7 @@ namespace pimoroni { bool blocking = false; - ShiftRegister sr = ShiftRegister(SR_CLOCK, SR_LATCH, SR_DATA); + //ShiftRegister sr = ShiftRegister(SR_CLOCK, SR_LATCH, SR_DATA); public: enum Button : uint8_t {