Skip to content

Commit 88e5089

Browse files
committed
Inky 7.3: Add to PicoGraphics.
1 parent 4928cef commit 88e5089

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

micropython/modules/picographics/micropython.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ target_sources(usermod_${MOD_NAME} INTERFACE
1111
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/uc8151/uc8151.cpp
1212
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/uc8159/uc8159.cpp
1313
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7567/st7567.cpp
14+
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/inky73/inky73.cpp
15+
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/shiftregister/shiftregister.cpp
16+
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/psram_display/psram_display.cpp
1417
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics.cpp
1518
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_1bit.cpp
1619
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_1bitY.cpp
@@ -20,6 +23,7 @@ target_sources(usermod_${MOD_NAME} INTERFACE
2023
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_rgb332.cpp
2124
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_rgb565.cpp
2225
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_rgb888.cpp
26+
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_inky7.cpp
2327
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/types.cpp
2428
)
2529

micropython/modules/picographics/picographics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ STATIC const mp_map_elem_t picographics_globals_table[] = {
150150
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_128X64), MP_ROM_INT(DISPLAY_INTERSTATE75_128X64) },
151151
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_192X64), MP_ROM_INT(DISPLAY_INTERSTATE75_192X64) },
152152
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_256X64), MP_ROM_INT(DISPLAY_INTERSTATE75_256X64) },
153+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_FRAME_7), MP_ROM_INT(DISPLAY_INKY_FRAME_7) },
153154

154155

155156
{ MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) },

micropython/modules/picographics/picographics.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "drivers/uc8151/uc8151.hpp"
55
#include "drivers/uc8159/uc8159.hpp"
66
#include "drivers/st7567/st7567.hpp"
7+
#include "drivers/inky73/inky73.hpp"
8+
#include "drivers/psram_display/psram_display.hpp"
79
#include "libraries/pico_graphics/pico_graphics.hpp"
810
#include "common/pimoroni_common.hpp"
911
#include "common/pimoroni_bus.hpp"
@@ -192,6 +194,14 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height,
192194
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
193195
if(pen_type == -1) pen_type = PEN_RGB888;
194196
break;
197+
case DISPLAY_INKY_FRAME_7:
198+
width = 800;
199+
height = 480;
200+
bus_type = BUS_SPI;
201+
// Portrait to match labelling
202+
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
203+
if(pen_type == -1) pen_type = PEN_INKY7;
204+
break;
195205
default:
196206
return false;
197207
}
@@ -214,6 +224,8 @@ size_t get_required_buffer_size(PicoGraphicsPenType pen_type, uint width, uint h
214224
return PicoGraphics_PenRGB565::buffer_size(width, height);
215225
case PEN_RGB888:
216226
return PicoGraphics_PenRGB888::buffer_size(width, height);
227+
case PEN_INKY7:
228+
return PicoGraphics_PenInky7::buffer_size(width, height);
217229
default:
218230
return 0;
219231
}
@@ -276,7 +288,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
276288
self->i2c = (_PimoroniI2C_obj_t *)MP_OBJ_TO_PTR(PimoroniI2C_make_new(&PimoroniI2C_type, 0, 0, nullptr));
277289
i2c_bus = (pimoroni::I2C *)(self->i2c->i2c);
278290
} else if (bus_type == BUS_SPI) {
279-
if(display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4) {
291+
if(display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4 || display == DISPLAY_INKY_FRAME_7) {
280292
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 28, PIN_UNUSED};
281293
} else if (display == DISPLAY_INKY_PACK) {
282294
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED};
@@ -292,6 +304,11 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
292304
// TODO grab BUSY and RESET from ARG_extra_pins
293305
self->display = m_new_class(UC8159, width, height, (Rotation)rotate, spi_bus);
294306

307+
} else if (display == DISPLAY_INKY_FRAME_7) {
308+
pen_type = PEN_INKY7;
309+
// TODO grab BUSY and RESET from ARG_extra_pins
310+
self->display = m_new_class(Inky73, width, height, (Rotation)rotate, spi_bus);
311+
295312
} else if (display == DISPLAY_TUFTY_2040) {
296313
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);
297314

@@ -324,15 +341,19 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
324341
size_t required_size = get_required_buffer_size((PicoGraphicsPenType)pen_type, width, height);
325342
if(required_size == 0) mp_raise_ValueError("Unsupported pen type!");
326343

327-
if (args[ARG_buffer].u_obj != mp_const_none) {
328-
mp_buffer_info_t bufinfo;
329-
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW);
330-
self->buffer = bufinfo.buf;
331-
if(bufinfo.len < (size_t)(required_size)) {
332-
mp_raise_ValueError("Supplied buffer is too small!");
333-
}
344+
if(pen_type == PEN_INKY7) {
345+
self->buffer = m_new_class(PSRamDisplay, width, height);
334346
} else {
335-
self->buffer = m_new(uint8_t, required_size);
347+
if (args[ARG_buffer].u_obj != mp_const_none) {
348+
mp_buffer_info_t bufinfo;
349+
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW);
350+
self->buffer = bufinfo.buf;
351+
if(bufinfo.len < (size_t)(required_size)) {
352+
mp_raise_ValueError("Supplied buffer is too small!");
353+
}
354+
} else {
355+
self->buffer = m_new(uint8_t, required_size);
356+
}
336357
}
337358

338359
// Create an instance of the graphics library
@@ -363,6 +384,9 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
363384
case PEN_RGB888:
364385
self->graphics = m_new_class(PicoGraphics_PenRGB888, self->display->width, self->display->height, self->buffer);
365386
break;
387+
case PEN_INKY7:
388+
self->graphics = m_new_class(PicoGraphics_PenInky7, self->display->width, self->display->height, *(IDirectDisplayDriver<uint8_t> *)self->buffer);
389+
break;
366390
default:
367391
break;
368392
}
@@ -376,7 +400,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
376400
self->graphics->clear();
377401

378402
// Update the LCD from the graphics library
379-
if (display != DISPLAY_INKY_FRAME && display != DISPLAY_INKY_FRAME_4 && display != DISPLAY_INKY_PACK) {
403+
if (display != DISPLAY_INKY_FRAME && display != DISPLAY_INKY_FRAME_4 && display != DISPLAY_INKY_PACK && display != DISPLAY_INKY_FRAME_7) {
380404
self->display->update(self->graphics);
381405
}
382406

micropython/modules/picographics/picographics.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ enum PicoGraphicsDisplay {
2323
DISPLAY_INTERSTATE75_64X64,
2424
DISPLAY_INTERSTATE75_128X64,
2525
DISPLAY_INTERSTATE75_192X64,
26-
DISPLAY_INTERSTATE75_256X64,
26+
DISPLAY_INTERSTATE75_256X64,
27+
DISPLAY_INKY_FRAME_7,
2728
};
2829

2930
enum PicoGraphicsPenType {
@@ -34,7 +35,8 @@ enum PicoGraphicsPenType {
3435
PEN_P8,
3536
PEN_RGB332,
3637
PEN_RGB565,
37-
PEN_RGB888
38+
PEN_RGB888,
39+
PEN_INKY7,
3840
};
3941

4042
enum PicoGraphicsBusType {

0 commit comments

Comments
 (0)