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

Consti dev #606

Merged
merged 20 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
98824a2
tx power - reset the selection model(s) to fix bug @Ivan
Consti10 Nov 8, 2023
e884881
tx power - whitelist for less confusion, add 720p60 16:9 to drop down…
Consti10 Nov 10, 2023
1725020
Always disable Qt::AA_DisableHighDpiScaling, vertical speed: fix arrow,
Consti10 Nov 13, 2023
6ef7272
status: fill width, openhd quick: center elements (fix usability on l…
Consti10 Nov 14, 2023
92ecd98
finalize: Everything is usable up to minimum resolution (480p 16:9)
Consti10 Nov 14, 2023
9dc6628
exp for android - re-enable high dpi scaling
Consti10 Nov 14, 2023
a66db5b
exp -set before writing the AA flag / screen scale
Consti10 Nov 14, 2023
683bf9e
exp -set before writing the AA flag / screen scale
Consti10 Nov 14, 2023
07fa49d
wb link rate widget - use combobox instead of buttons
Consti10 Nov 14, 2023
54576da
slightly decrease the default size of the artificial horizon
Consti10 Nov 14, 2023
38b3243
horizon ladder - scale home icon, restart qopenhd box - decrease size,
Consti10 Nov 14, 2023
b1fa5e3
make restart dialoque even smaller
Consti10 Nov 15, 2023
69a9de5
fix " "
Consti10 Nov 15, 2023
2a39c43
show restart dialoque when changed
Consti10 Nov 15, 2023
090bdee
debug
raphaelscholle Nov 15, 2023
810447c
Revert "debug"
raphaelscholle Nov 15, 2023
b391a47
status - look less shit on small screens
Consti10 Nov 16, 2023
8502c2f
use DEF als agreed in chat
Consti10 Nov 16, 2023
fd4dae3
use DEF als agreed in chat
Consti10 Nov 16, 2023
ebaf36b
Convert total distance to Coords and bug fixes
Nov 16, 2023
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 @@ -186,14 +186,23 @@ static void android_check_permissions(){
#endif
}


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

QCoreApplication::setOrganizationName("OpenHD");
QCoreApplication::setOrganizationDomain("openhd");
QCoreApplication::setApplicationName("QOpenHD");
{// Original screen resoluton before setting anything
//QApplication a(argc, argv);
const auto screen=QGuiApplication::primaryScreen();
if(screen){
const auto actual_size=screen->size();
QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height());
}
// a is deleted again
}

QSettings settings;
qDebug()<<"Storing settings at ["<<settings.fileName()<<"]";

const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt();
if (screen_custom_font_dpi) {
Expand All @@ -204,22 +213,11 @@ int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
}
//QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);

// From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime
// Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to
// result in tripple buffering with unlimited fps, a bit "better" regarding latency than default.
if(settings.value("dev_set_swap_interval_zero",false).toBool()){
qDebug()<<"Request swap interval of 0";
QSurfaceFormat format=QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
}

//QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
const double global_scale = settings.value("global_scale", 1.0).toDouble();
const std::string global_scale_s = std::to_string(global_scale);
QByteArray scaleAsQByteArray(global_scale_s.c_str(), global_scale_s.length());
qputenv("QT_SCALE_FACTOR", scaleAsQByteArray);
qDebug()<<"Storing settings at ["<<settings.fileName()<<"]";

// https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph-renderer.html
//qputenv("QSG_VISUALIZE", "overdraw");
Expand All @@ -234,10 +232,20 @@ int main(int argc, char *argv[]) {
//QLoggingCategory::setFilterRules("qt.qpa.eglfs.*=true");
//QLoggingCategory::setFilterRules("qt.qpa.egl*=true");

// From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime
// Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to
// result in tripple buffering with unlimited fps, a bit "better" regarding latency than default.
if(settings.value("dev_set_swap_interval_zero",false).toBool()){
qDebug()<<"Request swap interval of 0";
QSurfaceFormat format=QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
}

QApplication app(argc, argv);
// Customize cursor if needed
QOpenHD::instance().customize_cursor_from_settings();
{
{ // This includes dpi adjustment
QScreen* screen=app.primaryScreen();
if(screen){
QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height());
Expand Down
4 changes: 3 additions & 1 deletion app/osd/horizonladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ HorizonLadder::HorizonLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
setRenderTarget(RenderTarget::FramebufferObject);

//m_font.setPixelSize(14);
m_font.setPointSize(14);
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE);
m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE);
}

void HorizonLadder::paint(QPainter* painter) {
Expand Down Expand Up @@ -500,5 +501,6 @@ 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);
m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
2 changes: 1 addition & 1 deletion app/osd/horizonladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public slots:

