PicoGraphics: MicroPython support for Inky Frame 4.0
This commit is contained in:
parent
fb8cde305d
commit
c1816ae9d6
|
@ -124,6 +124,7 @@ STATIC const mp_map_elem_t picographics_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_I2C_OLED_128X128), MP_ROM_INT(DISPLAY_I2C_OLED_128X128) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_I2C_OLED_128X128), MP_ROM_INT(DISPLAY_I2C_OLED_128X128) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_PACK), MP_ROM_INT(DISPLAY_INKY_PACK) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_PACK), MP_ROM_INT(DISPLAY_INKY_PACK) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_FRAME), MP_ROM_INT(DISPLAY_INKY_FRAME) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_FRAME), MP_ROM_INT(DISPLAY_INKY_FRAME) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_FRAME_4), MP_ROM_INT(DISPLAY_INKY_FRAME_4) },
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) },
|
{ MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PEN_P4), MP_ROM_INT(PEN_P4) },
|
{ MP_ROM_QSTR(MP_QSTR_PEN_P4), MP_ROM_INT(PEN_P4) },
|
||||||
|
|
|
@ -105,6 +105,13 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height,
|
||||||
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
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;
|
||||||
|
case DISPLAY_INKY_FRAME_4:
|
||||||
|
width = 640;
|
||||||
|
height = 400;
|
||||||
|
bus_type = BUS_SPI;
|
||||||
|
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
||||||
|
if(pen_type == -1) pen_type = PEN_P4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +194,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||||
self->i2c = (_PimoroniI2C_obj_t *)MP_OBJ_TO_PTR(PimoroniI2C_make_new(&PimoroniI2C_type, 0, 0, nullptr));
|
self->i2c = (_PimoroniI2C_obj_t *)MP_OBJ_TO_PTR(PimoroniI2C_make_new(&PimoroniI2C_type, 0, 0, nullptr));
|
||||||
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 || display == DISPLAY_INKY_FRAME_4) {
|
||||||
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 28, 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};
|
||||||
|
@ -196,7 +203,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to create an appropriate display driver
|
// Try to create an appropriate display driver
|
||||||
if (display == DISPLAY_INKY_FRAME) {
|
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, spi_bus);
|
||||||
|
@ -273,7 +280,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||||
self->graphics->clear();
|
self->graphics->clear();
|
||||||
|
|
||||||
// Update the LCD from the graphics library
|
// Update the LCD from the graphics library
|
||||||
if (display != DISPLAY_INKY_FRAME && display != DISPLAY_INKY_PACK) {
|
if (display != DISPLAY_INKY_FRAME && display != DISPLAY_INKY_FRAME_4 && display != DISPLAY_INKY_PACK) {
|
||||||
self->display->update(self->graphics);
|
self->display->update(self->graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ enum PicoGraphicsDisplay {
|
||||||
DISPLAY_LCD_160X80,
|
DISPLAY_LCD_160X80,
|
||||||
DISPLAY_I2C_OLED_128X128,
|
DISPLAY_I2C_OLED_128X128,
|
||||||
DISPLAY_INKY_PACK,
|
DISPLAY_INKY_PACK,
|
||||||
DISPLAY_INKY_FRAME
|
DISPLAY_INKY_FRAME,
|
||||||
|
DISPLAY_INKY_FRAME_4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PicoGraphicsPenType {
|
enum PicoGraphicsPenType {
|
||||||
|
|
Loading…
Reference in New Issue