Skip to content

Commit d0bfd3d

Browse files
committed
Merge branch 'main' into new
2 parents 608c01a + 8728c6d commit d0bfd3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+577
-68
lines changed

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
sudo apt-get update
3636
sudo apt-get install -y gettext uncrustify
3737
- name: Run pre-commit
38-
uses: pre-commit/[email protected].0
38+
uses: pre-commit/[email protected].1
3939
- name: Make patch
4040
if: failure()
4141
run: git diff > ~/pre-commit.patch

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,11 @@ bool pin_number_is_free(uint8_t pin_number) {
161161
return false;
162162
}
163163
if (pin_number == PIN_PA30
164-
#ifdef SAM_D5X_E5X
165-
) {
166-
#endif
167164
#ifdef SAMD21
168-
|| pin_number == PIN_PA31) {
169-
#endif) {
165+
|| pin_number == PIN_PA31
166+
#endif
167+
)
168+
{
170169
return state->bit.PMUXEN == 1 && ((pmux->reg >> (4 * pin_index % 2)) & 0xf) == SWD_MUX;
171170
}
172171
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/busio/SPI.h"
30+
#include "shared-bindings/fourwire/FourWire.h"
31+
#include "shared-bindings/microcontroller/Pin.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
34+
#include "shared-bindings/board/__init__.h"
35+
36+
fourwire_fourwire_obj_t board_display_obj;
37+
38+
uint8_t display_init_sequence[] = {
39+
0xFE, 0x00, // Inter Register Enable1 (FEh)
40+
0xEF, 0x00, // Inter Register Enable2 (EFh)
41+
0xB6, 0x02, 0x00, 0x00, // Display Function Control (B6h) [S1→S360 source, G1→G32 gate]
42+
0x36, 0x01, 0x48, // Memory Access Control(36h) [Invert Row order, invert vertical scan order]
43+
0x3a, 0x01, 0x55, // COLMOD: Pixel Format Set (3Ah) [16 bits / pixel]
44+
0xC3, 0x01, 0x13, // Power Control 2 (C3h) [VREG1A = 5.06, VREG1B = 0.68]
45+
0xC4, 0x01, 0x13, // Power Control 3 (C4h) [VREG2A = -3.7, VREG2B = 0.68]
46+
0xC9, 0x01, 0x22, // Power Control 4 (C9h)
47+
0xF0, 0x06, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2a, // SET_GAMMA1 (F0h)
48+
0xF1, 0x06, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6f, // SET_GAMMA2 (F1h)
49+
0xF2, 0x06, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2a, // SET_GAMMA3 (F2h)
50+
0xF3, 0x06, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6f, // SET_GAMMA4 (F3h)
51+
52+
0x66, 0x0a, 0x3c, 0x00, 0xcd, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00,
53+
0x67, 0x0a, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98,
54+
0x74, 0x07, 0x10, 0x85, 0x80, 0x00, 0x00, 0x4e, 0x00,
55+
0x98, 0x02, 0x3e, 0x07,
56+
57+
0x35, 0x00, // Tearing Effect Line ON (35h) [both V-blanking and H-blanking]
58+
0x21, 0x00, // Display Inversion ON (21h)
59+
0x11, 0x80, 0x78, // Sleep Out Mode (11h) and delay(120)
60+
0x29, 0x80, 0x14, // Display ON (29h) and delay(20)
61+
0x2a, 0x04, 0x00, 0x00, 0x00, 239, // Column Address Set (2Ah) [Start col = 0, end col = 239]
62+
0x2b, 0x04, 0x00, 0x00, 0x00, 239, // Row Address Set (2Bh) [Start row = 0, end row = 239]
63+
};
64+
65+
void board_init(void) {
66+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
67+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
68+
bus->base.type = &fourwire_fourwire_type;
69+
70+
common_hal_fourwire_fourwire_construct(
71+
bus,
72+
spi,
73+
&pin_GPIO4, // DC
74+
&pin_GPIO7, // CS
75+
&pin_GPIO8, // RST
76+
40000000, // baudrate
77+
0, // polarity
78+
0 // phase
79+
);
80+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
81+
display->base.type = &busdisplay_busdisplay_type;
82+
83+
common_hal_busdisplay_busdisplay_construct(
84+
display,
85+
bus,
86+
240, // width (after rotation)
87+
240, // height (after rotation)
88+
0, // column start
89+
0, // row start
90+
0, // rotation
91+
16, // color depth
92+
false, // grayscale
93+
false, // pixels in a byte share a row. Only valid for depths < 8
94+
1, // bytes per cell. Only valid for depths < 8
95+
false, // reverse_pixels_in_byte. Only valid for depths < 8
96+
true, // reverse_pixels_in_word
97+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
98+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
99+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
100+
display_init_sequence,
101+
sizeof(display_init_sequence),
102+
&pin_GPIO9, // backlight pin
103+
NO_BRIGHTNESS_COMMAND,
104+
0.8f, // brightness
105+
false, // single_byte_bounds
106+
false, // data_as_commands
107+
true, // auto_refresh
108+
60, // native_frames_per_second
109+
true, // backlight_on_high
110+
false, // SH1107_addressing
111+
50000 // backlight pwm frequency
112+
);
113+
}
114+
115+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
116+
// Hold pind must be set high to avoid a power off when battery powered
117+
if (pin_number == 46) {
118+
// Turn on hold output
119+
gpio_set_direction(46, GPIO_MODE_DEF_OUTPUT);
120+
gpio_set_level(46, true);
121+
return true;
122+
}
123+
return false;
124+
}
125+
126+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
127+
128+
// TODO: Should we turn off the display when asleep, in board_deinit() ?
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2024 CDarius
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "M5Stack Dial"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
31+
32+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO21)
33+
34+
#define CIRCUITPY_BOARD_I2C (2)
35+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO12, .sda = &pin_GPIO11}, \
36+
{.scl = &pin_GPIO15, .sda = &pin_GPIO13}}
37+
38+
#define CIRCUITPY_BOARD_SPI (1)
39+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO6, .mosi = &pin_GPIO5}}
40+
41+
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
USB_VID = 0x303A
2+
USB_PID = 0x81DD
3+
4+
USB_PRODUCT = "M5stack - Dial"
5+
USB_MANUFACTURER = "M5Stack"
6+
7+
IDF_TARGET = esp32s3
8+
9+
CIRCUITPY_ESP_FLASH_MODE = qio
10+
CIRCUITPY_ESP_FLASH_FREQ = 80m
11+
CIRCUITPY_ESP_FLASH_SIZE = 8MB
12+
13+
CIRCUITPY_ESPCAMERA = 0
14+
CIRCUITPY_PARALLELDISPLAYBUS = 0
15+
16+
OPTIMIZATION_FLAGS = -Os

0 commit comments

Comments
 (0)