1
0
mirror of https://github.com/gryf/pywmtemp.git synced 2025-12-18 11:40:17 +01:00

Added new submethod for creating strings.

This commit is contained in:
2022-05-01 15:23:40 +02:00
parent edae2233a5
commit 54b863ece1

View File

@@ -207,9 +207,10 @@ class SensorDockApp(wmdocklib.DockApp):
position = 1
if count == 0:
for item in self.conf['readings']:
string, offset = self.get_reading(item)
self.add_string(string, 1, position)
# suport up to two reading. all surplus entries will be
# ignored.
for item in self.conf.get('readings', [])[:2]:
self._put_string(item, position)
position += self.char_height
count += 1
@@ -274,6 +275,17 @@ class SensorDockApp(wmdocklib.DockApp):
self._history[item.get('name')] = [0 for _ in
range(self.graph_width)]
def _put_string(self, item, position):
temp, displacement = self.get_reading(item)
name = item.get('name', '').upper()
name = name[:4]
if displacement:
name = ''.join([chr(ord(i) + displacement)
for i in name])
self.add_string(name, 1, position)
self.add_string(temp, 34, position)
def main():
parser = argparse.ArgumentParser()