generated from hulk/gd32f4xx_template_cmake_vscode
GUI v0.2.13: chart Y-axis range control (right-edge dual-handle slider)
- TemperatureChart gains a right-edge slider on a FIXED -20..120C rail (user-specified): top handle = upper bound, bottom handle = lower bound, drag middle band = pan keeping span, click free rail = snap that bound. First drag engages manual mode (yManualEngaged -> sync button state + config); release quantizes to 0.1C via yRangeChanged, min span 0.5C. Bound values during drag must come from live display range, not the stale paint cache (two drags without repaint made pan jump the range). - Auto/manual toggle moved into the card header (was a wrapped second row); pause/clear merged into header too; legend moved to top-left. - Value labels next to handles only visible on hover/drag (constant labels covered the curve per user feedback). - Out-of-range curves clipped back to the plot area (setClipRect); current-value marker suppressed outside the manual range. - Draft textbox rows from v0.2.10 superseded; versions v0.2.10..v0.2.13. - Fixed "no data yet" hint never disappearing: set_source cached a stale _has_data bool once at build time while data flows through the same list references; now evaluated live at paint time. - config: y_axis key persists mode/bounds; invalid stored values fall back to auto. selftest settings isolated to a temp dir (user json with stored manual state broke the fresh-default assertions). - selftest_gui: slider hit/drag/clamp/pan/clipping regression + hint gating; 83 checks all pass.
This commit is contained in:
@@ -32,6 +32,9 @@ SERIAL_CFG = {'port': '', 'baud': filmforge_rs485.DEFAULT_BAUD,
|
||||
REPORT_MS = 500 # 上报间隔输入框默认值
|
||||
WINDOW_SEC = DEFAULT_WINDOW_SEC
|
||||
THEME = 'System'
|
||||
Y_MODE = 'auto' # 曲线 Y 轴(温度轴): 'auto'=自适应 / 'manual'=固定范围
|
||||
Y_MIN = None # 手动 Y 轴上下限(℃), 仅 Y_MODE='manual' 且合法时生效
|
||||
Y_MAX = None
|
||||
|
||||
|
||||
def load_settings():
|
||||
@@ -68,6 +71,19 @@ def load_settings():
|
||||
theme = str(data.get('theme') or '')
|
||||
if theme in ('Dark', 'Light', 'System'):
|
||||
THEME = theme
|
||||
ax = data.get('y_axis')
|
||||
if isinstance(ax, dict):
|
||||
mode = str(ax.get('mode') or '')
|
||||
if mode in ('auto', 'manual'):
|
||||
globals()['Y_MODE'] = mode
|
||||
try:
|
||||
globals()['Y_MIN'] = round(float(ax.get('min')), 2)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
try:
|
||||
globals()['Y_MAX'] = round(float(ax.get('max')), 2)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def save_settings():
|
||||
@@ -77,6 +93,7 @@ def save_settings():
|
||||
'report_ms': REPORT_MS,
|
||||
'window_sec': WINDOW_SEC,
|
||||
'theme': THEME,
|
||||
'y_axis': {'mode': Y_MODE, 'min': Y_MIN, 'max': Y_MAX},
|
||||
}
|
||||
try:
|
||||
with open(SETTINGS_FILE, 'w', encoding='utf-8') as f:
|
||||
|
||||
Reference in New Issue
Block a user