mirror of
https://github.com/janishutz/BiogasControllerApp.git
synced 2025-11-25 22:04:24 +00:00
Update to the backend and new Screen.
Features: - Added a new settings page - Laid out some backend stuff to integrate some new features - prepared backend to include an option to have the previous values also displayed when updating them both screens where you may change configuration of the microcontroller
This commit is contained in:
96
BiogasControllerApp-V2.2/bin/lib/communication.py
Normal file
96
BiogasControllerApp-V2.2/bin/lib/communication.py
Normal file
@@ -0,0 +1,96 @@
|
||||
import bin.lib.lib
|
||||
com = bin.lib.lib.Com()
|
||||
|
||||
|
||||
class Communication:
|
||||
def __init__(self):
|
||||
self.__x = 0
|
||||
self.__data_recieve = 0
|
||||
self.__output = ""
|
||||
|
||||
def change_temp(self, data, special_port):
|
||||
com.connect(19200, special_port)
|
||||
com.send("PT")
|
||||
self.go = 0
|
||||
while True:
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "\n":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "P":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "T":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "\n":
|
||||
self.go = 1
|
||||
break
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
if self.go == 1:
|
||||
self.data = data
|
||||
while len(self.data) > 0:
|
||||
self.__data_recieve = com.receive(3)
|
||||
if self.__data_recieve != "":
|
||||
com.send_float(float(self.data.pop(0)))
|
||||
else:
|
||||
print("error")
|
||||
break
|
||||
else:
|
||||
print("Error")
|
||||
com.quitcom()
|
||||
|
||||
def change_all(self, data, special_port):
|
||||
com.connect(19200, special_port)
|
||||
com.send("PR")
|
||||
self.go = 0
|
||||
while True:
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "\n":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "P":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "R":
|
||||
self.__data_recieve = com.decode_ascii(com.receive(1))
|
||||
if self.__data_recieve == "\n":
|
||||
self.go = 1
|
||||
break
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
if self.go == 1:
|
||||
self.data = data
|
||||
while len(self.data) > 0:
|
||||
self.__data_recieve = com.receive(3)
|
||||
if self.__data_recieve != "":
|
||||
com.send_float(float(self.data.pop(0)))
|
||||
else:
|
||||
print("error")
|
||||
break
|
||||
else:
|
||||
print("Error")
|
||||
com.quitcom()
|
||||
|
||||
|
||||
class SwitchMode:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def enable_fastmode(self):
|
||||
com.connect(19200,"")
|
||||
com.send("FM")
|
||||
com.quitcom()
|
||||
|
||||
def disable_fastmode(self):
|
||||
com.connect(19200, "")
|
||||
com.send("NM")
|
||||
com.quitcom()
|
||||
Reference in New Issue
Block a user