Skip to content

Commit f94a5d8

Browse files
committed
Inky73: Use a GPIO for busy wait.
1 parent 5b9438d commit f94a5d8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/inky73/inky73.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace pimoroni {
4444
};
4545

4646
bool Inky73::is_busy() {
47-
return !(sr.read() & 128);
47+
return !gpio_get(BUSY);
4848
}
4949

5050
void Inky73::busy_wait(uint timeout_ms) {
@@ -75,6 +75,10 @@ namespace pimoroni {
7575
gpio_set_dir(RESET, GPIO_OUT);
7676
gpio_put(RESET, 1);
7777

78+
gpio_set_function(BUSY, GPIO_FUNC_SIO);
79+
gpio_set_dir(BUSY, GPIO_IN);
80+
gpio_set_pulls(BUSY, true, false);
81+
7882
gpio_set_function(SCK, GPIO_FUNC_SPI);
7983
gpio_set_function(MOSI, GPIO_FUNC_SPI);
8084
};
@@ -164,6 +168,12 @@ namespace pimoroni {
164168
gpio_put(CS, 0);
165169
spi_write_blocking(spi, (const uint8_t*)graphics->frame_buffer, graphics->bounds.w * graphics->bounds.h / 2);
166170
gpio_put(CS, 1);
171+
} else if (graphics->pen_type == PicoGraphics::PEN_3BIT) {
172+
graphics->frame_convert(PicoGraphics::PEN_P4, [this](void *buf, size_t length) {
173+
if (length > 0) {
174+
spi_write_blocking(spi, (const uint8_t*)buf, length);
175+
}
176+
});
167177
} else {
168178
graphics->frame_convert(PicoGraphics::PEN_INKY7, [this, &totalLength](void *buf, size_t length) {
169179
if (length > 0) {
@@ -175,7 +185,7 @@ namespace pimoroni {
175185
});
176186
}
177187

178-
gpio_put(DC, 0); // data mode
188+
gpio_put(DC, 0); // command mode
179189

180190
gpio_put(CS, 1);
181191

@@ -194,7 +204,8 @@ namespace pimoroni {
194204
}
195205

196206
bool Inky73::is_pressed(Button button) {
197-
return sr.read() & button;
207+
//return sr.read() & button;
208+
return false;
198209
}
199210

200211
}

drivers/inky73/inky73.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ namespace pimoroni {
2525
uint SCK = SPI_DEFAULT_SCK;
2626
uint MOSI = SPI_DEFAULT_MOSI;
2727
uint RESET = 27; //25;
28+
uint BUSY = 6;
2829

2930
uint SR_CLOCK = 8;
3031
uint SR_LATCH = 9;
3132
uint SR_DATA = 10;
3233

3334
bool blocking = false;
3435

35-
ShiftRegister<uint8_t> sr = ShiftRegister<uint8_t>(SR_CLOCK, SR_LATCH, SR_DATA);
36+
//ShiftRegister<uint8_t> sr = ShiftRegister<uint8_t>(SR_CLOCK, SR_LATCH, SR_DATA);
3637

3738
public:
3839
enum Button : uint8_t {

0 commit comments

Comments
 (0)