UC8159: Alternate resolution support.

This commit is contained in:
Phil Howard 2022-09-29 14:05:21 +01:00 committed by Phil Howard
parent c1816ae9d6
commit 7f02501fa6
3 changed files with 35 additions and 11 deletions

View File

@ -88,16 +88,27 @@ namespace pimoroni {
reset(); reset();
busy_wait(); busy_wait();
command(0x00, {0xE3, 0x08}); uint8_t dimensions[4] = {
command(0x01, {0x37, 0x00, 0x23, 0x23}); uint8_t(width >> 8),
command(0x03, {0x00}); uint8_t(width),
command(0x06, {0xC7, 0xC7, 0x1D}); uint8_t(height >> 8),
command(0x30, {0x3C}); uint8_t(height)
command(0x40, {0x00}); };
command(0x50, {0x37});
command(0x60, {0x22}); if (width == 600) {
command(0x61, {0x02, 0x58, 0x01, 0xC0}); command(PSR, {0xE3, 0x08});
command(0xE3, {0xAA}); } else {
command(PSR, {0xA3, 0x08});
}
command(PWR, {0x37, 0x00, 0x23, 0x23});
command(PFS, {0x00});
command(BTST, {0xC7, 0xC7, 0x1D});
command(PLL, {0x3C});
command(TSC, {0x00});
command(CDI, {0x37});
command(TCON, {0x22});
command(TRES, 4, dimensions);
command(PWS, {0xAA});
sleep_ms(100); sleep_ms(100);
@ -154,6 +165,15 @@ namespace pimoroni {
spi_write_blocking(spi, &reg, 1); spi_write_blocking(spi, &reg, 1);
gpio_put(DC, 1); // data mode gpio_put(DC, 1); // data mode
// HACK: Output 48 rows of data since our buffer is 400px tall
// but the display has no offset configuration and H/V scan
// are reversed.
// Any garbage data will do.
// 2px per byte, so we need width * 24 bytes
if(height == 400) {
spi_write_blocking(spi, (uint8_t *)graphics->frame_buffer, width * 24);
}
graphics->frame_convert(PicoGraphics::PEN_P4, [this](void *buf, size_t length) { graphics->frame_convert(PicoGraphics::PEN_P4, [this](void *buf, size_t length) {
if (length > 0) { if (length > 0) {
spi_write_blocking(spi, (const uint8_t*)buf, length); spi_write_blocking(spi, (const uint8_t*)buf, length);

View File

@ -16,6 +16,8 @@ namespace pimoroni {
// Variables // Variables
//-------------------------------------------------- //--------------------------------------------------
private: private:
uint16_t width;
uint16_t height;
spi_inst_t *spi = PIMORONI_SPI_DEFAULT_INSTANCE; spi_inst_t *spi = PIMORONI_SPI_DEFAULT_INSTANCE;
// interface pins with our standard defaults where appropriate // interface pins with our standard defaults where appropriate
@ -46,6 +48,8 @@ namespace pimoroni {
UC8159(uint16_t width, uint16_t height, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) : 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),
width(width),
height(height),
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) {
init(); init();

View File

@ -109,7 +109,7 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height,
width = 640; width = 640;
height = 400; height = 400;
bus_type = BUS_SPI; bus_type = BUS_SPI;
if(rotate == -1) rotate = (int)Rotation::ROTATE_0; if(rotate == -1) rotate = (int)Rotation::ROTATE_180;
if(pen_type == -1) pen_type = PEN_P4; if(pen_type == -1) pen_type = PEN_P4;
break; break;
default: default: