Skip to content

Commit 9a4c5fe

Browse files
V1.6.50 - WIP Updates
- Added yield() calls (ESP8266 board has a watchdog that resets if the code blocks for more than a few seconds). - Refactored HA/LST handling. - RA and DEC are now always updated and calculated according to stepper motor positions - Changed EEPROM writing code to only write if the value changed. - Added ability to slew by setting a speed for each axis. - Added Serial command: :Mc# - starts slewing in the direction specified by 'c' - Added Serial command: :XGH# - gets the HA - Added Serial command: :XGL# - gets the LST - Added Serial command: :XSMn# - set manual continuous slewing mode - Added Serial command: :XSXn.nnn# - set continuous slewing mode RA speed - Added Serial command: :XSYn.nnn# - set continuous slewing mode DEC speed - Changed Serial command :hU# to return 1 - Changed Serial command :MS# to return 0 (instead of 1) - Changed Serial command :MGdnnn# to return 1 (instead of nothing) - Changed Serial command :Qa# command to stop slewing in all directions - Added some debugging log functions back. - Wifi mode prints out connection details to Serial port.
1 parent 3d74917 commit 9a4c5fe

File tree

13 files changed

+467
-159
lines changed

13 files changed

+467
-159
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
#include "Globals.h"
2+
#include <EEPROM.h>
3+
4+
void EEPROMupdate(int loc, byte val)
5+
{
6+
if (EEPROM.read(loc)!=val)
7+
{
8+
EEPROM.write(loc,val);
9+
}
10+
}

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <Arduino.h>
55
#include <WString.h>
66

7+
void EEPROMupdate(int loc, byte val);
8+
79
// Set to 1 if you are in the northern hemisphere.
810
#define NORTHERN_HEMISPHERE 1
911

@@ -56,7 +58,7 @@ extern int PolarisRASecond;
5658
// 0 - Infrastructure Only - Connecting to a Router
5759
// 1 - AP Mode Only - Acting as a Router
5860
// 2 - Attempt Infrastructure, Fail over to AP Mode.
59-
#define WIFI_MODE 0
61+
#define WIFI_MODE 2
6062
#endif
6163

6264

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 93 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "MeadeCommandProcessor.h"
22
#include "Globals.h"
3+
#include "Utility.h"
34

