Skip to content

Commit

Permalink
Reduce the effect of noise on power flow direction visualisation
Browse files Browse the repository at this point in the history
We visualise the direction of power flow with an icon and a colour
e.g. feed-in icon with green colour gauge, versus grid-draw icon
     with blue colour gauge.

This commit ensures that we don't flicker between feed-in and
grid-draw visualisation if the value is actually zero and the
readings are just noise, by requiring that the feed-in value
exceeds a certain threshold before we recognise it.

(Note that this will not prevent flickering if feed-in amount
happens to hover around -0.5, but this is much less likely.)

Also, this aligns the expectation of the user with the value shown
e.g. -0.4 Watts will be shown as 0 W due to zero-digit-precision,
and so the user does not expect to see any feed-in at this value.

Contributes to #1328
  • Loading branch information
chriadam committed Jul 15, 2024
1 parent d2b767a commit ed0372b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions components/AcInputDirectionIcon.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import Victron.VenusOS

// When ESS feedback to grid is enabled, show an arrow indicating the flow direction.
CP.ColorImage {
property real activeInputPower: (!Global.acInputs.activeInput || !Global.acInputs.activeInput.power) ? 0
: Global.acInputs.activeInput.power <= -0.5 ? Global.acInputs.activeInput.power
: Global.acInputs.activeInput.power >= 0.5 ? Global.acInputs.activeInput.power
: 0 // clamp to zero any values close to zero (assume it's noise) to avoid UI flicker.
visible: Global.systemSettings.essFeedbackToGridEnabled && Global.acInputs.activeInput
source: !!Global.acInputs.activeInput
? (Global.acInputs.activeInput.power < 0 ? "qrc:/images/icon_to_grid.svg" : "qrc:/images/icon_from_grid.svg")
: ""
color: !Global.acInputs.activeInput || (Global.acInputs.activeInput.power || 0) === 0 ? Theme.color_background_disabled
: Global.acInputs.activeInput.power < 0 ? Theme.color_green
source: !Global.acInputs.activeInput ? ""
: activeInputPower < 0 ? "qrc:/images/icon_to_grid.svg"
: "qrc:/images/icon_from_grid.svg"
color: (!Global.acInputs.activeInput || activeInputPower === 0) ? Theme.color_background_disabled
: activeInputPower < 0 ? Theme.color_green
: Theme.color_blue
}
2 changes: 1 addition & 1 deletion components/SideMultiGauge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Item {
id: gaugeDelegate

readonly property bool feedingToGrid: root.inputMode
&& (model.power || 0) < 0
&& (model.power || 0) <= -0.5 // ignore noise values (negative close to zero)

width: Theme.geometry_briefPage_edgeGauge_width
height: root.height
Expand Down
2 changes: 1 addition & 1 deletion components/ThreePhaseBarGauge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Flow {
height: parent.height
sourceComponent: Global.isGxDevice ? cheapGauge : prettyGauge
readonly property bool feedingToGrid: root.inputMode
&& (model.power || 0) < 0
&& (model.power || 0) <= -0.5 // ignore noise values (negative close to zero)
}

Component {
Expand Down
2 changes: 1 addition & 1 deletion components/ThreePhaseDisplay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Flow {
delegate: Item {
id: phaseDelegate

readonly property bool feedingToGrid: root.inputMode && (model.power || 0) < 0
readonly property bool feedingToGrid: root.inputMode && (model.power || 0) <= -0.5 // ignore noise values (negative close to zero)
readonly property int valueStatus: feedingToGrid ? Theme.Ok
: root.phaseModelProperty ? Theme.getValueStatus(valueRange.valueAsRatio * 100, root.valueType)
: Theme.Ok
Expand Down

0 comments on commit ed0372b

Please sign in to comment.