Active data display in page skyview

This commit is contained in:
Thomas Hooge 2025-08-23 08:45:35 +02:00
parent c932724473
commit 0097a1eb1e
3 changed files with 59 additions and 17 deletions

View File

@ -4,23 +4,33 @@
#include "Pagedata.h" #include "Pagedata.h"
#include "OBP60Extensions.h" #include "OBP60Extensions.h"
#include <vector>
#include <algorithm> // for vector sorting
/* /*
* SkyView / Satellites * SkyView / Satellites
*/ */
class PageSkyView : public Page class PageSkyView : public Page
{ {
private:
GwBoatData *bd;
public: public:
PageSkyView(CommonData &common) : Page(common) PageSkyView(CommonData &common) : Page(common)
{ {
logger->logDebug(GwLog::LOG, "Instantiate PageSkyView"); // task name access is for example purpose only
TaskHandle_t currentTaskHandle = xTaskGetCurrentTaskHandle();
const char* taskName = pcTaskGetName(currentTaskHandle);
logger->logDebug(GwLog::LOG, "Instantiate PageSkyView in task '%s'", taskName);
} }
int handleKey(int key) { int handleKey(int key) {
// Code for keylock // return 0 to mark the key handled completely
// return the key to allow further action
if (key == 11) { if (key == 11) {
commonData->keylock = !commonData->keylock; commonData->keylock = !commonData->keylock;
return 0; // Commit the key return 0;
} }
return key; return key;
} }
@ -33,12 +43,25 @@ public:
setFlashLED(false); setFlashLED(false);
} }
#endif #endif
bd = pageData.api->getBoatData();
}; };
// Comparator function to sort by SNR
static bool compareBySNR(const GwSatInfo& a, const GwSatInfo& b) {
return a.SNR > b.SNR; // Sort in descending order
}
int displayPage(PageData &pageData) { int displayPage(PageData &pageData) {
// Logging boat values std::vector<GwSatInfo> sats;
logger->logDebug(GwLog::LOG, "Drawing at PageSkyView"); int nSat = bd->SatInfo->getNumSats();
logger->logDebug(GwLog::LOG, "Drawing at PageSkyView, %d satellites", nSat);
for (int i = 0; i < nSat; i++) {
sats.push_back(*bd->SatInfo->getAt(i));
}
std::sort(sats.begin(), sats.end(), compareBySNR);
// Draw page // Draw page
//*********************************************************** //***********************************************************
@ -49,6 +72,7 @@ public:
// current position // current position
epd->setFont(&Ubuntu_Bold8pt8b); epd->setFont(&Ubuntu_Bold8pt8b);
GwApi::BoatValue *bv_lat = pageData.values[0]; GwApi::BoatValue *bv_lat = pageData.values[0];
String sv_lat = commonData->fmt->formatValue(bv_lat, *commonData).svalue; String sv_lat = commonData->fmt->formatValue(bv_lat, *commonData).svalue;
//epd->setCursor(300, 40); //epd->setCursor(300, 40);
@ -108,21 +132,37 @@ public:
epd->setCursor(c.x - r + 2 , c.y + h / 2); epd->setCursor(c.x - r + 2 , c.y + h / 2);
epd->print("W"); epd->print("W");
// satellites epd->setFont(&Ubuntu_Bold8pt8b);
// show satellites in "map"
for (int i = 0; i < nSat; i++) {
float arad = sats[i].Azimut * M_PI / 180.0;
float erad = sats[i].Elevation * M_PI / 180.0;
uint16_t x = c.x + sin(arad) * erad * r;
uint16_t y = c.y + cos(arad) * erad * r;
epd->drawRect(x-4, y-4, 8, 8, commonData->fgcolor);
}
// Signal / Noise bars // Signal / Noise bars
epd->setFont(&Ubuntu_Bold8pt8b);
epd->setCursor(325, 34); epd->setCursor(325, 34);
epd->print("SNR"); epd->print("SNR");
epd->drawRect(270, 20, 125, 257, commonData->fgcolor); epd->drawRect(270, 20, 125, 257, commonData->fgcolor);
for (int i = 0; i < 12; i++) { int maxsat = std::min(nSat, 12);
for (int i = 0; i < maxsat; i++) {
uint16_t y = 29 + (i + 1) * 20; uint16_t y = 29 + (i + 1) * 20;
epd->setCursor(276, y); epd->setCursor(276, y);
char buffer[3]; char buffer[3];
snprintf(buffer, 3, "%02d", i+1); snprintf(buffer, 3, "%02d", static_cast<int>(sats[i].PRN));
epd->print(String(buffer)); epd->print(String(buffer));
epd->drawRect(305, y-12, 85, 14, commonData->fgcolor); epd->drawRect(305, y-12, 85, 14, commonData->fgcolor);
epd->setCursor(315, y);
// TODO SNR as number or as bar via mode key?
if (sats[i].SNR <= 100) {
// epd->print(sats[i].SNR);
epd->fillRect(307, y-10, int(81 * sats[i].SNR / 100.0), 10, commonData->fgcolor);
} else {
epd->print("n/a");
}
} }
return PAGE_UPDATE; return PAGE_UPDATE;

View File

@ -128,6 +128,7 @@ typedef struct{
//a base class that all pages must inherit from //a base class that all pages must inherit from
class Page{ class Page{
protected: protected:
// TODO Future: GwApi *api;
CommonData *commonData; CommonData *commonData;
GwConfigHandler *config; GwConfigHandler *config;
GwLog *logger; GwLog *logger;

View File

@ -122,7 +122,7 @@ void OBP60Init(GwApi *api){
typedef struct { typedef struct {
int page0 = 0; int page0 = 0;
QueueHandle_t queue; QueueHandle_t queue;
GwLog* logger = NULL; GwLog* logger = nullptr;
// GwApi* api = NULL; // GwApi* api = NULL;
uint sensitivity = 100; uint sensitivity = 100;
bool use_syspage = true; bool use_syspage = true;
@ -675,6 +675,7 @@ void OBP60Task(GwApi *api){
pages[i].page=description->creator(commonData); pages[i].page=description->creator(commonData);
pages[i].parameters.pageName=pageType; pages[i].parameters.pageName=pageType;
pages[i].parameters.pageNumber = i + 1; pages[i].parameters.pageNumber = i + 1;
pages[i].parameters.api = api;
LOG_DEBUG(GwLog::DEBUG,"found page %s for number %d",pageType.c_str(),i); LOG_DEBUG(GwLog::DEBUG,"found page %s for number %d",pageType.c_str(),i);
//fill in all the user defined parameters //fill in all the user defined parameters
for (int uid=0;uid<description->userParam;uid++){ for (int uid=0;uid<description->userParam;uid++){