QFont m_font;

QFont m_fontAwesome = QFont("Font Awesome 5 Free", 15, QFont::Bold, false);
QFont m_fontAwesome = QFont("Font Awesome 5 Free", 11, QFont::Bold, false);
double m_custom_font_scale=1.0;
};
#endif //QOPENHD_HORIZON_LADDER
50 changes: 23 additions & 27 deletions app/telemetry/models/fcmavlinksystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,28 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg)
const double lat=static_cast<double>(global_position_int.lat) / 10000000.0;
const double lon=static_cast<double>(global_position_int.lon) / 10000000.0;
// This way we could also calculate the flight distance - but aparently, this results in slightly too small values
// (probably could be fixed by using a distance calculation method that is a better fit)
/*if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){
const auto added_distance_m=distance_between(m_lat,m_lon,lat,lon);
total_dist = total_dist + added_distance_m;
//qDebug() << "total distance" << total_dist;
set_flight_distance_m( total_dist);
}*/
double added_distance_m=0.0;
if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){
// kind of dumb to do this for the first few meters....whatever...
if (m_last_lat==0.0 && m_last_lon==0.0){
added_distance_m=distance_between(m_lat,m_lon,lat,lon);
}
else {
added_distance_m=distance_between(m_last_lat,m_last_lon,lat,lon);
}
qDebug() << "added_distance_m" << added_distance_m;
if (added_distance_m > 2.0){

total_dist = total_dist + added_distance_m;
//qDebug() << "total distance" << total_dist;
//in sitl large distance can still be erroniously generated with hdop<20
if (m_armed ){
set_flight_distance_m( total_dist);
set_last_lat(lat);
set_last_lon(lon);
}
}
}
set_lat(lat);
set_lon(lon);
set_boot_time(global_position_int.time_boot_ms);
Expand Down Expand Up @@ -280,7 +295,6 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg)
set_throttle(vfr_hud.throttle);
set_air_speed_meter_per_second(vfr_hud.airspeed);
set_ground_speed_meter_per_second(vfr_hud.groundspeed);
update_flight_distance_using_groundspeed();
// qDebug() << "Speed- ground " << speed;
auto vsi = vfr_hud.climb;
set_vertical_speed_indicator_mps(vsi);
Expand Down Expand Up @@ -521,25 +535,6 @@ void FCMavlinkSystem::updateFlightTimer() {
}
}

void FCMavlinkSystem::update_flight_distance_using_groundspeed() {
if (m_gps_hdop > 20 || m_lat == 0.0){
//do not pollute distance if we have bad data
return;
}
if (m_armed==true){
const auto elapsed_ms = flightTimeStart.elapsed();
const auto time_diff_ms = elapsed_ms - m_flight_distance_last_time_ms;
m_flight_distance_last_time_ms = elapsed_ms;
const auto time_diff_s =time_diff_ms / 1000.0;
const auto added_distance = m_ground_speed_meter_per_second * time_diff_s;
//qDebug() << "added distance" << added_distance;
total_dist = total_dist + added_distance;
//qDebug() << "total distance" << total_dist;
set_flight_distance_m( total_dist);
}
}


