Skip to content

Commit

Permalink
improve connect panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 25, 2023
1 parent ea63198 commit 4036632
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 56 deletions.
16 changes: 4 additions & 12 deletions app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,8 @@ MavlinkTelemetry &MavlinkTelemetry::instance()
void MavlinkTelemetry::start()
{
QSettings settings;
const bool dev_use_tcp = settings.value("dev_mavlink_via_tcp",false).toBool();
if(dev_use_tcp){
// TODO
}else{
// default, udp, passive (like QGC)
auto cb_udp=[this](mavlink_message_t msg){
process_mavlink_message(msg);
};
const auto ip="0.0.0.0"; //"127.0.0.1"
m_udp_connection=std::make_unique<UDPConnection>(ip,QOPENHD_GROUND_CLIENT_UDP_PORT_IN,cb_udp);
m_udp_connection->start();
}
// By default, we always use UDP / localhost mode.
enable_udp();
}

bool MavlinkTelemetry::sendMessage(mavlink_message_t msg){
Expand Down Expand Up @@ -228,6 +218,7 @@ void MavlinkTelemetry::add_tcp_connection_handler(QString ip)
};
m_tcp_connection=std::make_unique<TCPConnection>(ip.toStdString(),QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT,cb_tcp);
m_tcp_connection->start();
set_udp_localhost_mode_enabled(false);
}

