Skip to content

Commit 644b3b3

Browse files
committed
Merge branch 'm5stack_cardputer' of github.com:jamesjnadeau/circuitpython into m5stack_cardputer
2 parents be6804c + baf0e00 commit 644b3b3

File tree

3 files changed

+22
-45
lines changed

3 files changed

+22
-45
lines changed

ports/espressif/boards/m5stack_cardputer/board.c

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,23 @@ fourwire_fourwire_obj_t board_display_obj;
3737

3838
#define DELAY 0x80
3939

40-
// display init sequence according to LilyGO example app
4140
uint8_t display_init_sequence[] = {
42-
// sw reset
43-
0x01, 0 | DELAY, 150,
44-
// sleep out
45-
0x11, 0 | DELAY, 255,
46-
// normal display mode on
47-
0x13, 0,
48-
// display and color format settings
49-
0x36, 1, 0x68,
50-
0xB6, 2, 0x0A, 0x82,
51-
0x3A, 1 | DELAY, 0x55, 10,
52-
// ST7789V frame rate setting
53-
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
54-
// voltages: VGH / VGL
55-
0xB7, 1, 0x35,
56-
// ST7789V power setting
57-
0xBB, 1, 0x28,
58-
0xC0, 1, 0x0C,
59-
0xC2, 2, 0x01, 0xFF,
60-
0xC3, 1, 0x10,
61-
0xC4, 1, 0x20,
62-
0xC6, 1, 0x0F,
63-
0xD0, 2, 0xA4, 0xA1,
64-
// ST7789V gamma setting
65-
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
66-
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
41+
// SWRESET and Delay 140ms
42+
0x01, 0 | DELAY, 140,
43+
// SLPOUT and Delay 10ms
44+
0x11, 0 | DELAY, 10,
45+
// COLMOD 65k colors and 16 bit 5-6-5
46+
0x3A, 1, 0x55,
47+
// INVON Iiversion on
6748
0x21, 0,
68-
// display on
69-
0x29, 0 | DELAY, 255,
49+
// NORON normal operation (full update)
50+
0x13, 0,
51+
// MADCTL columns RTL, page/column reverse order
52+
0x36, 1, 0x60,
53+
// RAMCTRL color word little endian
54+
0xB0, 2, 0x00, 0xF8,
55+
// DIPON display on
56+
0x29, 0,
7057
};
7158

7259

@@ -102,7 +89,7 @@ void board_init(void) {
10289
false, // pixels in a byte share a row. Only valid for depths < 8
10390
1, // bytes per cell. Only valid for depths < 8
10491
false, // reverse_pixels_in_byte. Only valid for depths < 8
105-
true, // reverse_pixels_in_word
92+
false, // reverse_pixels_in_word
10693
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
10794
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
10895
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
@@ -117,20 +104,10 @@ void board_init(void) {
117104
60, // native_frames_per_second
118105
true, // backlight_on_high
119106
false, // SH1107_addressing
120-
50000 // backlight pwm frequency
107+
350 // backlight pwm frequency
121108
);
122109
}
123110

124-
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
125-
// Override the I2C/TFT power pin reset to prevent resetting the display.
126-
if (pin_number == 21) {
127-
// Turn on TFT and I2C
128-
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
129-
gpio_set_level(21, true);
130-
return true;
131-
}
132-
return false;
133-
}
134111

135112
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
136113

ports/espressif/boards/m5stack_cardputer/mpconfigboard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
#define MICROPY_HW_NEOPIXEL (&pin_GPIO21)
3333
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1)
3434
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)
35-
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
36-
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
37-
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO34)
35+
#define CIRCUITPY_BOARD_SPI (2)
36+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35}, \
37+
{.clock = &pin_GPIO40, .mosi = &pin_GPIO14, .miso = &pin_GPIO39}}

ports/espressif/boards/m5stack_cardputer/pins.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "shared-bindings/board/__init__.h"
22

33
#include "shared-module/displayio/__init__.h"
4-
4+
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1)
55
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
66
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
77

@@ -65,7 +65,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
6565

6666
// Other
6767
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
68-
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
68+
{ MP_ROM_QSTR(MP_QSTR_PORTA_I2C), MP_ROM_PTR(&board_i2c_obj) },
6969
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
7070

7171
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}

0 commit comments

Comments
 (0)