Skip to content

Commit 0615876

Browse files
authored
Merge pull request #4439 from dhalbert/adafruit_funhouse
Adafruit funhouse
2 parents d012561 + d7a2ae9 commit 0615876

File tree

13 files changed

+338
-71
lines changed

13 files changed

+338
-71
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ jobs:
445445
board:
446446
- "adafruit_feather_esp32s2_nopsram"
447447
- "adafruit_feather_esp32s2_tftback_nopsram"
448+
- "adafruit_funhouse"
448449
- "adafruit_magtag_2.9_grayscale"
449450
- "adafruit_metro_esp32s2"
450451
- "electroniccats_bastwifi"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ TAGS
8686
####################
8787
.venv
8888
.env
89+
90+
# Uncrustify formatting
91+
*.uncrustify

locale/circuitpython.pot

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ msgstr ""
338338
msgid "All UART peripherals are in use"
339339
msgstr ""
340340

341+
#: shared-bindings/pwmio/PWMOut.c
342+
msgid "All channels in use"
343+
msgstr ""
344+
341345
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
342346
msgid "All event channels in use"
343347
msgstr ""
@@ -667,7 +671,7 @@ msgstr ""
667671
msgid "Cannot unambiguously get sizeof scalar"
668672
msgstr ""
669673

670-
#: ports/stm/common-hal/pwmio/PWMOut.c
674+
#: shared-bindings/pwmio/PWMOut.c
671675
msgid "Cannot vary frequency on a timer that is already in use"
672676
msgstr ""
673677

@@ -749,14 +753,6 @@ msgstr ""
749753
msgid "Could not initialize UART"
750754
msgstr ""
751755

752-
#: ports/esp32s2/common-hal/pwmio/PWMOut.c ports/stm/common-hal/pwmio/PWMOut.c
753-
msgid "Could not initialize channel"
754-
msgstr ""
755-
756-
#: ports/esp32s2/common-hal/pwmio/PWMOut.c ports/stm/common-hal/pwmio/PWMOut.c
757-
msgid "Could not initialize timer"
758-
msgstr ""
759-
760756
#: ports/stm/common-hal/pwmio/PWMOut.c
761757
msgid "Could not re-init channel"
762758
msgstr ""
@@ -777,7 +773,7 @@ msgstr ""
777773
msgid "Could not set address"
778774
msgstr ""
779775

780-
#: ports/stm/common-hal/pwmio/PWMOut.c
776+
#: shared-bindings/pwmio/PWMOut.c
781777
msgid "Could not start PWM"
782778
msgstr ""
783779

@@ -1026,7 +1022,7 @@ msgstr ""
10261022
msgid "Framebuffer requires %d bytes"
10271023
msgstr ""
10281024

1029-
#: ports/stm/common-hal/pwmio/PWMOut.c
1025+
#: shared-bindings/pwmio/PWMOut.c
10301026
msgid "Frequency must match existing PWMOut using this timer"
10311027
msgstr ""
10321028

@@ -1254,10 +1250,6 @@ msgstr ""
12541250
msgid "Invalid frequency"
12551251
msgstr ""
12561252

1257-
#: ports/stm/common-hal/pwmio/PWMOut.c
1258-
msgid "Invalid frequency supplied"
1259-
msgstr ""
1260-
12611253
#: supervisor/shared/safe_mode.c
12621254
msgid "Invalid memory access."
12631255
msgstr ""
@@ -1303,10 +1295,6 @@ msgstr ""
13031295
msgid "Invalid pins"
13041296
msgstr ""
13051297

1306-
#: ports/stm/common-hal/pwmio/PWMOut.c
1307-
msgid "Invalid pins for PWMOut"
1308-
msgstr ""
1309-
13101298
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
13111299
#: shared-bindings/displayio/FourWire.c
13121300
msgid "Invalid polarity"
@@ -1559,18 +1547,6 @@ msgstr ""
15591547
msgid "No long integer support"
15601548
msgstr ""
15611549

1562-
#: ports/esp32s2/common-hal/pwmio/PWMOut.c
1563-
msgid "No more channels available"
1564-
msgstr ""
1565-
1566-
#: ports/esp32s2/common-hal/pwmio/PWMOut.c
1567-
msgid "No more timers available"
1568-
msgstr ""
1569-
1570-
#: ports/stm/common-hal/pwmio/PWMOut.c
1571-
msgid "No more timers available on this pin."
1572-
msgstr ""
1573-
15741550
#: shared-bindings/wifi/Radio.c
15751551
msgid "No network with that ssid"
15761552
msgstr ""
@@ -2124,11 +2100,6 @@ msgstr ""
21242100
msgid "Timeout is too long: Maximum timeout length is %d seconds"
21252101
msgstr ""
21262102