45
/////////////////////////////////////////////////////////////////////////////////////////
56
//
@@ -75,7 +76,22 @@
7576
//
7677
// :GX#
7778
// Get Mount Status
78-
// Returns: string reflecting the mounts' status
79+
// Returns: string reflecting the mounts' status. The string is a comma-delimited list of statuses:
80+
// Idle,--T,11219,0,927,071906,+900000,#
81+
// | | | | | | |
82+
// | | | | | | |
83+
// | | | | | | |
84+
// | | | | | | +------------------ [6] The current DEC position
85+
// | | | | | +------------------------- [5] The current RA position
86+
// | | | | +------------------------------- [4] The Tracking stepper position
87+
// | | | +---------------------------------- [3] The DEC stepper position
88+
// | | +-------------------------------------- [2] The RA stepper position
89+
// | +------------------------------------------- [1] The motion state.
90+
// | First character is RA slewing state ('R' is East, 'r' is West, '-' is stopped).
91+
// | Second character is DEC slewing state ('d' is North, 'D' is South, '-' is stopped).
92+
// | Third character is TRK slewing state ('T' is Tracking, '-' is stopped).
93+
// +----------------------------------------------- [0] The mount status. One of 'Idle', 'Parked', 'Parking', 'Guiding', 'SlewToTarget', 'FreeSlew', 'ManualSlew', 'Tracking'
94+
//
7995
//
8096
//------------------------------------------------------------------
8197
// SET FAMILY
@@ -111,22 +127,28 @@
111127
// :MS#
112128
// Start Slew to Target (Asynchronously)
113129
// This starts slewing the scope to the target RA and DEC coordinates and returns immediately.
114-
// Returns: 1
130+
// Returns: 0
115131
//
116132
// -- MOVEMENT Extensions --
117133
//
118134
// :MGdnnnn#
119135
// Run a Guide pulse
120136
// This runs the motors for a short period of time.
121137
// Where d is one of 'N', 'E', 'W', or 'S' and nnnn is the duration in ms.
122-
// Returns: nothing
138+
// Returns: 1
123139
//
124140
// :MTs#
125141
// Set Tracking mode
126142
// This turns the scopes tracking mode on or off.
127143
// Where s is 1 to turn on Tracking and 0 to turn it off.
128144
// Returns: 1
129145
//
146+
// :Mc#
147+
// Start slewing
148+
// This starts slewing the mount in the given direction.
149+
// Where c is one of 'n', 'e', 'w', or 's'.
150+
// Returns: nothing
151+
//
130152
//------------------------------------------------------------------
131153
// HOME FAMILY
132154
//
@@ -146,7 +168,7 @@
146168
// :hU#
147169
// Unpark Scope
148170
// This currently simply turns on tracking.
149-
// Returns: Nothing
171+
// Returns: 1
150172
//
151173
//------------------------------------------------------------------
152174
// QUIT MOVEMENT FAMILY
@@ -157,7 +179,7 @@
157179
// Returns: 1 when all motors have stopped.
158180
//
159181
// :Qd#
160-
// Stop slew in specified direction where d is n, s, e, w
182+
// Stop slew in specified direction where d is n, s, e, w, a (the first four are the cardinal directions, a stands for All).
161183
// Returns: nothing
162184
//
163185
// -- QUIT MOVEMENT Extensions --
@@ -190,6 +212,16 @@
190212
// Get the adjustment factor used to speed up (>1.0) or slow down (<1.0) the tracking speed of the mount.
191213
// Returns: float
192214
//
215+
// :XGH#
216+
// Get HA
217+
// Get the current HA of the mount.
218+
// Returns: HHMMSS
219+
//
220+
// :XGL#
221+
// Get LST
222+
// Get the current LST of the mount.
223+
// Returns: HHMMSS
224+
//
193225
// :XSRn#
194226
// Set RA steps
195227
// Set the number of steps the RA stepper motor needs to take to rotate by one degree
@@ -207,6 +239,22 @@
207239
// Set the adjustment factor used to speed up (>1.0) or slow down (<1.0) the tracking speed of the mount.
208240
// Returns: nothing
209241
//
242+
// :XSMn#
243+
// Set Manual Slewing Mode
244+
// Toggle the manual slewing mode state where the RA and DEC motors run at a constant speed.
245+
// Where n is '1' to turn it on, otherwise turn it off.
246+
// Returns: nothing
247+
//
248+
// :XSXn.nnn#
249+
// Set RA manual slewing speed
250+
// Set the speed of the RA motor, immediately. Must be in manual slewing mode
251+
// Returns: nothing
252+
//
253+
// :XSYn.nnn#
254+
// Set DEC manual slewing speed
255+
// Set the speed of the DEC motor, immediately.
256+
// Returns: nothing
257+
//
210258
/////////////////////////////////////////////////////////////////////////////////////////
211259

212260
MeadeCommandProcessor* MeadeCommandProcessor::_instance = nullptr;
@@ -288,6 +336,8 @@ String MeadeCommandProcessor::handleMeadeGetInfo(String inCmd) {
288336
}
289337
return retVal + "#";
290338
}
339+
340+
return "0#";
291341
}
292342

293343
/////////////////////////////
@@ -332,8 +382,6 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
332382
if ((inCmd[3] == ':') && (inCmd[6] == ':'))
333383
{
334384
_mount->targetRA().set(inCmd.substring(1, 3).toInt(), inCmd.substring(4, 6).toInt(), inCmd.substring(7, 9).toInt());
335-
_mount->targetRA().addTime(_mount->getHACorrection());
336-
_mount->targetRA().subtractTime(_mount->HA());
337385
return "1";
338386
}
339387
else {
@@ -351,10 +399,11 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
351399
secLST = inCmd.substring(6, 8).toInt();
352400
}
353401

