@@ -75,6 +75,9 @@ class HomeScreen : public UIScreen {
7575 RADIO,
7676 BLUETOOTH,
7777 ADVERT,
78+ #if UI_GPS_PAGE == 1
79+ GPS,
80+ #endif
7881#if UI_SENSORS_PAGE == 1
7982 SENSORS,
8083#endif
@@ -250,6 +253,47 @@ 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 UI_GPS_PAGE == 1
257+ } else if (_page == HomePage::GPS) {
258+ LocationProvider* nmea = sensors.getLocationProvider ();
259+ int y = 18 ;
260+ display.setCursor (0 , y);
261+ display.print (_task->getGPSState () ? " gps on" : " gps off" );
262+ if (nmea == NULL ) {
263+ y = y + 12 ;
264+ display.setCursor (0 , y);
265+ display.print (" Can't access GPS" );
266+ } else {
267+ char buf[50 ];
268+ strcpy (buf, nmea->isValid ()?" fix" :" no fix" );
269+ display.setCursor (
270+ display.width ()-display.getTextWidth (buf)-1 , y);
271+ display.print (buf);
272+ y = y + 12 ;
273+ display.setCursor (0 ,y);
274+ display.print (" sat" );
275+ sprintf (buf, " %d" , nmea->satellitesCount ());
276+ display.setCursor (
277+ display.width ()-display.getTextWidth (buf)-1 , y);
278+ display.print (buf);
279+ y = y + 12 ;
280+ display.setCursor (0 ,y);
281+ display.print (" pos" );
282+ sprintf (buf, " %.4f %.4f" ,
283+ nmea->getLatitude ()/1000000 ., nmea->getLongitude ()/1000000 .);
284+ display.setCursor (
285+ display.width ()-display.getTextWidth (buf)-1 , y);
286+ display.print (buf);
287+ y = y + 12 ;
288+ display.setCursor (0 ,y);
289+ display.print (" alt" );
290+ sprintf (buf, " %.2f" , nmea->getAltitude ()/1000 .);
291+ display.setCursor (
292+ display.width ()-display.getTextWidth (buf)-1 , y);
293+ display.print (buf);
294+ y = y + 12 ;
295+ }
296+ #endif
253297#if UI_SENSORS_PAGE == 1
254298 } else if (_page == HomePage::SENSORS) {
255299 int y = 18 ;
@@ -364,6 +408,12 @@ class HomeScreen : public UIScreen {
364408 }
365409 return true ;
366410 }
411+ #if UI_GPS_PAGE == 1
412+ if (c == KEY_ENTER && _page == HomePage::GPS) {
413+ _task->toggleGPS ();
414+ return true ;
415+ }
416+ #endif
367417#if UI_SENSORS_PAGE == 1
368418 if (c == KEY_ENTER && _page == HomePage::SENSORS) {
369419 _task->toggleGPS ();
@@ -773,6 +823,18 @@ char UITask::handleTripleClick(char c) {
773823 return c;
774824}
775825
826+ bool UITask::getGPSState () {
827+ if (_sensors != NULL ) {
828+ int num = _sensors->getNumSettings ();
829+ for (int i = 0 ; i < num; i++) {
830+ if (strcmp (_sensors->getSettingName (i), " gps" ) == 0 ) {
831+ return !strcmp (_sensors->getSettingValue (i), " 1" );
832+ }
833+ }
834+ }
835+ return false ;
836+ }
837+
776838void UITask::toggleGPS () {
777839 if (_sensors != NULL ) {
778840 // toggle GPS on/off
0 commit comments