-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (27 loc) · 915 Bytes
/
main.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
from gui import GUI
from ina219 import INA219
from ili9488 import ILI9488
import time
# GUI frames per sec.
FRAMES_SEC = 1
if __name__=='__main__':
gui = GUI(FRAMES_SEC)
ina219 = INA219()
timestamp = time.ticks_ms()
debounce = True
while True:
if(time.ticks_diff(time.ticks_ms(), timestamp) < 1000 * FRAMES_SEC):
time.sleep_ms(10)
if debounce:
gui.handle_touch()
debounce = False
continue
debounce = True
timestamp = time.ticks_ms()
# Add current, power, work and bus voltage to digram data.
gui.add_current_value(ina219.get_current())
power = ina219.get_power()
gui.update_power(power)
gui.update_work(power)
gui.set_bus_voltage(ina219.get_bus_voltage())
gui.update()