forked from micropython/micropython
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9201 from SeanTheITGuy/spotpear_esp32c3_lcd_1_4
Add support for Spotpear ESP32C3 w/ 1.44" LCD.
- Loading branch information
Showing
5 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
ports/espressif/boards/spotpear_esp32c3_lcd_1_44/board.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2023 CDarius | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
#include "supervisor/board.h" | ||
#include "mpconfigboard.h" | ||
#include "shared-bindings/microcontroller/Pin.h" | ||
#include "shared-module/displayio/__init__.h" | ||
#include "shared-module/displayio/mipi_constants.h" | ||
|
||
// display init sequence according to adafruit_st7735r.py library | ||
uint8_t display_init_sequence[] = { | ||
0x01, 0x80, 0x96, // SWRESET and Delay 150ms | ||
0x11, 0x80, 0xff, // SLPOUT and Delay | ||
0xb1, 0x03, 0x01, 0x2C, 0x2D, // _FRMCTR1 | ||
0xb2, 0x03, 0x01, 0x2C, 0x2D, // _FRMCTR2 | ||
0xb3, 0x06, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, // _FRMCTR3 | ||
0xb4, 0x01, 0x07, // _INVCTR line inversion | ||
0xc0, 0x03, 0xa2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA | ||
0xc1, 0x01, 0xc5, // _PWCTR2 VGH=14.7V, VGL=-7.35V | ||
0xc2, 0x02, 0x0a, 0x00, // _PWCTR3 Opamp current small, Boost frequency | ||
0xc3, 0x02, 0x8a, 0x2a, | ||
0xc4, 0x02, 0x8a, 0xee, | ||
0xc5, 0x01, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V | ||
0x36, 0x01, 0xc8, // MADCTL Rotate display | ||
0x3a, 0x01, 0x05, // COLMOD - 16bit color | ||
0xe0, 0x10, 0x02, 0x1c, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2d, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma | ||
0xe1, 0x10, 0x03, 0x1d, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10, // _GMCTRN1 | ||
0x13, 0x80, 0x0a, // _NORON | ||
0x29, 0x80, 0x64 // _DISPON | ||
}; | ||
|
||
static bool display_init(void) { | ||
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
busio_spi_obj_t *spi = &bus->inline_bus; | ||
common_hal_busio_spi_construct(spi, &pin_GPIO3, &pin_GPIO4, NULL, false); | ||
common_hal_busio_spi_never_reset(spi); | ||
|
||
bus->base.type = &fourwire_fourwire_type; | ||
|
||
common_hal_fourwire_fourwire_construct( | ||
bus, | ||
spi, | ||
&pin_GPIO0, // DC | ||
&pin_GPIO2, // CS | ||
&pin_GPIO5, // RST | ||
10000000, // baudrate | ||
0, // polarity | ||
0 // phase | ||
); | ||
|
||
busdisplay_busdisplay_obj_t *display = &allocate_display()->display; | ||
display->base.type = &busdisplay_busdisplay_type; | ||
|
||
common_hal_busdisplay_busdisplay_construct( | ||
display, | ||
bus, | ||
128, // width (after rotation) | ||
128, // height (after rotation) | ||
2, // column start | ||
1, // row start | ||
0, // rotation | ||
16, // color depth | ||
false, // grayscale | ||
false, // pixels in a byte share a row. Only valid for depths < 8 | ||
1, // bytes per cell. Only valid for depths < 8 | ||
false, // reverse_pixels_in_byte. Only valid for depths < 8 | ||
true, // reverse_pixels_in_word | ||
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command | ||
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command | ||
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command | ||
display_init_sequence, | ||
sizeof(display_init_sequence), | ||
NULL, // backlight pin | ||
NO_BRIGHTNESS_COMMAND, | ||
1.0f, // brightness | ||
false, // single_byte_bounds | ||
false, // data_as_commands | ||
true, // auto_refresh | ||
80, // native_frames_per_second | ||
false, // backlight_on_high | ||
false, // SH1107_addressing | ||
50000 // backlight pwm frequency | ||
); | ||
|
||
return true; | ||
} | ||
|
||
void board_init(void) { | ||
display_init(); | ||
} |
32 changes: 32 additions & 0 deletions
32
ports/espressif/boards/spotpear_esp32c3_lcd_1_44/mpconfigboard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2023 Neradoc | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
// Board setup | ||
#define MICROPY_HW_BOARD_NAME "Spotpear ESP32C3 LCD 1.44" | ||
#define MICROPY_HW_MCU_NAME "ESP32-C3FH4" | ||
|
||
#define MICROPY_HW_LED_STATUS (&pin_GPIO11) | ||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) |
10 changes: 10 additions & 0 deletions
10
ports/espressif/boards/spotpear_esp32c3_lcd_1_44/mpconfigboard.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CIRCUITPY_CREATOR_ID = 0x18760000 | ||
CIRCUITPY_CREATION_ID = 0x00DD0001 | ||
|
||
IDF_TARGET = esp32c3 | ||
|
||
CIRCUITPY_ESP_FLASH_MODE = qio | ||
CIRCUITPY_ESP_FLASH_FREQ = 80m | ||
CIRCUITPY_ESP_FLASH_SIZE = 4MB | ||
|
||
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "shared-bindings/board/__init__.h" | ||
#include "shared-module/displayio/__init__.h" | ||
|
||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = { | ||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
||
// buttons | ||
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO9) }, | ||
{ MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO9) }, | ||
{ MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO8) }, | ||
{ MP_ROM_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO10) }, | ||
|
||
// Status LED | ||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO11) }, | ||
|
||
// SPI LCD | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO4) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO3) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO0) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO5) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO2) }, | ||
|
||
// UART (on header 1) | ||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, | ||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, | ||
|
||
// User available GPIO, Header 1 | ||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, | ||
|
||
// Objects | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, | ||
}; | ||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); |
15 changes: 15 additions & 0 deletions
15
ports/espressif/boards/spotpear_esp32c3_lcd_1_44/sdkconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Espressif IoT Development Framework Configuration | ||
# | ||
# | ||
# Component config | ||
# | ||
# | ||
# LWIP | ||
# | ||
CONFIG_LWIP_LOCAL_HOSTNAME="spotpear-esp32c3-lcd-1-44" | ||
# end of LWIP | ||
|
||
# end of Component config | ||
|
||
# end of Espressif IoT Development Framework Configuration |