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

2.5.2 beta #604

Merged
merged 20 commits into from
Nov 7, 2023
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
36 changes: 22 additions & 14 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const QVector<QString> permissions({"android.permission.INTERNET",
#include "telemetry/models/rcchannelsmodel.h"
#include "telemetry/settings/mavlinksettingsmodel.h"
#include "telemetry/settings/wblinksettingshelper.h"
#include "telemetry/settings/frequencyhelper.h"
#include "telemetry/settings/pollutionhelper.h"
#include "osd/speedladder.h"
#include "osd/altitudeladder.h"
#include "osd/headingladder.h"
Expand Down Expand Up @@ -168,6 +170,22 @@ static void write_platform_context_properties(QQmlApplicationEngine& engine){
#endif
}

static void android_check_permissions(){
#if defined(__android__)
qDebug()<<"Android request permissions";
for(const QString &permission : permissions) {
auto result = QtAndroid::checkPermission(permission);
if (result == QtAndroid::PermissionResult::Denied) {
auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission}));
if (resultHash[permission] == QtAndroid::PermissionResult::Denied) {
LogMessagesModel::instanceGround().add_message_warn("QOpenHD","Android - missing permissions");
return;
}
}
}
#endif
}


int main(int argc, char *argv[]) {

Expand Down Expand Up @@ -233,20 +251,8 @@ int main(int argc, char *argv[]) {
applePlatform->registerNotifications();
#endif

QOpenHD::instance().keep_screen_on(true);
#if defined(__android__)
qDebug()<<"Android request permissions";
for(const QString &permission : permissions) {
auto result = QtAndroid::checkPermission(permission);
if (result == QtAndroid::PermissionResult::Denied) {
auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission}));
if (resultHash[permission] == QtAndroid::PermissionResult::Denied) {
return 0;
}
}
}
#endif

QOpenHD::instance().keep_screen_on(true);
android_check_permissions();
load_fonts();

qmlRegisterType<SpeedLadder>("OpenHD", 1, 0, "SpeedLadder");
Expand Down Expand Up @@ -282,6 +288,8 @@ int main(int argc, char *argv[]) {
engine.rootContext()->setContextProperty("_ohdSystemAirSettingsModel", &MavlinkSettingsModel::instanceAir());
engine.rootContext()->setContextProperty("_ohdSystemGroundSettings", &MavlinkSettingsModel::instanceGround());
engine.rootContext()->setContextProperty("_wbLinkSettingsHelper", &WBLinkSettingsHelper::instance());
engine.rootContext()->setContextProperty("_frequencyHelper", &FrequencyHelper::instance());
engine.rootContext()->setContextProperty("_pollutionHelper", &PollutionHelper::instance());
engine.rootContext()->setContextProperty("_fcMavlinkSystem", &FCMavlinkSystem::instance());
engine.rootContext()->setContextProperty("_fcMavlinkAction", &FCAction::instance());
engine.rootContext()->setContextProperty("_fcMavlinkMissionItemsModel", &FCMavlinkMissionItemsModel::instance());
Expand Down
11 changes: 10 additions & 1 deletion app/osd/altitudeladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "debug_overdraw.hpp"

static constexpr int DEFAULT_FONT_PIXEL_SIZE=11;

AltitudeLadder::AltitudeLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
qDebug() << "AltitudeLadder::AltitudeLadder()";
setRenderTarget(RenderTarget::FramebufferObject);
Expand Down Expand Up @@ -119,6 +121,13 @@ void AltitudeLadder::setAltitudeRange(int altitudeRange) {
void AltitudeLadder::setFontFamily(QString fontFamily) {
m_fontFamily = fontFamily;
emit fontFamilyChanged(m_fontFamily);
m_font = QFont(m_fontFamily, 13, QFont::Bold, false);
m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false);
update();
}

void AltitudeLadder::set_custom_font_scale(double custom_font_scale)
{
m_custom_font_scale=custom_font_scale;
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
8 changes: 7 additions & 1 deletion app/osd/altitudeladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <QQuickPaintedItem>
#include <QPainter>

#include "../../../lib/lqtutils_master/lqtutils_prop.h"

class AltitudeLadder : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Expand All @@ -10,7 +12,8 @@ class AltitudeLadder : public QQuickPaintedItem {
// actual altitude, unit - less
Q_PROPERTY(int altitude MEMBER m_altitude WRITE set_altitude NOTIFY altitude_changed)
Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)

public:
Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale)
public:
explicit AltitudeLadder(QQuickItem* parent = nullptr);

Expand All @@ -25,6 +28,7 @@ public slots:
void setAltitudeRange(int altitudeRange);
void set_altitude(double alt);
void setFontFamily(QString fontFamily);
void set_custom_font_scale(double custom_font_scale);
signals:
void colorChanged(QColor color);
void glowChanged(QColor glow);
Expand All @@ -43,4 +47,6 @@ public slots:
QString m_fontFamily;
QFont m_font;

double m_custom_font_scale=1.0;

};
1 change: 0 additions & 1 deletion app/osd/aoagauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <QQuickPaintedItem>
#include <QPainter>


