finish all
This commit is contained in:
parent
684de2bc00
commit
d51d2e994e
|
@ -1,2 +1,4 @@
|
|||
pip==24.1.1
|
||||
setuptools==65.5.0
|
||||
customtkinter==5.2.2
|
||||
darkdetect==0.8.0
|
||||
packaging==24.1
|
||||
pyserial==3.5
|
||||
|
|
38
src/main.py
38
src/main.py
|
@ -29,7 +29,8 @@ class App(ctk.CTk):
|
|||
# appearance and font
|
||||
ctk.set_appearance_mode("dark")
|
||||
ctk.set_default_color_theme("dark-blue")
|
||||
ctk.set_widget_scaling(2.0)
|
||||
ctk.set_window_scaling(0.8)
|
||||
# ctk.set_widget_scaling(2.0)
|
||||
self.font = ctk.CTkFont(family="", size=17)
|
||||
|
||||
# get the screen dimension
|
||||
|
@ -94,9 +95,9 @@ class App(ctk.CTk):
|
|||
return None
|
||||
|
||||
def __data_frame(self) -> None:
|
||||
def setGain(value, i:int, stringVar: ctk.StringVar)-> None:
|
||||
def setGain(value, i: int, stringVar: ctk.StringVar) -> None:
|
||||
self.gain_values[i] = value
|
||||
stringVar.set(f'{value:.2f}')
|
||||
stringVar.set(f"{value:.2f}")
|
||||
return None
|
||||
|
||||
def switchSlider(i: int, slider: ctk.CTkSlider) -> None:
|
||||
|
@ -176,7 +177,9 @@ class App(ctk.CTk):
|
|||
gain_str.append(
|
||||
ctk.StringVar(gain_slider[i], f"{self.gain_default[i]:.2f}")
|
||||
)
|
||||
gain_slider[i].configure(command=functools.partial(setGain, i=i, stringVar=gain_str[i]))
|
||||
gain_slider[i].configure(
|
||||
command=functools.partial(setGain, i=i, stringVar=gain_str[i])
|
||||
)
|
||||
|
||||
# gain value
|
||||
ctk.CTkLabel(gain_frame[i], text=str(gain_min[i]), font=self.font).pack(
|
||||
|
@ -233,6 +236,7 @@ class App(ctk.CTk):
|
|||
if not self.serial_status:
|
||||
try:
|
||||
self.serial = serial.Serial(self.select_port, self.serial_baudrate)
|
||||
self.serial.open()
|
||||
except AttributeError:
|
||||
print("Failed to Connect Serial")
|
||||
else:
|
||||
|
@ -254,7 +258,9 @@ class App(ctk.CTk):
|
|||
self.serial_baudrate = int(baudrate)
|
||||
if self.serial_status:
|
||||
try:
|
||||
self.serial.baudrate = int(baudrate)
|
||||
self.serial.close()
|
||||
self.serial = serial.Serial(self.select_port, self.serial_baudrate)
|
||||
self.serial.open()
|
||||
except Exception:
|
||||
print("Failed to Set Serial Baudrate")
|
||||
else:
|
||||
|
@ -263,15 +269,25 @@ class App(ctk.CTk):
|
|||
print("Please Connect to Serial")
|
||||
|
||||
def setISP(self, event: Optional[Any] = None):
|
||||
def switchSign(i: int) -> str:
|
||||
match i:
|
||||
case 0:
|
||||
return 'r'
|
||||
case 1:
|
||||
return 'g'
|
||||
case 2:
|
||||
return 'b'
|
||||
case 3:
|
||||
return 'a'
|
||||
case 4:
|
||||
return 's'
|
||||
case _:
|
||||
return 'error'
|
||||
|
||||
if self.serial_status:
|
||||
self.serial.open()
|
||||
for i in range(5):
|
||||
if self.gain_enable[i]:
|
||||
match i:
|
||||
case 1:
|
||||
self.serial.write(b'r')
|
||||
|
||||
self.serial.close()
|
||||
self.serial.write(f"{switchSign(i)}{bin(int(self.gain_values[i]))}{bin(int(self.gain_values[i] % 1 * 256))}")
|
||||
else:
|
||||
print("Please Connect to Serial")
|
||||
|
||||
|
|
Loading…
Reference in New Issue