@@ -16,17 +16,25 @@ def show_adc(lcd, adc):
1616 pass
1717 for i in range (3 ):
1818 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 )
2125 lcd .write ('%4s: ' % ('TEMP' , 'VBAT' , 'VREF' )[i ])
2226 if i > 0 :
2327 s = '%6.3fV' % data [i ]
2428 else :
2529 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 )
2735 lcd .write (s )
2836
29- def test_features (lcd ):
37+ def test_features (lcd , orient = lcd160cr . PORTRAIT ):
3038 # if we run on pyboard then use ADC and RTC features
3139 try :
3240 import pyb
@@ -38,7 +46,7 @@ def test_features(lcd):
3846
3947 # set orientation and clear screen
4048 lcd = get_lcd (lcd )
41- lcd .set_orient (lcd160cr . PORTRAIT )
49+ lcd .set_orient (orient )
4250 lcd .set_pen (0 , 0 )
4351 lcd .erase ()
4452
@@ -114,10 +122,10 @@ def test_features(lcd):
114122 lcd .set_pos (2 , 9 )
115123 lcd .write ('%.2f fps' % (1000000 / dt ))
116124
117- def test_mandel (lcd ):
125+ def test_mandel (lcd , orient = lcd160cr . PORTRAIT ):
118126 # set orientation and clear screen
119127 lcd = get_lcd (lcd )
120- lcd .set_orient (lcd160cr . PORTRAIT )
128+ lcd .set_orient (orient )
121129 lcd .set_pen (0 , 0xffff )
122130 lcd .erase ()
123131
@@ -140,9 +148,11 @@ def in_set(c):
140148 spi = lcd .fast_spi ()
141149
142150 # draw the Mandelbrot set line-by-line
151+ hh = ((h - 1 ) / 3.2 )
152+ ww = ((w - 1 ) / 2.4 )
143153 for v in range (h ):
144154 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 )
146156 if c < 16 :
147157 rgb = c << 12 | c << 6
148158 else :
@@ -151,10 +161,10 @@ def in_set(c):
151161 line [2 * u + 1 ] = rgb >> 8
152162 spi .write (line )
153163
154- def test_all (lcd ):
164+ def test_all (lcd , orient = lcd160cr . PORTRAIT ):
155165 lcd = get_lcd (lcd )
156- test_features (lcd )
157- test_mandel (lcd )
166+ test_features (lcd , orient )
167+ test_mandel (lcd , orient )
158168
159169print ('To run all tests: test_all(<lcd>)' )
160170print ('Individual tests are: test_features, test_mandel' )
0 commit comments