-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_320.py
64 lines (52 loc) · 1.45 KB
/
test_320.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
""""
Gauge test for 320x240 screens
-- Expects class elements in lib subfolder
-- Expects bitmap.py files in bitmap subfolder
"""
import utime
import math
from random import randint
from random import random
import st7789
import tft_config
import lib.simple_gauge as gauge_class
#import lib.gauge_circle as gauge_circle
#import lib.meter as meter
from lib.panel_helpers import chunked_bitmap
import gc
tft = tft_config.config(1)
def move_to (curr, prev):
if curr > prev:
return prev + 1
if curr < prev:
return prev - 1
return curr
def main():
'''
Draw 1 gauges and update it
'''
# enable display
tft.init()
tft.rotation(0)
tft.inversion_mode(False)
tft.fill(st7789.BLACK)
g1 = gauge_class.gauge(tft,0,0,240,bezel='bitmap.240Bar')
gc.collect()
g1.update(randint(20,100))
autostate = 'bitmap.AutoState'
bm = __import__(autostate) # import the bitmap .py file
ref = autostate.replace('bitmap.','') # reference to the object in the .py file, replace is a better option
chunked_bitmap(tft, getattr(bm,ref),0,240)
del bm
del ref
gc.collect()
utime.sleep_ms(100)
while True:
v1 = randint(0,100)
v2 = int(gc.mem_free()/1024)
for i in range(20):
gc.collect()
g1.update(move_to(v1,g1.value))
print("Gauge 1: {} Free Memory: {}".format(g1.value,v2))
utime.sleep_ms(100)
main()