From: Alexandra Lanes Date: Sat, 4 Jun 2022 14:31:41 +0000 (+0200) Subject: Allow choice of port on the Build HAT X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ajlanes/git?a=commitdiff_plain;h=6480d64857dedb8d10c2af283af40304579c7b7d;p=legofocuser.git Allow choice of port on the Build HAT It appears that text values come out of the pyINDI library as 0x0a 0x0a 0x20 0x20 0x20 0x20 --- diff --git a/legofocuser.py b/legofocuser.py index 3dc8f19..563b58e 100755 --- a/legofocuser.py +++ b/legofocuser.py @@ -16,8 +16,6 @@ https://www.indilib.org/developers/driver-howto.html#h2-properties class LegoFocuser(device): - - motor = Motor('A') def ISGetProperties(self, device=None): """Property Definiations are generated @@ -41,6 +39,18 @@ class LegoFocuser(device): mainloop """ + # BUILD_HAT_PORT - the port on the Build HAT to which the + # motor is connected. + + if name == "BUILD_HAT_PORT": + try: + port = self.IUUpdate(device, name, names, values) + port.state='Ok' + port["PORT"].value = port["PORT"].value.strip() + self.IDSet(port) + except Exception as error: + self.IDMessage(f"BUILD_HAT_PORT error: {error}") + self.IUUpdate(device, name, names, values, Set=True) def ISNewNumber(self, device, name, names, values): @@ -133,16 +143,22 @@ class LegoFocuser(device): conn = self.IUUpdate(device, name, names, values) if conn["CONNECT"].value == 'Off': conn.state = "Idle" - + self._is_connected = False else: + conn.state = "Busy" + self.IDSet(conn) + prt = self.IUFind("BUILD_HAT_PORT") + portval = prt["PORT"].value.strip() + self.motor = Motor(portval) conn.state = "Ok" + self._is_connected = True self.IDSet(conn) except Exception as error: self.IDMessage(f"IUUpdate error: {error}") raise - + if name == "FOCUS_MOTION": try: focus = self.IUUpdate(device, name, names, values, Set=True) diff --git a/legofocuser.xml b/legofocuser.xml index 8f55275..713b202 100644 --- a/legofocuser.xml +++ b/legofocuser.xml @@ -9,6 +9,13 @@ On + + + A + + + + On