void MavlinkTelemetry::enable_udp()
Expand All @@ -238,6 +229,7 @@ void MavlinkTelemetry::enable_udp()
auto cb_udp=[this](mavlink_message_t msg){
process_mavlink_message(msg);
};
set_udp_localhost_mode_enabled(true);
const auto ip="0.0.0.0"; //"127.0.0.1"
m_udp_connection=std::make_unique<UDPConnection>(ip,QOPENHD_GROUND_CLIENT_UDP_PORT_IN,cb_udp);
m_udp_connection->start();
Expand Down
1 change: 1 addition & 0 deletions app/telemetry/MavlinkTelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MavlinkTelemetry : public QObject
// A couple of stats exposed as QT properties
L_RO_PROP(int,telemetry_pps_in,set_telemetry_pps_in,-1)
L_RO_PROP(int,telemetry_bps_in,set_telemetry_bps_in,-1)
L_RO_PROP(bool,udp_localhost_mode_enabled,set_udp_localhost_mode_enabled,true)
//
private:
// We follow the same practice as QGrouncontroll: Listen for incoming data on a specific UDP port,
Expand Down
4 changes: 3 additions & 1 deletion qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
<file>ui/widgets/map/MapWidget.qml</file>
<file>ui/configpopup/status/StatusCardsColumn.qml</file>
<file>ui/configpopup/status/ActionsColumn.qml</file>
<file>ui/configpopup/connect/InfoPane.qml</file>
<file>ui/configpopup/connect/PaneUSBTether.qml</file>
<file>ui/configpopup/connect/PaneWIFI.qml</file>
<file>ui/configpopup/connect/PaneCustom.qml</file>
Expand All @@ -252,5 +251,8 @@
<file>ui/configpopup/status/QOpenHDVersionCard.qml</file>
<file>ui/elements/CardToast.qml</file>
<file>ui/elements/ButtonYellow.qml</file>
<file>ui/configpopup/connect/PaneLocalhost.qml</file>
<file>ui/configpopup/connect/PaneInfo.qml</file>
<file>ui/configpopup/connect/GenericInfoPane.qml</file>
</qresource>
</RCC>
52 changes: 10 additions & 42 deletions qml/ui/configpopup/connect/ConnectPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Item {
TabButton {
text: qsTr("INFO")
}
TabButton{
text: "LOCAL"
}
TabButton {
text: qsTr("USB Tether")
}
Expand All @@ -55,53 +58,18 @@ Item {
anchors.bottom: parent.bottom
currentIndex: selectItemInStackLayoutBar.currentIndex

Rectangle{
width: parent.width
height: parent.height
ColumnLayout{
anchors.fill: parent
spacing: 6
Text{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: 50
//width:parent.width
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignTop
text: "When running QOpenHD on an external device (e.g. android phone)\n"+
"you have to use one of the given choices to connect the device to the OpenHD ground station"
}
Text{
Layout.preferredHeight: 50
text: "You are already connected to your ground station - nothing to do."
color: "#706F1D" // dark green
visible: m_is_connected_gnd
}
Text{
Layout.preferredHeight: 50
text: "Looks like you are not connected to your ground station - please use one of the given choices to connect."
color: "red"
visible: !m_is_connected_gnd
}
Item{
Layout.fillHeight: true
// filler
}
}
}

/*InfoPane{
m_info_text: {
return "When running QOpenHD on an external device (e.g. android phone)\n"+
"you have to use one of the given choices to connect the device to the OpenHD ground station"
}
}*/
PaneInfo{
}

PaneLocalhost{
}

PaneUSBTether{
id: pane_usb_tether
}

InfoPane{
GenericInfoPane{
m_info_text: {
return"1) Make sure ETH_HOTSPOT_E is disabled (Ground param)\n\n"+
"2) Enable ETH_PASSIVE_F on your openhd ground unit (Ground param)\n\n"+
Expand All @@ -110,7 +78,7 @@ Item {
"Video and telemetry forwarding should start automatically, and your GCS can get internet from your phone."
}
}
InfoPane{
GenericInfoPane{
m_info_text: {
return "1) Make sure ETH_PASSIVE_F is disabled (Ground param)\n\n"+
"2) Enable ETH_HOTSPOT_E on your openhd ground unit (Ground param)\n\n"+
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion qml/ui/configpopup/connect/PaneCustom.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Rectangle {
height: parent.height
//color: "green"

property string m_info_text: "CUSTOM"
property string m_info_text: "ADVANCED - Connect to a ground station (running OpenHD core) located anywhere in your network using TCP.\n"+
"After connecting (mavlink) via TCP, video will also be streamed to this device (using UDP)."

ColumnLayout{
anchors.fill: parent

spacing: 6

Text{
Layout.alignment: Qt.AlignTop
width:parent.width
Expand Down
47 changes: 47 additions & 0 deletions qml/ui/configpopup/connect/PaneInfo.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.0
import QtQuick.Controls.Material 2.12

import Qt.labs.settings 1.0

import OpenHD 1.0

import "../../../ui" as Ui
import "../../elements"

Rectangle{
width: parent.width
height: parent.height
ColumnLayout{
anchors.fill: parent
spacing: 6
Text{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: 50
//width:parent.width
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignTop
text: "When running QOpenHD on an external device (e.g. android phone)\n"+
"you have to use one of the given choices to connect the device to the OpenHD ground station"
}
Text{
Layout.preferredHeight: 50
text: "You are already connected to your ground station - nothing to do."
color: "#706F1D" // dark green
visible: m_is_connected_gnd
}
Text{
Layout.preferredHeight: 50
text: "Looks like you are not connected to your ground station - please use one of the given choices to connect."
color: "red"
visible: !m_is_connected_gnd
}
Item{
Layout.fillHeight: true
// filler
}
}
}
52 changes: 52 additions & 0 deletions qml/ui/configpopup/connect/PaneLocalhost.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.0
import QtQuick.Controls.Material 2.12

import Qt.labs.settings 1.0

import OpenHD 1.0

import "../../../ui" as Ui
import "../../elements"

Rectangle {
width: parent.width
height: parent.height
//color: "green"

property string m_info_text: "Use this mode if you are running QOpenHD on your ground station itself - e.g. if you are using a RPI as ground station and connected
a display via HDMI to your ground station, or x86 and running OpenHD Core and QOpenHD on the same system."+
"In this mode, QOpenHD uses UDP localhost to communicate with OpenHD core via mavlink (lowest latency and best performance).
However, if you are running QOpenHD as an app on an external device (e.g. your android phone) you have to use the appropiate connection page and its description to
connect QOpenHD to your ground station."

property bool m_local_mode_enabled: _mavlinkTelemetry.udp_localhost_mode_enabled

ColumnLayout{
anchors.fill: parent

spacing: 6
Text{
Layout.fillWidth: true
Layout.preferredHeight: 200
//Layout.alignment: Qt.AlignTop
//width:parent.width
wrapMode: Text.WordWrap
text: m_info_text
}
Button{
text: m_local_mode_enabled ? "LOCAL MODE ACTIVE" : "ENABLE LOCAL MODE"
onClicked: {
_mavlinkTelemetry.enable_udp()
}
enabled: !m_local_mode_enabled
}
// filler
Item{
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
21 changes: 21 additions & 0 deletions qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import OpenHD 1.0
import "../../../ui" as Ui
import "../../elements"

import QtCharts 2.0

// This is an extra screen for changing the frequency / channel width -
// They both need to match !
Rectangle{
Expand Down Expand Up @@ -97,6 +99,10 @@ Rectangle{
create_list_model_supported();
}

function update_pollution_graph(){

}

//
Component.onCompleted: {

Expand Down Expand Up @@ -629,6 +635,21 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur
text: _wbLinkSettingsHelper.text_for_qml
}
}
ChartView {
title: "Bar series"
width: parent.width
height: rowHeight * 3
legend.alignment: Qt.AlignBottom
antialiasing: true

PercentBarSeries {
id: hm_bar_series
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
}
}
}
}
}
Expand Down

0 comments on commit 4036632

Please sign in to comment.