Skip to content

Commit 4e9eff5

Browse files
authored
Merge pull request #10303 from relic-se/tinycircuits_thumby
TinyCircuits Thumby and Thumby Color
2 parents a7df997 + fde84b9 commit 4e9eff5

10 files changed

Lines changed: 399 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cooper Dalrymple
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
10+
#include "shared-bindings/busio/SPI.h"
11+
#include "shared-bindings/fourwire/FourWire.h"
12+
#include "shared-bindings/microcontroller/Pin.h"
13+
#include "shared-module/displayio/__init__.h"
14+
#include "shared-module/displayio/mipi_constants.h"
15+
#include "shared-bindings/board/__init__.h"
16+
17+
18+
uint8_t display_init_sequence[] = {
19+
0xAE, 0, // DISPLAY_OFF
20+
0x20, 1, 0x00, // Set memory addressing to horizontal mode.
21+
0x81, 1, 0xcf, // set contrast control
22+
0xA1, 0, // Column 127 is segment 0
23+
0xA6, 0, // Normal display
24+
0xc8, 0, // Normal display
25+
0xA8, 1, 0x3f, // Mux ratio is 1/64
26+
0xd5, 1, 0x80, // Set divide ratio
27+
0xd9, 1, 0xf1, // Set pre-charge period
28+
0xda, 1, 0x12, // Set com configuration
29+
0xdb, 1, 0x40, // Set vcom configuration
30+
0x8d, 1, 0x14, // Enable charge pump
31+
0xAF, 0, // DISPLAY_ON
32+
};
33+
34+
void board_init(void) {
35+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
36+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
37+
bus->base.type = &fourwire_fourwire_type;
38+
common_hal_fourwire_fourwire_construct(bus,
39+
spi,
40+
CIRCUITPY_BOARD_OLED_DC, // Command or data
41+
CIRCUITPY_BOARD_OLED_CS, // Chip select
42+
CIRCUITPY_BOARD_OLED_RESET, // Reset
43+
10000000, // Baudrate
44+
0, // Polarity
45+
0); // Phase
46+
47+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
48+
display->base.type = &busdisplay_busdisplay_type;
49+
common_hal_busdisplay_busdisplay_construct(
50+
display,
51+
bus,
52+
72, // Width (after rotation)
53+
40, // Height (after rotation)
54+
28, // column start
55+
28, // row start
56+
0, // rotation
57+
1, // Color depth
58+
true, // grayscale
59+
false, // pixels in byte share row. only used for depth < 8
60+
1, // bytes per cell. Only valid for depths < 8
61+
false, // reverse_pixels_in_byte. Only valid for depths < 8
62+
true, // reverse_pixels_in_word
63+
0x21, // Set column command
64+
0x22, // Set row command
65+
44, // Write memory command
66+
display_init_sequence,
67+
sizeof(display_init_sequence),
68+
NULL, // backlight pin
69+
0x81,
70+
1.0f, // brightness
71+
true, // single_byte_bounds
72+
true, // data_as_commands
73+
true, // auto_refresh
74+
60, // native_frames_per_second
75+
true, // backlight_on_high
76+
false, // SH1107_addressing
77+
0); // backlight pwm frequency
78+
}
79+
80+
void reset_board(void) {
81+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cooper Dalrymple
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#define MICROPY_HW_BOARD_NAME "TinyCircuits Thumby"
10+
#define MICROPY_HW_MCU_NAME "rp2040"
11+
12+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
13+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
14+
15+
#define CIRCUITPY_BOARD_OLED_DC (&pin_GPIO17)
16+
#define CIRCUITPY_BOARD_OLED_CS (&pin_GPIO16)
17+
#define CIRCUITPY_BOARD_OLED_RESET (&pin_GPIO20)
18+
19+
#define CIRCUITPY_BOARD_SPI (1)
20+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = DEFAULT_SPI_BUS_SCK, .mosi = DEFAULT_SPI_BUS_MOSI, .miso = NULL}}
21+
22+
// For entering safe mode
23+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO6)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
USB_VID = 0x1209
2+
USB_PID = 0x3500
3+
USB_PRODUCT = "Thumby"
4+
USB_MANUFACTURER = "TinyCircuits"
5+
6+
CHIP_VARIANT = RP2040
7+
CHIP_FAMILY = rp2
8+
9+
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
10+
11+
CIRCUITPY_STAGE = 1
12+
CIRCUITPY_AUDIOIO = 1
13+
CIRCUITPY_AUDIOPWMIO = 1
14+
CIRCUITPY_KEYPAD = 1
15+
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_framebuf
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SSD1306
18+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DisplayIO_SSD1306
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Put board-specific pico-sdk definitions here. This file must exist.
10+
11+
// Allow extra time for xosc to start.
12+
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cooper Dalrymple
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
static const mp_rom_map_elem_t board_module_globals_table[] = {
11+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
12+
13+
// Link Cable (ASR00074)
14+
{ MP_ROM_QSTR(MP_QSTR_EXT_TX), MP_ROM_PTR(&pin_GPIO0) },
15+
{ MP_ROM_QSTR(MP_QSTR_EXT), MP_ROM_PTR(&pin_GPIO1) },
16+
{ MP_ROM_QSTR(MP_QSTR_EXT_PU), MP_ROM_PTR(&pin_GPIO1) },
17+
18+
// 0.42 inch OLED AST1042
19+
{ MP_ROM_QSTR(MP_QSTR_OLED_CS), MP_ROM_PTR(CIRCUITPY_BOARD_OLED_CS) },
20+
{ MP_ROM_QSTR(MP_QSTR_OLED_DC), MP_ROM_PTR(CIRCUITPY_BOARD_OLED_DC) },
21+
{ MP_ROM_QSTR(MP_QSTR_OLED_RESET), MP_ROM_PTR(CIRCUITPY_BOARD_OLED_RESET) },
22+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(DEFAULT_SPI_BUS_SCK) },
23+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(DEFAULT_SPI_BUS_MOSI) },
24+
25+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
26+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
27+
28+
// Buttons
29+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_LEFT), MP_ROM_PTR(&pin_GPIO3) },
30+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_UP), MP_ROM_PTR(&pin_GPIO4) },
31+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_RIGHT), MP_ROM_PTR(&pin_GPIO5) },
32+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_DOWN), MP_ROM_PTR(&pin_GPIO6) },
33+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_1), MP_ROM_PTR(&pin_GPIO24) },
34+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_2), MP_ROM_PTR(&pin_GPIO27) },
35+
36+
// Mono PWM Speaker
37+
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO28) },
38+
39+
// Hardware revision ID pins
40+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ID3), MP_ROM_PTR(&pin_GPIO12) },
41+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ID2), MP_ROM_PTR(&pin_GPIO13) },
42+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ID1), MP_ROM_PTR(&pin_GPIO14) },
43+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ID0), MP_ROM_PTR(&pin_GPIO15) },
44+
45+
// Power pins
46+
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO26) }
47+
};
48+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cooper Dalrymple
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/busio/SPI.h"
10+
#include "shared-bindings/fourwire/FourWire.h"
11+
#include "shared-bindings/microcontroller/Pin.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-module/displayio/mipi_constants.h"
14+
#include "shared-bindings/board/__init__.h"
15+
16+
17+
#define DELAY 0x80
18+
19+
// display init sequence according to TinyCircuits-Tiny-Game-Engine
20+
uint8_t display_init_sequence[] = {
21+
0xFE, 0, // inter register enable 1
22+
0xEF, 0, // inter register enable 2
23+
0xB0, 1, 0xC0,
24+
0xB1, 1, 0x80,
25+
0xB2, 1, 0x2F,
26+
0xB3, 1, 0x03,
27+
0xB7, 1, 0x01,
28+
0xB6, 1, 0x19,
29+
0xAC, 1, 0xC8, // Complement Principle of RGB 5, 6, 5
30+
0xAB, 1, 0x0f, // ?
31+
0x3A, 1, 0x05, // COLMOD: Pixel Format Set
32+
0xB4, 1, 0x04, // ?
33+
0xA8, 1, 0x07, // Frame Rate Set
34+
0xB8, 1, 0x08, // ?
35+
0xE7, 1, 0x5A, // VREG_CTL
36+
0xE8, 1, 0x23, // VGH_SET
37+
0xE9, 1, 0x47, // VGL_SET
38+
0xEA, 1, 0x99, // VGH_VGL_CLK
39+
0xC6, 1, 0x30, // ?
40+
0xC7, 1, 0x1F, // ?
41+
0xF0, 14, 0x05, 0x1D, 0x51, 0x2F, 0x85, 0x2A, 0x11, 0x62, 0x00, 0x07, 0x07, 0x0F, 0x08, 0x1F, // SET_GAMMA1
42+
0xF1, 14, 0x2E, 0x41, 0x62, 0x56, 0xA5, 0x3A, 0x3f, 0x60, 0x0F, 0x07, 0x0A, 0x18, 0x18, 0x1D, // SET_GAMMA2
43+
0x11, 0 | DELAY, 120,
44+
0x29, 0 | DELAY, 10, // display on
45+
};
46+
47+
void board_init(void) {
48+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
49+
busio_spi_obj_t *spi = &bus->inline_bus;
50+
common_hal_busio_spi_construct(
51+
spi,
52+
DEFAULT_SPI_BUS_SCK, // CLK
53+
DEFAULT_SPI_BUS_MOSI, // MOSI
54+
NULL, // MISO not connected
55+
false // Not half-duplex
56+
);
57+
58+
common_hal_busio_spi_never_reset(spi);
59+
60+
bus->base.type = &fourwire_fourwire_type;
61+
62+
common_hal_fourwire_fourwire_construct(
63+
bus,
64+
spi,
65+
CIRCUITPY_BOARD_LCD_DC, // DC
66+
CIRCUITPY_BOARD_LCD_CS, // CS
67+
CIRCUITPY_BOARD_LCD_RESET, // RST
68+
80000000, // baudrate
69+
0, // polarity
70+
0 // phase
71+
);
72+
73+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
74+
display->base.type = &busdisplay_busdisplay_type;
75+
common_hal_busdisplay_busdisplay_construct(
76+
display,
77+
bus,
78+
128, // width (after rotation)
79+
128, // height (after rotation)
80+
0, // column start
81+
0, // row start
82+
0, // rotation
83+
16, // color depth
84+
false, // grayscale
85+
false, // pixels in a byte share a row. Only valid for depths < 8
86+
1, // bytes per cell. Only valid for depths < 8
87+
false, // reverse_pixels_in_byte. Only valid for depths < 8
88+
true, // reverse_pixels_in_word
89+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
90+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
91+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
92+
display_init_sequence,
93+
sizeof(display_init_sequence),
94+
CIRCUITPY_BOARD_LCD_BACKLIGHT, // backlight pin
95+
NO_BRIGHTNESS_COMMAND,
96+
1.0f, // brightness
97+
false, // single_byte_bounds
98+
false, // data_as_commands
99+
true, // auto_refresh
100+
60, // native_frames_per_second
101+
true, // backlight_on_high
102+
false, // SH1107_addressing
103+
50000 // backlight pwm frequency
104+
);
105+
}
106+
107+
void reset_board(void) {
108+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cooper Dalrymple
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#define MICROPY_HW_BOARD_NAME "TinyCircuits Thumby Color"
10+
#define MICROPY_HW_MCU_NAME "rp2350"
11+
12+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9)
13+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8)
14+
15+
#define CIRCUITPY_BOARD_I2C (1)
16+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = DEFAULT_I2C_BUS_SCL, .sda = DEFAULT_I2C_BUS_SDA}}
17+
18+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
19+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
20+
21+
#define CIRCUITPY_BOARD_LCD_DC (&pin_GPIO16)
22+
#define CIRCUITPY_BOARD_LCD_CS (&pin_GPIO17)
23+
#define CIRCUITPY_BOARD_LCD_RESET (&pin_GPIO4)
24+
#define CIRCUITPY_BOARD_LCD_BACKLIGHT (&pin_GPIO7)
25+
26+
#define CIRCUITPY_BOARD_SPI (1)
27+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = DEFAULT_SPI_BUS_SCK, .mosi = DEFAULT_SPI_BUS_MOSI, .miso = NULL}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
USB_VID = 0x1209
2+
USB_PID = 0x3501
3+
USB_PRODUCT = "Thumby Color"
4+
USB_MANUFACTURER = "TinyCircuits"
5+
6+
CHIP_VARIANT = RP2350
7+
CHIP_PACKAGE = A
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
11+
12+
CIRCUITPY_STAGE = 1
13+
CIRCUITPY_AUDIOIO = 1
14+
CIRCUITPY_AUDIOPWMIO = 1
15+
CIRCUITPY_KEYPAD = 1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Put board-specific pico-sdk definitions here. This file must exist.

0 commit comments

Comments
 (0)