+ get battery & exception handler
This commit is contained in:
parent
14f904e71c
commit
2271236a31
@ -1,4 +1,4 @@
|
||||
import tkinter as tk, robomasterpy as rm, datetime
|
||||
import tkinter as tk, robomasterbfi as rm, datetime
|
||||
from tkinter import ttk
|
||||
|
||||
class RobomasterUI:
|
||||
@ -62,6 +62,7 @@ class RobomasterUI:
|
||||
ttk.Button(gripper_frame, text="Open Gripper", command=self.open_gripper).grid(row=1, column=0, columnspan=2, pady=5, sticky="we")
|
||||
ttk.Button(gripper_frame, text="Close Gripper", command=self.close_gripper).grid(row=2, column=0, columnspan=2, pady=5, sticky="we")
|
||||
ttk.Button(gripper_frame, text="Gripper Status", command=self.get_gripper_status).grid(row=3, column=0, columnspan=2, pady=5, sticky="we")
|
||||
ttk.Button(master, text="Get Battery", command=self.get_battery).grid(row=1, column=0, padx=10, pady=0, sticky="we")
|
||||
|
||||
led_frame = ttk.LabelFrame(master, text="LED Control")
|
||||
led_frame.grid(row=0, column=2, padx=10, pady=10, sticky="n")
|
||||
@ -96,7 +97,7 @@ class RobomasterUI:
|
||||
ttk.Button(led_frame, text="Set LED", command=self.led_control_ui).grid(row=5, column=0, columnspan=2, pady=5, sticky="we")
|
||||
|
||||
chassis_frame = ttk.LabelFrame(master, text="Chassis Control (WASDQE)")
|
||||
chassis_frame.grid(row=1, column=0, columnspan=3, padx=10, pady=10, sticky="n")
|
||||
chassis_frame.grid(row=2, column=0, columnspan=3, padx=10, pady=10, sticky="n")
|
||||
|
||||
tk.Label(chassis_frame, text="XY Speed (m/s):", fg='white', bg='#121212').grid(row=0, column=0, padx=5, pady=5, sticky="e")
|
||||
self.chassis_x_speed_entry = tk.Entry(chassis_frame, width=5, fg='white', bg='#333333', insertbackground='white')
|
||||
@ -203,6 +204,9 @@ class RobomasterUI:
|
||||
except ValueError:
|
||||
self._display_output("Error: Invalid speed value")
|
||||
|
||||
def get_battery(self):
|
||||
self._command_executor(self.cmd.robot_battery)
|
||||
|
||||
def led_control_ui(self):
|
||||
comp_str = self.comp_combo.get()
|
||||
effect_str = self.effect_combo.get()
|
||||
@ -231,8 +235,11 @@ def main():
|
||||
except Exception as e:
|
||||
print(f"Error connecting to Robomaster: {e}")
|
||||
finally:
|
||||
try:
|
||||
if cmd:
|
||||
cmd.led_control(comp="all", effect="solid", r=0, g=0, b=255)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user