Skip to content

Commit

Permalink
improve UI if card sub type is known
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Apr 16, 2024
1 parent 473f7cf commit cb832ee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions app/telemetry/models/wificard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void WiFiCard::process_mavlink(const mavlink_openhd_stats_monitor_mode_wifi_card
bool supported = false;
if(card_type==0 || card_type==1)supported=true;
set_card_type_supported(supported);
set_card_sub_type(msg.dummy2);
}

int WiFiCard::helper_get_gnd_curr_best_rssi()
Expand Down
3 changes: 3 additions & 0 deletions app/telemetry/models/wificard.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class WiFiCard : public QObject
L_RO_PROP(int,card_type_supported,set_card_type_supported,false)
// exta
L_RO_PROP(int,card_sub_type,set_card_sub_type,-1)
public:
L_RO_PROP(int,mWIFI_CARD_SUB_TYPE_RTL8812AU_ASUS,unused_WIFI_CARD_SUB_TYPE_RTL8812AU_ASUS,1)
L_RO_PROP(int,mWIFI_CARD_SUB_TYPE_RTL8812AU_X20,unused_WIFI_CARD_SUB_TYPE_RTL8812AU_X20,2)
public:
explicit WiFiCard(bool is_air,int card_idx,QObject *parent = nullptr);
static constexpr int N_CARDS=4;
Expand Down
43 changes: 22 additions & 21 deletions qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,31 @@ PopupBigGeneric{
_messageBoxInstance.set_text_and_show("Changing tx power is only possible on openhd supported cards.");
return;
}
// The user has to enter the card type every time - otherwise, we have issues with air and ground
comboBoxCardSelectManufacturer.currentIndex=0;
combo_box_txpower_disarmed.currentIndex=0;
combo_box_txpower_armed.currentIndex=0;
comboBoxCardSelectManufacturer.model= get_model_manufacturer_for_chip_type()

const card_sub_type=m_is_air ? _wifi_card_air.card_sub_type : _wifi_card_gnd0.card_sub_type
if(card_sub_type==10){
// rtl8812 x20
if(card_sub_type==_wifi_card_air.mWIFI_CARD_SUB_TYPE_RTL8812AU_ASUS){
// rtl8812 ASUS
m_user_selected_card_manufacturer=2;
m_card_type_provided_by_openhd=true;
}else if(card_sub_type==_wifi_card_air.mWIFI_CARD_SUB_TYPE_RTL8812AU_X20){
// rtl8812 x20
m_user_selected_card_manufacturer=3;
m_card_type_provided_by_openhd=true;
}else{
// User has to set the card type ...
// we don't know the card type .. user has to set it
m_user_selected_card_manufacturer=-1;
m_card_type_provided_by_openhd=false;
}
// The user has to enter the card type every time - otherwise, we have issues with air and ground
if(m_user_selected_card_manufacturer>=0){
comboBoxCardSelectManufacturer.currentIndex=m_user_selected_card_manufacturer;
}else{
comboBoxCardSelectManufacturer.currentIndex=0;
}
combo_box_txpower_disarmed.currentIndex=0;
combo_box_txpower_armed.currentIndex=0;

visible=true;
enabled=true;
}
Expand All @@ -74,19 +84,10 @@ PopupBigGeneric{
return _wifi_card_gnd0.card_type;
}

function get_card_chipset_str(){
var chipset=get_chipset_type();
if(chipset==0){
return "RTL88XXAU";
}else if(chipset==1){
return "RTL88XXBU";
}
return "ERROR";
}
// Should never show up !
ListModel{
id: model_error
ListElement {title: "Not Enabled"; value: -1}
id: model_manufacturer_unknown_chipset
ListElement {title: "Unknown chipset"; value: -1}
}

ListModel{
Expand All @@ -111,7 +112,7 @@ PopupBigGeneric{
}else if(chip_type==1){
return model_rtl8812bu_manufacturers;
}
return model_error;
return model_manufacturer_unknown_chipset;
}

// TX power choices for each chipset / manufacturer
Expand Down Expand Up @@ -184,7 +185,7 @@ PopupBigGeneric{
var chip_type=get_chipset_type();
var manufacturer=m_user_selected_card_manufacturer;
if(manufacturer<0){
return model_error;
return model_manufacturer_unknown_chipset;
}
var ret;
if(chip_type==0){
Expand Down Expand Up @@ -263,7 +264,7 @@ PopupBigGeneric{
id: comboBoxCardSelectManufacturer
Layout.minimumWidth: 180
Layout.preferredWidth: 480
model: get_model_manufacturer_for_chip_type()
model: model_manufacturer_unknown_chipset
textRole: "title"
onCurrentIndexChanged: {
var manufacturer = comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value;
Expand Down

0 comments on commit cb832ee

Please sign in to comment.