2127-
#: ports/stm/common-hal/pwmio/PWMOut.c
2128-
msgid ""
2129-
"Timer was reserved for internal use - declare PWM pins earlier in the program"
2130-
msgstr ""
2131-
21322103
#: supervisor/shared/safe_mode.c
21332104
msgid "To exit, please reset the board without "
21342105
msgstr ""
@@ -3737,6 +3708,7 @@ msgstr ""
37373708

37383709
#: ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h
37393710
#: ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h
3711+
#: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h
37403712
#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h
37413713
#: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h
37423714
#: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
30+
#include "shared-bindings/busio/SPI.h"
31+
#include "shared-bindings/displayio/FourWire.h"
32+
#include "shared-bindings/microcontroller/Pin.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-module/displayio/mipi_constants.h"
35+
36+
#include "esp_log.h"
37+
38+
displayio_fourwire_obj_t board_display_obj;
39+
40+
#define DELAY 0x80
41+
42+
uint8_t display_init_sequence[] = {
43+
0x01, 0 | DELAY, 150, // SWRESET
44+
0x11, 0 | DELAY, 255, // SLPOUT
45+
0x36, 1, 0b10100000, // _MADCTL for rotation 0
46+
0x3a, 1, 0x55, // COLMOD - 16bit color
47+
0x21, 0 | DELAY, 10, // _INVON
48+
0x13, 0 | DELAY, 10, // _NORON
49+
0x29, 0 | DELAY, 255, // _DISPON
50+
};
51+
52+
void board_init(void) {
53+
// USB
54+
common_hal_never_reset_pin(&pin_GPIO19);
55+
common_hal_never_reset_pin(&pin_GPIO20);
56+
57+
// Debug UART
58+
#ifdef DEBUG
59+
common_hal_never_reset_pin(&pin_GPIO37);
60+
common_hal_never_reset_pin(&pin_GPIO38);
61+
#endif /* DEBUG */
62+
63+
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
64+
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL);
65+
common_hal_busio_spi_never_reset(spi);
66+
67+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
68+
bus->base.type = &displayio_fourwire_type;
69+
common_hal_displayio_fourwire_construct(bus,
70+
spi,
71+
&pin_GPIO39, // TFT_DC Command or data
72+
&pin_GPIO40, // TFT_CS Chip select
73+
&pin_GPIO41, // TFT_RESET Reset
74+
60000000, // Baudrate
75+
0, // Polarity
76+
0); // Phase
77+
78+
// workaround as board_init() is called before reset_port() in main.c
79+
pwmout_reset();
80+
81+
displayio_display_obj_t* display = &displays[0].display;
82+
display->base.type = &displayio_display_type;
83+
common_hal_displayio_display_construct(
84+
display,
85+
bus,
86+
240, // Width (after rotation)
87+
240, // Height (after rotation)
88+
80, // column start
89+
0, // row start
90+
270, // rotation
91+
16, // Color depth
92+
false, // Grayscale
93+
false, // Pixels in a byte share a row. Only used for depth < 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+
0x37, // set vertical scroll command
101+
display_init_sequence,
102+
sizeof(display_init_sequence),
103+
&pin_GPIO21, // backlight pin
104+
NO_BRIGHTNESS_COMMAND,
105+
1.0f, // brightness (ignored)
106+
true, // auto_brightness
107+
false, // single_byte_bounds
108+
false, // data_as_commands
109+
true, // auto_refresh
110+
60, // native_frames_per_second
111+
true, // backlight_on_high
112+
false); // not SH1107
113+
}
114+
115+
bool board_requests_safe_mode(void) {
116+
return false;
117+
}
118+
119+
void reset_board(void) {
120+
}
121+
122+
void board_deinit(void) {
123+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 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+
//Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "Adafruit FunHome"
30+
#define MICROPY_HW_MCU_NAME "ESP32S2"
31+
32+
#define MICROPY_HW_APA_MOSI (&pin_GPIO14)
33+
#define MICROPY_HW_APA_SCK (&pin_GPIO15)
34+
35+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
36+
37+
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
38+
39+
#define AUTORESET_DELAY_MS 500
40+
41+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO33)
42+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO34)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x80FA
3+
USB_PRODUCT = "FunHouse"
4+
USB_MANUFACTURER = "Adafruit"
5+
6+
INTERNAL_FLASH_FILESYSTEM = 1
7+
LONGINT_IMPL = MPZ
8+
9+
# The default queue depth of 16 overflows on release builds,
10+
# so increase it to 32.
11+
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
12+
13+
CIRCUITPY_ESP_FLASH_MODE=dio
14+
CIRCUITPY_ESP_FLASH_FREQ=40m
15+
CIRCUITPY_ESP_FLASH_SIZE=4MB
16+
17+
CIRCUITPY_MODULE=wrover
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "shared-module/displayio/__init__.h"
4+
5+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
6+
7+
{ MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO21) },
8+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO40) },
9+
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) },
10+
{ MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO35) },
11+
{ MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) },
12+
{ MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO36) },
13+
14+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_DOWN), MP_ROM_PTR(&pin_GPIO3) },
15+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_SELECT), MP_ROM_PTR(&pin_GPIO4) },
16+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_UP), MP_ROM_PTR(&pin_GPIO5) },
17+
18+
{ MP_ROM_QSTR(MP_QSTR_CAP6), MP_ROM_PTR(&pin_GPIO6) },
19+
{ MP_ROM_QSTR(MP_QSTR_CAP7), MP_ROM_PTR(&pin_GPIO7) },
20+
{ MP_ROM_QSTR(MP_QSTR_CAP8), MP_ROM_PTR(&pin_GPIO8) },
21+
{ MP_ROM_QSTR(MP_QSTR_CAP9), MP_ROM_PTR(&pin_GPIO9) },
22+
{ MP_ROM_QSTR(MP_QSTR_CAP10), MP_ROM_PTR(&pin_GPIO10) },
23+
{ MP_ROM_QSTR(MP_QSTR_CAP11), MP_ROM_PTR(&pin_GPIO11) },
24+
{ MP_ROM_QSTR(MP_QSTR_CAP12), MP_ROM_PTR(&pin_GPIO12) },
25+
{ MP_ROM_QSTR(MP_QSTR_CAP13), MP_ROM_PTR(&pin_GPIO13) },
26+
27+
{ MP_ROM_QSTR(MP_QSTR_DOTSTAR_DATA), MP_ROM_PTR(&pin_GPIO14) },
28+
{ MP_ROM_QSTR(MP_QSTR_DOTSTAR_CLOCK), MP_ROM_PTR(&pin_GPIO15) },
29+
30+
{ MP_ROM_QSTR(MP_QSTR_PIR_SENSE), MP_ROM_PTR(&pin_GPIO16) },
31+
32+
{ MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_GPIO18) },
33+
34+
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO42) },
35+
36+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO37) },
37+
38+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) },
39+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) },
40+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO1) },
41+
42+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO33) },
43+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO34) },
44+
45+
{ MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_TX), MP_ROM_PTR(&pin_GPIO37) },
46+
{ MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_RX), MP_ROM_PTR(&pin_GPIO38) },
47+
48+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
49+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
50+
};
51+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
2+
3+
#
4+
# SPI RAM config
5+
#
6+
# CONFIG_SPIRAM_TYPE_AUTO is not set
7+
CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
8+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
9+
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
10+
CONFIG_SPIRAM_SIZE=2097152
11+
12+
#
13+
# PSRAM clock and cs IO for ESP32S2
14+
#
15+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
16+
CONFIG_DEFAULT_PSRAM_CS_IO=26
17+
# end of PSRAM clock and cs IO for ESP32S2
18+
19+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
20+
# CONFIG_SPIRAM_RODATA is not set
21+
# CONFIG_SPIRAM_SPEED_80M is not set
22+
CONFIG_SPIRAM_SPEED_40M=y
23+
# CONFIG_SPIRAM_SPEED_26M is not set
24+
# CONFIG_SPIRAM_SPEED_20M is not set
25+
CONFIG_SPIRAM=y
26+
CONFIG_SPIRAM_BOOT_INIT=y
27+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
28+
CONFIG_SPIRAM_USE_MEMMAP=y
29+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
30+
# CONFIG_SPIRAM_USE_MALLOC is not set
31+
CONFIG_SPIRAM_MEMTEST=y
32+
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
33+
# end of SPI RAM config

0 commit comments

Comments
 (0)