diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 248b9bd5..c48c6972 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -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 diff --git a/examples/companion_radio/ui-new/UITask.h b/examples/companion_radio/ui-new/UITask.h index 5a087eeb..c24d33a4 100644 --- a/examples/companion_radio/ui-new/UITask.h +++ b/examples/companion_radio/ui-new/UITask.h @@ -71,6 +71,7 @@ public: bool isButtonPressed() const; void toggleBuzzer(); + bool getGPSState(); void toggleGPS(); diff --git a/src/helpers/SensorManager.h b/src/helpers/SensorManager.h index 0e4bc27d..1ace6220 100644 --- a/src/helpers/SensorManager.h +++ b/src/helpers/SensorManager.h @@ -1,6 +1,7 @@ #pragma once #include +#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; } }; diff --git a/src/helpers/sensors/EnvironmentSensorManager.h b/src/helpers/sensors/EnvironmentSensorManager.h index 3302d6f6..09c6cae4 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.h +++ b/src/helpers/sensors/EnvironmentSensorManager.h @@ -39,6 +39,7 @@ protected: public: #if ENV_INCLUDE_GPS EnvironmentSensorManager(LocationProvider &location): _location(&location){}; + LocationProvider* getLocationProvider() { return _location; } #else EnvironmentSensorManager(){}; #endif diff --git a/src/helpers/sensors/LocationProvider.h b/src/helpers/sensors/LocationProvider.h index f51eea28..f93dec48 100644 --- a/src/helpers/sensors/LocationProvider.h +++ b/src/helpers/sensors/LocationProvider.h @@ -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; }; diff --git a/variants/lilygo_techo/platformio.ini b/variants/lilygo_techo/platformio.ini index e814ea54..b5e94b2d 100644 --- a/variants/lilygo_techo/platformio.ini +++ b/variants/lilygo_techo/platformio.ini @@ -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 diff --git a/variants/t1000-e/target.h b/variants/t1000-e/target.h index 6ac0d3a6..27351b94 100644 --- a/variants/t1000-e/target.h +++ b/variants/t1000-e/target.h @@ -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 diff --git a/variants/wio-tracker-l1-eink/platformio.ini b/variants/wio-tracker-l1-eink/platformio.ini index a41e9e23..db22c01b 100644 --- a/variants/wio-tracker-l1-eink/platformio.ini +++ b/variants/wio-tracker-l1-eink/platformio.ini @@ -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} + +