UC8159: Alternate resolution support.

pull/527/head
Phil Howard 2022-09-29 14:05:21 +01:00 zatwierdzone przez Phil Howard
rodzic c1816ae9d6
commit 7f02501fa6
3 zmienionych plików z 35 dodań i 11 usunięć

Wyświetl plik

@ -88,16 +88,27 @@ namespace pimoroni {
reset();
busy_wait();
command(0x00, {0xE3, 0x08});
command(0x01, {0x37, 0x00, 0x23, 0x23});
command(0x03, {0x00});
command(0x06, {0xC7, 0xC7, 0x1D});
command(0x30, {0x3C});
command(0x40, {0x00});
command(0x50, {0x37});
command(0x60, {0x22});
command(0x61, {0x02, 0x58, 0x01, 0xC0});
command(0xE3, {0xAA});
uint8_t dimensions[4] = {
uint8_t(width >> 8),
uint8_t(width),
uint8_t(height >> 8),
uint8_t(height)
};
if (width == 600) {
command(PSR, {0xE3, 0x08});
} 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);
@ -154,6 +165,15 @@ namespace pimoroni {
spi_write_blocking(spi, &reg, 1);
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) {
if (length > 0) {
spi_write_blocking(spi, (const uint8_t*)buf, length);

Wyświetl plik

@ -16,6 +16,8 @@ namespace pimoroni {
// Variables
//--------------------------------------------------
private:
uint16_t width;
uint16_t height;
spi_inst_t *spi = PIMORONI_SPI_DEFAULT_INSTANCE;
// 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) :
DisplayDriver(width, height, ROTATE_0),
width(width),
height(height),
spi(pins.spi),
CS(pins.cs), DC(pins.dc), SCK(pins.sck), MOSI(pins.mosi), BUSY(busy), RESET(reset) {
init();

Wyświetl plik

@ -109,7 +109,7 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height,
width = 640;
height = 400;
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;
break;
default: