feat(color): GPS QR code locator tool (#6431)

This commit is contained in:
3djc
2025-07-10 08:32:05 +10:00
committed by GitHub
parent 5cb5de6470
commit 93f2895bf0
27 changed files with 216 additions and 5 deletions
+1
View File
@@ -97,6 +97,7 @@ set(GUI_SRC
radio/radio_tools.cpp
radio/radio_trainer.cpp
radio/radio_version.cpp
radio/radio_gps_tool.cpp
)
macro(add_gui_src src)
+8 -2
View File
@@ -371,7 +371,13 @@ QRCode::QRCode(Window *parent, coord_t x, coord_t y, coord_t sz, std::string dat
LcdFlags color, LcdFlags bgColor) :
Window(parent, {x, y, sz, sz})
{
auto qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor));
lv_qrcode_update(qr, data.c_str(), data.length());
qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor));
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setData(data);
}
void QRCode::setData(std::string data)
{
if (qr)
lv_qrcode_update(qr, data.c_str(), data.length());
}
+3
View File
@@ -216,5 +216,8 @@ class QRCode : public Window
std::string getName() const override { return "QRCode"; }
#endif
void setData(std::string data);
protected:
lv_obj_t* qr = nullptr;
};
@@ -0,0 +1,78 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "radio_gps_tool.h"
#include "edgetx.h"
RadioGpsTool::RadioGpsTool() :
Page(ICON_RADIO_TOOLS)
{
init();
buildHeader(header);
buildBody(body);
}
void RadioGpsTool::buildHeader(Window* window)
{
header->setTitle(STR_MENUTOOLS);
header->setTitle2(STR_GPS_MODEL_LOCATOR);
}
void RadioGpsTool::buildBody(Window* window)
{
window->padAll(PAD_ZERO);
gpsLabel = new StaticText(window, {PAD_LARGE, PAD_LARGE, LV_SIZE_CONTENT, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L));
gpsQR = new QRCode(window, (window->width() - QR_SZ) / 2, (window->height() - QR_SZ) / 2, QR_SZ, "");
new TextButton(window,
{window->width() - BTN_SZ - PAD_LARGE * 2, window->height() - EdgeTxStyles::UI_ELEMENT_HEIGHT - PAD_LARGE * 2, BTN_SZ, 0},
STR_REFRESH, [=]() {
refresh();
return 0;
});
refresh();
}
void RadioGpsTool::init()
{
gpsSensorID = -1;
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
if (isGPSSensor(i+1)) {
gpsSensorID = i;
return;
}
}
}
void RadioGpsTool::refresh()
{
if (gpsSensorID >= 0) {
static TelemetryItem& gpsItem = telemetryItems[gpsSensorID];
char gps_uri[64];
snprintf(gps_uri, sizeof(gps_uri), "geo:%f,%f", (float)gpsItem.gps.latitude / 1000000, (float)gpsItem.gps.longitude / 1000000);
gpsQR->setData(gps_uri);
gpsQR->show();
gpsLabel->setText(getGPSSensorValue(gpsItem, 0));
} else {
gpsQR->hide();
gpsLabel->setText(STR_NODATA);
}
}
@@ -0,0 +1,43 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "page.h"
class RadioGpsTool: public Page
{
public:
explicit RadioGpsTool();
protected:
int8_t gpsSensorID;
StaticText* gpsLabel = nullptr;
QRCode* gpsQR = nullptr;
static LAYOUT_VAL_SCALED(QR_SZ, 150)
static LAYOUT_VAL_SCALED(BTN_SZ, 80)
void buildHeader(Window * window);
void buildBody(Window * window);
void init();
void refresh();
};
+20 -3
View File
@@ -29,6 +29,7 @@
#include "edgetx.h"
#include "radio_ghost_module_config.h"
#include "radio_spectrum_analyser.h"
#include "radio_gps_tool.h"
#include "standalone_lua.h"
#include "etx_lv_theme.h"
@@ -140,6 +141,19 @@ static void scanLuaTools(std::list<ToolEntry>& scripts)
}
#endif
static bool isModelGPSSensorPresent()
{
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
if (isGPSSensor(i+1)) return true;
}
return false;
}
static void run_gpstool(Window* parent, const std::string&)
{
new RadioGpsTool();
}
#if defined(PXX2) || defined(MULTIMODULE)
#if defined(HARDWARE_INTERNAL_MODULE)
@@ -242,19 +256,22 @@ void RadioToolsPage::rebuild(Window* window)
}
#endif
if (isModelGPSSensorPresent())
tools.emplace_back(ToolEntry{STR_GPS_MODEL_LOCATOR, "", run_gpstool});
#if defined(HARDWARE_INTERNAL_MODULE)
if (intSpecAnalyser)
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int});
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_INT, "", run_spektrum_int});
#endif
#if defined(HARDWARE_EXTERNAL_MODULE)
if (extSpecAnalyser)
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext});
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_EXT, "", run_spektrum_ext});
#endif
#if defined(GHOST)
if (isModuleGhost(EXTERNAL_MODULE)) {
tools.emplace_back(ToolEntry{"Ghost module config", {}, run_ghost_config});
tools.emplace_back(ToolEntry{STR_GHOST_MODULE_CONFIG, "", run_ghost_config});
}
#endif
+3
View File
@@ -488,6 +488,9 @@ const char STR_POWER_METER_EXT[] = TR_POWER_METER_EXT;
const char STR_POWER_METER_INT[] = TR_POWER_METER_INT;
const char STR_SPECTRUM_ANALYSER_EXT[] = TR_SPECTRUM_ANALYSER_EXT;
const char STR_SPECTRUM_ANALYSER_INT[] = TR_SPECTRUM_ANALYSER_INT;
const char STR_GHOST_MODULE_CONFIG[] = TR_GHOST_MODULE_CONFIG;
const char STR_GPS_MODEL_LOCATOR[] = TR_GPS_MODEL_LOCATOR;
const char STR_REFRESH[] = TR_REFRESH;
const char STR_WAITING_FOR_RX[] = TR_WAITING_FOR_RX;
const char STR_WAITING_FOR_TX[] = TR_WAITING_FOR_TX;
const char STR_WAITING_FOR_MODULE[] = TR_WAITING_FOR_MODULE;
+3
View File
@@ -707,6 +707,9 @@ extern const char STR_POWER_METER_EXT[];
extern const char STR_POWER_METER_INT[];
extern const char STR_SPECTRUM_ANALYSER_EXT[];
extern const char STR_SPECTRUM_ANALYSER_INT[];
extern const char STR_GHOST_MODULE_CONFIG[];
extern const char STR_GPS_MODEL_LOCATOR[];
extern const char STR_REFRESH[];
extern const char STR_WAITING_FOR_RX[];
extern const char STR_WAITING_FOR_TX[];
extern const char STR_WAITING_FOR_MODULE[];
+3
View File
@@ -647,6 +647,9 @@
#define TR_POWER_METER_INT "功率计 (内置)"
#define TR_SPECTRUM_ANALYSER_EXT "频谱仪 (外置)"
#define TR_SPECTRUM_ANALYSER_INT "频谱仪 (内置)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD卡已满"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\n日志和截屏功能将被禁用"
+3
View File
@@ -658,6 +658,9 @@
#define TR_POWER_METER_INT "Měřič výkonu (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spektální an. (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spektální an. (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "Plná karta SD"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogování dat a snímky obrazovky vypnuty"
+3
View File
@@ -651,6 +651,9 @@
#define TR_POWER_METER_INT "Strøm meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD kort fuldt"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLog & skærmklip deaktiveret"
+3
View File
@@ -646,6 +646,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD-Karte voll"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs und Screenshots deaktiviert"
+3
View File
@@ -651,6 +651,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD card full"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs and Screenshots disabled"
+3
View File
@@ -642,6 +642,9 @@
#define TR_POWER_METER_INT "Medidor potencia(INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Espectro (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Espectro (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD Card llena"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs and Screenshots disabled"
+3
View File
@@ -656,6 +656,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD Card Full"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs and Screenshots disabled"
+3
View File
@@ -649,6 +649,9 @@
#define TR_POWER_METER_INT "Puissancemètre (INT)"
#define TR_SPECTRUM_ANALYSER_EXT TR("Spectre (EXT)", "Analyseur Spectre (EXT)")
#define TR_SPECTRUM_ANALYSER_INT TR("Spectre (INT)", "Analyseur Spectre (INT)")
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD carte pleine"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nJournaux et Impr. écran désactivé"
+3
View File
@@ -650,6 +650,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "הדיסק מלא״"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\לוגים ושמירת צילומי מסך מושבתים"
+3
View File
@@ -651,6 +651,9 @@
#define TR_POWER_METER_INT "Meter Potenza (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spettro (EST)"
#define TR_SPECTRUM_ANALYSER_INT "Spettro (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SDCard piena"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs e Screenshots disattivati"
+3
View File
@@ -650,6 +650,9 @@
#define TR_POWER_METER_INT "出力メーター\n(内部)"
#define TR_SPECTRUM_ANALYSER_EXT "スペクトラム\n(外部)"
#define TR_SPECTRUM_ANALYSER_INT "スペクトラム\n(内部)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SDカード空き容量なし"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nログとスクリーンショット保存が無効"
+3
View File
@@ -694,6 +694,9 @@
#define TR_POWER_METER_INT "전력 측정기 (내부)"
#define TR_SPECTRUM_ANALYSER_EXT "스펙트럼 분석 (외부)"
#define TR_SPECTRUM_ANALYSER_INT "스펙트럼 분석 (내부)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD 카드가 가득 찼습니다"
#if defined(COLORLCD)
+3
View File
@@ -643,6 +643,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD-Kaart vol"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs and Screenshots disabled"
+3
View File
@@ -644,6 +644,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spectrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spectrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "Pełna karta SD"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogi i zrzuty ekranu wyłączone"
+3
View File
@@ -654,6 +654,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Espectro (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Espectro (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "Cart SD cheio"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLogs e captura de tela desativados"
+3
View File
@@ -655,6 +655,9 @@
#define TR_POWER_METER_INT "Изм мощност (Внут)"
#define TR_SPECTRUM_ANALYSER_EXT "Спек анализ (Внеш)"
#define TR_SPECTRUM_ANALYSER_INT "Спек анализ (Внут)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD карта заполнена"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nЛоги и скриншоты откл"
+3
View File
@@ -665,6 +665,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Spektrum (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Spektrum (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD-kortet fullt"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nLoggar och skärmklipp inaktiverade"
+3
View File
@@ -651,6 +651,9 @@
#define TR_POWER_METER_INT "功率計 (內置)"
#define TR_SPECTRUM_ANALYSER_EXT "頻譜儀 (外置)"
#define TR_SPECTRUM_ANALYSER_INT "頻譜儀 (內置)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD卡已滿"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\n日誌和截屏功能將被禁用"
+3
View File
@@ -653,6 +653,9 @@
#define TR_POWER_METER_INT "Power Meter (INT)"
#define TR_SPECTRUM_ANALYSER_EXT "Спектр (EXT)"
#define TR_SPECTRUM_ANALYSER_INT "Спектр (INT)"
#define TR_GHOST_MODULE_CONFIG "Ghost module config"
#define TR_GPS_MODEL_LOCATOR "GPS model locator"
#define TR_REFRESH "Refresh"
#define TR_SDCARD_FULL "SD карта повна"
#if defined(COLORLCD)
#define TR_SDCARD_FULL_EXT TR_SDCARD_FULL "\nЛоги і скріншоти вимкнені"