diff --git a/Releases.md b/Releases.md index a08c1cc..9b7a9ee 100644 --- a/Releases.md +++ b/Releases.md @@ -1,3 +1,8 @@ +# 2.0.2 + +Fix bug when new theme chosen; resulting in dashboard not updating +Added ablity to scale the fuel locally for current sensors that are not accurate + # 2.0.1 Fix logo display diff --git a/src/dashx/app/modules/model/tools/battery.lua b/src/dashx/app/modules/model/tools/battery.lua index 85e88fa..fe594f5 100644 --- a/src/dashx/app/modules/model/tools/battery.lua +++ b/src/dashx/app/modules/model/tools/battery.lua @@ -105,6 +105,16 @@ local function openPage(pageIdx, title, script) dashx.app.formFields[formFieldCount]:suffix("%") dashx.app.formFields[formFieldCount]:default(30) + formFieldCount = formFieldCount + 1 + formLineCnt = formLineCnt + 1 + dashx.app.formLines[formLineCnt] = form.addLine("@i18n(app.modules.model.consumption_scale)@") + dashx.app.formFields[formFieldCount] = form.addNumberField(dashx.app.formLines[formLineCnt], nil, 50, 200, function() + if dashx.session.modelPreferences and dashx.session.modelPreferences.battery then return dashx.session.modelPreferences.battery.consumptionScale end + return nil + end, function(newValue) if dashx.session.modelPreferences then dashx.session.modelPreferences.battery.consumptionScale = newValue end end) + dashx.app.formFields[formFieldCount]:suffix("%") + dashx.app.formFields[formFieldCount]:default(100) + enableWakeup = true end diff --git a/src/dashx/app/modules/settings/tools/dashboard_theme.lua b/src/dashx/app/modules/settings/tools/dashboard_theme.lua index acade2f..c5c334a 100644 --- a/src/dashx/app/modules/settings/tools/dashboard_theme.lua +++ b/src/dashx/app/modules/settings/tools/dashboard_theme.lua @@ -193,7 +193,7 @@ local function onSaveMenu() dashx.ini.save_ini_file(dashx.session.modelPreferencesFile, dashx.session.modelPreferences) end - dashx.widgets.dashboard.reload_themes(true) + dashx.session.dashboardThemeReloadPending = true dashx.app.triggers.closeSave = true return true diff --git a/src/dashx/i18n/de.json b/src/dashx/i18n/de.json index 061f911..73bf391 100644 --- a/src/dashx/i18n/de.json +++ b/src/dashx/i18n/de.json @@ -2804,6 +2804,11 @@ "needs_translation": true, "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": true, + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": true, diff --git a/src/dashx/i18n/en.json b/src/dashx/i18n/en.json index ba5c7ae..0965118 100644 --- a/src/dashx/i18n/en.json +++ b/src/dashx/i18n/en.json @@ -2804,6 +2804,11 @@ "needs_translation": "false", "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": "false", + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": "false", diff --git a/src/dashx/i18n/es.json b/src/dashx/i18n/es.json index ef5c7c8..ca3fae5 100644 --- a/src/dashx/i18n/es.json +++ b/src/dashx/i18n/es.json @@ -2804,6 +2804,11 @@ "needs_translation": true, "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": true, + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": true, diff --git a/src/dashx/i18n/fr.json b/src/dashx/i18n/fr.json index 126aed2..b9f1408 100644 --- a/src/dashx/i18n/fr.json +++ b/src/dashx/i18n/fr.json @@ -2804,6 +2804,11 @@ "needs_translation": true, "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": true, + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": true, diff --git a/src/dashx/i18n/it.json b/src/dashx/i18n/it.json index c045033..a3e66e2 100644 --- a/src/dashx/i18n/it.json +++ b/src/dashx/i18n/it.json @@ -2804,6 +2804,11 @@ "needs_translation": true, "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": true, + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": true, diff --git a/src/dashx/i18n/nl.json b/src/dashx/i18n/nl.json index 83b5b8a..59ab1c0 100644 --- a/src/dashx/i18n/nl.json +++ b/src/dashx/i18n/nl.json @@ -2804,6 +2804,11 @@ "needs_translation": true, "translation": "Consumption Warning %" }, + "consumption_scale": { + "english": "Consumption Scale", + "needs_translation": true, + "translation": "Consumption Scale" + }, "battery_full_voltage": { "english": "Cell Full Voltage", "needs_translation": true, diff --git a/src/dashx/lib/runtime.lua b/src/dashx/lib/runtime.lua index 7365594..f3d79e0 100644 --- a/src/dashx/lib/runtime.lua +++ b/src/dashx/lib/runtime.lua @@ -36,7 +36,8 @@ local modelPreferenceDefaults = { vbatmaxcellvoltage = 43, vbatfullcellvoltage = 41, lvcPercentage = 30, - consumptionWarningPercentage = 30 + consumptionWarningPercentage = 30, + consumptionScale = 100 } } @@ -116,7 +117,8 @@ local function buildBatteryConfig(prefs) vbatmaxcellvoltage = (tonumber(battery.vbatmaxcellvoltage) or 43) / 10, vbatfullcellvoltage = (tonumber(battery.vbatfullcellvoltage) or 41) / 10, lvcPercentage = tonumber(battery.lvcPercentage) or 30, - consumptionWarningPercentage = tonumber(battery.consumptionWarningPercentage) or 30 + consumptionWarningPercentage = tonumber(battery.consumptionWarningPercentage) or 30, + consumptionScale = tonumber(battery.consumptionScale) or 100 } end @@ -471,6 +473,7 @@ local function normalizeWidgetSettings(widget) widget.vbatmaxcellvoltage = clamp(math.floor(tonumber(widget.vbatmaxcellvoltage) or 43), 5, 600) widget.vbatfullcellvoltage = clamp(math.floor(tonumber(widget.vbatfullcellvoltage) or 41), 5, 600) widget.consumptionWarningPercentage = clamp(math.floor(tonumber(widget.consumptionWarningPercentage) or 30), 0, 100) + widget.consumptionScale = clamp(math.floor(tonumber(widget.consumptionScale) or 100), 50, 200) widget.inflightswitch_delay = clamp(math.floor(tonumber(widget.inflightswitch_delay) or 10), 0, 120) widget.armswitch = normalizeSwitchValue(widget.armswitch) widget.inflightswitch = normalizeSwitchValue(widget.inflightswitch) @@ -495,6 +498,7 @@ function runtime.readWidgetSettings(widget) widget.vbatmaxcellvoltage = tonumber(batteryPrefs.vbatmaxcellvoltage) or 43 widget.vbatfullcellvoltage = tonumber(batteryPrefs.vbatfullcellvoltage) or 41 widget.consumptionWarningPercentage = tonumber(batteryPrefs.consumptionWarningPercentage) or 30 + widget.consumptionScale = tonumber(batteryPrefs.consumptionScale) or 100 widget.armswitch = modelPrefs.armswitch or false widget.inflightswitch = modelPrefs.inflightswitch or false widget.inflightswitch_delay = tonumber(modelPrefs.inflightswitch_delay) or 10 @@ -539,6 +543,7 @@ function runtime.writeWidgetSettings(widget) prefs.battery.vbatmaxcellvoltage = widget.vbatmaxcellvoltage prefs.battery.vbatfullcellvoltage = widget.vbatfullcellvoltage prefs.battery.consumptionWarningPercentage = widget.consumptionWarningPercentage + prefs.battery.consumptionScale = widget.consumptionScale dashx.ini.save_ini_file(prefFile, prefs) diff --git a/src/dashx/lib/smartfuel.lua b/src/dashx/lib/smartfuel.lua index 1051db1..71035a0 100644 --- a/src/dashx/lib/smartfuel.lua +++ b/src/dashx/lib/smartfuel.lua @@ -161,6 +161,10 @@ local function smartFuelCalc() local consumption = telemetry and telemetry.getSensor and telemetry.getSensor("consumption") or nil + if consumption and bc.consumptionScale and bc.consumptionScale ~= 100 then + consumption = consumption * bc.consumptionScale / 100 + end + if not fuelStartingPercent then if voltage and cellCount > 0 then diff --git a/src/dashx/widgets/dashboard/configure.lua b/src/dashx/widgets/dashboard/configure.lua index bb3acb6..934ee1a 100644 --- a/src/dashx/widgets/dashboard/configure.lua +++ b/src/dashx/widgets/dashboard/configure.lua @@ -205,6 +205,16 @@ function configui.configure(widget) reserveField:suffix("%") end + local scaleLine = addLine(batteryPanel, "@i18n(app.modules.model.consumption_scale)@") + local scaleField = form.addNumberField(scaleLine, nil, 50, 200, function() + return math.floor(tonumber(widget.consumptionScale) or 100) + end, function(value) + widget.consumptionScale = clamp(math.floor(tonumber(value) or 100), 50, 200) + end) + if scaleField and scaleField.suffix then + scaleField:suffix("%") + end + local triggersPanel = form.addExpansionPanel("@i18n(app.modules.model.triggers)@") triggersPanel:open(false) diff --git a/src/dashx/widgets/dashboard/dashboard.lua b/src/dashx/widgets/dashboard/dashboard.lua index 6943a60..cbd905e 100644 --- a/src/dashx/widgets/dashboard/dashboard.lua +++ b/src/dashx/widgets/dashboard/dashboard.lua @@ -619,6 +619,11 @@ function dashboard.wakeup(widget) if dashx.session and dashx.session.dashboardThemeReloadPending then dashx.session.dashboardThemeReloadPending = false + local prefFile = "SCRIPTS:/" .. dashx.config.preferences .. "/preferences.ini" + local freshPrefs = dashx.ini.load_ini_file(prefFile) + if freshPrefs and freshPrefs.dashboard and dashx.preferences then + dashx.preferences.dashboard = freshPrefs.dashboard + end reloadTheme() end