@@ -16,17 +16,25 @@ def show_adc(lcd, adc):
16
16
pass
17
17
for i in range (3 ):
18
18
lcd .set_text_color ((825 , 1625 , 1600 )[i ], 0 )
19
- lcd .set_font (2 )
20
- lcd .set_pos (0 , 100 + i * 16 )
19
+ if lcd .h == 160 :
20
+ lcd .set_font (2 )
21
+ lcd .set_pos (0 , 100 + i * 16 )
22
+ else :
23
+ lcd .set_font (2 , trans = 1 )
24
+ lcd .set_pos (0 , lcd .h - 60 + i * 16 )
21
25
lcd .write ('%4s: ' % ('TEMP' , 'VBAT' , 'VREF' )[i ])
22
26
if i > 0 :
23
27
s = '%6.3fV' % data [i ]
24
28
else :
25
29
s = '%5.1f°C' % data [i ]
26
- lcd .set_font (1 , bold = 0 , scale = 1 )
30
+ if lcd .h == 160 :
31
+ lcd .set_font (1 , bold = 0 , scale = 1 )
32
+ else :
33
+ lcd .set_font (1 , bold = 0 , scale = 1 , trans = 1 )
34
+ lcd .set_pos (45 , lcd .h - 60 + i * 16 )
27
35
lcd .write (s )
28
36
29
- def test_features (lcd ):
37
+ def test_features (lcd , orient = lcd160cr . PORTRAIT ):
30
38
# if we run on pyboard then use ADC and RTC features
31
39
try :
32
40
import pyb
@@ -38,7 +46,7 @@ def test_features(lcd):
38
46
39
47
# set orientation and clear screen
40
48
lcd = get_lcd (lcd )
41
- lcd .set_orient (lcd160cr . PORTRAIT )
49
+ lcd .set_orient (orient )
42
50
lcd .set_pen (0 , 0 )
43
51
lcd .erase ()
44
52
@@ -114,10 +122,10 @@ def test_features(lcd):
114
122
lcd .set_pos (2 , 9 )
115
123
lcd .write ('%.2f fps' % (1000000 / dt ))
116
124
117
- def test_mandel (lcd ):
125
+ def test_mandel (lcd , orient = lcd160cr . PORTRAIT ):
118
126
# set orientation and clear screen
119
127
lcd = get_lcd (lcd )
120
- lcd .set_orient (lcd160cr . PORTRAIT )
128
+ lcd .set_orient (orient )
121
129
lcd .set_pen (0 , 0xffff )
122
130
lcd .erase ()
123
131
@@ -140,9 +148,11 @@ def in_set(c):
140
148
spi = lcd .fast_spi ()
141
149
142
150
# draw the Mandelbrot set line-by-line
151
+ hh = ((h - 1 ) / 3.2 )
152
+ ww = ((w - 1 ) / 2.4 )
143
153
for v in range (h ):
144
154
for u in range (w ):
145
- c = in_set ((v / (( h - 1 ) / 3.2 ) - 2 .3 ) + (u / (( w - 1 ) / 2.4 ) - 1.2 ) * 1j )
155
+ c = in_set ((v / hh - 2 .3 ) + (u / ww - 1.2 ) * 1j )
146
156
if c < 16 :
147
157
rgb = c << 12 | c << 6
148
158
else :
@@ -151,10 +161,10 @@ def in_set(c):
151
161
line [2 * u + 1 ] = rgb >> 8
152
162
spi .write (line )
153
163
154
- def test_all (lcd ):
164
+ def test_all (lcd , orient = lcd160cr . PORTRAIT ):
155
165
lcd = get_lcd (lcd )
156
- test_features (lcd )
157
- test_mandel (lcd )
166
+ test_features (lcd , orient )
167
+ test_mandel (lcd , orient )
158
168
159
169
print ('To run all tests: test_all(<lcd>)' )
160
170
print ('Individual tests are: test_features, test_mandel' )
0 commit comments