kopia lustrzana https://github.com/pimoroni/pimoroni-pico
UC8159: 0/180 degree rotation support.
rodzic
7f02501fa6
commit
6aa1bbd271
|
@ -96,9 +96,17 @@ namespace pimoroni {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (width == 600) {
|
if (width == 600) {
|
||||||
command(PSR, {0xE3, 0x08});
|
if (rotation == ROTATE_0) {
|
||||||
|
command(PSR, {0xE3, 0x08});
|
||||||
|
} else {
|
||||||
|
command(PSR, {0xEF, 0x08});
|
||||||
|
}
|
||||||
} else {
|
} 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(PWR, {0x37, 0x00, 0x23, 0x23});
|
||||||
command(PFS, {0x00});
|
command(PFS, {0x00});
|
||||||
|
@ -171,7 +179,7 @@ namespace pimoroni {
|
||||||
// are reversed.
|
// are reversed.
|
||||||
// Any garbage data will do.
|
// Any garbage data will do.
|
||||||
// 2px per byte, so we need width * 24 bytes
|
// 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);
|
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) {
|
||||||
|
|
|
@ -16,8 +16,6 @@ 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
|
||||||
|
@ -44,12 +42,12 @@ 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, 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) :
|
UC8159(uint16_t width, uint16_t height, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) : UC8159(width, height, ROTATE_0, pins, busy, reset) {};
|
||||||
DisplayDriver(width, height, ROTATE_0),
|
|
||||||
width(width),
|
UC8159(uint16_t width, uint16_t height, Rotation rotation, SPIPins pins, uint busy=PIN_UNUSED, uint reset=27) :
|
||||||
height(height),
|
DisplayDriver(width, height, rotation),
|
||||||
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();
|
||||||
|
|
|
@ -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_180;
|
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
||||||
if(pen_type == -1) pen_type = PEN_P4;
|
if(pen_type == -1) pen_type = PEN_P4;
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
if (display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4) {
|
||||||
pen_type = PEN_3BIT; // FORCE to 3BIT
|
pen_type = PEN_3BIT; // FORCE to 3BIT
|
||||||
// TODO grab BUSY and RESET from ARG_extra_pins
|
// 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) {
|
} else if (display == DISPLAY_TUFTY_2040) {
|
||||||
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);
|
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);
|
||||||
|
|
Ładowanie…
Reference in New Issue