Using a picker object to configure the picker now, deriving display format from steps.

This commit is contained in:
thmichel
2025-10-29 13:54:14 +01:00
parent 2cd171637c
commit 6a0ec34cdb
4 changed files with 18 additions and 20 deletions

View File

@@ -44,11 +44,15 @@ class HomeAssistantNumericFactory extends WatchUi.PickerFactory {
if (val != null) {
mStep = val.toString().toFloat();
}
val = data.get("display_format");
if (val != null) {
mFormatString = val.toString();
}
if (mStep < 0.01) {
mFormatString="%.3f";
} else if (mStep < 0.1) {
mFormatString="%2f";
} else if (mStep < 1) {
mFormatString="%.1f";
} else {
mFormatString="%d";
}
}
//! Get the index of a number item