From f83f22a6fbccd68b2a51ad500e54efb2ef2eafba Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 29 Nov 2023 12:06:56 +0100 Subject: [PATCH] send step as string to avoid js-rounding issue for 0.1 --- interface/src/project/types.ts | 2 +- src/emsdevice.cpp | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index 05cf46073..9fe1bde37 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -130,7 +130,7 @@ export interface DeviceValue { c?: string; // command, optional l?: string[]; // list, optional h?: string; // help text, optional - s?: number; // steps for up/down, optional + s?: string; // steps for up/down, optional m?: number; // min, optional x?: number; // max, optional } diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 08ccb9b3f..c9c6bc6a5 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -969,19 +969,15 @@ void EMSdevice::generate_values_web(JsonObject & output) { } // handle INTs else { - // add step if it's not 1 - if (dv.numeric_operator > 0) { - obj["s"] = (float)1 / dv.numeric_operator; - } else if (dv.numeric_operator < 0) { - obj["s"] = (float)(-1) * dv.numeric_operator; - } - // add min and max values, if available int16_t dv_set_min; uint32_t dv_set_max; if (dv.get_min_max(dv_set_min, dv_set_max)) { obj["m"] = dv_set_min; obj["x"] = dv_set_max; + // add steps to numeric values as rendered string to avoid rounding floats in js + char s[10]; + obj["s"] = Helpers::render_value(s, (uint32_t)1, dv.numeric_operator); } } }