void FCMavlinkSystem::set_armed(bool armed) {
if(m_armed==armed)return; //there has been no change so exit
if (armed && !m_armed) {
Expand All @@ -550,6 +545,7 @@ void FCMavlinkSystem::set_armed(bool armed) {
* vehicle is disarmed, causing it to appear to stop in the UI.
*/
flightTimeStart.start();
set_flight_distance_m(0.0); //reset the flight distance
if (m_home_latitude == 0.0 || m_home_longitude == 0.0) {
//LocalMessage::instance()->showMessage("No Home Position in FCMavlinkSystem", 4);
// Not needed anymore after we just set the proper rate(s)
Expand Down
7 changes: 3 additions & 4 deletions app/telemetry/models/fcmavlinksystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class FCMavlinkSystem : public QObject
//
L_RO_PROP(double,lat,set_lat,0.0)
L_RO_PROP(double,lon,set_lon,0.0)
L_RO_PROP(double,last_lat,set_last_lat,0.0)
L_RO_PROP(double,last_lon,set_last_lon,0.0)
L_RO_PROP(int,satellites_visible,set_satellites_visible,0)
L_RO_PROP(double,gps_hdop,set_gps_hdop,-1)
L_RO_PROP(double,gps_vdop,set_gps_vdop,-1)
Expand Down Expand Up @@ -164,9 +166,6 @@ class FCMavlinkSystem : public QObject
void calculate_home_course();
// Updates the flight time by increasing the time when armed
void updateFlightTimer();
// Calculates the flght distance (dirty) by taking time delta and current speed into account
// replaced by using distance between lat,lon point(s) (this is a bit more accurate)
void update_flight_distance_using_groundspeed();
// Something something luke
void updateVehicleAngles();
// Something somethng luke
Expand Down Expand Up @@ -202,7 +201,7 @@ class FCMavlinkSystem : public QObject
double speed_last_time = 0.0;

qint64 m_flight_distance_last_time_ms= 0;
long total_dist= 0;
double total_dist= 0.0;

QElapsedTimer totalTime;
QElapsedTimer flightTimeStart;
Expand Down
10 changes: 10 additions & 0 deletions app/telemetry/settings/documentedparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ static std::map<std::string, void *> get_whitelisted_params()
ret["CONFIG_BOOT_AIR"]=nullptr;
ret[openhd::WB_MAX_FEC_BLOCK_SIZE_FOR_PLATFORM]=nullptr;
ret[openhd::WB_DEV_AIR_SET_HIGH_RETRANSMIT_COUNT]=nullptr;
// TX POWER Whitelisted, since they should be changed from the quick wizzard
ret[openhd::WB_TX_POWER_MILLI_WATT]=nullptr;
ret[openhd::WB_TX_POWER_MILLI_WATT_ARMED]=nullptr;
ret[openhd::WB_RTL8812AU_TX_PWR_IDX_OVERRIDE]=nullptr;
ret[openhd::WB_RTL8812AU_TX_PWR_IDX_ARMED]=nullptr;
// STBC / LDPC - Whitelisted, since they should be changed from the quick wizzard
ret[openhd::WB_ENABLE_LDPC]=nullptr;
ret[openhd::WB_ENABLE_STBC]=nullptr;
// Whitelisted since normally it should not be changed / has no effect anyways
ret[openhd::WB_ENABLE_SHORT_GUARD]=nullptr;
//ret[""]=nullptr;
return ret;
}
Expand Down
14 changes: 11 additions & 3 deletions app/telemetry/settings/frequencyhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance()
return instance;
}

QList<int> FrequencyHelper::get_frequencies(bool openhd_bands_only)
QList<int> FrequencyHelper::get_frequencies(int filter)
{
QList<int> ret;
if(openhd_bands_only){
if(filter==0){
auto tmp=openhd::get_openhd_channels_1_to_5();
for(auto& channel:tmp){
ret.push_back(channel.frequency);
Expand All @@ -24,7 +24,15 @@ QList<int> FrequencyHelper::get_frequencies(bool openhd_bands_only)
const auto frequency_items=openhd::get_all_channels_2G_5G();
for(auto& item:frequency_items){
if(item.is_legal_at_least_one_country){
ret.push_back(item.frequency);
if(filter==1){
if(item.frequency<3000){
ret.push_back(item.frequency);
}
}else{
if(item.frequency>3000){
ret.push_back(item.frequency);
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/telemetry/settings/frequencyhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject
public:
explicit FrequencyHelper(QObject *parent = nullptr);
static FrequencyHelper &instance();

Q_INVOKABLE QList<int> get_frequencies(bool openhd_bands_only);
// Filter: 0 - OpenHD 1-5 only, 1= all 2.4G freq, 2 = all 5.8G freq
Q_INVOKABLE QList<int> get_frequencies(int filter);
Q_INVOKABLE QList<int> get_frequencies_all_40Mhz();

Q_INVOKABLE bool get_frequency_radar(int frequency_mhz);
Expand Down
7 changes: 5 additions & 2 deletions app/util/qopenhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool QOpenHD::overwrite_settings_from_backup_file()

bool QOpenHD::reset_settings()
{
#ifdef __linux__
/*#ifdef __linux__
QSettings settings;
std::string file_name = settings.fileName().toStdString();
int result = remove(file_name.c_str());
Expand All @@ -213,7 +213,10 @@ bool QOpenHD::reset_settings()
qDebug() << "Error: Failed to delete file" << QString::fromStdString(file_name);
return false;
#endif
return false;
return false;*/
QSettings settings;
settings.clear();
return true;
}


Expand Down
8 changes: 4 additions & 4 deletions app/util/qrenderstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ void QRenderStats::registerOnWindow(QQuickWindow *window)
connect(window, &QQuickWindow::afterRenderPassRecording, this, &QRenderStats::m_QQuickWindow_afterRenderPassRecording, Qt::DirectConnection);
}

void QRenderStats::set_display_width_height(int width, int height)
void QRenderStats::set_screen_width_height(int width, int height)
{
std::stringstream ss;
ss<<width<<"x"<<height;
set_display_width_height_str(ss.str().c_str());
set_screen_width_height_str(ss.str().c_str());
}

void QRenderStats::set_window_width_height(int width, int height)
void QRenderStats::set_display_width_height(int width, int height)
{
std::stringstream ss;
ss<<width<<"x"<<height;
set_window_width_height_str(ss.str().c_str());
set_display_width_height_str(ss.str().c_str());
}

void QRenderStats::m_QQuickWindow_beforeRendering()
Expand Down
7 changes: 5 additions & 2 deletions app/util/qrenderstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
class QRenderStats : public QObject
{
Q_OBJECT
public:
L_RO_PROP(QString, main_render_stats, set_main_render_stats, "NA")
// It can be quite nice for debugging to see what resolution QOpenHD's main window is rendered at
// Resolution of the screen / display itself
L_RO_PROP(QString, display_width_height_str, set_display_width_height_str, "NA")
L_RO_PROP(QString, screen_width_height_str, set_screen_width_height_str, "NA")
// Resolution qopenhd is rendering at
L_RO_PROP(QString, window_width_height_str, set_window_width_height_str, "NA")
L_RW_PROP(int, window_width, set_window_width, -1)
L_RW_PROP(int, window_height, set_window_height, -1)
// Time QT spent "rendering", probably aka creating the GPU command buffer
L_RO_PROP(QString, qt_rendering_time, set_qt_rendering_time, "NA")
// Time QT spent "recording the render pass"
Expand All @@ -32,8 +35,8 @@ class QRenderStats : public QObject
void register_to_root_window(QQmlApplicationEngine& engine);
// Manually regster the QML window
void registerOnWindow(QQuickWindow* window);
void set_screen_width_height(int width,int height);
void set_display_width_height(int width,int height);
void set_window_width_height(int width,int height);
public slots:
void m_QQuickWindow_beforeRendering();
void m_QQuickWindow_afterRendering();
Expand Down
7 changes: 7 additions & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ ApplicationWindow {
width: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_height : m_window_width
height: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_width : m_window_height

onWidthChanged: {
_qrenderstats.set_window_width(width)
}
onHeightChanged: {
_qrenderstats.set_window_height(height)
}

contentOrientation: settings.general_screen_rotation===0 ? Qt.PortraitOrientation : Qt.LandscapeOrientation
contentItem.rotation: settings.general_screen_rotation

Expand Down
6 changes: 6 additions & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,11 @@
<file>video/SecondaryVideoGstreamerPane.qml</file>
<file>ui/elements/SettingsHeaderElement.qml</file>
<file>ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml</file>
<file>ui/configpopup/openhd_settings/OpenHDQuickPanel.qml</file>
<file>ui/elements/BaseHeaderItem.qml</file>
<file>ui/elements/ButtonIconInfo2.qml</file>
<file>ui/elements/CardBasic.qml</file>
<file>ui/elements/ButtonIconConnect.qml</file>
<file>ui/elements/SmallHeaderInfoRow.qml</file>
</qresource>
</RCC>
19 changes: 7 additions & 12 deletions qml/ui/configpopup/ConfigPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ import "status"
// Contains the selector on the left and a stack view for the panels on the right
Rectangle {
id: settings_form

// The connect is only needed when qopenhd is not running on the ground system itself (e.g. android)
property bool m_show_connect_option: true // _qopenhd.is_android()
//width: 1280
//height: 720
anchors.fill: parent
//width: parent.width * settings.screen_settings_overlay_size_percent / 100;
//height: parent.height * settings.screen_settings_overlay_size_percent / 100;
z: 4.0
color: "transparent"

// size of the elements in the left bar - e.g. what allows switching between all the tabs
property int left_sidebar_elements_height: 46
Expand Down Expand Up @@ -64,14 +68,6 @@ Rectangle {
}
}*/

//anchors.fill: parent
width: parent.width * settings.screen_settings_overlay_size_percent / 100;
height: parent.height * settings.screen_settings_overlay_size_percent / 100;

z: 4.0

color: "transparent"

Rectangle {
id: spacerTopSpacer
width: 132
Expand Down Expand Up @@ -210,7 +206,6 @@ Rectangle {
// We only need the connect panel on android (external device)
// On localhost, QOpenHD "automatically" connects due to udp localhost method
ConfigPopupSidebarButton{
visible: m_show_connect_option
id: connect_button
m_icon_text: "\uf6ff"
m_description_text: "Connect"
Expand Down
Loading
Loading