-
Notifications
You must be signed in to change notification settings - Fork 2
/
data_display.py
61 lines (55 loc) · 2.32 KB
/
data_display.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
# data_display.py
# Class which updates the display in 2 ways
# * refresh_timestamp: update UTC GPS received time each second
# * refresh_all: update entire display by calling refresh_data
# uses:
# lopylcd: a simplified i2c 128x64 display driver
# config: global application parameters
#
import lopylcd
import config
class DATA_display():
timestamp = (0, 0, 0)
packets = 0
gateways = 0
distance = 0
bestdx = 0
def __init__(self):
self.display = lopylcd.lopylcd(config.SDA, config.SCL)
self.refresh_all(self.timestamp, self.packets,
self.gateways, self.distance, self.bestdx)
def refresh_all(self, timestamp, packets, gateways, distance, bestdx):
self.timestamp = timestamp
self.packets = packets
self.gateways = gateways
self.distance = distance
self.bestdx = bestdx
if self.display.isConnected():
self.hh = self.timestamp[0]
self.mm = self.timestamp[1]
self.ss = self.timestamp[2]
self.display.set_contrast(config.CONTRAST)
self.display.displayOn()
self.display.clearBuffer()
self.display.addString(0, 0, config.SIGNON)
self.display.addString(0, 1, "--------------------")
self.display.addString(0, 2, "UTC Time: {:02d}:{:02d}:{:02.0f}"
.format(self.hh, self.mm, self.ss))
self.display.addString(0, 3, " ")
self.display.addString(0, 4, "Packets: {:5d}".format(self.packets))
self.display.addString(0, 5, "Gateways: {:3d}".format(self.gateways))
self.display.addString(0, 6, "Last dist: {:5d} m".format(self.distance))
self.display.addString(0, 7, "Max dist: {:5d} m".format(self.bestdx))
self.display.drawBuffer()
else:
print("Error: LCD not found")
def refresh_timestamp(self, timestamp):
self.hh = timestamp[0]
self.mm = timestamp[1]
self.ss = timestamp[2]
if self.display.isConnected():
self.display.addString(0, 2, "UTC Time: {:02d}:{:02d}:{:02.0f}"
.format(self.hh, self.mm, self.ss))
self.display.drawBuffer()
else:
print("Error: LCD not found")