forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added new board: M5Stack DinMeter (esp32s3) #10650
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,107 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "mpconfigboard.h" | ||
| #include "supervisor/board.h" | ||
| #include "supervisor/shared/serial.h" | ||
| #include "shared-bindings/busio/SPI.h" | ||
| #include "shared-bindings/fourwire/FourWire.h" | ||
| #include "shared-bindings/microcontroller/Pin.h" | ||
| #include "shared-module/displayio/__init__.h" | ||
| #include "shared-module/displayio/mipi_constants.h" | ||
| #include "shared-bindings/board/__init__.h" | ||
| #include "py/runtime.h" | ||
| #include "py/ringbuf.h" | ||
| #include "shared/runtime/interrupt_char.h" | ||
|
|
||
|
|
||
| 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 | ||
| 0x21, 0x00, // _INVON | ||
| 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 | ||
| }; | ||
|
|
||
|
|
||
| // Overrides the weakly linked function from supervisor/shared/board.c | ||
| void board_init(void) { | ||
| busio_spi_obj_t *spi = common_hal_board_create_spi(0); | ||
| fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
| bus->base.type = &fourwire_fourwire_type; | ||
|
|
||
| // see here for inspiration: https://github.com/m5stack/M5GFX/blob/33d7d3135e816a86a008fae8ab3757938cee95d2/src/M5GFX.cpp#L1350 | ||
| common_hal_fourwire_fourwire_construct( | ||
| bus, | ||
| spi, | ||
| &pin_GPIO4, // DC | ||
| &pin_GPIO7, // CS | ||
| &pin_GPIO8, // RST | ||
| 40000000, // 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, | ||
| 240, // width (after rotation) | ||
| 135, // height (after rotation) | ||
| 40, // column start | ||
| 52, // 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), | ||
| &pin_GPIO9, // backlight pin | ||
| NO_BRIGHTNESS_COMMAND, | ||
| 1.0f, // brightness | ||
| false, // single_byte_bounds | ||
| false, // data_as_commands | ||
| true, // auto_refresh | ||
| 80, // native_frames_per_second | ||
| true, // backlight_on_high | ||
| false, // SH1107_addressing | ||
| 50000 // backlight pwm frequency | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| bool espressif_board_reset_pin_number(gpio_num_t pin_number) { | ||
| // Hold pin must be set high to avoid a power off when battery powered | ||
| if (pin_number == 46) { | ||
| // Turn on hold output | ||
| config_pin_as_output_with_level(pin_number, true); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // TODO: Should we turn off the display when asleep, in board_deinit() ? |
This file contains hidden or 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,22 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2024 CDarius | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025 juergenpabel | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #pragma once | ||
|
|
||
| // Micropython setup | ||
|
|
||
| #define MICROPY_HW_BOARD_NAME "M5Stack DinMeter" | ||
| #define MICROPY_HW_MCU_NAME "ESP32S3" | ||
|
|
||
| #define CIRCUITPY_BOARD_I2C (2) | ||
| #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO12, .sda = &pin_GPIO11}, \ | ||
| {.scl = &pin_GPIO15, .sda = &pin_GPIO13}} | ||
|
|
||
| #define CIRCUITPY_BOARD_SPI (1) | ||
| #define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO6, .mosi = &pin_GPIO5}} | ||
|
|
||
| #define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1) |
This file contains hidden or 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 @@ | ||
| USB_VID = 0x303A | ||
| USB_PID = 0x81DD | ||
|
|
||
| USB_PRODUCT = "M5stack - DinMeter" | ||
| USB_MANUFACTURER = "M5Stack" | ||
|
|
||
| IDF_TARGET = esp32s3 | ||
|
|
||
| CIRCUITPY_ESP_FLASH_MODE = qio | ||
| CIRCUITPY_ESP_FLASH_FREQ = 80m | ||
| CIRCUITPY_ESP_FLASH_SIZE = 8MB | ||
|
|
||
| # Very few pins. | ||
| CIRCUITPY_ESPCAMERA = 0 | ||
| CIRCUITPY_PARALLELDISPLAYBUS = 0 | ||
This file contains hidden or 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,61 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025 Juergen Pabel | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "shared-bindings/board/__init__.h" | ||
|
|
||
| #include "shared-module/displayio/__init__.h" | ||
|
|
||
| CIRCUITPY_BOARD_BUS_SINGLETON(porta_i2c, i2c, 1) | ||
|
|
||
| static const mp_rom_map_elem_t board_module_globals_table[] = { | ||
| CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
|
||
| // Port A | ||
| { MP_ROM_QSTR(MP_QSTR_PORTA_SCL), MP_ROM_PTR(&pin_GPIO15) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, | ||
| { MP_ROM_QSTR(MP_QSTR_PORTA_SDA), MP_ROM_PTR(&pin_GPIO13) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, | ||
|
|
||
| // Port B | ||
| { MP_ROM_QSTR(MP_QSTR_PORTB_IN), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_PORTB_OUT), MP_ROM_PTR(&pin_GPIO2) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, | ||
| { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO2) }, | ||
|
|
||
| // Encoder | ||
| { MP_ROM_QSTR(MP_QSTR_ENC_A), MP_ROM_PTR(&pin_GPIO41) }, | ||
| { MP_ROM_QSTR(MP_QSTR_ENC_B), MP_ROM_PTR(&pin_GPIO40) }, | ||
|
|
||
| // Button | ||
| { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, | ||
| { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, | ||
| { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, | ||
|
|
||
| // Misc | ||
| { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO11) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO12) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO3) }, | ||
| { MP_ROM_QSTR(MP_QSTR_KNOB_BUTTON), MP_ROM_PTR(&pin_GPIO42) }, | ||
| { MP_ROM_QSTR(MP_QSTR_POWER_HOLD), MP_ROM_PTR(&pin_GPIO46) }, | ||
|
|
||
| // Display | ||
| { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO6) }, | ||
| { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO5) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO7) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO4) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO8) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO9) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_PORTA_I2C), MP_ROM_PTR(&board_porta_i2c_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} | ||
| }; | ||
| MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); |
This file contains hidden or 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,14 @@ | ||
| # | ||
| # Espressif IoT Development Framework Configuration | ||
| # | ||
| # | ||
| # Component config | ||
| # | ||
| # | ||
| # LWIP | ||
| # | ||
| # end of LWIP | ||
|
|
||
| # end of Component config | ||
|
|
||
| # end of Espressif IoT Development Framework Configuration |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.