Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance battery indicator visuals with new SVGs and color coding #11881

Merged
merged 23 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dc2148c
Enhance battery indicator visuals
Paschalis Sep 15, 2024
feb382c
Added colorYellow and colorYellowGreen to QGCPalette and updated Batt…
Paschalis Sep 17, 2024
ae4249a
Update color definitions for improved visibility for light theme
Paschalis Sep 17, 2024
c6ab475
Apply battery colors only in dark theme
Paschalis Sep 18, 2024
c7be67c
Update qgcimages.qrc to include new battery icons.
Paschalis Sep 20, 2024
e047024
Add battery configuration settings for dark and light themes.
Paschalis Sep 20, 2024
7bda84d
Implement logic for configurable battery thresholds.
Paschalis Sep 20, 2024
cf43592
Add header definitions for battery indicator settings.
Paschalis Sep 20, 2024
0b8cfbc
Improve battery indicator with dark theme support and configurable co…
Paschalis Sep 20, 2024
fb186df
Fix SVG file namespace issues in TelemRSSI.svg.
Paschalis Sep 20, 2024
5138b77
Add new battery configuration icons for light and dark themes (Batter…
Paschalis Sep 20, 2024
81ee7db
Modify palette, battery indicator, and update images.
Paschalis Sep 21, 2024
4f78b5a
Remove unnecessary battery images.
Paschalis Sep 21, 2024
012cbb4
Add BatteryEMERGENCY.svg image.
Paschalis Sep 21, 2024
7563664
Update ChangeLog with new battery display feature.
Paschalis Sep 21, 2024
0f5c193
Updated BatteryIndicatorSettings and UI for dynamic visibility and va…
Paschalis Sep 23, 2024
0461be3
Merge branch 'master' into master
Paschalis Sep 23, 2024
fc5d511
Merge branch 'mavlink:master' into master
Paschalis Sep 25, 2024
c2ce804
feat: Update battery indicator settings and visibility logic
Paschalis Sep 28, 2024
3a33e93
Merge branch 'master' into master
Paschalis Sep 28, 2024
80806a3
Adjusted spacing in BatteryIndicator.qml for better code readability
Paschalis Sep 28, 2024
fd10395
Merge branch 'master' into master
Paschalis Oct 2, 2024
27d3eb3
Merge branch 'mavlink:master' into master
Paschalis Oct 6, 2024
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
12 changes: 7 additions & 5 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Note: This file only contains high level features or important fixes.

## 5.0 - Daily Build

* New combined compass and attitude instrument
* You can select between multiple instruments by clicking on the instrument conntrol on a desktop build or press and hold on mobile builds
* Support for Fly View and Joystick custom mavlink actions has changed. Both the name and formation of the command file is different now. Go to QGC docs to understand how it works now.
* Support for setting individual Mavlink message rates in the Mavlink Inspector.
* Support for Mavlink 2 signing
* Introduced a new combined compass and attitude instrument for enhanced navigation.
* Select between multiple instruments by clicking the instrument control on desktop or pressing and holding on mobile.
* Updated support for Fly View and Joystick custom MAVLink actions; command file names and formats have changed—refer to QGC docs for details.
* Added functionality for setting individual MAVLink message rates in the MAVLink Inspector.
* Enabled support for MAVLink 2 signing.
* Dynamic battery display that reduces the number of bars based on battery percentage, with configurable states (100%, Config 1, Config 2, Low, Critical) for clearer status indication.


## 4.1

Expand Down
6 changes: 6 additions & 0 deletions qgcimages.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<file alias="attitudePointer.svg">src/FlightMap/Images/attitudePointer.svg</file>
<file alias="AwarenessAircraft.svg">src/FlightMap/Images/AwarenessAircraft.svg</file>
<file alias="Battery.svg">src/UI/toolbar/Images/Battery.svg</file>
<file alias="BatteryGreen.svg">src/UI/toolbar/Images/BatteryGreen.svg</file>
<file alias="BatteryYellowGreen.svg">src/UI/toolbar/Images/BatteryYellowGreen.svg</file>
<file alias="BatteryYellow.svg">src/UI/toolbar/Images/BatteryYellow.svg</file>
<file alias="BatteryOrange.svg">src/UI/toolbar/Images/BatteryOrange.svg</file>
<file alias="BatteryCritical.svg">src/UI/toolbar/Images/BatteryCritical.svg</file>
<file alias="BatteryEMERGENCY.svg">src/UI/toolbar/Images/BatteryEMERGENCY.svg</file>
<file alias="camera.svg">resources/camera.svg</file>
<file alias="camera_photo.svg">src/Camera/images/camera_photo.svg</file>
<file alias="camera_video.svg">src/Camera/images/camera_video.svg</file>
Expand Down
8 changes: 5 additions & 3 deletions src/QmlControls/QGCPalette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ void QGCPalette::_buildMap()
DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c")
DECLARE_QGC_COLOR(mapIndicator, "#585858", "#be781c", "#585858", "#be781c")
DECLARE_QGC_COLOR(mapIndicatorChild, "#585858", "#766043", "#585858", "#766043")
DECLARE_QGC_COLOR(colorGreen, "#009431", "#009431", "#00e04b", "#00e04b")
DECLARE_QGC_COLOR(colorOrange, "#b95604", "#b95604", "#de8500", "#de8500")
DECLARE_QGC_COLOR(colorRed, "#ed3939", "#ed3939", "#f32836", "#f32836")
DECLARE_QGC_COLOR(colorGreen, "#008f2d", "#008f2d", "#00e04b", "#00e04b")
DECLARE_QGC_COLOR(colorYellow, "#a2a200", "#a2a200", "#ffff00", "#ffff00")
DECLARE_QGC_COLOR(colorYellowGreen, "#799f26", "#799f26", "#9dbe2f", "#9dbe2f")
DECLARE_QGC_COLOR(colorOrange, "#bf7539", "#bf7539", "#de8500", "#de8500")
DECLARE_QGC_COLOR(colorRed, "#b52b2b", "#b52b2b", "#f32836", "#f32836")
DECLARE_QGC_COLOR(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf")
DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff")
DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44")
Expand Down
2 changes: 2 additions & 0 deletions src/QmlControls/QGCPalette.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class QGCPalette : public QObject
DEFINE_QGC_COLOR(brandingPurple, setBrandingPurple)
DEFINE_QGC_COLOR(brandingBlue, setBrandingBlue)
DEFINE_QGC_COLOR(colorGreen, setColorGreen)
DEFINE_QGC_COLOR(colorYellow, setColorYellow)
DEFINE_QGC_COLOR(colorYellowGreen, setColorYellowGreen)
DEFINE_QGC_COLOR(colorOrange, setColorOrange)
DEFINE_QGC_COLOR(colorRed, setColorRed)
DEFINE_QGC_COLOR(colorGrey, setColorGrey)
Expand Down
39 changes: 26 additions & 13 deletions src/Settings/BatteryIndicator.SettingsGroup.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "display",
"shortDesc": "Select values to display in indicator",
"enumStrings": "Percentage,Voltage,Percentage and Voltage",
"enumValues": "0,1,2",
"type": "uint32",
"default": false
}
]
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts": [
{
"name": "display",
"shortDesc": "Select values to display in indicator",
"enumStrings": "Percentage,Voltage,Percentage and Voltage",
"enumValues": "0,1,2",
"type": "uint32",
"default": false
},
{
"name": "threshold1",
"shortDesc": "Battery level threshold 1",
"type": "uint32",
"default": 80,
"units": "%"
},
{
"name": "threshold2",
"shortDesc": "Battery level threshold 2",
"type": "uint32",
"default": 60,
"units": "%"
}
]
}
48 changes: 48 additions & 0 deletions src/Settings/BatteryIndicatorSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "BatteryIndicatorSettings.h"

