fix wrong data bug
This commit is contained in:
parent
8f12454e19
commit
4f85e5b1f2
20
src/main.py
20
src/main.py
|
@ -48,11 +48,11 @@ class App(ctk.CTk):
|
|||
|
||||
# find the center point
|
||||
if self.system_platform == "Linux":
|
||||
center_x = int(screen_width / 2 - width / 2)
|
||||
center_y = int(screen_height / 2 - height / 2)
|
||||
center_x = int(screen_width / 2 - width / 2)
|
||||
center_y = int(screen_height / 2 - height / 2)
|
||||
elif self.system_platform == "Windows":
|
||||
center_x = int(screen_width / 2 - width / 4)
|
||||
center_y = int(screen_height / 2 - height / 4)
|
||||
center_x = int(screen_width / 2 - width / 4)
|
||||
center_y = int(screen_height / 2 - height / 4)
|
||||
# set the position of the self to the center of the screen
|
||||
self.geometry(f"{width}x{height}+{center_x}+{center_y}")
|
||||
|
||||
|
@ -345,15 +345,15 @@ class App(ctk.CTk):
|
|||
case _:
|
||||
return "error"
|
||||
|
||||
def toAscii(num: float) -> str:
|
||||
return chr(int(num))
|
||||
|
||||
if self.serial_status:
|
||||
for i in range(5):
|
||||
if self.gain_enable[i]:
|
||||
bytes = f"{switchSign(i)}{toAscii(self.gain_values[i])}{toAscii(self.gain_values[i] % 1 * 256)}\0"
|
||||
print(f"Send:{bytes}")
|
||||
self.serial.write(bytes.encode())
|
||||
bytes = list(map(lambda x: ord(x), list(switchSign(i))))
|
||||
bytes.append(int(self.gain_values[i]))
|
||||
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:
|
||||
print("Please Connect to Serial")
|
||||
messagebox.showError("Please Connect Serial Port")
|
||||
|
|
Loading…
Reference in New Issue