354-
DayTime ha(hLST, minLST, secLST);
355-
DayTime pol(PolarisRAHour, PolarisRAMinute, PolarisRASecond);
356-
ha.subtractTime(pol);
357-
_mount->setHA(ha);
402+
DayTime lst(hLST, minLST, secLST);
403+
#ifdef DEBUG_MODE
404+
logv("MeadeSetInfo: Received LST: %d:%d:%d", hLST,minLST,secLST);
405+
#endif
406+
_mount->setLST(lst);
358407
}
359408
else if (inCmd[1] == 'P') {
360409
// Set home point
@@ -365,6 +414,9 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
365414
// Set HA
366415
int hHA = inCmd.substring(1, 3).toInt();
367416
int minHA = inCmd.substring(4, 6).toInt();
417+
#ifdef DEBUG_MODE
418+
logv("MeadeSetInfo: Received HA: %d:%d:%d", hHA, minHA, 0);
419+
#endif
368420
_mount->setHA(DayTime(hHA, minHA, 0));
369421
}
370422

@@ -444,22 +496,27 @@ String MeadeCommandProcessor::handleMeadeMovement(String inCmd) {
444496
else if (inCmd[1] == 'W') direction = WEST;
445497
int duration = (inCmd[2] - '0') * 1000 + (inCmd[3] - '0') * 100 + (inCmd[4] - '0') * 10 + (inCmd[5] - '0');
446498
_mount->guidePulse(direction, duration);
499+
return "1";
447500
}
448501
}
449502
else if (inCmd[0] == 'e') {
450503
_mount->startSlewing(EAST);
504+
return "";
451505
}
452506
else if (inCmd[0] == 'w') {
453507
_mount->startSlewing(WEST);
508+
return "";
454509
}
455510
else if (inCmd[0] == 'n') {
456511
_mount->startSlewing(NORTH);
512+
return "";
457513
}
458514
else if (inCmd[0] == 's') {
459515
_mount->startSlewing(SOUTH);
516+
return "";
460517
}
461518

462-
return "";
519+
return "0";
463520
}
464521

465522
/////////////////////////////
@@ -474,6 +531,7 @@ String MeadeCommandProcessor::handleMeadeHome(String inCmd) {
474531
}
475532
else if (inCmd[0] == 'U') { // Unpark
476533
_mount->startSlewing(TRACKING);
534+
return "1";
477535
}
478536
return "";
479537
}
@@ -519,6 +577,16 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd) {
519577
else if (inCmd[1] == 'S') {
520578
return String(_mount->getSpeedCalibration(), 5) + "#";
521579
}
580+
else if (inCmd[1] == 'H') {
581+
char scratchBuffer[10];
582+
sprintf(scratchBuffer, "%02d%02d%02d#", _mount->HA().getHours(), _mount->HA().getMinutes(), _mount->HA().getSeconds());
583+
return String(scratchBuffer);
584+
}
585+
else if (inCmd[1] == 'L') {
586+
char scratchBuffer[10];
587+
sprintf(scratchBuffer, "%02d%02d%02d#", _mount->LST().getHours(), _mount->LST().getMinutes(), _mount->LST().getSeconds());
588+
return String(scratchBuffer);
589+
}
522590
}
523591
else if (inCmd[0] == 'S') { // Set RA/DEC steps/deg, speedfactor
524592
if (inCmd[1] == 'R') {
@@ -530,6 +598,15 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd) {
530598
else if (inCmd[1] == 'S') {
531599
_mount->setSpeedCalibration(inCmd.substring(2).toFloat(), true);
532600
}
601+
else if (inCmd[1] == 'M') {
602+
_mount->setManualSlewMode(inCmd[2] == '1');
603+
}
604+
else if (inCmd[1] == 'X') {
605+
_mount->setSpeed(RA_STEPS, inCmd.substring(2).toFloat());
606+
}
607+
else if (inCmd[1] == 'Y') {
608+
_mount->setSpeed(DEC_STEPS, inCmd.substring(2).toFloat());
609+
}
533610
}
534611
return "";
535612
}
@@ -548,7 +625,10 @@ String MeadeCommandProcessor::handleMeadeQuit(String inCmd) {
548625
}
549626

550627
switch (inCmd[0]) {
551-
case 'e':
628+
case 'a':
629+
_mount->stopSlewing(ALL_DIRECTIONS);
630+
break;
631+
case 'e':
552632
_mount->stopSlewing(EAST);
553633
break;
554634
case 'w':

0 commit comments

Comments
 (0)