4444//
4545// :Gd#
4646// Get Target Declination
47- // Where s is + or -, DD is degrees, MM is minutes, SS is seconds.
4847// Returns: sDD*MM'SS
48+ // Where s is + or -, DD is degrees, MM is minutes, SS is seconds.
4949//
5050// :GD#
5151// Get Current Declination
52- // Where s is + or -, DD is degrees, MM is minutes, SS is seconds.
5352// Returns: sDD*MM'SS
53+ // Where s is + or -, DD is degrees, MM is minutes, SS is seconds.
5454//
5555// :Gr#
5656// Get Target Right Ascension
57- // Where HH is hour, MM is minutes, SS is seconds.
5857// Returns: HH:MM:SS
58+ // Where HH is hour, MM is minutes, SS is seconds.
5959//
6060// :GR#
6161// Get Current Right Ascension
62- // Where HH is hour, MM is minutes, SS is seconds.
6362// Returns: HH:MM:SS
63+ // Where HH is hour, MM is minutes, SS is seconds.
6464//
6565// -- GET Extensions --
6666// :GIS#
9393// | Third character is TRK slewing state ('T' is Tracking, '-' is stopped).
9494// +----------------------------------------------- [0] The mount status. One of 'Idle', 'Parked', 'Parking', 'Guiding', 'SlewToTarget', 'FreeSlew', 'ManualSlew', 'Tracking'
9595//
96- //
96+ // : Gt#
97+ // Get Site Latitude
98+ // Returns: sDD*MM
99+ // Where s is + or - and DD is the latitude in degrees and MM the minutes.
100+ //
101+ // : Gg#
102+ // Get Site Latitude
103+ // Returns: DDD*MM
104+ // Where DDD is the longitude in degrees and MM the minutes. Negative (W) longitudes have had 360 added to them.
105+ //
97106// ------------------------------------------------------------------
98107// SET FAMILY
99108//
109118// Where HH is hours, MM is minutes, SS is seconds.
110119// Returns: 1 if successfully set, otherwise 0
111120//
121+ // :StsDD*MM#
122+ // Set Site Latitude
123+ // This sets the latitude of the location of the mount.
124+ // Where s is the sign ('+' or '-'), DD is the degree (90 or less), MM is minutes.
125+ // Returns: 1 if successfully set, otherwise 0
126+ //
127+ // :SgDDD*MM#
128+ // Set Site Longitude
129+ // This sets the longitude of the location of the mount.
130+ // Where DDD the nmber of degrees (0 to 360), MM is minutes. W Latitudes get 360 added to them. So W122 (or -122) would be 238.
131+ // Returns: 1 if successfully set, otherwise 0
132+ //
133+ // :SGsHH#
134+ // Set Site UTC Offset
135+ // This sets the offset of the timezone in which the mount is in hours from UTC.
136+ // Where s is the sign and HH is the number of hours.
137+ // CURRENTLY IGNORED.
138+ // Returns: 1
139+ //
140+ // :SLHH:MM:SS#
141+ // Set Site Local Time
142+ // This sets the local time of the timezone in which the mount is located.
143+ // Where HH is hours, MM is minutes and SS is seconds.
144+ // CURRENTLY IGNORED.
145+ // Returns: 1
146+ //
147+ // :SCMM/DD/YY#
148+ // Set Site Date
149+ // This sets the date
150+ // Where HHMM is the month, DD is teh day and YY is the year since 2000.
151+ // CURRENTLY IGNORED.
152+ // Returns: 1Updating Planetary Data
153+ //
112154// -- SET Extensions --
113155// :SHHH:MM#
114156// Set Hour Time (HA)
115157// This sets the scopes HA.
116158// Where HH is hours, MM is minutes.
117159// Returns: 1 if successfully set, otherwise 0
118160//
161+ // :SHP#
162+ // Set Home Point
163+ // This sets the current orientation of the scope as its home point.
164+ // Returns: 1
165+ //
119166// :SHLHH:MM#
120167// Set LST Time
121168// This sets the scopes LST (and HA).
129176// Returns: 1 if successfully set, otherwise 0
130177//
131178// ------------------------------------------------------------------
179+ // RATE CONTROL FAMILY
180+ //
181+ // :Rs#
182+ // Set Slew rate
183+ // Where s is one of 'S', 'M', 'C', or 'G' in order of decreasing speed
184+ // CURRENTLY IGNORED
185+ // Returns: nothing
186+ // ------------------------------------------------------------------
132187// MOVEMENT FAMILY
133188//
134189// :MS#
140195//
141196// :MGdnnnn#
142197// Run a Guide pulse
143- // This runs the motors for a short period of time.
198+ // This runs the motors at increased speed for a short period of time.
144199// Where d is one of 'N', 'E', 'W', or 'S' and nnnn is the duration in ms.
145200// Returns: 1
146201//
157212// Returns: nothing
158213//
159214// ------------------------------------------------------------------
215+ // SYNC FAMILY
216+ //
217+ // :CM#
218+ // Synchronizes the mount to the current target RA and DEC values.
219+ //
220+ // ------------------------------------------------------------------
160221// HOME FAMILY
161222//
162223// :hP#
@@ -347,17 +408,35 @@ String MeadeCommandProcessor::handleMeadeGetInfo(String inCmd) {
347408 case ' X' : return _mount->getStatusString () + " #" ;
348409
349410 case ' I' :
350- String retVal = " " ;
351- if (cmdTwo == ' S' ) {
352- retVal = _mount->isSlewingRAorDEC () ? " 1" : " 0" ;
353- }
354- else if (cmdTwo == ' T' ) {
355- retVal = _mount->isSlewingTRK () ? " 1" : " 0" ;
356- }
357- else if (cmdTwo == ' G' ) {
358- retVal = _mount->isGuiding () ? " 1" : " 0" ;
411+ {
412+ String retVal = " " ;
413+ if (cmdTwo == ' S' ) {
414+ retVal = _mount->isSlewingRAorDEC () ? " 1" : " 0" ;
415+ }
416+ else if (cmdTwo == ' T' ) {
417+ retVal = _mount->isSlewingTRK () ? " 1" : " 0" ;
418+ }
419+ else if (cmdTwo == ' G' ) {
420+ retVal = _mount->isGuiding () ? " 1" : " 0" ;
421+ }
422+ return retVal + " #" ;
423+ }
424+ case ' t' : {
425+ auto lat = DegreeTime (_mount->latitude ());
426+ char achBuffer[20 ];
427+ sprintf (achBuffer, " %c%02d*%02d#" , lat.getTotalDegrees () >= 0 ? ' +' : ' -' , int (fabs (lat.getDegrees ())), lat.getMinutes ());
428+ return String (achBuffer);
429+ }
430+ case ' g' : {
431+ float lon = _mount->longitude ();
432+ if (lon < 0 ) {
433+ lon += 360 ;
434+ }
435+ int lonMin = (lon - (int )lon) * 60 ;
436+ char achBuffer[20 ];
437+ sprintf (achBuffer, " %03d*%02d#" , (int )lon, lonMin);
438+ return String (achBuffer);
359439 }
360- return retVal + " #" ;
361440 }
362441
363442 return " 0#" ;
@@ -423,7 +502,7 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
423502
424503 DayTime lst (hLST, minLST, secLST);
425504#ifdef DEBUG_MODE
426- logv (" MeadeSetInfo: Received LST: %d:%d:%d" , hLST,minLST,secLST);
505+ logv (" MeadeSetInfo: Received LST: %d:%d:%d" , hLST, minLST, secLST);
427506#endif
428507 _mount->setLST (lst);
429508 }
@@ -445,26 +524,41 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
445524 return " 1" ;
446525 }
447526 else if ((inCmd[0 ] == ' Y' ) && inCmd.length () == 19 ) {
448- // Sync RA, DEC - current position is teh given coordinate
527+ // Sync RA, DEC - current position is the given coordinate
449528 // 0123456789012345678
450529 // :SY+84*03:02.18:34:12
451530 int sgn = inCmd[1 ] == ' +' ? 1 : -1 ;
452531 if ((inCmd[4 ] == ' *' ) && (inCmd[7 ] == ' :' ) && (inCmd[10 ] == ' .' ) && (inCmd[13 ] == ' :' ) && (inCmd[16 ] == ' :' )) {
453532 int deg = inCmd.substring (2 , 4 ).toInt ();
454- _mount->syncPosition (inCmd.substring (11 , 13 ).toInt (), inCmd.substring (14 , 16 ).toInt (), inCmd.substring (17 , 19 ).toInt (),sgn * deg + (NORTHERN_HEMISPHERE ? -90 : 90 ), inCmd.substring (5 , 7 ).toInt (), inCmd.substring (8 , 10 ).toInt ());
533+ _mount->syncPosition (inCmd.substring (11 , 13 ).toInt (), inCmd.substring (14 , 16 ).toInt (), inCmd.substring (17 , 19 ).toInt (), sgn * deg + (NORTHERN_HEMISPHERE ? -90 : 90 ), inCmd.substring (5 , 7 ).toInt (), inCmd.substring (8 , 10 ).toInt ());
455534 return " 1" ;
456535 }
457- else {
458- return " 0" ;
459- }
536+ return " 0" ;
460537 }
461- else if ((inCmd[0 ] == ' t' )) // longitude : :St+30*29#
538+ else if ((inCmd[0 ] == ' t' )) // latitude : :St+30*29#
462539 {
463- return " 1" ;
540+ float sgn = inCmd[1 ] == ' +' ? 1 .0f : -1 .0f ;
541+ if (inCmd[4 ] == ' *' ) {
542+ int deg = inCmd.substring (2 , 4 ).toInt ();
543+ int minute = inCmd.substring (5 , 7 ).toInt ();
544+ _mount->setLatitude (sgn * (1 .0f * deg + (minute / 60 .0f )));
545+ return " 1" ;
546+ }
547+ return " 0" ;
464548 }
465- else if (inCmd[0 ] == ' g' ) // latitude :Sg097*34#
549+ else if (inCmd[0 ] == ' g' ) // longitude :Sg097*34#
466550 {
467- return " 1" ;
551+ if (inCmd[4 ] == ' *' ) {
552+ int deg = inCmd.substring (1 , 4 ).toInt ();
553+ int minute = inCmd.substring (5 , 7 ).toInt ();
554+ float lon = 1 .0f * deg + (1 .0f * minute / 60 .0f );
555+ if (lon > 180 ) {
556+ lon -= 360 ;
557+ }
558+ _mount->setLongitude (lon);
559+ return " 1" ;
560+ }
561+ return " 0" ;
468562 }
469563 else if (inCmd[0 ] == ' G' ) // utc offset :SG+05#
470564 {
@@ -660,25 +754,25 @@ String MeadeCommandProcessor::handleMeadeQuit(String inCmd) {
660754
661755 switch (inCmd[0 ]) {
662756 case ' a' :
663- _mount->stopSlewing (ALL_DIRECTIONS);
757+ _mount->stopSlewing (ALL_DIRECTIONS);
664758 break ;
665759 case ' e' :
666- _mount->stopSlewing (EAST);
667- break ;
668- case ' w' :
669- _mount->stopSlewing (WEST);
670- break ;
671- case ' n' :
672- _mount->stopSlewing (NORTH);
673- break ;
674- case ' s' :
675- _mount->stopSlewing (SOUTH);
676- break ;
677- case ' q' :
678- inSerialControl = false ;
679- _lcdMenu->setCursor (0 , 0 );
680- _lcdMenu->updateDisplay ();
681- break ;
760+ _mount->stopSlewing (EAST);
761+ break ;
762+ case ' w' :
763+ _mount->stopSlewing (WEST);
764+ break ;
765+ case ' n' :
766+ _mount->stopSlewing (NORTH);
767+ break ;
768+ case ' s' :
769+ _mount->stopSlewing (SOUTH);
770+ break ;
771+ case ' q' :
772+ inSerialControl = false ;
773+ _lcdMenu->setCursor (0 , 0 );
774+ _lcdMenu->updateDisplay ();
775+ break ;
682776 }
683777
684778 return " " ;
@@ -694,8 +788,8 @@ String MeadeCommandProcessor::handleMeadeSetSlewRate(String inCmd) {
694788 case ' C' : // Center - 2nd Slowest
695789 case ' G' : // Guide - Slowest
696790 default :
697- return " " ;
698791 }
792+ return " " ;
699793}
700794
701795String MeadeCommandProcessor::processCommand (String inCmd) {
0 commit comments