Skip to content

Commit 6d71d22

Browse files
committed
create copy of 16M version as starting point
1 parent bbff8b5 commit 6d71d22

File tree

5 files changed

+214
-0
lines changed

5 files changed

+214
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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/microcontroller/Pin.h"
30+
#include "shared-module/displayio/__init__.h"
31+
#include "shared-module/displayio/mipi_constants.h"
32+
33+
#define DELAY 0x80
34+
35+
// display init sequence according to LilyGO example app
36+
uint8_t display_init_sequence[] = {
37+
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
38+
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD and Delay 10ms
40+
0x36, 0x01, 0x08, // _MADCTL
41+
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
42+
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
43+
0x36, 0x01, 0xC0, // _MADCTL
44+
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
45+
};
46+
47+
static void display_init(void) {
48+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
49+
busio_spi_obj_t *spi = &bus->inline_bus;
50+
51+
common_hal_busio_spi_construct(
52+
spi,
53+
&pin_GPIO18, // CLK
54+
&pin_GPIO19, // MOSI
55+
NULL, // MISO not connected
56+
false); // Not half-duplex
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+
&pin_GPIO16, // DC
66+
&pin_GPIO5, // CS
67+
&pin_GPIO23, // RST
68+
24000000, // baudrate (default from the driver)
69+
// 40000000,
70+
0, // polarity
71+
0 // phase
72+
);
73+
74+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
75+
display->base.type = &busdisplay_busdisplay_type;
76+
77+
common_hal_busdisplay_busdisplay_construct(
78+
display,
79+
bus,
80+
240, // width (after rotation)
81+
135, // height (after rotation)
82+
53, // column start
83+
40, // row start
84+
270, // rotation
85+
16, // color depth
86+
false, // grayscale
87+
false, // pixels in a byte share a row. Only valid for depths < 8
88+
1, // bytes per cell. Only valid for depths < 8
89+
false, // reverse_pixels_in_byte. Only valid for depths < 8
90+
true, // reverse_pixels_in_word
91+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
92+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
93+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
94+
display_init_sequence,
95+
sizeof(display_init_sequence),
96+
&pin_GPIO4, // backlight pin
97+
NO_BRIGHTNESS_COMMAND,
98+
1.0f, // brightness
99+
false, // single_byte_bounds
100+
false, // data_as_commands
101+
true, // auto_refresh
102+
60, // native_frames_per_second
103+
true, // backlight_on_high
104+
false, // SH1107_addressing
105+
50000 // backlight pwm frequency
106+
);
107+
}
108+
109+
void board_init(void) {
110+
// Display
111+
display_init();
112+
}
113+
114+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 "LILYGO TTGO T-DISPLAY v1.1"
30+
#define MICROPY_HW_MCU_NAME "ESP32"
31+
32+
// UART pins attached to the USB-serial converter chip
33+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
34+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CIRCUITPY_CREATOR_ID = 0xC3C30000
2+
CIRCUITPY_CREATION_ID = 0x00320002
3+
4+
IDF_TARGET = esp32
5+
6+
CIRCUITPY_ESP_FLASH_MODE = qio
7+
CIRCUITPY_ESP_FLASH_FREQ = 80m
8+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9+
10+
CIRCUITPY_ESPCAMERA = 0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
3+
4+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
5+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
6+
7+
{ MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO0) },
8+
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
9+
10+
{ MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO35) },
11+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
12+
13+
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
14+
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
15+
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
16+
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
17+
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
18+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
19+
{ MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) },
20+
{ MP_ROM_QSTR(MP_QSTR_IO25), MP_ROM_PTR(&pin_GPIO25) },
21+
{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
22+
{ MP_ROM_QSTR(MP_QSTR_IO27), MP_ROM_PTR(&pin_GPIO27) },
23+
24+
{ MP_ROM_QSTR(MP_QSTR_IO32), MP_ROM_PTR(&pin_GPIO32) },
25+
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
26+
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
27+
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
28+
29+
// 1.14 inch LCD ST7789
30+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO19) },
31+
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO18) },
32+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO5) },
33+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO23) },
34+
{ MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO4) },
35+
{ MP_ROM_QSTR(MP_QSTR_LCD_D_C), MP_ROM_PTR(&pin_GPIO16) },
36+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
37+
38+
// Battery Sense
39+
{ MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO34) },
40+
};
41+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# LWIP
9+
#
10+
CONFIG_LWIP_LOCAL_HOSTNAME="TTGO-TDISPLAY"
11+
# end of LWIP
12+
13+
# end of Component config
14+
15+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)