mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 21:25:46 +00:00
ui_task: initial gps page
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <CayenneLPP.h>
|
||||
#include "sensors/LocationProvider.h"
|
||||
|
||||
#define TELEM_PERM_BASE 0x01 // 'base' permission includes battery
|
||||
#define TELEM_PERM_LOCATION 0x02
|
||||
@@ -21,4 +22,5 @@ public:
|
||||
virtual const char* getSettingName(int i) const { return NULL; }
|
||||
virtual const char* getSettingValue(int i) const { return NULL; }
|
||||
virtual bool setSettingValue(const char* name, const char* value) { return false; }
|
||||
virtual LocationProvider* getLocationProvider() { return NULL; }
|
||||
};
|
||||
|
||||
@@ -39,6 +39,7 @@ protected:
|
||||
public:
|
||||
#if ENV_INCLUDE_GPS
|
||||
EnvironmentSensorManager(LocationProvider &location): _location(&location){};
|
||||
LocationProvider* getLocationProvider() { return _location; }
|
||||
#else
|
||||
EnvironmentSensorManager(){};
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,8 @@ public:
|
||||
virtual bool isValid() = 0;
|
||||
virtual long getTimestamp() = 0;
|
||||
virtual void sendSentence(const char * sentence);
|
||||
virtual void reset();
|
||||
virtual void begin();
|
||||
virtual void stop();
|
||||
virtual void loop();
|
||||
virtual void reset() = 0;
|
||||
virtual void begin() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void loop() = 0;
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D PIN_GPS_EN=GPS_EN
|
||||
-D PIN_GPS_RESET_ACTIVE=LOW
|
||||
-D TELEM_BME280_ADDRESS=0x77
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D BACKLIGHT_BTN=PIN_BUTTON2
|
||||
@@ -92,6 +93,7 @@ build_flags =
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
-D UI_SENSORS_PAGE=1
|
||||
-D UI_GPS_PAGE=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
LocationProvider* getLocationProvider() { return _nmea; }
|
||||
};
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
|
||||
@@ -55,6 +55,7 @@ build_flags = ${WioTrackerL1Eink.build_flags}
|
||||
; -D MESH_DEBUG=1
|
||||
-D UI_RECENT_LIST_SIZE=6
|
||||
-D UI_SENSORS_PAGE=1
|
||||
-D UI_GPS_PAGE=1
|
||||
build_src_filter = ${WioTrackerL1Eink.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
|
||||
Reference in New Issue
Block a user