Skip to content

Commit 80b66db

Browse files
committed
feature: Support Air10x_LCD module
1 parent 4b51d56 commit 80b66db

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

docs/en/api-reference/lcd.ST7735.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ Methods
126126
+---------+----------------------------------------------------------------------------------------------------------+
127127
| Display | Default Orientation Tables |
128128
+=========+==========================================================================================================+
129-
| 160x80 | ((0x00, 80, 160, 26, 1), (0x60, 160, 80, 1, 26), (0xC0, 80, 160, 26, 1), (0xA0, 80, 160, 1, 26)) |
129+
| 160x80 | ((0x00, 80, 160, 26, 1), (0x60, 160, 80, 1, 26), (0xC0, 80, 160, 26, 1), (0xA0, 160, 80, 1, 26)) |
130+
+---------+----------------------------------------------------------------------------------------------------------+
131+
| 160x80 | ((0x00, 80, 160, 24, 0), (0x60, 160, 80, 0, 24), (0xC0, 80, 160, 24, 0), (0xA0, 160, 80, 0, 24)) |
130132
+---------+----------------------------------------------------------------------------------------------------------+
131133
| other | ((0x00, 0, 0, 0, 0), (0x60, 0, 0, 0, 0), (0xC0, 0, 0, 0, 0), (0xA0, 0, 0, 0, 0)) |
132134
+---------+----------------------------------------------------------------------------------------------------------+

docs/zh_CN/api-reference/lcd.ST7735.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ Methods
124124
+---------+----------------------------------------------------------------------------------------------------------+
125125
| Display | Default Orientation Tables |
126126
+=========+==========================================================================================================+
127-
| 160x80 | ((0x00, 80, 160, 26, 1), (0x60, 160, 80, 1, 26), (0xC0, 80, 160, 26, 1), (0xA0, 80, 160, 1, 26)) |
127+
| 160x80 | ((0x00, 80, 160, 26, 1), (0x60, 160, 80, 1, 26), (0xC0, 80, 160, 26, 1), (0xA0, 160, 80, 1, 26)) |
128+
+---------+----------------------------------------------------------------------------------------------------------+
129+
| 160x80 | ((0x00, 80, 160, 24, 0), (0x60, 160, 80, 0, 24), (0xC0, 80, 160, 24, 0), (0xA0, 160, 80, 0, 24)) |
128130
+---------+----------------------------------------------------------------------------------------------------------+
129131
| other | ((0x00, 0, 0, 0, 0), (0x60, 0, 0, 0, 0), (0xC0, 0, 0, 0, 0), (0xA0, 0, 0, 0, 0)) |
130132
+---------+----------------------------------------------------------------------------------------------------------+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://wiki.luatos.com/peripherals/lcd_air10x/index.html
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from machine import Pin, SPI, SoftSPI
2+
import lcd
3+
4+
TFA = const(1)
5+
BFA = const(1)
6+
7+
# init_cmd
8+
# cmd(int) args(bytes) delay(ms)
9+
_init_cmd = (
10+
(0x11, b'', 120),
11+
12+
(0x20, b'', 0), # lcd_inv_off如果颜色错了就用0x21
13+
14+
(0xB1, b'\x05\x3A\x3A', 0),
15+
16+
(0xB2, b'\x05\x3A\x3A', 0),
17+
18+
(0xB3, b'\x05\x3A\x3A\x05\x3A\x3A', 0),
19+
20+
(0xB4, b'\x03', 0), # Dotinversion
21+
22+
(0xC0, b'\x62\x02\x04', 0),
23+
24+
(0xC1, b'\xC0', 0),
25+
26+
(0xC2, b'\x0D\x00', 0),
27+
28+
(0xC3, b'\x8D\x6A', 0),
29+
30+
(0xC4, b'\x8D\xEE', 0),
31+
32+
(0xC5, b'\x0E', 0), # VCOM
33+
34+
(0xE0, b'\x10\x0E\x02\x03\x0E\x07\x02\x07\x0A\x12\x27\x37\x00\x0D\x0E\x10', 0),
35+
36+
(0xE1, b'\x10\x0E\x03\x03\x0F\x06\x02\x08\x0A\x13\x26\x36\x00\x0D\x0E\x10', 0),
37+
38+
(0x3A, b'\x05', 0),
39+
40+
(0x36, b'\x78', 0), # direction
41+
42+
(0x29, b'', 0),
43+
)
44+
45+
def config():
46+
hspi = SPI(2, sck=Pin(18), mosi=Pin(17), miso=None)
47+
# hspi = SoftSPI(baudrate=80 * 1000* 1000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
48+
panel = lcd.SPIPanel(spi=hspi, dc=Pin(15), cs=Pin(14), pclk=60000000, width=80, height=160)
49+
st = lcd.ST7735(panel, reset=Pin(16), backlight=Pin(13), color_space=lcd.BGR)
50+
st.backlight_on()
51+
st.reset()
52+
# st.custom_init(_init_cmd)
53+
st.init()
54+
st.invert_color(False)
55+
st.rotation(0, (
56+
(0x00, 80, 160, 24, 0),
57+
(0x60, 160, 80, 0, 24),
58+
(0xC0, 80, 160, 24, 0),
59+
(0xA0, 160, 80, 0, 24)
60+
)
61+
)
62+
return st
63+
64+
65+
def color565(r, g, b):
66+
c = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
67+
c = (c >> 8) | (c << 8) & 0xFFFF
68+
return c

0 commit comments

Comments
 (0)