Skip to content

Commit

Permalink
Modified ics-manager description
Browse files Browse the repository at this point in the history
  • Loading branch information
iory committed Nov 12, 2024
1 parent fd41041 commit e0cb5df
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions rcb4/ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def close_connection(self):

def display_status(self):
options = [
"Servo ID",
"Current Servo ID",
"Angle",
"Baud Rate",
"Rotation Mode",
Expand All @@ -288,7 +288,7 @@ def display_status(self):
"Serial Mode",
"Free",
]
selectable_options = ["Servo ID", "Angle"]
selectable_options = ["Current Servo ID", "Angle"]
try:
use_previous_result = False
while True:
Expand Down Expand Up @@ -329,19 +329,21 @@ def display_status(self):
for i, option in enumerate(options):
if i == self.selected_index:
print(
f"{Fore.YELLOW}>> {option}: {self.get_status(option, result)}{Style.RESET_ALL}"
f">> {option}: {self.get_status(option, result, selected=True)}"
)
else:
print(f" {option}: {self.get_status(option, result)}")
print(f" {option}: {self.get_status(option, result, selected=False)}")
print("----------------------\n")
print(
"Use ↑↓ to navigate, ←→ to adjust Servo ID or Servo Angles, 'q' to quit."
"Use ↑↓ to navigate, ←→ to adjust Current Servo ID or Servo Angles"
)
print(f"Press 'Enter' when Current Servo ID is selected to save the currently highlighted ID in {Fore.GREEN}green{Style.RESET_ALL}.")
print("Press 'z' to reset servo position")
print(
"Press 'r' to toggle rotation mode (enables continuous wheel-like rotation)"
)
print("Press 'f' to set free mode\n")
print("'q' to quit.")

use_previous_result = False

Expand Down Expand Up @@ -370,7 +372,7 @@ def display_status(self):
use_previous_result = True
elif (
key == readchar.key.ENTER
and selectable_options[self.selected_index] == "Servo ID"
and selectable_options[self.selected_index] == "Current Servo ID"
):
self.set_servo_id(self.servo_id)
time.sleep(0.3)
Expand All @@ -379,7 +381,7 @@ def display_status(self):
time.sleep(0.3)
elif (
key == readchar.key.LEFT
and selectable_options[self.selected_index] == "Servo ID"
and selectable_options[self.selected_index] == "Current Servo ID"
):
use_previous_result = True
if self.servo_id_index == 0:
Expand All @@ -389,7 +391,7 @@ def display_status(self):
self.servo_id = self.servo_candidates[self.servo_id_index]
elif (
key == readchar.key.RIGHT
and selectable_options[self.selected_index] == "Servo ID"
and selectable_options[self.selected_index] == "Current Servo ID"
):
use_previous_result = True
if self.servo_id_index == len(self.servo_candidates) - 1:
Expand Down Expand Up @@ -418,22 +420,25 @@ def display_status(self):
except KeyboardInterrupt:
print("\nDisplay stopped by user.")

def get_status(self, option, param=None):
def get_status(self, option, param=None, selected=False):
"""Return the status based on the selected option."""
if option == "Servo ID":
if option == "Current Servo ID":
if param is not None:
current_servo_id = param["servo-id"]
else:
current_servo_id = self.get_servo_id()

str = f"{Style.RESET_ALL}["
for i, servo_id in enumerate(self.servo_candidates):
if i == self.servo_id_index:
str += f"{Fore.GREEN}{servo_id}{Style.RESET_ALL} "
else:
str += f"{servo_id} "
str += "]"
return f"{current_servo_id} -> {str}"
s = f'{current_servo_id}'
if selected:
str = f"{Style.RESET_ALL}["
for i, servo_id in enumerate(self.servo_candidates):
if i == self.servo_id_index:
str += f"{Fore.GREEN}{servo_id}{Style.RESET_ALL} "
else:
str += f"{servo_id} "
str += "]"
s += f' -> Next Servo ID: {str}'
return s
elif option == "Angle":
return f"{self.read_angle()}"
elif option == "Baud Rate":
Expand Down

0 comments on commit e0cb5df

Please sign in to comment.