|
5 | 5 | #include "WifiControl.hpp"
|
6 | 6 | #include "Gyro.hpp"
|
7 | 7 |
|
| 8 | +#if USE_GPS == 1 |
| 9 | +bool gpsAqcuisitionComplete(); // defined in c72_menuHA_GPS.hpp |
| 10 | +#endif |
8 | 11 | /////////////////////////////////////////////////////////////////////////////////////////
|
9 | 12 | //
|
10 | 13 | // Serial support
|
|
41 | 44 | // Returns: '|#' if slewing, ' #' if not
|
42 | 45 | //
|
43 | 46 | //------------------------------------------------------------------
|
| 47 | +// GPS FAMILY |
| 48 | +// |
| 49 | +// :gT# |
| 50 | +// Attempts to set the mount time and location from the GPS for 2 minutes. This is essentially a |
| 51 | +// blocking call, no other activities take place (except tracking, but only if interrupt-driven). |
| 52 | +// Use :Gt# and :Gg# to retrieve Lat and Long, |
| 53 | +// Returns: 1 if the data was set, 0 if not (timedout) |
| 54 | +// |
| 55 | +// :gTnnn# |
| 56 | +// Attempts to set the mount time and location from the GPS with a custom timeout. This is also blocking |
| 57 | +// but by using a low timeout, you can avoid long pauses and let the user know that it's not ready yet. |
| 58 | +// Where nnn is an integer defining the number of milliseconds to wait for the GPS to get a bearing. |
| 59 | +// Returns: 1 if the data was set, 0 if not (timedout) |
| 60 | +// |
| 61 | +//------------------------------------------------------------------ |
44 | 62 | // GET FAMILY
|
45 | 63 | //
|
46 | 64 | // :GVP#
|
|
71 | 89 | // Returns: HH:MM:SS
|
72 | 90 | // Where HH is hour, MM is minutes, SS is seconds.
|
73 | 91 | //
|
| 92 | +// :Gt# |
| 93 | +// Get Site Latitude |
| 94 | +// Returns: sDD*MM |
| 95 | +// Where s is + or - and DD is the latitude in degrees and MM the minutes. |
| 96 | +// |
| 97 | +// :Gg# |
| 98 | +// Get Site Longitude |
| 99 | +// Returns: DDD*MM |
| 100 | +// Where DDD is the longitude in degrees and MM the minutes. Negative (W) longitudes have had 360 added to them. |
| 101 | +// |
| 102 | +// |
74 | 103 | // -- GET Extensions --
|
75 | 104 | // :GIS#
|
76 | 105 | // Get DEC or RA Slewing
|
|
106 | 135 | //
|
107 | 136 | // * Az and Alt are optional. The string may only be 3 characters long
|
108 | 137 | //
|
109 |
| -// |
110 |
| -// : Gt# |
111 |
| -// Get Site Latitude |
112 |
| -// Returns: sDD*MM |
113 |
| -// Where s is + or - and DD is the latitude in degrees and MM the minutes. |
114 |
| -// |
115 |
| -// : Gg# |
116 |
| -// Get Site Latitude |
117 |
| -// Returns: DDD*MM |
118 |
| -// Where DDD is the longitude in degrees and MM the minutes. Negative (W) longitudes have had 360 added to them. |
119 |
| -// |
120 | 138 | //------------------------------------------------------------------
|
121 | 139 | // SET FAMILY
|
122 | 140 | //
|
@@ -507,6 +525,30 @@ String MeadeCommandProcessor::handleMeadeGetInfo(String inCmd) {
|
507 | 525 | return "0#";
|
508 | 526 | }
|
509 | 527 |
|
| 528 | +///////////////////////////// |
| 529 | +// GPS CONTROL |
| 530 | +///////////////////////////// |
| 531 | +String MeadeCommandProcessor::handleMeadeGPSCommands(String inCmd) { |
| 532 | + #if USE_GPS == 1 |
| 533 | + if (inCmd[0] == 'T') { |
| 534 | + unsigned long timeoutLen = 2UL * 60UL * 1000UL; |
| 535 | + if (inCmd.length() > 1) { |
| 536 | + timeoutLen = inCmd.substring(1).toInt(); |
| 537 | + } |
| 538 | + // Wait at most 2 minutes |
| 539 | + unsigned long timeoutTime = millis() + timeoutLen; |
| 540 | + while (millis() < timeoutTime) { |
| 541 | + if (gpsAqcuisitionComplete()) { |
| 542 | + LOGV1(DEBUG_MEADE, F("MEADE: GPS startup, GPS acquired")); |
| 543 | + return "1"; |
| 544 | + } |
| 545 | + } |
| 546 | + } |
| 547 | + #endif |
| 548 | + LOGV1(DEBUG_MEADE, F("MEADE: GPS startup, no GPS signal")); |
| 549 | + return "0"; |
| 550 | +} |
| 551 | + |
510 | 552 | /////////////////////////////
|
511 | 553 | // SYNC CONTROL
|
512 | 554 | /////////////////////////////
|
@@ -941,6 +983,7 @@ String MeadeCommandProcessor::processCommand(String inCmd) {
|
941 | 983 | case 'S': return handleMeadeSetInfo(inCmd);
|
942 | 984 | case 'M': return handleMeadeMovement(inCmd);
|
943 | 985 | case 'G': return handleMeadeGetInfo(inCmd);
|
| 986 | + case 'g': return handleMeadeGPSCommands(inCmd); |
944 | 987 | case 'C': return handleMeadeSyncControl(inCmd);
|
945 | 988 | case 'h': return handleMeadeHome(inCmd);
|
946 | 989 | case 'I': return handleMeadeInit(inCmd);
|
|
0 commit comments