Skip to content

Commit 8abe62d

Browse files
V1.6.16 - Updates
- Added ability to comment out features (Serial support, Guided Setup and Points Of Interest due to memory pressure - Made Up and Down buttons work in the CAL menu - Added support to Serial for syncing RA and DEC, meaning you can tell the mount that it is currently at a specific RA and DEC.
1 parent 1ead163 commit 8abe62d

File tree

14 files changed

+180
-63
lines changed

14 files changed

+180
-63
lines changed

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#ifndef _GLOBALS_H_
22
#define _GLOBALS_H_
3+
34
// Set to 1 if you are in the northern hemisphere.
45
#define NORTHERN_HEMISPHERE 1
56

6-
#define DEBUG_MODE
7-
87
// Time in ms between LCD screen updates during slewing operations
98
#define DISPLAY_UPDATE_TIME 200
109

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,49 @@ const DegreeTime Mount::currentDEC() const {
211211
return decC;
212212
}
213213

214+
/////////////////////////////////
215+
//
216+
// syncRA
217+
//
218+
/////////////////////////////////
219+
// Set the current RA position to be the given time. We do this by adjusting HA by the
220+
// difference between the current RA and the RA that we were told we were actually at.
221+
void Mount::syncRA(int hour, int minute, int second) {
222+
// Given the display RA coordinates...
223+
DayTime newRA = DayTime(hour, minute, second);
224+
225+
// ... convert to the system RA values
226+
newRA.subtractTime(_HACorrection);
227+
228+
// Calculate the difference between the new system RA and the current system RA
229+
DayTime deltaRA = DayTime(newRA);
230+
deltaRA.subtractTime(_currentRA);
231+
232+
// Now add this difference to HA.
233+
DayTime newHA = DayTime(_HATime);
234+
newHA.addTime(deltaRA);
235+
setHA(newHA);
236+
237+
float targetRA,targetDEC;
238+
calculateRAandDECSteppers(targetRA,targetDEC);
239+
_stepperRA->setCurrentPosition(targetRA);
240+
}
241+
242+
/////////////////////////////////
243+
//
244+
// syncDEC
245+
//
246+
/////////////////////////////////
247+
// Set the current DEC position to be the given degrees (which are 0 .. -180 for Northern Hemisphere)
248+
void Mount::syncDEC(int degree, int minute, int second) {
249+
Serial.println("SyncDEC: " + String(degree) + ":" + String(minute) + ":" + String(second));
250+
_currentDEC = DegreeTime(degree, minute, second);
251+
_targetDEC = _currentDEC;
252+
float targetRA,targetDEC;
253+
calculateRAandDECSteppers(targetRA,targetDEC);
254+
_stepperDEC->setCurrentPosition(targetDEC);
255+
}
256+
214257
/////////////////////////////////
215258
//
216259
// startSlewingToTarget
@@ -223,8 +266,9 @@ void Mount::startSlewingToTarget() {
223266
// Calculate new RA stepper target (and DEC)
224267
_currentDECStepperPosition = _stepperDEC->currentPosition();
225268
_currentRAStepperPosition = _stepperRA->currentPosition();
226-
227-
calculateRAandDECSteppers();
269+
float targetRA,targetDEC;
270+
calculateRAandDECSteppers(targetRA,targetDEC);
271+
moveSteppersTo(targetRA,targetDEC);
228272

229273
_mountStatus |= STATUS_SLEWING | STATUS_SLEWING_TO_TARGET;
230274
_totalDECMove = 1.0f * _stepperDEC->distanceToGo();
@@ -577,7 +621,7 @@ float Mount::getSpeed(int direction) {
577621
//
578622
// This code tells the steppers to what location to move to, given the select right ascension and declination
579623
/////////////////////////////////
580-
void Mount::calculateRAandDECSteppers() {
624+
void Mount::calculateRAandDECSteppers(float& targetRA, float &targetDEC) {
581625
float hourPos = _targetRA.getTotalHours();
582626
// Map [0 to 24] range to [-12 to +12] range
583627
if (hourPos > 12) {
@@ -614,8 +658,8 @@ void Mount::calculateRAandDECSteppers() {
614658

615659
// float targetRA = clamp(-moveRA, -RAStepperLimit, RAStepperLimit);
616660
// float targetDEC = clamp(moveDEC, DECStepperUpLimit, DECStepperDownLimit);
617-
float targetRA = -moveRA;
618-
float targetDEC = moveDEC;
661+
targetRA = -moveRA;
662+
targetDEC = moveDEC;
619663

620664
// Can we get there without physical issues? (not doing anything with this yet)
621665
// isUnreachable = ((targetRA != -moveRA) || (targetDEC != moveDEC));
@@ -626,7 +670,8 @@ void Mount::calculateRAandDECSteppers() {
626670
// if (stepperDEC.currentPosition() != (targetDEC)) {
627671
// Serial.println("Moving DEC from " + String(stepperDEC.currentPosition()) + " to " + targetDEC);
628672
// }
629-
673+
}
674+
void Mount::moveSteppersTo(float targetRA, float targetDEC) {
630675
// Show time: tell the steppers where to go!
631676
_stepperRA->moveTo(targetRA);
632677
_stepperDEC->moveTo(targetDEC);

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class Mount {
5959
// Get current DEC value.
6060
const DegreeTime currentDEC() const;
6161

62+
// Set the current RA position to be the given time
63+
void syncRA(int hour, int minute, int second);
64+
65+
// Set the current DEC position to be the given degrees
66+
void syncDEC(int degree, int minute, int second);
67+
6268
float getSpeedCalibration();
6369

6470
void setSpeedCalibration(float val);
@@ -114,10 +120,11 @@ class Mount {
114120
float getSpeed(int direction);
115121

116122
void displayStepperPositionThrottled();
117-
123+
118124
private:
119-
void calculateRAandDECSteppers();
125+
void calculateRAandDECSteppers(float& targetRA, float& targetDEC);
120126
void displayStepperPosition();
127+
void moveSteppersTo(float targetRA, float targetDEC);
121128

122129
// Returns NOT_SLEWING, SLEWING_DEC, SLEWING_RA, or SLEWING_BOTH. SLEWING_TRACKING is an overlaid bit.
123130
byte slewStatus();
@@ -128,15 +135,15 @@ class Mount {
128135
int _stepsPerDECDegree;
129136
long _lastHASet;
130137
DayTime _HAAdjust;
131-
138+
132139
DayTime _targetRA;
133140
DayTime _currentRA;
134141
long _currentRAStepperPosition;
135-
142+
136143
DegreeTime _targetDEC;
137144
DegreeTime _currentDEC;
138145
long _currentDECStepperPosition;
139-
146+
140147
float _totalDECMove;
141148
float _totalRAMove;
142149

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
=======================================================================================================================================
1616
*/
17-
String version = "V1.6.15";
17+
String version = "V1.6.16";
1818

1919
// See NORTHERN_HEMISPHERE in Globals.h if you not in the northern hemisphere
2020

@@ -72,9 +72,39 @@ int s = 25;
7272
// Comment this out to save some code space
7373
// #define DEBUG_MODE
7474

75+
// Uncomment to run a key diagnostic. No tracker functions are on at all.
76+
// #define LCD_BUTTON_TEST
77+
78+
////////////////////////////////////////////////////////////////
79+
//
80+
// FEATURE SUPPORT SECTION
81+
//
82+
// Since the Arduino Uno has very little memory (32KB code, 2KB data) all features
83+
// stretch the Uno a little too far. So in order to save memory we allow you to enable
84+
// and disable features to help manage memory usage.
85+
// If you run the tracker with an Arduino Mega, you can uncomment all the features.
86+
//
87+
// If you would like to drive your OAT mount with only the LCD Shield,
88+
// you should comment out SUPPORT_SERIAL_CONTROL
89+
//
90+
// If you feel comfortable with configuring the OAT at startup manually, you should comment
91+
// out SUPPORT_GUIDED_STARTUP (maybe after you've used it for a while you know what to do).
92+
//
93+
// The POI menu can take a little data memory and you may not need it. If not, you can comment
94+
// out SUPPORT_POINTS_OF_INTEREST
95+
//
96+
////////////////////////////////////////////////////////////////
97+
98+
7599
// Uncomment this to support the heating menu
76100
// NOTE: Heating is currently not supported!
77101
// #define SUPPORT_HEATING
78102

79-
// Uncomment to run a key diagnostic
80-
// #define LCD_BUTTON_TEST
103+
// Uncomment to support Guided Startup
104+
// #define SUPPORT_GUIDED_STARTUP
105+
106+
// Uncomment to support Serial MEADE support
107+
#define SUPPORT_SERIAL_CONTROL
108+
109+
// Uncomment to support POI menu. Since memory is running low, this can be disabled in lieu of serial support.
110+
#define SUPPORT_POINTS_OF_INTEREST

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
// How many menu items at most?
4141
#define MAXMENUITEMS 10
4242

43+
#ifdef SUPPORT_GUIDED_STARTUP
4344
bool inStartup = true; // Start with a guided startup
45+
#else
46+
bool inStartup = false; // Start with a guided startup
47+
#endif
4448

4549
// Serial control variables
4650
bool inSerialControl = false; // When the serial port is in control

Software/Arduino code/OpenAstroTracker/b_setup.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ void setup() {
1515
//Serial.begin(38400);
1616
Serial.begin(57600);
1717
//BT.begin(9600);
18-
18+
1919
#ifdef DEBUG_MODE
2020
Serial.println("Hello");
2121
#endif
22-
22+
2323
// Show a splash screen
2424
lcdMenu.setCursor(0, 0);
2525
lcdMenu.printMenu("OpenAstroTracker");
@@ -59,7 +59,9 @@ void setup() {
5959
// Create the LCD top-level menu items
6060
lcdMenu.addItem("RA", RA_Menu);
6161
lcdMenu.addItem("DEC", DEC_Menu);
62+
#ifdef SUPPORT_POINTS_OF_INTEREST
6263
lcdMenu.addItem("POI", POI_Menu);
64+
#endif
6365
lcdMenu.addItem("HOME", Home_Menu);
6466
lcdMenu.addItem("HA", HA_Menu);
6567
#ifdef SUPPORT_HEATING
@@ -72,8 +74,11 @@ void setup() {
7274
while (millis() - now < 750) {
7375
mount.loop();
7476
}
77+
78+
lcdMenu.updateDisplay();
79+
7580
#ifdef DEBUG_MODE
7681
Serial.println("SetupDone");
7782
#endif
78-
83+
7984
}

Software/Arduino code/OpenAstroTracker/c65_startup.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef SUPPORT_GUIDED_STARTUP
12
//////////////////////////////////////////////////////////////
23
// This file contains the Starup 'wizard' that guides you through initial setup
34

@@ -120,3 +121,4 @@ void prinStartupMenu() {
120121
break;
121122
}
122123
}
124+
#endif

Software/Arduino code/OpenAstroTracker/c722_menuPOI.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef SUPPORT_POINTS_OF_INTEREST
12
struct PointOfInterest {
23
char* pDisplay;
34
byte hourRA;
@@ -62,3 +63,4 @@ void printPOISubmenu() {
6263
lcdMenu.printMenu(pointOfInterest[currentPOI].pDisplay);
6364
}
6465
}
66+
#endif

Software/Arduino code/OpenAstroTracker/c72_menuHA.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ bool processHAKeys() {
3434
EEPROM.update(2, mount.HA().getMinutes());
3535
lcdMenu.printMenu("Stored.");
3636
mount.delay(500);
37+
38+
#ifdef SUPPORT_GUIDED_STARTUP
3739
if (startupState == StartupWaitForHACompletion) {
3840
startupState = StartupHAConfirmed;
3941
inStartup = true;
4042
}
43+
#endif
4144
}
4245
break;
4346

4447
case btnRIGHT: {
45-
if (startupState != StartupWaitForHACompletion) {
48+
#ifdef SUPPORT_GUIDED_STARTUP
49+
if (startupState != StartupWaitForHACompletion)
50+
#endif
51+
{
4652
lcdMenu.setNextActive();
4753
}
4854
}

Software/Arduino code/OpenAstroTracker/c74_menuHEAT.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
bool processHeatKeys() {
21
#ifdef SUPPORT_HEATING
3-
byte key;
2+
3+
bool processHeatKeys() {
4+
byte key;
45
switch (key) {
56
case btnUP:
67
case btnDOWN:
@@ -54,12 +55,10 @@ byte key;
5455
}
5556
break;
5657
}
57-
#endif
58-
return true;
58+
return true;
5959
}
6060

6161
void printHeatSubmenu() {
62-
#ifdef SUPPORT_HEATING
6362
String menu = format("RA%c%s%c DEC%c%s%c ",
6463
heatselect == 0 ? ">" : ":",
6564
RAheat == 0 ? "Off" : "On ",
@@ -69,5 +68,6 @@ void printHeatSubmenu() {
6968
heatselect == 1 ? "<" : " "
7069
);
7170
lcdMenu.printMenu(menu);
72-
#endif
7371
}
72+
73+
#endif

0 commit comments

Comments
 (0)