Skip to content

Commit

Permalink
Add solar & wind priority feature
Browse files Browse the repository at this point in the history
Fixes #1325
  • Loading branch information
DanielMcInnes committed Jan 26, 2025
1 parent 59e1215 commit 074ac78
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,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
Expand Down
49 changes: 49 additions & 0 deletions components/widgets/BatteryWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@

import QtQuick
import Victron.VenusOS
import QtQuick.Controls.impl as CP

OverviewWidget {
id: root

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.
Expand Down Expand Up @@ -64,6 +69,18 @@ OverviewWidget {
uid: Global.system.serviceUid + "/Batteries"
}

VeQuickItem {
id: preferRenewableEnergy

uid: Global.system.veBus.serviceUid ? Global.system.veBus.serviceUid + "/Dc/0/PreferRenewableEnergy" : ""
}

VeQuickItem {
id: remoteGeneratorSelected

uid: Global.system.veBus.serviceUid ? Global.system.veBus.serviceUid + "/Ac/State/RemoteGeneratorSelected" : ""
}

title: CommonWords.battery
icon.source: batteryData.icon
type: VenusOS.OverviewWidget_Type_Battery
Expand Down Expand Up @@ -174,13 +191,31 @@ 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
font.pixelSize: Theme.font_overviewPage_battery_timeToGo_pixelSize
}
},

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

Expand Down Expand Up @@ -210,6 +245,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

Expand Down
5 changes: 5 additions & 0 deletions images/icon_charging_generator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/icon_charging_grid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions images/icon_charging_renewables.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions images/icon_charging_shore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pages/vebusdevice/PageVeBus.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions themes/geometry/FiveInch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions themes/geometry/SevenInch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 074ac78

Please sign in to comment.