UC8159: 0/180 degree rotation support.

pull/527/head
Phil Howard 2022-09-30 20:13:25 +01:00
rodzic 7f02501fa6
commit 6aa1bbd271
3 zmienionych plików z 18 dodań i 12 usunięć

Wyświetl plik

@ -96,9 +96,17 @@ namespace pimoroni {
};
if (width == 600) {
command(PSR, {0xE3, 0x08});
if (rotation == ROTATE_0) {
command(PSR, {0xE3, 0x08});
} else {
command(PSR, {0xEF, 0x08});
}
} else {
command(PSR, {0xA3, 0x08});
if (rotation == ROTATE_0) {
command(PSR, {0xA3, 0x08});
} else {
command(PSR, {0xAF, 0x08});
}
}
command(PWR, {0x37, 0x00, 0x23, 0x23});
command(PFS, {0x00});
@ -171,7 +179,7 @@ namespace pimoroni {
// are reversed.
// Any garbage data will do.
// 2px per byte, so we need width * 24 bytes
if(height == 400) {
if(height == 400 && rotation == ROTATE_0) {
spi_write_blocking(spi, (uint8_t *)graphics->frame_buffer, width * 24);
}
graphics->frame_convert(PicoGraphics::PEN_P4, [this](void *buf, size_t length) {

Wyświetl plik

@ -16,8 +16,6 @@ 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
@ -44,12 +42,12 @@ 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, 28, PIN_UNUSED}) {};
UC8159(uint16_t width, uint16_t height) : UC8159(width, height, ROTATE_0, {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=PIN_UNUSED, uint reset=27) :
DisplayDriver(width, height, ROTATE_0),
width(width),
height(height),
UC8159(uint16_t width, uint16_t height, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) : UC8159(width, height, ROTATE_0, pins, busy, reset) {};
UC8159(uint16_t width, uint16_t height, Rotation rotation, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) :
DisplayDriver(width, height, rotation),
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_180;
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
if(pen_type == -1) pen_type = PEN_P4;
break;
default:
@ -206,7 +206,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
if (display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4) {
pen_type = PEN_3BIT; // FORCE to 3BIT
// TODO grab BUSY and RESET from ARG_extra_pins
self->display = m_new_class(UC8159, width, height, spi_bus);
self->display = m_new_class(UC8159, width, height, (Rotation)rotate, spi_bus);
} else if (display == DISPLAY_TUFTY_2040) {
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);