Skip to content

Commit 3c10409

Browse files
committed
support enable-pin as DigitalInOut (Badger2040W compatibility)
1 parent 957d011 commit 3c10409

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@
3333
#include "shared-module/displayio/__init__.h"
3434
#include "shared-bindings/board/__init__.h"
3535
#include "supervisor/shared/board.h"
36+
#include "inky-shared.h"
3637

3738
#define DELAY 0x80
3839

40+
digitalio_digitalinout_obj_t enable_pin_obj;
41+
3942
// This is an SPD1656 control chip. The display is a 5.7" ACeP EInk.
4043

4144
const uint8_t display_start_sequence[] = {
4245
0x01, 4, 0x37, 0x00, 0x23, 0x23, // power setting
43-
0x00, 2, 0xef, 0x08, // panel setting (PSR)
46+
0x00, 2, 0xe3, 0x08, // panel setting (PSR, 0xe3: no rotation)
4447
0x03, 1, 0x00, // PFS
4548
0x06, 3, 0xc7, 0xc7, 0x1d, // booster
4649
0x30, 1, 0x3c, // PLL setting
@@ -62,6 +65,14 @@ const uint8_t refresh_sequence[] = {
6265
};
6366

6467
void board_init(void) {
68+
// Drive the EN_3V3 pin high so the board stays awake on battery power
69+
enable_pin_obj.base.type = &digitalio_digitalinout_type;
70+
common_hal_digitalio_digitalinout_construct(&enable_pin_obj, &pin_GPIO2);
71+
common_hal_digitalio_digitalinout_switch_to_output(&enable_pin_obj, true, DRIVE_MODE_PUSH_PULL);
72+
73+
// Never reset
74+
common_hal_digitalio_digitalinout_never_reset(&enable_pin_obj);
75+
6576
displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
6677
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
6778

@@ -89,7 +100,7 @@ void board_init(void) {
89100
480, // ram_height
90101
0, // colstart
91102
0, // rowstart
92-
180, // rotation
103+
0, // rotation
93104
NO_COMMAND, // set_column_window_command
94105
NO_COMMAND, // set_row_window_command
95106
NO_COMMAND, // set_current_column_command
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef PIMORONI_INKY_SHARED
2+
#define PIMORONI_INKY_SHARED
3+
4+
#include "shared-bindings/digitalio/DigitalInOut.h"
5+
6+
extern digitalio_digitalinout_obj_t enable_pin_obj;
7+
8+
#endif // PIMORONI_INKY_SHARED

ports/raspberrypi/boards/pimoroni_inky_frame_5_7/pins.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "supervisor/board.h"
44
#include "shared-module/displayio/__init__.h"
5+
#include "inky-shared.h"
56

67
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
78
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
89

910
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) },
1011
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) },
11-
{ MP_ROM_QSTR(MP_QSTR_HOLD_SYS_EN), MP_ROM_PTR(&pin_GPIO2) },
1212
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO3) },
1313

1414
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
@@ -48,5 +48,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4848
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
4949

5050
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
51+
{ MP_ROM_QSTR(MP_QSTR_ENABLE_DIO), MP_ROM_PTR(&enable_pin_obj)}, // GP2
5152
};
5253
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)