Merge pull request #821 from fdlamotte/ui_gps_page
ui_task: initial gps page
This commit is contained in:
@@ -75,6 +75,9 @@ class HomeScreen : public UIScreen {
|
|||||||
RADIO,
|
RADIO,
|
||||||
BLUETOOTH,
|
BLUETOOTH,
|
||||||
ADVERT,
|
ADVERT,
|
||||||
|
#if ENV_INCLUDE_GPS == 1
|
||||||
|
GPS,
|
||||||
|
#endif
|
||||||
#if UI_SENSORS_PAGE == 1
|
#if UI_SENSORS_PAGE == 1
|
||||||
SENSORS,
|
SENSORS,
|
||||||
#endif
|
#endif
|
||||||
@@ -170,7 +173,7 @@ public:
|
|||||||
|
|
||||||
// curr page indicator
|
// curr page indicator
|
||||||
int y = 14;
|
int y = 14;
|
||||||
int x = display.width() / 2 - 25;
|
int x = display.width() / 2 - 5 * (HomePage::Count-1);
|
||||||
for (uint8_t i = 0; i < HomePage::Count; i++, x += 10) {
|
for (uint8_t i = 0; i < HomePage::Count; i++, x += 10) {
|
||||||
if (i == _page) {
|
if (i == _page) {
|
||||||
display.fillRect(x-1, y-1, 3, 3);
|
display.fillRect(x-1, y-1, 3, 3);
|
||||||
@@ -250,6 +253,34 @@ public:
|
|||||||
display.setColor(DisplayDriver::GREEN);
|
display.setColor(DisplayDriver::GREEN);
|
||||||
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
|
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
|
||||||
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
|
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
|
||||||
|
#if ENV_INCLUDE_GPS == 1
|
||||||
|
} else if (_page == HomePage::GPS) {
|
||||||
|
LocationProvider* nmea = sensors.getLocationProvider();
|
||||||
|
int y = 18;
|
||||||
|
display.drawTextLeftAlign(0, y, _task->getGPSState() ? "gps on" : "gps off");
|
||||||
|
if (nmea == NULL) {
|
||||||
|
y = y + 12;
|
||||||
|
display.drawTextLeftAlign(0, y, "Can't access GPS");
|
||||||
|
} else {
|
||||||
|
char buf[50];
|
||||||
|
strcpy(buf, nmea->isValid()?"fix":"no fix");
|
||||||
|
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||||
|
y = y + 12;
|
||||||
|
display.drawTextLeftAlign(0, y, "sat");
|
||||||
|
sprintf(buf, "%d", nmea->satellitesCount());
|
||||||
|
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||||
|
y = y + 12;
|
||||||
|
display.drawTextLeftAlign(0, y, "pos");
|
||||||
|
sprintf(buf, "%.4f %.4f",
|
||||||
|
nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.);
|
||||||
|
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||||
|
y = y + 12;
|
||||||
|
display.drawTextLeftAlign(0, y, "alt");
|
||||||
|
sprintf(buf, "%.2f", nmea->getAltitude()/1000.);
|
||||||
|
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||||
|
y = y + 12;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if UI_SENSORS_PAGE == 1
|
#if UI_SENSORS_PAGE == 1
|
||||||
} else if (_page == HomePage::SENSORS) {
|
} else if (_page == HomePage::SENSORS) {
|
||||||
int y = 18;
|
int y = 18;
|
||||||
@@ -364,6 +395,12 @@ public:
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if ENV_INCLUDE_GPS == 1
|
||||||
|
if (c == KEY_ENTER && _page == HomePage::GPS) {
|
||||||
|
_task->toggleGPS();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if UI_SENSORS_PAGE == 1
|
#if UI_SENSORS_PAGE == 1
|
||||||
if (c == KEY_ENTER && _page == HomePage::SENSORS) {
|
if (c == KEY_ENTER && _page == HomePage::SENSORS) {
|
||||||
_task->toggleGPS();
|
_task->toggleGPS();
|
||||||
@@ -773,6 +810,18 @@ char UITask::handleTripleClick(char c) {
|
|||||||
return 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() {
|
void UITask::toggleGPS() {
|
||||||
if (_sensors != NULL) {
|
if (_sensors != NULL) {
|
||||||
// toggle GPS on/off
|
// toggle GPS on/off
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public:
|
|||||||
bool isButtonPressed() const;
|
bool isButtonPressed() const;
|
||||||
|
|
||||||
void toggleBuzzer();
|
void toggleBuzzer();
|
||||||
|
bool getGPSState();
|
||||||
void toggleGPS();
|
void toggleGPS();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <CayenneLPP.h>
|
#include <CayenneLPP.h>
|
||||||
|
#include "sensors/LocationProvider.h"
|
||||||
|
|
||||||
#define TELEM_PERM_BASE 0x01 // 'base' permission includes battery
|
#define TELEM_PERM_BASE 0x01 // 'base' permission includes battery
|
||||||
#define TELEM_PERM_LOCATION 0x02
|
#define TELEM_PERM_LOCATION 0x02
|
||||||
@@ -21,4 +22,5 @@ public:
|
|||||||
virtual const char* getSettingName(int i) const { return NULL; }
|
virtual const char* getSettingName(int i) const { return NULL; }
|
||||||
virtual const char* getSettingValue(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 bool setSettingValue(const char* name, const char* value) { return false; }
|
||||||
|
virtual LocationProvider* getLocationProvider() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
EnvironmentSensorManager(LocationProvider &location): _location(&location){};
|
EnvironmentSensorManager(LocationProvider &location): _location(&location){};
|
||||||
|
LocationProvider* getLocationProvider() { return _location; }
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager(){};
|
EnvironmentSensorManager(){};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public:
|
|||||||
virtual bool isValid() = 0;
|
virtual bool isValid() = 0;
|
||||||
virtual long getTimestamp() = 0;
|
virtual long getTimestamp() = 0;
|
||||||
virtual void sendSentence(const char * sentence);
|
virtual void sendSentence(const char * sentence);
|
||||||
virtual void reset();
|
virtual void reset() = 0;
|
||||||
virtual void begin();
|
virtual void begin() = 0;
|
||||||
virtual void stop();
|
virtual void stop() = 0;
|
||||||
virtual void loop();
|
virtual void loop() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ public:
|
|||||||
setCursor(mid_x - w/2, y);
|
setCursor(mid_x - w/2, y);
|
||||||
print(str);
|
print(str);
|
||||||
}
|
}
|
||||||
|
virtual void drawTextRightAlign(int x_anch, int y, const char* str) {
|
||||||
|
int w = getTextWidth(str);
|
||||||
|
setCursor(x_anch - w, y);
|
||||||
|
print(str);
|
||||||
|
}
|
||||||
|
virtual void drawTextLeftAlign(int x_anch, int y, const char* str) {
|
||||||
|
setCursor(x_anch, y);
|
||||||
|
print(str);
|
||||||
|
}
|
||||||
|
|
||||||
// convert UTF-8 characters to displayable block characters for compatibility
|
// convert UTF-8 characters to displayable block characters for compatibility
|
||||||
virtual void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) {
|
virtual void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ build_flags = ${nrf52_base.build_flags}
|
|||||||
-D ENV_INCLUDE_BME280=1
|
-D ENV_INCLUDE_BME280=1
|
||||||
-D GPS_BAUD_RATE=9600
|
-D GPS_BAUD_RATE=9600
|
||||||
-D PIN_GPS_EN=GPS_EN
|
-D PIN_GPS_EN=GPS_EN
|
||||||
|
-D PIN_GPS_RESET_ACTIVE=LOW
|
||||||
-D TELEM_BME280_ADDRESS=0x77
|
-D TELEM_BME280_ADDRESS=0x77
|
||||||
-D DISPLAY_CLASS=GxEPDDisplay
|
-D DISPLAY_CLASS=GxEPDDisplay
|
||||||
-D BACKLIGHT_BTN=PIN_BUTTON2
|
-D BACKLIGHT_BTN=PIN_BUTTON2
|
||||||
@@ -92,6 +93,7 @@ build_flags =
|
|||||||
-D OFFLINE_QUEUE_SIZE=256
|
-D OFFLINE_QUEUE_SIZE=256
|
||||||
-D UI_RECENT_LIST_SIZE=9
|
-D UI_RECENT_LIST_SIZE=9
|
||||||
-D UI_SENSORS_PAGE=1
|
-D UI_SENSORS_PAGE=1
|
||||||
|
-D UI_GPS_PAGE=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; -D MESH_DEBUG=1
|
||||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public:
|
|||||||
const char* getSettingName(int i) const override;
|
const char* getSettingName(int i) const override;
|
||||||
const char* getSettingValue(int i) const override;
|
const char* getSettingValue(int i) const override;
|
||||||
bool setSettingValue(const char* name, const char* value) override;
|
bool setSettingValue(const char* name, const char* value) override;
|
||||||
|
LocationProvider* getLocationProvider() { return _nmea; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
Reference in New Issue
Block a user