fix wrong data bug
This commit is contained in:
parent
8f12454e19
commit
4f85e5b1f2
12
src/main.py
12
src/main.py
|
@ -345,15 +345,15 @@ class App(ctk.CTk):
|
||||||
case _:
|
case _:
|
||||||
return "error"
|
return "error"
|
||||||
|
|
||||||
def toAscii(num: float) -> str:
|
|
||||||
return chr(int(num))
|
|
||||||
|
|
||||||
if self.serial_status:
|
if self.serial_status:
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
if self.gain_enable[i]:
|
if self.gain_enable[i]:
|
||||||
bytes = f"{switchSign(i)}{toAscii(self.gain_values[i])}{toAscii(self.gain_values[i] % 1 * 256)}\0"
|
bytes = list(map(lambda x: ord(x), list(switchSign(i))))
|
||||||
print(f"Send:{bytes}")
|
bytes.append(int(self.gain_values[i]))
|
||||||
self.serial.write(bytes.encode())
|
bytes.append(int(self.gain_values[i] % 1 * 256))
|
||||||
|
bytes.append(0)
|
||||||
|
print(f"Send:{bytes} \t Hex:0x" + f"{hex(int( self.gain_values[i] * 256 )).replace('0x', '')}".zfill(4))
|
||||||
|
self.serial.write(bytes)
|
||||||
else:
|
else:
|
||||||
print("Please Connect to Serial")
|
print("Please Connect to Serial")
|
||||||
messagebox.showError("Please Connect Serial Port")
|
messagebox.showError("Please Connect Serial Port")
|
||||||
|
|
Loading…
Reference in New Issue