From 64417ace4d5374a26fb2f75f9c0cc8a380b55d2f Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 27 Jul 2020 23:33:00 -0400 Subject: [PATCH] thermometer control --- base.py | 36 +++++++++++++++++- control.py | 110 ++++++++++++++++++++++++++++++++++++++++++++--------- menu.py | 2 +- rezpy.py | 5 +++ 4 files changed, 131 insertions(+), 22 deletions(-) diff --git a/base.py b/base.py index e82e6f5..08cd3d6 100644 --- a/base.py +++ b/base.py @@ -28,7 +28,7 @@ class rObject: _rmap = {} _resources = {} - # also a define=proeprty to trigger export in equ file? + # also a define=property to trigger export in equ file? def __init__(self, id=None, attr=None): rType = self.rType self.id = id @@ -109,8 +109,12 @@ class rObject: for rType,rList in rObject._resources.items(): for r in rList: bb = bytes(r) + + data = [bb[x*16:x*16+16] for x in range(0, len(bb)+15>>4)] + print("{}(${:08x}) {{".format(r.rName, r.get_id())) - print("\t$\"" + bb.hex() + "\"") + for x in data: + print("\t$\"" + x.hex() + "\"") print("}\n") @staticmethod @@ -123,7 +127,35 @@ class rObject: print(content) print("}\n") +# container for a 0-terminated list of resource ids. +class rList(rObject): + def __init__(self, *children, id=None, attr=None): + super().__init__(id=id, attr=attr) + self.children = children + tt = self.rChildType + for x in self.children: + if not isinstance(x, tt): + raise TypeError("bad type: {}".format(type(x))) + + def __bytes__(self): + bb = bytearray(4 + len(self.children)) + offset = 0 + for x in self.children: + struct.pack_into("