|
1 | 1 | #ifdef SUPPORT_SERIAL_CONTROL
|
2 | 2 |
|
| 3 | +///////////////////////////////////////////////////////////////////////////////////////// |
| 4 | +// |
| 5 | +// Serial support |
| 6 | +// |
| 7 | +// The Serial protocol implemented her is the Meade protocol with some extensions. |
| 8 | +// The Meade protocol commands start with a colon and end with a hash. |
| 9 | +// The first letter determines the family of functions (G for Get, S for Set, M for Movement, etc.) |
| 10 | +// |
| 11 | +// The set of Meade features implemented are: |
| 12 | +// |
| 13 | +//------------------------------------------------------------------ |
| 14 | +// INITIALIZE FAMILY |
| 15 | +// |
| 16 | +// :I# - Initialize Scope |
| 17 | +// This puts the Arduino in Serial Control Mode and displays RA on line 1 and |
| 18 | +// DEC on line 2 of the display. Serial Control Mode can be ended manually by |
| 19 | +// pressing the SELECT key, or programmatically with the :Qq# command. |
| 20 | +// Returns: nothing |
| 21 | +// |
| 22 | +//------------------------------------------------------------------ |
| 23 | +// GET FAMILY |
| 24 | +// |
| 25 | +// :GVP# |
| 26 | +// Get the Product Name |
| 27 | +// Returns: 'OpenAstroTracker' |
| 28 | +// |
| 29 | +// :GVN# |
| 30 | +// Get the Firmware Version Number |
| 31 | +// Returns: 'V1.major.minor' from OpenAstroTracker.ino |
| 32 | +// |
| 33 | +// :Gd# |
| 34 | +// Get Target Declination |
| 35 | +// Where s is + or -, DD is degrees, MM is minutes, SS is seconds. |
| 36 | +// Returns: sDD*MM'SS |
| 37 | +// |
| 38 | +// :GD# |
| 39 | +// Get Current Declination |
| 40 | +// Where s is + or -, DD is degrees, MM is minutes, SS is seconds. |
| 41 | +// Returns: sDD*MM'SS |
| 42 | +// |
| 43 | +// :Gr# |
| 44 | +// Get Target Right Ascension |
| 45 | +// Where HH is hour, MM is minutes, SS is seconds. |
| 46 | +// Returns: HH:MM:SS |
| 47 | +// |
| 48 | +// :GR# |
| 49 | +// Get Current Right Ascension |
| 50 | +// Where HH is hour, MM is minutes, SS is seconds. |
| 51 | +// Returns: HH:MM:SS |
| 52 | +// |
| 53 | +// -- GET Extensions -- |
| 54 | +// :GIS# |
| 55 | +// Get DEC or RA Slewing |
| 56 | +// Returns: 1 if either RA or DEC is slewing. 0 if not. |
| 57 | +// |
| 58 | +// :GIT# |
| 59 | +// Get Tracking |
| 60 | +// Returns: 1 if tracking is on. 0 if not. |
| 61 | +// |
| 62 | +//------------------------------------------------------------------ |
| 63 | +// SET FAMILY |
| 64 | +// |
| 65 | +// :SdsDD*MM:SS# |
| 66 | +// Set Target Declination |
| 67 | +// This sets the target DEC. Use a Movement command to slew there. |
| 68 | +// Where s is + or -, DD is degrees, MM is minutes, SS is seconds. |
| 69 | +// Returns: 1 if successfully set, otherwise 0 |
| 70 | +// |
| 71 | +// :SrHH:MM:SS# |
| 72 | +// Set Right Ascension |
| 73 | +// This sets the target RA. Use a Movement command to slew there. |
| 74 | +// Where HH is hours, MM is minutes, SS is seconds. |
| 75 | +// Returns: 1 if successfully set, otherwise 0 |
| 76 | +// |
| 77 | +// -- SET Extensions -- |
| 78 | +// :SHHH:MM# |
| 79 | +// Set Hour Time (HA) |
| 80 | +// This sets the scopes HA. |
| 81 | +// Where HH is hours, MM is minutes. |
| 82 | +// Returns: 1 if successfully set, otherwise 0 |
| 83 | +// |
| 84 | +// :SysDD*MM:SS.HH:MM:SS# |
| 85 | +// Synchronize Declination and Right Ascension. |
| 86 | +// This tells the scope what it is currently pointing at. |
| 87 | +// Where s is + or -, DD is degrees, HH is hours, MM is minutes, SS is seconds. |
| 88 | +// Returns: 1 if successfully set, otherwise 0 |
| 89 | +// |
| 90 | +//------------------------------------------------------------------ |
| 91 | +// MOVEMENT FAMILY |
| 92 | +// |
| 93 | +// :MS# |
| 94 | +// Start Slew to Target (Asynchronously) |
| 95 | +// This starts slewing the scope to the target RA and DEC coordinates and returns immediately. |
| 96 | +// Returns: 1 |
| 97 | +// |
| 98 | +// -- MOVEMENT Extensions -- |
| 99 | +// :MSy# |
| 100 | +// Slew to Target Synchronously |
| 101 | +// This slews the scope to the target RA and DEC coordinates before returning. |
| 102 | +// Returns: 1 |
| 103 | +// |
| 104 | +// :MTs# |
| 105 | +// Set Tracking mode |
| 106 | +// This turns the scopes tracking mode on or off. |
| 107 | +// Where s is 1 to turn on Tracking and 0 to turn it off. |
| 108 | +// Returns: 1 |
| 109 | +// |
| 110 | +//------------------------------------------------------------------ |
| 111 | +// HOME FAMILY |
| 112 | +// |
| 113 | +// :hP# |
| 114 | +// Park Scope and stop motors |
| 115 | +// This slews the scope back to it's home position (RA ring centered, DEC |
| 116 | +// at 90, basically pointing at celestial pole) and stops all movement (including tracking). |
| 117 | +// Returns: 1 when the scope is parked. |
| 118 | +// |
| 119 | +// -- PARK Extensions -- |
| 120 | +// :hU# |
| 121 | +// Unpark Scope |
| 122 | +// This currently simply turns on tracking. |
| 123 | +// Returns: 1 |
| 124 | +// |
| 125 | +//------------------------------------------------------------------ |
| 126 | +// QUIT MOVEMENT FAMILY |
| 127 | +// |
| 128 | +// :Q# |
| 129 | +// Stop all motors |
| 130 | +// This stops all motors, including tracking. Note that deceleration curves are still followed. |
| 131 | +// Returns: 1 when all motors have stopped. |
| 132 | +// |
| 133 | +// -- QUIT MOVEMENT Extensions -- |
| 134 | +// :Qq# |
| 135 | +// Disconnect, Quit Control mode |
| 136 | +// This quits Serial Control mode and starts tracking. |
| 137 | +// Returns: nothing |
| 138 | +// |
| 139 | +///////////////////////////////////////////////////////////////////////////////////////// |
| 140 | + |
3 | 141 | /////////////////////////////
|
4 | 142 | // INIT
|
5 | 143 | /////////////////////////////
|
@@ -46,11 +184,14 @@ void handleMeadeGetInfo(String inCmd) {
|
46 | 184 | Serial.print(mount.DECString(MEADE_STRING | CURRENT_STRING));
|
47 | 185 | }
|
48 | 186 | break;
|
49 |
| - |
| 187 | + |
50 | 188 | case 'I': {
|
51 | 189 | if (cmdTwo == 'S') {
|
52 | 190 | Serial.print(mount.isSlewingRAorDEC() ? "1" : "0");
|
53 | 191 | }
|
| 192 | + else if (cmdTwo == 'T') { |
| 193 | + Serial.print(mount.isSlewingTRK() ? "1" : "0"); |
| 194 | + } |
54 | 195 | Serial.print("0");
|
55 | 196 | }
|
56 | 197 | break;
|
@@ -130,10 +271,25 @@ void handleMeadeMovement(String inCmd) {
|
130 | 271 | }
|
131 | 272 | Serial.print("1");
|
132 | 273 | }
|
| 274 | + else if (inCmd[0] == 'T') { |
| 275 | + if (inCmd.length() > 1) { |
| 276 | + if (inCmd[1] == '1') { |
| 277 | + mount.startSlewing(TRACKING); |
| 278 | + Serial.print("1"); |
| 279 | + } |
| 280 | + else if (inCmd[1] == '0') { |
| 281 | + mount.stopSlewing(TRACKING); |
| 282 | + Serial.print("1"); |
| 283 | + } |
| 284 | + } |
| 285 | + else { |
| 286 | + Serial.print("0"); |
| 287 | + } |
| 288 | + } |
133 | 289 | }
|
134 | 290 |
|
135 | 291 | /////////////////////////////
|
136 |
| -// PARK |
| 292 | +// HOME |
137 | 293 | /////////////////////////////
|
138 | 294 | void handleMeadeHome(String inCmd) {
|
139 | 295 | if (inCmd[0] == 'P') { // Park
|
|
0 commit comments