@@ -75,6 +75,9 @@ class HomeScreen : public UIScreen {
7575 RADIO,
7676 BLUETOOTH,
7777 ADVERT,
78+ #if ENV_INCLUDE_GPS == 1
79+ GPS,
80+ #endif
7881#if UI_SENSORS_PAGE == 1
7982 SENSORS,
8083#endif
@@ -170,7 +173,7 @@ class HomeScreen : public UIScreen {
170173
171174 // curr page indicator
172175 int y = 14 ;
173- int x = display.width () / 2 - 25 ;
176+ int x = display.width () / 2 - 5 * (HomePage::Count- 1 ) ;
174177 for (uint8_t i = 0 ; i < HomePage::Count; i++, x += 10 ) {
175178 if (i == _page) {
176179 display.fillRect (x-1 , y-1 , 3 , 3 );
@@ -250,6 +253,34 @@ class HomeScreen : public UIScreen {
250253 display.setColor (DisplayDriver::GREEN);
251254 display.drawXbm ((display.width () - 32 ) / 2 , 18 , advert_icon, 32 , 32 );
252255 display.drawTextCentered (display.width () / 2 , 64 - 11 , " advert: " PRESS_LABEL);
256+ #if ENV_INCLUDE_GPS == 1
257+ } else if (_page == HomePage::GPS) {
258+ LocationProvider* nmea = sensors.getLocationProvider ();
259+ int y = 18 ;
260+ display.drawTextLeftAlign (0 , y, _task->getGPSState () ? " gps on" : " gps off" );
261+ if (nmea == NULL ) {
262+ y = y + 12 ;
263+ display.drawTextLeftAlign (0 , y, " Can't access GPS" );
264+ } else {
265+ char buf[50 ];
266+ strcpy (buf, nmea->isValid ()?" fix" :" no fix" );
267+ display.drawTextRightAlign (display.width ()-1 , y, buf);
268+ y = y + 12 ;
269+ display.drawTextLeftAlign (0 , y, " sat" );
270+ sprintf (buf, " %d" , nmea->satellitesCount ());
271+ display.drawTextRightAlign (display.width ()-1 , y, buf);
272+ y = y + 12 ;
273+ display.drawTextLeftAlign (0 , y, " pos" );
274+ sprintf (buf, " %.4f %.4f" ,
275+ nmea->getLatitude ()/1000000 ., nmea->getLongitude ()/1000000 .);
276+ display.drawTextRightAlign (display.width ()-1 , y, buf);
277+ y = y + 12 ;
278+ display.drawTextLeftAlign (0 , y, " alt" );
279+ sprintf (buf, " %.2f" , nmea->getAltitude ()/1000 .);
280+ display.drawTextRightAlign (display.width ()-1 , y, buf);
281+ y = y + 12 ;
282+ }
283+ #endif
253284#if UI_SENSORS_PAGE == 1
254285 } else if (_page == HomePage::SENSORS) {
255286 int y = 18 ;
@@ -364,6 +395,12 @@ class HomeScreen : public UIScreen {
364395 }
365396 return true ;
366397 }
398+ #if ENV_INCLUDE_GPS == 1
399+ if (c == KEY_ENTER && _page == HomePage::GPS) {
400+ _task->toggleGPS ();
401+ return true ;
402+ }
403+ #endif
367404#if UI_SENSORS_PAGE == 1
368405 if (c == KEY_ENTER && _page == HomePage::SENSORS) {
369406 _task->toggleGPS ();
@@ -773,6 +810,18 @@ char UITask::handleTripleClick(char c) {
773810 return c;
774811}
775812
813+ bool UITask::getGPSState () {
814+ if (_sensors != NULL ) {
815+ int num = _sensors->getNumSettings ();
816+ for (int i = 0 ; i < num; i++) {
817+ if (strcmp (_sensors->getSettingName (i), " gps" ) == 0 ) {
818+ return !strcmp (_sensors->getSettingValue (i), " 1" );
819+ }
820+ }
821+ }
822+ return false ;
823+ }
824+
776825void UITask::toggleGPS () {
777826 if (_sensors != NULL ) {
778827 // toggle GPS on/off
0 commit comments