Skip to content

Commit ec4cb22

Browse files
committed
further work
1 parent 7c2f85b commit ec4cb22

File tree

6 files changed

+163
-22
lines changed

6 files changed

+163
-22
lines changed

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/board.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ uint8_t start_sequence[] = {
3131
0x3c, 0x01, 0x00, // Border color
3232
0x2c, 0x01, 0x3c, // VCOM Register, 0x3c = -1.5v? ✅
3333
0x22, 0x01, 0xc7, // Display update sequence ✅
34-
// 0x04, 0x03, 0x07, 0xac, 0x32, // Set voltage of VSH and VSL (yellow)
34+
0x04, 0x03, 0x07, 0xac, 0x32, // Set voltage of VSH and VSL (yellow)
3535
// LUT (yellow)
36-
// 0x32, 0x46,
37-
// 0xfa, 0x94, 0x8c, 0xc0, 0xd0, 0x00, 0x00,
38-
// 0xfa, 0x94, 0x2c, 0x80, 0xe0, 0x00, 0x00,
39-
// 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40-
// 0xfa, 0x94, 0xf8, 0x80, 0x50, 0x00, 0xcc,
41-
// 0xbf, 0x58, 0xfc, 0x80, 0xd0, 0x00, 0x11,
42-
// 0x40, 0x10, 0x40, 0x10, 0x08,
43-
// 0x08, 0x10, 0x04, 0x04, 0x10,
44-
// 0x08, 0x08, 0x03, 0x08, 0x20,
45-
// 0x08, 0x04, 0x00, 0x00, 0x10,
46-
// 0x10, 0x08, 0x08, 0x00, 0x20,
47-
// 0x00, 0x00, 0x00, 0x00, 0x00,
48-
// 0x00, 0x00, 0x00, 0x00, 0x00,
36+
0x32, 0x46,
37+
0xfa, 0x94, 0x8c, 0xc0, 0xd0, 0x00, 0x00,
38+
0xfa, 0x94, 0x2c, 0x80, 0xe0, 0x00, 0x00,
39+
0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40+
0xfa, 0x94, 0xf8, 0x80, 0x50, 0x00, 0xcc,
41+
0xbf, 0x58, 0xfc, 0x80, 0xd0, 0x00, 0x11,
42+
0x40, 0x10, 0x40, 0x10, 0x08,
43+
0x08, 0x10, 0x04, 0x04, 0x10,
44+
0x08, 0x08, 0x03, 0x08, 0x20,
45+
0x08, 0x04, 0x00, 0x00, 0x10,
46+
0x10, 0x08, 0x08, 0x00, 0x20,
47+
0x00, 0x00, 0x00, 0x00, 0x00,
48+
0x00, 0x00, 0x00, 0x00, 0x00,
4949
0x11, 0x01, 0x03, // Data entry mode setting 0x03 = X/Y increment ✅
5050
// self._send_command(0x44, [0x00, (self.cols // 8) - 1]) # Set RAM X Start/End
5151
0x44, 0x02, 0x00, 0x31, // Set RAM X Start/End
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2020 Joey Castillo
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/busio/SPI.h"
10+
#include "shared-bindings/fourwire/FourWire.h"
11+
#include "shared-bindings/microcontroller/Pin.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-module/displayio/mipi_constants.h"
14+
#include "shared-bindings/board/__init__.h"
15+
#include "shared-bindings/digitalio/DigitalInOut.h"
16+
17+
#define HEIGHT 300
18+
#define WIDTH 400
19+
20+
// Sequences pulled from InkyWhat driver (https://github.com/alanta/CircuitPython_InkyWhat)
21+
uint8_t start_sequence[] = {
22+
0x12, 0x80, 0x80, // Software reset ✅ TODO wait for busy instead of fixed delay
23+
0x12, 0x80, 0x80, // Software reset ✅ TODO wait for busy instead of fixed delay
24+
0x74, 0x01, 0x54, // set analog block control ✅
25+
0x7e, 0x01, 0x3b, // set digital block control ✅
26+
0x01, 0x03, 0x2b, 0x01, 0x00, // driver output control
27+
0x03, 0x01, 0x17, // Gate driving voltage ✅
28+
0x04, 0x03, 0x07, 0xac, 0x32, // Source Driving voltage ✅
29+
0x3a, 0x01, 0x07, // Dummy line period ✅
30+
0x3b, 0x01, 0x04, // Gate line width ✅
31+
0x3c, 0x01, 0x00, // Border color
32+
0x2c, 0x01, 0x3c, // VCOM Register, 0x3c = -1.5v? ✅
33+
0x22, 0x01, 0xc7, // Display update sequence ✅
34+
// 0x04, 0x03, 0x07, 0xac, 0x32, // Set voltage of VSH and VSL (yellow)
35+
// LUT (yellow)
36+
// 0x32, 0x46,
37+
// 0xfa, 0x94, 0x8c, 0xc0, 0xd0, 0x00, 0x00,
38+
// 0xfa, 0x94, 0x2c, 0x80, 0xe0, 0x00, 0x00,
39+
// 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40+
// 0xfa, 0x94, 0xf8, 0x80, 0x50, 0x00, 0xcc,
41+
// 0xbf, 0x58, 0xfc, 0x80, 0xd0, 0x00, 0x11,
42+
// 0x40, 0x10, 0x40, 0x10, 0x08,
43+
// 0x08, 0x10, 0x04, 0x04, 0x10,
44+
// 0x08, 0x08, 0x03, 0x08, 0x20,
45+
// 0x08, 0x04, 0x00, 0x00, 0x10,
46+
// 0x10, 0x08, 0x08, 0x00, 0x20,
47+
// 0x00, 0x00, 0x00, 0x00, 0x00,
48+
// 0x00, 0x00, 0x00, 0x00, 0x00,
49+
0x11, 0x01, 0x03, // Data entry mode setting 0x03 = X/Y increment ✅
50+
// self._send_command(0x44, [0x00, (self.cols // 8) - 1]) # Set RAM X Start/End
51+
0x44, 0x02, 0x00, 0x31, // Set RAM X Start/End
52+
// self._send_command(0x45, [0x00, 0x00] + packed_height) # Set RAM Y Start/End
53+
0x45, 0x04, 0x00, 0x00, 0x2b, 0x01, // Set RAM Y Start/End
54+
};
55+
56+
uint8_t stop_sequence[] = {
57+
0x10, 0x01, 0x01 // Enter Deep Sleep
58+
};
59+
60+
uint8_t refresh_sequence[] = {
61+
0x20, 0x00
62+
};
63+
64+
void board_init(void) {
65+
66+
// Pull EPD Enable pin high
67+
digitalio_digitalinout_obj_t vext_pin_obj;
68+
vext_pin_obj.base.type = &digitalio_digitalinout_type;
69+
common_hal_digitalio_digitalinout_construct(&vext_pin_obj, &pin_GPIO7);
70+
common_hal_digitalio_digitalinout_switch_to_output(&vext_pin_obj, true, DRIVE_MODE_PUSH_PULL);
71+
common_hal_digitalio_digitalinout_never_reset(&vext_pin_obj);
72+
73+
// Set up SPI bus
74+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
75+
busio_spi_obj_t *spi = &bus->inline_bus;
76+
common_hal_busio_spi_construct(spi, &pin_GPIO12, &pin_GPIO11, NULL, false);
77+
common_hal_busio_spi_never_reset(spi);
78+
79+
bus->base.type = &fourwire_fourwire_type;
80+
common_hal_fourwire_fourwire_construct(bus,
81+
spi,
82+
&pin_GPIO46, // EPD_DC Command or data
83+
&pin_GPIO45, // EPD_CS Chip select
84+
&pin_GPIO47, // EPD_RST Reset
85+
1000000, // Baudrate
86+
0, // Polarity
87+
0); // Phase
88+
89+
// Set up EPD object
90+
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
91+
display->base.type = &epaperdisplay_epaperdisplay_type;
92+
common_hal_epaperdisplay_epaperdisplay_construct(display,
93+
bus,
94+
start_sequence,
95+
sizeof(start_sequence),
96+
0, // start up time
97+
stop_sequence,
98+
sizeof(stop_sequence),
99+
WIDTH, // width
100+
HEIGHT, // height
101+
300, // RAM width
102+
400, // RAM height
103+
0, // colstart
104+
0, // rowstart
105+
90, // rotation
106+
NO_COMMAND, // set_column_window_command
107+
NO_COMMAND, // set_row_window_command
108+
0x4E, // set_current_column_command
109+
0x4F, // set_current_row_command
110+
0x24, // write_black_ram_command
111+
false, // black_bits_inverted
112+
0x26, // write_color_ram_command (can add this for grayscale eventually)
113+
false, // color_bits_inverted
114+
0x000000, // highlight_color
115+
refresh_sequence, // refresh_display_sequence
116+
sizeof(refresh_sequence),
117+
40, // refresh_time
118+
&pin_GPIO48, // busy_pin
119+
false, // busy_state
120+
5, // seconds_per_frame
121+
false, // chip_select (don't always toggle chip select)
122+
false, // grayscale
123+
false, // acep
124+
false, // two_byte_sequence_length
125+
false); // address_little_endian
126+
}
127+
128+
void board_deinit(void) {
129+
epaperdisplay_epaperdisplay_obj_t *display = &displays[0].epaper_display;
130+
if (display->base.type == &epaperdisplay_epaperdisplay_type) {
131+
while (common_hal_epaperdisplay_epaperdisplay_get_busy(display)) {
132+
RUN_BACKGROUND_TASKS;
133+
}
134+
}
135+
common_hal_displayio_release_displays();
136+
}
137+
138+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/mpconfigboard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define MICROPY_HW_BOARD_NAME "CrowPanel 4.2 EPaper"
1212
#define MICROPY_HW_MCU_NAME "ESP32S3"
13-
#define MICROPY_HW_LED_STATUS (&pin_GPIO17)
13+
#define MICROPY_HW_LED_STATUS (&pin_GPIO41)
1414
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
1515

1616
#define CIRCUITPY_BOARD_SPI (2)
@@ -20,8 +20,8 @@
2020
}
2121