class AoaGauge : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Expand Down
1 change: 1 addition & 0 deletions app/osd/debug_overdraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
// Such that we can enable / disable the "overdraw debugging" with just a single variable change
static constexpr bool ENABLE_DEBUG_OVERDRAW=false;


#endif // DEBUG_OVERDRAW_HPP
1 change: 0 additions & 1 deletion app/osd/flightpathvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <QQuickPaintedItem>
#include <QPainter>


class FlightPathVector : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Expand Down
11 changes: 10 additions & 1 deletion app/osd/headingladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "debug_overdraw.hpp"

static constexpr int DEFAULT_FONT_PIXEL_SIZE=11;

HeadingLadder::HeadingLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
qDebug() << "HeadingLadder::HeadingLadder()";
setRenderTarget(RenderTarget::FramebufferObject);
Expand Down Expand Up @@ -235,6 +237,13 @@ void HeadingLadder::setHomeHeading(int homeHeading) {
void HeadingLadder::setFontFamily(QString fontFamily) {
m_fontFamily = fontFamily;
emit fontFamilyChanged(m_fontFamily);
m_font = QFont(m_fontFamily, 11, QFont::Bold, false);
m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false);
update();
}

void HeadingLadder::set_custom_font_scale(double custom_font_scale)
{
m_custom_font_scale=custom_font_scale;
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
9 changes: 6 additions & 3 deletions app/osd/headingladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <QQuickPaintedItem>
#include <QPainter>

#include "../../../lib/lqtutils_master/lqtutils_prop.h"

class HeadingLadder : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Expand All @@ -16,8 +18,8 @@ class HeadingLadder : public QQuickPaintedItem {

Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)


//show_horizon_heading_ladder
public:
Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale)

public:
explicit HeadingLadder(QQuickItem* parent = nullptr);
Expand All @@ -39,7 +41,7 @@ public slots:
void setHomeHeading(int homeHeading);

void setFontFamily(QString fontFamily);

void set_custom_font_scale(double custom_font_scale);
signals:
void colorChanged(QColor color);
void glowChanged(QColor glow);
Expand Down Expand Up @@ -69,4 +71,5 @@ public slots:
QFont m_font;

QFont m_fontAwesome = QFont("Font Awesome 5 Free", 14, QFont::Bold, false);
double m_custom_font_scale=1.0;
};
12 changes: 10 additions & 2 deletions app/osd/horizonladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include <QPainter>
#include <math.h>

#include "common/TimeHelper.hpp"
#include "debug_overdraw.hpp"

static constexpr int DEFAULT_FONT_PIXEL_SIZE=11;

HorizonLadder::HorizonLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
qDebug() << "HorizonLadder::HorizonLadder()";
setRenderTarget(RenderTarget::FramebufferObject);
Expand Down Expand Up @@ -491,6 +492,13 @@ void HorizonLadder::setShowHorizonHome(bool showHorizonHome) {
void HorizonLadder::setFontFamily(QString fontFamily) {
m_fontFamily = fontFamily;
emit fontFamilyChanged(m_fontFamily);
m_font = QFont(m_fontFamily, 11, QFont::Bold, false);
m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false);
update();
}

void HorizonLadder::set_custom_font_scale(double custom_font_scale)
{
m_custom_font_scale=custom_font_scale;
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
6 changes: 4 additions & 2 deletions app/osd/horizonladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class HorizonLadder : public QQuickPaintedItem {
L_RW_PROP(bool,show_center_indicator, set_show_center_indicator, true)
// Adjust the stroke strength of the lines, in percent
//L_RW_PROP(double,line_stroke_strength_perc, set_line_stroke_strength_perc, 100)

public:
Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale)
public:
explicit HorizonLadder(QQuickItem* parent = nullptr);

Expand Down Expand Up @@ -61,7 +62,7 @@ public slots:
void setShowHorizonHome(bool showHorizonHome);

void setFontFamily(QString fontFamily);

void set_custom_font_scale(double custom_font_scale);
signals:
void colorChanged(QColor color);
void glowChanged(QColor glow);
Expand Down Expand Up @@ -108,5 +109,6 @@ public slots:
QFont m_font;

QFont m_fontAwesome = QFont("Font Awesome 5 Free", 15, QFont::Bold, false);
double m_custom_font_scale=1.0;
};
#endif //QOPENHD_HORIZON_LADDER
11 changes: 10 additions & 1 deletion app/osd/speedladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "debug_overdraw.hpp"

