mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
ui_task: initial gps page
This commit is contained in:
parent
ea13fa899e
commit
76aa7cf488
8 changed files with 74 additions and 4 deletions
|
|
@ -75,6 +75,9 @@ class HomeScreen : public UIScreen {
|
|||
RADIO,
|
||||
BLUETOOTH,
|
||||
ADVERT,
|
||||
#if UI_GPS_PAGE == 1
|
||||
GPS,
|
||||
#endif
|
||||
#if UI_SENSORS_PAGE == 1
|
||||
SENSORS,
|
||||
#endif
|
||||
|
|
@ -250,6 +253,47 @@ public:
|
|||
display.setColor(DisplayDriver::GREEN);
|
||||
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
|
||||
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
|
||||
#if UI_GPS_PAGE == 1
|
||||
} else if (_page == HomePage::GPS) {
|
||||
LocationProvider* nmea = sensors.getLocationProvider();
|
||||
int y = 18;
|
||||
display.setCursor(0, y);
|
||||
display.print(_task->getGPSState() ? "gps on" : "gps off");
|
||||
if (nmea == NULL) {
|
||||
y = y + 12;
|
||||
display.setCursor(0, y);
|
||||
display.print("Can't access GPS");
|
||||
} else {
|
||||
char buf[50];
|
||||
strcpy(buf, nmea->isValid()?"fix":"no fix");
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("sat");
|
||||
sprintf(buf, "%d", nmea->satellitesCount());
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("pos");
|
||||
sprintf(buf, "%.4f %.4f",
|
||||
nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.);
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("alt");
|
||||
sprintf(buf, "%.2f", nmea->getAltitude()/1000.);
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
y = y + 12;
|
||||
}
|
||||
#endif
|
||||
#if UI_SENSORS_PAGE == 1
|
||||
} else if (_page == HomePage::SENSORS) {
|
||||
int y = 18;
|
||||
|
|
@ -364,6 +408,12 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#if UI_GPS_PAGE == 1
|
||||
if (c == KEY_ENTER && _page == HomePage::GPS) {
|
||||
_task->toggleGPS();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if UI_SENSORS_PAGE == 1
|
||||
if (c == KEY_ENTER && _page == HomePage::SENSORS) {
|
||||
_task->toggleGPS();
|
||||
|
|
@ -773,6 +823,18 @@ char UITask::handleTripleClick(char c) {
|
|||
return c;
|
||||
}
|
||||
|
||||
bool UITask::getGPSState() {
|
||||
if (_sensors != NULL) {
|
||||
int num = _sensors->getNumSettings();
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (strcmp(_sensors->getSettingName(i), "gps") == 0) {
|
||||
return !strcmp(_sensors->getSettingValue(i), "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UITask::toggleGPS() {
|
||||
if (_sensors != NULL) {
|
||||
// toggle GPS on/off
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public:
|
|||
bool isButtonPressed() const;
|
||||
|
||||
void toggleBuzzer();
|
||||
bool getGPSState();
|
||||
void toggleGPS();
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue