From 06fed4b7c051da8d6f50816a790eec6fb159082d Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Tue, 14 Jan 2025 15:57:26 +1000 Subject: [PATCH] Add solar & wind priority feature Fixes #1325 --- CMakeLists.txt | 4 +++ components/widgets/BatteryWidget.qml | 50 ++++++++++++++++++++++++++++ images/icon_charging_generator.svg | 5 +++ images/icon_charging_grid.svg | 4 +++ images/icon_charging_renewables.svg | 18 ++++++++++ images/icon_charging_shore.svg | 7 ++++ pages/vebusdevice/PageVeBus.qml | 3 ++ themes/geometry/FiveInch.json | 2 ++ themes/geometry/SevenInch.json | 2 ++ 9 files changed, 95 insertions(+) create mode 100644 images/icon_charging_generator.svg create mode 100644 images/icon_charging_grid.svg create mode 100644 images/icon_charging_renewables.svg create mode 100644 images/icon_charging_shore.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cc657130..8886d1979 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1058,6 +1058,10 @@ qt_add_resources(${PROJECT_NAME} "${PROJECT_NAME}_large_resources" images/ess.svg images/freshWater.svg images/icon_black_water_24.svg + images/icon_charging_generator.svg + images/icon_charging_grid.svg + images/icon_charging_renewables.svg + images/icon_charging_shore.svg images/icon_CL_24.svg images/icon_fresh_water_24.svg images/icon_raw_water_24.svg diff --git a/components/widgets/BatteryWidget.qml b/components/widgets/BatteryWidget.qml index f1d686f9b..6d0c2f736 100644 --- a/components/widgets/BatteryWidget.qml +++ b/components/widgets/BatteryWidget.qml @@ -5,10 +5,16 @@ import QtQuick import Victron.VenusOS +import QtQuick.Controls.impl as CP OverviewWidget { id: root + readonly property string vebusPrefix: BackendConnection.serviceUidFromName(Global.acInputs.highlightedInput.inputInfo.serviceName, Global.acInputs.highlightedInput.inputInfo.deviceInstance) + readonly property bool preferRenewable: preferRenewableEnergy.isValid + readonly property bool preferRenewableOverride: preferRenewableEnergy.value === 0 || preferRenewableEnergy.value === 2 + readonly property bool preferRenewableOverrideGenset: remoteGeneratorSelected.value === 1 || Global.acInputs.activeInSource === VenusOS.AcInputs_InputSource_Generator + onClicked: { // If com.victronenergy.system/Batteries has only one battery, then show the device // settings for that battery; otherwise, show the full battery list using BatteryListPage. @@ -64,6 +70,18 @@ OverviewWidget { uid: Global.system.serviceUid + "/Batteries" } + VeQuickItem { + id: preferRenewableEnergy + + uid: vebusPrefix ? vebusPrefix + "/Dc/0/PreferRenewableEnergy" : "" + } + + VeQuickItem { + id: remoteGeneratorSelected + + uid: vebusPrefix ? vebusPrefix + "/Ac/State/RemoteGeneratorSelected" : "" + } + title: CommonWords.battery icon.source: batteryData.icon type: VenusOS.OverviewWidget_Type_Battery @@ -174,6 +192,7 @@ OverviewWidget { } Label { text: Global.system.battery.timeToGo == 0 ? "" : Utils.secondsToString(Global.system.battery.timeToGo) + visible: Global.system.battery.timeToGo color: Theme.color_font_primary width: parent.width elide: Text.ElideRight @@ -181,6 +200,23 @@ OverviewWidget { } }, + CP.ColorImage { + anchors { + left: parent.left + leftMargin: Theme.geometry_overviewPage_widget_content_horizontalMargin + bottom: batteryVoltageDisplay.top + bottomMargin: Theme.geometry_overviewPage_widget_battery_bottomRow_bottomMargin + } + fillMode: Image.PreserveAspectFit + color: Theme.color_font_primary + visible: root.preferRenewableOverride + source: root.preferRenewableOverrideGenset ? + "qrc:/images/icon_charging_generator.svg" : + Global.acInputs.activeInSource === VenusOS.AcInputs_InputSource_Shore ? + "qrc:/images/icon_charging_shore.svg" : + "qrc:/images/icon_charging_grid.svg" + }, + QuantityLabel { id: batteryVoltageDisplay @@ -210,6 +246,20 @@ OverviewWidget { font.pixelSize: root._useSmallFont ? Theme.font_size_body1 : Theme.font_size_body2 }, + CP.ColorImage { + anchors { + bottom: batteryPowerDisplay.top + bottomMargin: Theme.geometry_overviewPage_batterywidget_renewable_icon_bottom_margin + right: parent.right + rightMargin: Theme.geometry_overviewPage_batterywidget_renewable_icon_right_margin + } + + fillMode: Image.PreserveAspectFit + color: Theme.color_font_primary + visible: root.preferRenewable + source: "qrc:/images/icon_charging_renewables.svg" + }, + QuantityLabel { id: batteryPowerDisplay diff --git a/images/icon_charging_generator.svg b/images/icon_charging_generator.svg new file mode 100644 index 000000000..bdc3ec710 --- /dev/null +++ b/images/icon_charging_generator.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/images/icon_charging_grid.svg b/images/icon_charging_grid.svg new file mode 100644 index 000000000..11e503b35 --- /dev/null +++ b/images/icon_charging_grid.svg @@ -0,0 +1,4 @@ + + + + diff --git a/images/icon_charging_renewables.svg b/images/icon_charging_renewables.svg new file mode 100644 index 000000000..03d261e87 --- /dev/null +++ b/images/icon_charging_renewables.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/images/icon_charging_shore.svg b/images/icon_charging_shore.svg new file mode 100644 index 000000000..dd7bcad5b --- /dev/null +++ b/images/icon_charging_shore.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/pages/vebusdevice/PageVeBus.qml b/pages/vebusdevice/PageVeBus.qml index 373ee4d49..36cf579c7 100644 --- a/pages/vebusdevice/PageVeBus.qml +++ b/pages/vebusdevice/PageVeBus.qml @@ -165,6 +165,9 @@ Page { //% "The system will return to normal operation, prioritizing renewable energy.\nDo you want to continue?" readonly property string returnToNormal: qsTrId("vebus_device_return_to_normal_operation") + //% "Charge battery" + title: qsTrId("page_vebus_charge_battery") + GradientListView { Timer { diff --git a/themes/geometry/FiveInch.json b/themes/geometry/FiveInch.json index 311e4a72a..cf6c93134 100644 --- a/themes/geometry/FiveInch.json +++ b/themes/geometry/FiveInch.json @@ -263,6 +263,8 @@ "geometry_overviewPage_widget_solar_graph_bar_width": 8, "geometry_overviewPage_widget_solar_graph_bar_radius": 8, "geometry_overviewPage_widget_solar_graph_margins": 8, + "geometry_overviewPage_batterywidget_renewable_icon_right_margin": 8, + "geometry_overviewPage_batterywidget_renewable_icon_bottom_margin": 3, "geometry_three_phase_column_spacing": -2, "geometry_three_phase_gauge_spacing": 4, diff --git a/themes/geometry/SevenInch.json b/themes/geometry/SevenInch.json index 0b7892c6c..de23fd7ab 100644 --- a/themes/geometry/SevenInch.json +++ b/themes/geometry/SevenInch.json @@ -263,6 +263,8 @@ "geometry_overviewPage_widget_solar_graph_bar_width": 8, "geometry_overviewPage_widget_solar_graph_bar_radius": 8, "geometry_overviewPage_widget_solar_graph_margins": 8, + "geometry_overviewPage_batterywidget_renewable_icon_right_margin": 8, + "geometry_overviewPage_batterywidget_renewable_icon_bottom_margin": 3, "geometry_three_phase_column_spacing": 0, "geometry_three_phase_gauge_spacing": 4,