Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If57 update #7997

Merged
merged 13 commits into from
Apr 3, 2024
16 changes: 13 additions & 3 deletions ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
#include "shared-module/displayio/__init__.h"
#include "shared-bindings/board/__init__.h"
#include "supervisor/shared/board.h"
#include "inky-shared.h"

#define DELAY 0x80

digitalio_digitalinout_obj_t enable_pin_obj;

// This is an SPD1656 control chip. The display is a 5.7" ACeP EInk.

const uint8_t display_start_sequence[] = {
0x01, 4, 0x37, 0x00, 0x23, 0x23, // power setting
0x00, 2, 0xef, 0x08, // panel setting (PSR)
0x00, 2, 0xe3, 0x08, // panel setting (PSR, 0xe3: no rotation)
0x03, 1, 0x00, // PFS
0x06, 3, 0xc7, 0xc7, 0x1d, // booster
0x30, 1, 0x3c, // PLL setting
Expand All @@ -62,6 +65,13 @@ const uint8_t refresh_sequence[] = {
};

void board_init(void) {
// Drive the EN_3V3 pin high so the board stays awake on battery power
enable_pin_obj.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&enable_pin_obj, &pin_GPIO2);
common_hal_digitalio_digitalinout_switch_to_output(&enable_pin_obj, true, DRIVE_MODE_PUSH_PULL);

// Never reset
common_hal_digitalio_digitalinout_never_reset(&enable_pin_obj);
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
busio_spi_obj_t *spi = common_hal_board_create_spi(0);

Expand Down Expand Up @@ -89,7 +99,7 @@ void board_init(void) {
480, // ram_height
0, // colstart
0, // rowstart
180, // rotation
0, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
Expand All @@ -103,7 +113,7 @@ void board_init(void) {
28.0, // refresh_time
NULL, // busy_pin
false, // busy_state
30.0, // seconds_per_frame
40.0, // seconds_per_frame
false, // always_toggle_chip_select
false, // grayscale
true, // acep
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef PIMORONI_INKY_SHARED
#define PIMORONI_INKY_SHARED

#include "shared-bindings/digitalio/DigitalInOut.h"

extern digitalio_digitalinout_obj_t enable_pin_obj;

#endif // PIMORONI_INKY_SHARED
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ CFLAGS += -DCYW43_PIN_WL_HOST_WAKE=24 -DCYW43_PIN_WL_REG_ON=23 -DCYW43_WL_GPIO_C
# Must be accompanied by a linker script change
CFLAGS += -DCIRCUITPY_FIRMWARE_SIZE='(1536 * 1024)'

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-pcf85063a
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD
41 changes: 40 additions & 1 deletion ports/raspberrypi/boards/pimoroni_inky_frame_5_7/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,46 @@

#include "supervisor/board.h"
#include "shared-module/displayio/__init__.h"
#include "py/objtuple.h"
#include "py/qstr.h"

#include "inky-shared.h"

// for use with keypad.ShiftRegisterKeys: map keycode (bit-number)
// to logical names board.KEYCODES.SW_A etc.
// N.B.: labels and bit-numbers in the schematic are reversed, i.e.
// SW_A on D0 has bit-number 7

STATIC const qstr board_keycodes_fields[] = {
MP_QSTR_SW_A,
MP_QSTR_SW_B,
MP_QSTR_SW_C,
MP_QSTR_SW_D,
MP_QSTR_SW_E,
MP_QSTR_RTC_ALARM,
MP_QSTR_EXT_TRIGGER,
MP_QSTR_INKY_BUS
};

STATIC MP_DEFINE_ATTRTUPLE(
board_keycodes_obj,
board_keycodes_fields,
8,
MP_ROM_INT(7),
MP_ROM_INT(6),
MP_ROM_INT(5),
MP_ROM_INT(4),
MP_ROM_INT(3),
MP_ROM_INT(2),
MP_ROM_INT(1),
MP_ROM_INT(0)
);

STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS

{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_HOLD_SYS_EN), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO3) },

{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
Expand Down Expand Up @@ -39,6 +72,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_INKY_RES), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_INKY_DC), MP_ROM_PTR(&pin_GPIO28) },

{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) },
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },

{ MP_ROM_QSTR(MP_QSTR_PICO_LED), MP_ROM_PTR(&pin_CYW0) },
{ MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1) },
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2) },

Expand All @@ -48,5 +85,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },

{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
{ MP_ROM_QSTR(MP_QSTR_ENABLE_DIO), MP_ROM_PTR(&enable_pin_obj)}, // GP2
{ MP_ROM_QSTR(MP_QSTR_KEYCODES), MP_ROM_PTR(&board_keycodes_obj)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);