refactor: Rename obstacle current settings in Modbus tool UI

Renamed "Set Obstacle Open" and "Set Obstacle Close" menu options to "Set Obstacle Current Open" and "Set Obstacle Current Close" respectively in . This provides more precise terminology for the obstacle detection current thresholds.
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit is contained in:
Eduard Iten 2025-07-11 09:25:19 +02:00
parent 8467b3e347
commit dcbd02ad7a
1 changed files with 32 additions and 7 deletions

View File

@ -9,8 +9,33 @@ from pymodbus.client import ModbusSerialClient
from pymodbus.exceptions import ModbusException
# --- Register Definitions ---
# (omitted for brevity, no changes here)
REG_INPUT_VALVE_STATE_MOVEMENT = 0x0000
REG_INPUT_MOTOR_OPEN_CURRENT_MA = 0x0001
REG_INPUT_MOTOR_CLOSE_CURRENT_MA = 0x0002
REG_INPUT_DIGITAL_INPUTS_STATE = 0x0020
REG_INPUT_BUTTON_EVENTS = 0x0021
REG_INPUT_FIRMWARE_VERSION_MAJOR_MINOR = 0x00F0
REG_INPUT_FIRMWARE_VERSION_PATCH = 0x00F1
REG_INPUT_DEVICE_STATUS = 0x00F2
REG_INPUT_UPTIME_SECONDS_LOW = 0x00F3
REG_INPUT_UPTIME_SECONDS_HIGH = 0x00F4
REG_INPUT_SUPPLY_VOLTAGE_MV = 0x00F5
REG_INPUT_FWU_LAST_CHUNK_CRC = 0x0100
REG_HOLDING_VALVE_COMMAND = 0x0000
REG_HOLDING_MAX_OPENING_TIME_S = 0x0001
REG_HOLDING_MAX_CLOSING_TIME_S = 0x0002
REG_HOLDING_END_CURRENT_THRESHOLD_OPEN_MA = 0x0003
REG_HOLDING_END_CURRENT_THRESHOLD_CLOSE_MA = 0x0004
REG_HOLDING_OBSTACLE_THRESHOLD_OPEN_MA = 0x0005
REG_HOLDING_OBSTACLE_THRESHOLD_CLOSE_MA = 0x0006
REG_HOLDING_DIGITAL_OUTPUTS_STATE = 0x0010
REG_HOLDING_WATCHDOG_TIMEOUT_S = 0x00F0
REG_HOLDING_DEVICE_RESET = 0x00F1
REG_HOLDING_FWU_COMMAND = 0x0100
REG_HOLDING_FWU_CHUNK_OFFSET_LOW = 0x0101
REG_HOLDING_FWU_CHUNK_OFFSET_HIGH = 0x0102
REG_HOLDING_FWU_CHUNK_SIZE = 0x0103
REG_HOLDING_FWU_DATA_BUFFER = 0x0180
# --- Global State ---
@ -214,7 +239,7 @@ def main_menu(stdscr, slave_id):
stdscr.bkgd(' ', curses.color_pair(1))
menu = ["Open Valve", "Close Valve", "Stop Valve", "Settings", "Reset Node", "Firmware Update", "Exit"]
settings_menu = ["Set Max Open Time", "Set Max Close Time", "Set End Current Open", "Set End Current Close", "Set Obstacle Open", "Set Obstacle Close", "Set Watchdog", "Back"]
settings_menu = ["Set Max Open Time", "Set Max Close Time", "Set End Current Open", "Set End Current Close", "Set Obstacle Current Open", "Set Obstacle Current Close", "Set Watchdog", "Back"]
current_menu = menu
current_row_idx = 0
message, message_time = "", 0
@ -260,9 +285,9 @@ def main_menu(stdscr, slave_id):
input_mode, input_prompt, input_target_reg = True, "Enter End Current Threshold Close (mA): ", REG_HOLDING_END_CURRENT_THRESHOLD_CLOSE_MA
elif selected_option == "Set Watchdog":
input_mode, input_prompt, input_target_reg = True, "Enter Watchdog Timeout (s): ", REG_HOLDING_WATCHDOG_TIMEOUT_S
elif selected_option == "Set Obstacle Open":
elif selected_option == "Set Obstacle Current Open":
input_mode, input_prompt, input_target_reg = True, "Enter Obstacle Threshold Open (mA): ", REG_HOLDING_OBSTACLE_THRESHOLD_OPEN_MA
elif selected_option == "Set Obstacle Close":
elif selected_option == "Set Obstacle Current Close":
input_mode, input_prompt, input_target_reg = True, "Enter Obstacle Threshold Close (mA): ", REG_HOLDING_OBSTACLE_THRESHOLD_CLOSE_MA
elif selected_option == "Reset Node":
try:
@ -307,9 +332,9 @@ def main_menu(stdscr, slave_id):
stdscr.addstr(2, col4, "Uptime:", bold); stdscr.addstr(2, col4 + 14, str(current_data.get('uptime', 'N/A')), normal)
stdscr.addstr(3, col4, "Dev. Status:", bold); stdscr.addstr(3, col4 + 14, str(current_data.get('device_status', 'N/A')), normal)
stdscr.addstr(4, col4, "Supply V:", bold); stdscr.addstr(4, col4 + 14, str(current_data.get('supply_voltage', 'N/A')), normal)
stdscr.addstr(6, 0, "" * (w - 1), normal)
stdscr.addstr(8, 0, "" * (w - 1), normal)
for idx, row in enumerate(current_menu):
draw_button(stdscr, 7 + (idx * 2), w // 2 - len(row) // 2, row, idx == current_row_idx)
draw_button(stdscr, 9 + (idx * 2), w // 2 - len(row) // 2, row, idx == current_row_idx)
if time.time() - message_time < 2.0: stdscr.addstr(h - 2, 0, message.ljust(w - 1), curses.color_pair(1) | curses.A_BOLD)
if input_mode:
curses.curs_set(1); stdscr.addstr(h - 2, 0, (input_prompt + input_str).ljust(w-1), curses.color_pair(2)); stdscr.move(h - 2, len(input_prompt) + len(input_str))