2222
// UART pins attached to the USB-serial converter chip
23-
#define DEFAULT_UART_BUS_RX (&pin_GPIO43)
24-
#define DEFAULT_UART_BUS_TX (&pin_GPIO44)
23+
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
24+
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
2525

2626
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX
2727
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/mpconfigboard.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
99
IDF_TARGET = esp32s3
1010

1111
CIRCUITPY_ESP_FLASH_SIZE = 8MB
12-
CIRCUITPY_ESP_FLASH_MODE = qio
12+
CIRCUITPY_ESP_FLASH_MODE = dio
1313
CIRCUITPY_ESP_FLASH_FREQ = 80m
1414

1515
CIRCUITPY_ESP_PSRAM_SIZE = 8MB
1616
CIRCUITPY_ESP_PSRAM_MODE = opi
1717
CIRCUITPY_ESP_PSRAM_FREQ = 80m
18+
19+
CIRCUITPY_ESPCAMERA = 0

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/pins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
3737
{ MP_ROM_QSTR(MP_QSTR_EPD_DC), MP_ROM_PTR(&pin_GPIO46) },
3838
{ MP_ROM_QSTR(MP_QSTR_EPD_CS), MP_ROM_PTR(&pin_GPIO45) },
3939
{ MP_ROM_QSTR(MP_QSTR_EPD_CLK), MP_ROM_PTR(&pin_GPIO12) },
40-
{ MP_ROM_QSTR(MP_QSTR_EPD_MOSI), MP_ROM_PTR(&pin_GPIO10) },
40+
{ MP_ROM_QSTR(MP_QSTR_EPD_MOSI), MP_ROM_PTR(&pin_GPIO11) },
4141

4242
// TF Slot
4343
{ MP_ROM_QSTR(MP_QSTR_TF_CS), MP_ROM_PTR(&pin_GPIO10) },
@@ -59,9 +59,9 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
5959
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
6060
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
6161

62-
// TODO: Are the UART pins really this, or are they reversed?
63-
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO44) },
64-
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO43) },
62+
// UART
63+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
64+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
6565

6666
// Objects
6767
{ MP_ROM_QSTR(MP_QSTR_TF_SPI), MP_ROM_PTR(&board_tf_spi_obj) },

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/sdkconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# LWIP
99
#
10+
CONFIG_ESP_PHY_ENABLE_USB=n
1011
# end of LWIP
1112

1213
# end of Component config

0 commit comments

Comments
 (0)