min/max to web value edit

This commit is contained in:
MichaelDvP
2022-03-21 20:21:55 +01:00
parent 4ae406b3e1
commit a0a3d8ef3a
3 changed files with 8 additions and 1 deletions

View File

@@ -239,7 +239,7 @@ const DashboardData: FC = () => {
sx={{ width: '30ch' }}
type={deviceValue.u ? 'number' : 'text'}
onChange={updateValue(setDeviceValue)}
inputProps={{ step: deviceValue.s }}
inputProps={deviceValue.u ? { min: deviceValue.m, max: deviceValue.x, step: deviceValue.s } : {}}
InputProps={{
startAdornment: <InputAdornment position="start">{DeviceValueUOM_s[deviceValue.u]}</InputAdornment>
}}

View File

@@ -133,6 +133,8 @@ export interface DeviceValue {
l: string[]; // list
h?: string; // help text
s?: string; // steps for up/down
m?: string; // min
x?: string; // max
}
export interface DeviceData {

View File

@@ -741,6 +741,11 @@ void EMSdevice::generate_values_web(JsonObject & output) {
} else if (divider < 0) {
obj["s"] = Helpers::render_value(s, (-1) * divider, 0);
}
int16_t dv_set_min, dv_set_max;
if (dv.get_min_max(dv_set_min, dv_set_max)) {
obj["m"] = Helpers::render_value(s, dv_set_min, 0);
obj["x"] = Helpers::render_value(s, dv_set_max, 0);
}
}
}
}