#include <QSettings>
#include <QtQml/QQmlEngine>

DECLARE_SETTINGGROUP(BatteryIndicator, "BatteryIndicator")
Expand All @@ -17,3 +18,50 @@ DECLARE_SETTINGGROUP(BatteryIndicator, "BatteryIndicator")
}

DECLARE_SETTINGSFACT(BatteryIndicatorSettings, display)
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, threshold1)
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, threshold2)

// Set threshold1 with validation
void BatteryIndicatorSettings::setThreshold1(int value) {
// Ensure value is at least 16 and less than 100
if (value < 16) {
threshold1()->setRawValue(17);
} else if (value > 99) {
threshold1()->setRawValue(99);
} else {
// Check if value is greater than threshold2
if (value > threshold2()->rawValue().toInt()) {
threshold1()->setRawValue(value);
} else {
// Ensure threshold1 is greater than threshold2
threshold1()->setRawValue(threshold2()->rawValue().toInt() + 1);
}
}
}

// Set threshold2 with validation
void BatteryIndicatorSettings::setThreshold2(int value) {
// Ensure value is greater than 15
if (value <= 15) {
threshold2()->setRawValue(16); // Adjust to the minimum valid value
return;
}

// Check if value is less than threshold1
if (value < threshold1()->rawValue().toInt()) {
threshold2()->setRawValue(value);
} else {
// Ensure threshold2 is less than threshold1
threshold2()->setRawValue(threshold1()->rawValue().toInt() - 1);
}
}

