Merge pull request #414 from pimoroni/patch-inky-frame-wait
UC8159: Timeout-based busy wait.
This commit is contained in:
commit
1ec0908f2f
|
@ -38,10 +38,19 @@ namespace pimoroni {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool UC8159::is_busy() {
|
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);
|
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()) {
|
while(is_busy()) {
|
||||||
tight_loop_contents();
|
tight_loop_contents();
|
||||||
}
|
}
|
||||||
|
@ -137,15 +146,17 @@ namespace pimoroni {
|
||||||
busy_wait();
|
busy_wait();
|
||||||
|
|
||||||
command(PON); // turn on
|
command(PON); // turn on
|
||||||
busy_wait();
|
busy_wait(200);
|
||||||
|
|
||||||
command(DRF); // start display refresh
|
command(DRF); // start display refresh
|
||||||
busy_wait();
|
busy_wait(200);
|
||||||
|
|
||||||
if(blocking) {
|
if(blocking) {
|
||||||
busy_wait();
|
busy_wait(32 * 1000);
|
||||||
|
|
||||||
command(POF); // turn off
|
command(POF); // turn off
|
||||||
|
} else {
|
||||||
|
timeout = make_timeout_time_ms(32 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,13 @@ namespace pimoroni {
|
||||||
|
|
||||||
// interface pins with our standard defaults where appropriate
|
// interface pins with our standard defaults where appropriate
|
||||||
uint CS = SPI_BG_FRONT_CS;
|
uint CS = SPI_BG_FRONT_CS;
|
||||||
uint DC = 27;
|
uint DC = 28;
|
||||||
uint SCK = SPI_DEFAULT_SCK;
|
uint SCK = SPI_DEFAULT_SCK;
|
||||||
uint MOSI = SPI_DEFAULT_MOSI;
|
uint MOSI = SPI_DEFAULT_MOSI;
|
||||||
uint BUSY = 26;
|
uint BUSY = PIN_UNUSED;
|
||||||
uint RESET = 25;
|
uint RESET = 27;
|
||||||
|
|
||||||
|
absolute_time_t timeout = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum colour : uint8_t {
|
enum colour : uint8_t {
|
||||||
|
@ -44,9 +46,9 @@ namespace pimoroni {
|
||||||
CLEAN = 7
|
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),
|
DisplayDriver(width, height, ROTATE_0),
|
||||||
spi(pins.spi),
|
spi(pins.spi),
|
||||||
CS(pins.cs), DC(pins.dc), SCK(pins.sck), MOSI(pins.mosi), BUSY(busy), RESET(reset) {
|
CS(pins.cs), DC(pins.dc), SCK(pins.sck), MOSI(pins.mosi), BUSY(busy), RESET(reset) {
|
||||||
|
@ -58,7 +60,7 @@ namespace pimoroni {
|
||||||
// Methods
|
// Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public:
|
public:
|
||||||
void busy_wait();
|
void busy_wait(uint minimum_wait_ms=0);
|
||||||
void reset();
|
void reset();
|
||||||
void power_off();
|
void power_off();
|
||||||
|
|
||||||
|
|
|
@ -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);
|
i2c_bus = (pimoroni::I2C *)(self->i2c->i2c);
|
||||||
} else if (bus_type == BUS_SPI) {
|
} else if (bus_type == BUS_SPI) {
|
||||||
if(display == DISPLAY_INKY_FRAME) {
|
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) {
|
} 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};
|
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue