ctrl_panel: Pin down units for editable fields

Avoids awkward value editing
This commit is contained in:
atse 2024-06-27 17:28:12 +08:00
parent 3c7b21a709
commit ddeb5e988e
2 changed files with 20 additions and 29 deletions

View File

@ -44,7 +44,7 @@
"children":[
{
"name":"i_set",
"title":"Set Current",
"title":"Set Current (mA)",
"type":"float",
"value":0,
"step":100,
@ -54,7 +54,6 @@
],
"triggerOnShow":true,
"decimals":6,
"suffix":"mA",
"param":[
"pwm",
"ch",
@ -65,7 +64,7 @@
},
{
"name": "target",
"title":"Set Temperature",
"title":"Set Temperature (°C)",
"type":"float",
"value":25,
"step":0.1,
@ -73,7 +72,7 @@
-273,
300
],
"format":"{value:.4f} °C",
"format":"{value:.4f}",
"param":[
"pid",
"ch",
@ -92,7 +91,7 @@
"children":[
{
"name":"max_i_pos",
"title":"Max Cooling Current",
"title":"Max Cooling Current (mA)",
"type":"float",
"value":0,
"step":100,
@ -101,7 +100,6 @@
0,
2000
],
"suffix":"mA",
"param":[
"pwm",
"ch",
@ -112,7 +110,7 @@
},
{
"name":"max_i_neg",
"title":"Max Heating Current",
"title":"Max Heating Current (mA)",
"type":"float",
"value":0,
"step":100,
@ -121,7 +119,6 @@
0,
2000
],
"suffix":"mA",
"param":[
"pwm",
"ch",
@ -132,7 +129,7 @@
},
{
"name":"max_v",
"title":"Max Absolute Voltage",
"title":"Max Absolute Voltage (V)",
"type":"float",
"value":0,
"step":0.1,
@ -141,7 +138,6 @@
5
],
"siPrefix":true,
"suffix":"V",
"param":[
"pwm",
"ch",
@ -163,7 +159,7 @@
"children":[
{
"name":"t0",
"title":"T₀",
"title":"T₀ (°C)",
"type":"float",
"value":25,
"step":0.1,
@ -171,7 +167,7 @@
-100,
100
],
"format":"{value:.4f} °C",
"format":"{value:.4f}",
"param":[
"s-h",
"ch",
@ -182,12 +178,11 @@
},
{
"name":"r0",
"title":"R₀",
"title":"R₀ (Ω)",
"type":"float",
"value":10000,
"step":1,
"siPrefix":true,
"suffix":"Ω",
"param":[
"s-h",
"ch",
@ -198,11 +193,10 @@
},
{
"name":"b",
"title":"B",
"title":"B (K)",
"type":"float",
"value":3950,
"step":1,
"suffix":"K",
"decimals":4,
"param":[
"s-h",
@ -292,7 +286,7 @@
"children":[
{
"name":"output_min",
"title":"Minimum",
"title":"Minimum (mA)",
"type":"float",
"step":100,
"limits":[
@ -300,7 +294,6 @@
2000
],
"decimals":6,
"suffix":"mA",
"param":[
"pid",
"ch",
@ -311,7 +304,7 @@
},
{
"name":"output_max",
"title":"Maximum",
"title":"Maximum (mA)",
"type":"float",
"step":100,
"limits":[
@ -319,7 +312,6 @@
2000
],
"decimals":6,
"suffix":"mA",
"param":[
"pid",
"ch",
@ -339,11 +331,11 @@
"children":[
{
"name":"target_temp",
"title":"Target Temperature",
"title":"Target Temperature (°C)",
"type":"float",
"value":20,
"step":0.1,
"format":"{value:.4f} °C",
"format":"{value:.4f}",
"pid_autotune":[
"target_temp",
"ch"
@ -352,7 +344,7 @@
},
{
"name":"test_current",
"title":"Test Current",
"title":"Test Current (mA)",
"type":"float",
"value":0,
"decimals":6,
@ -361,7 +353,6 @@
-2000,
2000
],
"suffix":"mA",
"pid_autotune":[
"test_current",
"ch"
@ -370,12 +361,12 @@
},
{
"name":"temp_swing",
"title":"Temperature Swing",
"title":"Temperature Swing (°C)",
"type":"float",
"value":1.5,
"step":0.1,
"prefix":"±",
"format":"{value:.4f} °C",
"format":"{value:.4f}",
"pid_autotune":[
"temp_swing",
"ch"
@ -384,11 +375,11 @@
},
{
"name":"lookback",
"title":"Lookback",
"title":"Lookback (s)",
"type":"float",
"value":3.0,
"step":0.1,
"format":"{value:.4f} s",
"format":"{value:.4f}",
"pid_autotune":[
"lookback",
"ch"

View File

@ -267,7 +267,7 @@ class MainWindow(QtWidgets.QMainWindow):
for inner_param, change, data in changes:
if change == "value":
if inner_param.opts.get("param", None) is not None:
if inner_param.opts.get("suffix", None) == "mA":
if inner_param.opts.get("title", None).endswith(" (mA)"):
data /= 1000 # Given in mA
thermostat_param = inner_param.opts["param"]