bool BatteryIndicatorSettings::visible() const {
QSettings settings;
return settings.value("ShowBatterySettings", true).toBool();
}

bool BatteryIndicatorSettings::thresholdEditable() const {
QSettings settings;
return settings.value("ThresholdEditable", true).toBool();
}
19 changes: 18 additions & 1 deletion src/Settings/BatteryIndicatorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ class BatteryIndicatorSettings : public SettingsGroup
DEFINE_SETTING_NAME_GROUP()

DEFINE_SETTINGFACT(display)
};
DEFINE_SETTINGFACT(threshold1)
DEFINE_SETTINGFACT(threshold2)

Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
Copy link
Contributor

@DonLakeFlyer DonLakeFlyer Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So all f this is incorrect with respect to how settings groups.facts work:

  • There is no need for adding a visible property. It already exists on both the group and on each setting. You can access them in Qml using QGroundControl.settingsManager.batteryIndicatorSettings.visible for visibility which should control whether to show the battery indicator panel. And then QGroundControl.settingsManager.batteryIndicatorSettings.threshold1.visible for the thresholds.
  • To implement validation on the C++ side you need to implement you own settings fact creation using DECLARE_SETTINGSFACT_NO_FUNC. Look at AppSettings.cc for examples. Then in that code you connect to the rawValueChanged signal. And in you signal handler that is where you do the validation.

Copy link
Contributor Author

@Paschalis Paschalis Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2024-09-28 23-02-35

I streamlined the visibility management by utilizing existing properties in QGroundControl.settingsManager.batteryIndicatorSettings and removed redundant properties. Additionally, I implemented validation for threshold settings using DECLARE_SETTINGSFACT_NO_FUNC

Screenshot from 2024-09-28 21-16-04

and confirmed the correct storage of new threshold values after verifying defaults from the JSON file.

Screenshot from 2024-09-28 22-54-15

Thanks!

Q_PROPERTY(bool thresholdEditable READ thresholdEditable NOTIFY thresholdEditableChanged)

// Setters for thresholds
// Expose setters to QML
Q_INVOKABLE void setThreshold1(int value);
Q_INVOKABLE void setThreshold2(int value);

bool visible() const; // Group visibility
bool thresholdEditable() const; // Single editable property for both thresholds

signals:
void visibleChanged();
void thresholdEditableChanged();
};
Loading
Loading