static constexpr int DEFAULT_FONT_PIXEL_SIZE=11;

SpeedLadder::SpeedLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
qDebug() << "SpeedLadder::SpeedLadder()";
setRenderTarget(RenderTarget::FramebufferObject);
Expand Down Expand Up @@ -129,6 +131,13 @@ void SpeedLadder::setSpeed(int speed) {
void SpeedLadder::setFontFamily(QString fontFamily) {
m_fontFamily = fontFamily;
emit fontFamilyChanged(m_fontFamily);
m_font = QFont(m_fontFamily, 10, QFont::Bold, false);
m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false);
update();
}

void SpeedLadder::set_custom_font_scale(double custom_font_scale)
{
m_custom_font_scale=custom_font_scale;
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
8 changes: 5 additions & 3 deletions app/osd/speedladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QQuickPaintedItem>
#include <QPainter>

#include "../../../lib/lqtutils_master/lqtutils_prop.h"

class SpeedLadder : public QQuickPaintedItem {
Q_OBJECT
Expand All @@ -13,7 +14,8 @@ class SpeedLadder : public QQuickPaintedItem {
Q_PROPERTY(int speed MEMBER m_speed WRITE setSpeed NOTIFY speedChanged)

Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)

public:
Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale)
public:
explicit SpeedLadder(QQuickItem* parent = nullptr);

Expand All @@ -31,7 +33,7 @@ public slots:

void setSpeed(int speed);
void setFontFamily(QString fontFamily);

void set_custom_font_scale(double custom_font_scale);
signals:
void colorChanged(QColor color);
void glowChanged(QColor glow);
Expand All @@ -51,5 +53,5 @@ public slots:
QString m_fontFamily;

QFont m_font;

double m_custom_font_scale=1.0;
};
2 changes: 1 addition & 1 deletion app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool MavlinkTelemetry::change_manual_tcp_ip(QString ip)

void MavlinkTelemetry::send_heartbeat_loop()
{
while(true){
while(m_heartbeat_thread_run){
//qDebug()<<"send_heartbeat_loop";
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
perform_connection_management();
Expand Down
8 changes: 3 additions & 5 deletions app/telemetry/models/aohdsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,16 @@ bool AOHDSystem::process_message(const mavlink_message_t &msg)
CameraStreamModel::instance(0).update_mavlink_openhd_camera_status_air(parsedMsg);
}else if(msg.compid==OHD_COMP_ID_AIR_CAMERA_SECONDARY){
CameraStreamModel::instance(1).update_mavlink_openhd_camera_status_air(parsedMsg);
set_dirty_air_has_secondary_cam(true);
// Feature - tell user to enable 2 cameras in qopenhd
set_n_openhd_cameras(2);
const int value_in_qopenhd=QOpenHDVideoHelper::get_qopenhd_n_cameras();
if(value_in_qopenhd!=2){
const auto elapsed=std::chrono::steady_clock::now()-m_last_n_cameras_message;
if(elapsed>std::chrono::seconds(10)){
auto message="QOpenHD is not configured for dual cam usage, go to QOpenHD settings / General to configure your GCS to show secondary camera screen";
qDebug()<<message;
WorkaroundMessageBox::makePopupMessage(message,8);
if(elapsed>std::chrono::seconds(5)){
LogMessagesModel::instanceGround().add_message_debug("QOpenHD","Please enable 2 camera control");
m_last_n_cameras_message=std::chrono::steady_clock::now();
}
HUDLogMessagesModel::instance().add_message_info("QOpenHD only shows 1 camera");
}

}
Expand Down
2 changes: 2 additions & 0 deletions app/telemetry/models/aohdsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class AOHDSystem : public QObject
L_RO_PROP(int,wb_gnd_operating_mode,set_wb_gnd_operating_mode,-1)
//
L_RO_PROP(int,air_reported_fc_sys_id,set_air_reported_fc_sys_id,-1)
//
L_RO_PROP(bool,dirty_air_has_secondary_cam,set_dirty_air_has_secondary_cam,false)
private:
const bool m_is_air; // either true (for air) or false (for ground)
uint8_t get_own_sys_id()const{
Expand Down
Loading
Loading