Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Releases.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/dashx/app/modules/model/tools/battery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/dashx/app/modules/settings/tools/dashboard_theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/dashx/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions src/dashx/lib/runtime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ local modelPreferenceDefaults = {
vbatmaxcellvoltage = 43,
vbatfullcellvoltage = 41,
lvcPercentage = 30,
consumptionWarningPercentage = 30
consumptionWarningPercentage = 30,
consumptionScale = 100
}
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions src/dashx/lib/smartfuel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/dashx/widgets/dashboard/configure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions src/dashx/widgets/dashboard/dashboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading