Merge pull request #414 from pimoroni/patch-inky-frame-wait

UC8159: Timeout-based busy wait.
patch-uc8159-3bpp
Philip Howard 2022-06-29 10:40:50 +01:00 zatwierdzone przez GitHub
commit 1ec0908f2f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 24 dodań i 11 usunięć

Wyświetl plik

@ -38,10 +38,19 @@ namespace pimoroni {
};
bool UC8159::is_busy() {
if(BUSY == PIN_UNUSED) {
if(timeout > 0 && absolute_time_diff_us(get_absolute_time(), timeout) > 0) {
return true;
} else {
timeout = 0;
return false;
}
}
return !gpio_get(BUSY);
}
void UC8159::busy_wait() {
void UC8159::busy_wait(uint minimum_wait_ms) {
timeout = make_timeout_time_ms(minimum_wait_ms);
while(is_busy()) {
tight_loop_contents();
}
@ -137,15 +146,17 @@ namespace pimoroni {
busy_wait();
command(PON); // turn on
busy_wait();
busy_wait(200);
command(DRF); // start display refresh
busy_wait();
busy_wait(200);
if(blocking) {
busy_wait();
busy_wait(32 * 1000);
command(POF); // turn off
} else {
timeout = make_timeout_time_ms(32 * 1000);
}
}

Wyświetl plik

@ -26,11 +26,13 @@ namespace pimoroni {
// interface pins with our standard defaults where appropriate
uint CS = SPI_BG_FRONT_CS;
uint DC = 27;
uint DC = 28;
uint SCK = SPI_DEFAULT_SCK;
uint MOSI = SPI_DEFAULT_MOSI;
uint BUSY = 26;
uint RESET = 25;
uint BUSY = PIN_UNUSED;
uint RESET = 27;
absolute_time_t timeout = 0;
public:
enum colour : uint8_t {
@ -44,9 +46,9 @@ namespace pimoroni {
CLEAN = 7
};
UC8159(uint16_t width, uint16_t height) : UC8159(width, height, {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 27, PIN_UNUSED}) {};
UC8159(uint16_t width, uint16_t height) : UC8159(width, height, {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 28, PIN_UNUSED}) {};
UC8159(uint16_t width, uint16_t height, SPIPins pins, uint busy=26, uint reset=25) :
UC8159(uint16_t width, uint16_t height, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) :
DisplayDriver(width, height, ROTATE_0),
spi(pins.spi),
CS(pins.cs), DC(pins.dc), SCK(pins.sck), MOSI(pins.mosi), BUSY(busy), RESET(reset) {
@ -58,7 +60,7 @@ namespace pimoroni {
// Methods
//--------------------------------------------------
public:
void busy_wait();
void busy_wait(uint minimum_wait_ms=0);
void reset();
void power_off();

Wyświetl plik

@ -186,7 +186,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
i2c_bus = (pimoroni::I2C *)(self->i2c->i2c);
} else if (bus_type == BUS_SPI) {
if(display == DISPLAY_INKY_FRAME) {
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 27, PIN_UNUSED};
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 28, PIN_UNUSED};
} else if (display == DISPLAY_INKY_PACK) {
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED};
}