Skip to content

Commit 8eab4c3

Browse files
V1.6.19 - Updates
- Moved Firmware configuration information to Globals.h since Arduino IDE does not include .ino files when compiling C++ files. - Default firmware configuration is to include everything except Serial (and HEAT, cause that's broken). - Removed a bunch of commented out debugging code. - Made the LCD now constantly display RA and DEC when in Serial control mode (SELECT still exits). - All Meade commands now return a 0 or 1 to indicate failure or success. - Removed the logging string collection from Serial because we are so memory constrained already, that logging is a luxury we can't afford.
1 parent dff0f28 commit 8eab4c3

File tree

10 files changed

+114
-128
lines changed

10 files changed

+114
-128
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,55 @@
11
#ifndef _GLOBALS_H_
22
#define _GLOBALS_H_
33

4+
#include <Arduino.h>
5+
46
// Set to 1 if you are in the northern hemisphere.
57
#define NORTHERN_HEMISPHERE 1
68

79
// Time in ms between LCD screen updates during slewing operations
810
#define DISPLAY_UPDATE_TIME 200
911

12+
// Make some variables in the sketch files available to the C++ code.
13+
extern bool inSerialControl;
14+
15+
// Comment this out to save some code space
16+
// #define DEBUG_MODE
17+
18+
// Uncomment to run a key diagnostic. No tracker functions are on at all.
19+
// #define LCD_BUTTON_TEST
20+
21+
////////////////////////////////////////////////////////////////
22+
//
23+
// FEATURE SUPPORT SECTION
24+
//
25+
// Since the Arduino Uno has very little memory (32KB code, 2KB data) all features
26+
// stretch the Uno a little too far. So in order to save memory we allow you to enable
27+
// and disable features to help manage memory usage.
28+
// If you run the tracker with an Arduino Mega, you can uncomment all the features.
29+
//
30+
// If you would like to drive your OAT mount with only the LCD Shield,
31+
// you should comment out SUPPORT_SERIAL_CONTROL
32+
//
33+
// If you feel comfortable with configuring the OAT at startup manually, you should comment
34+
// out SUPPORT_GUIDED_STARTUP (maybe after you've used it for a while you know what to do).
35+
//
36+
// The POI menu can take a little data memory and you may not need it. If not, you can comment
37+
// out SUPPORT_POINTS_OF_INTEREST
38+
//
39+
////////////////////////////////////////////////////////////////
40+
41+
// Uncomment this to support the heating menu
42+
// NOTE: Heating is currently not supported!
43+
// #define SUPPORT_HEATING
44+
45+
// Uncomment to support Guided Startup
46+
#define SUPPORT_GUIDED_STARTUP
47+
48+
// Uncomment to support POI menu. Since memory is running low, this can be disabled in lieu of serial support.
49+
#define SUPPORT_POINTS_OF_INTEREST
50+
51+
// Uncomment to support Serial MEADE support
52+
// #define SUPPORT_SERIAL_CONTROL
53+
54+
1055
#endif

Software/Arduino code/OpenAstroTracker/LcdMenu.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ void LcdMenu::setNextActive() {
8787
// It also places the selector arrows around the active one.
8888
// It then sends the string to the LCD, keeping the selector arrows centered in the same place.
8989
void LcdMenu::updateDisplay() {
90-
//Serial.println("UD+");
91-
//Serial.flush();
9290
_lcd.setCursor(0, 0);
9391
String menuString = "";
9492
byte offsetToActive = 0;
@@ -107,39 +105,24 @@ void LcdMenu::updateDisplay() {
107105
offset += strlen(scratchBuffer);
108106
}
109107

110-
//Serial.println("UUD1: [" + menuString + "]");
111-
//Serial.flush();
112-
113108
// Determine where to place the active menu item. (empty space around longest item divided by two).
114109
int margin = (_columns - (_longestDisplay)) / 2;
115110
int offsetIntoString = offsetToActive - margin;
116111

117-
//Serial.println("UD1: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
118-
//Serial.flush();
119-
120112
// Pad the front if we don't have enough to offset the string to the arrow locations (happens on first item(s))
121113
while (offsetIntoString < 0) {
122114
_lcd.print(" ");
123115
offsetIntoString++;
124116
}
125117

126-
//Serial.println("UD2a: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
127-
//Serial.println("UD2b: [" + menuString + "]");
128-
//Serial.flush();
129-
130118
// Display the actual menu string
131119
String displayString = menuString.substring(offsetIntoString, offsetIntoString + _columns);
132-
//Serial.println("UD3: [" + displayString + "]");
133-
//Serial.flush();
134120

135121
// Pad the end with spaces so the display is cleared when getting to the last item(s).
136122
while (displayString.length() < _columns) {
137123
displayString += " ";
138124
}
139125

140-
//Serial.println("UD4: [" + displayString + "]");
141-
//Serial.flush();
142-
143126
printMenu(displayString);
144127

145128
// Pad the end with spaces so the display is cleared when getting to the last item(s).

Software/Arduino code/OpenAstroTracker/LcdMenu.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <Arduino.h>
55
#include <LiquidCrystal.h>
6+
#include "Globals.h"
67

78
// A single menu item (like RA, HEAT, POL, etc.)
89
// The ID is just a number, it has no relevance for the order of the items

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ void Mount::syncRA(int hour, int minute, int second) {
234234
newHA.addTime(deltaRA);
235235
setHA(newHA);
236236

237-
float targetRA,targetDEC;
238-
calculateRAandDECSteppers(targetRA,targetDEC);
237+
float targetRA, targetDEC;
238+
calculateRAandDECSteppers(targetRA, targetDEC);
239239
_stepperRA->setCurrentPosition(targetRA);
240240
}
241241

@@ -246,11 +246,10 @@ void Mount::syncRA(int hour, int minute, int second) {
246246
/////////////////////////////////
247247
// Set the current DEC position to be the given degrees (which are 0 .. -180 for Northern Hemisphere)
248248
void Mount::syncDEC(int degree, int minute, int second) {
249-
Serial.println("SyncDEC: " + String(degree) + ":" + String(minute) + ":" + String(second));
250249
_currentDEC = DegreeTime(degree, minute, second);
251250
_targetDEC = _currentDEC;
252-
float targetRA,targetDEC;
253-
calculateRAandDECSteppers(targetRA,targetDEC);
251+
float targetRA, targetDEC;
252+
calculateRAandDECSteppers(targetRA, targetDEC);
254253
_stepperDEC->setCurrentPosition(targetDEC);
255254
}
256255

@@ -262,13 +261,12 @@ void Mount::syncDEC(int degree, int minute, int second) {
262261
// Calculates movement parameters and program steppers to move
263262
// there. Must call loop() frequently to actually move.
264263
void Mount::startSlewingToTarget() {
265-
//Serial.println("StSlew2Trgt!");
266264
// Calculate new RA stepper target (and DEC)
267265
_currentDECStepperPosition = _stepperDEC->currentPosition();
268266
_currentRAStepperPosition = _stepperRA->currentPosition();
269-
float targetRA,targetDEC;
270-
calculateRAandDECSteppers(targetRA,targetDEC);
271-
moveSteppersTo(targetRA,targetDEC);
267+
float targetRA, targetDEC;
268+
calculateRAandDECSteppers(targetRA, targetDEC);
269+
moveSteppersTo(targetRA, targetDEC);
272270

273271
_mountStatus |= STATUS_SLEWING | STATUS_SLEWING_TO_TARGET;
274272
_totalDECMove = 1.0f * _stepperDEC->distanceToGo();
@@ -394,7 +392,6 @@ bool Mount::isParked() {
394392
// Starts manual slewing in one of eight directions or tracking
395393
/////////////////////////////////
396394
void Mount::startSlewing(int direction) {
397-
//Serial.println("StrtSlew: > " + String(direction) + " " + mountStatusString());
398395
if (direction & TRACKING) {
399396
_stepperTRK->setSpeed(_trackingSpeed);
400397

@@ -419,7 +416,6 @@ void Mount::startSlewing(int direction) {
419416
_mountStatus |= STATUS_SLEWING;
420417
}
421418
}
422-
//Serial.println("StrtSlew: < " + mountStatusString());
423419
}
424420

425421
/////////////////////////////////
@@ -429,24 +425,18 @@ void Mount::startSlewing(int direction) {
429425
// Stop manual slewing in one of two directions or Tracking. NS is the same. EW is the same
430426
/////////////////////////////////
431427
void Mount::stopSlewing(int direction) {
432-
//Serial.println("StopSlw: > " + String(direction) + " " + mountStatusString());
433428
if (direction & TRACKING) {
434-
//Serial.println("StpSlw: TRK OFF");
435429
// Turn off tracking
436430
_mountStatus &= ~STATUS_TRACKING;
437431
_stepperTRK->stop();
438432
}
439433

440434
if ((direction & (NORTH | SOUTH)) != 0) {
441435
_stepperDEC->stop();
442-
//Serial.println("StpSlw: DEC OFF");
443436
}
444437
if ((direction & (WEST | EAST)) != 0) {
445438
_stepperRA->stop();
446-
//Serial.println("StpSlw: RA OFF");
447439
}
448-
449-
//Serial.println("StpSlw: < " + mountStatusString());
450440
}
451441

452442
/////////////////////////////////
@@ -537,7 +527,6 @@ void Mount::loop() {
537527
_currentDEC = _targetDEC;
538528
}
539529

540-
//Serial.println("Loop: RA " + String(raStillRunning) + String(decStillRunning) );
541530
displayStepperPositionThrottled();
542531
}
543532
else {
@@ -553,7 +542,9 @@ void Mount::loop() {
553542

554543
// Make sure we do one last update when the steppers have stopped.
555544
displayStepperPosition();
556-
_lcdMenu->updateDisplay();
545+
if (!inSerialControl) {
546+
_lcdMenu->updateDisplay();
547+
}
557548
}
558549
}
559550

@@ -580,7 +571,6 @@ void Mount::setHome() {
580571
/////////////////////////////////
581572
void Mount::setTargetToHome() {
582573
float trackedSeconds = _stepperTRK->currentPosition() / _trackingSpeed; // steps/steps/s
583-
// Serial.println("Pos: " + String(stepperTRK->currentPosition()) + " Secs:" + String(trackedSeconds , 3));
584574

585575
// In order for RA coordinates to work correctly, we need to
586576
// offset HATime by elapsed time since last HA set and also
@@ -685,16 +675,17 @@ void Mount::moveSteppersTo(float targetRA, float targetDEC) {
685675
/////////////////////////////////
686676
void Mount::displayStepperPosition() {
687677
String disp ;
678+
688679
if ((abs(_totalDECMove) > 0.001) && (abs(_totalRAMove) > 0.001)) {
689680
float decDist = 100.0 - 100.0 * _stepperDEC->distanceToGo() / _totalDECMove;
690681
float raDist = 100.0 - 100.0 * _stepperRA->distanceToGo() / _totalRAMove;
691682

692-
sprintf(scratchBuffer, "D %s %d%%", DECString(LCD_STRING | CURRENT_STRING).c_str(), (int)decDist);
693-
_lcdMenu->setCursor(0, 1);
694-
_lcdMenu->printMenu(String(scratchBuffer));
695683
sprintf(scratchBuffer, "R %s %d%%", RAString(LCD_STRING | CURRENT_STRING).c_str(), (int)raDist);
696684
_lcdMenu->setCursor(0, 0);
697685
_lcdMenu->printMenu(String(scratchBuffer));
686+
sprintf(scratchBuffer, "D %s %d%%", DECString(LCD_STRING | CURRENT_STRING).c_str(), (int)decDist);
687+
_lcdMenu->setCursor(0, 1);
688+
_lcdMenu->printMenu(String(scratchBuffer));
698689
return;
699690
}
700691
else if (abs(_totalDECMove) > 0.001) {
@@ -707,13 +698,35 @@ void Mount::displayStepperPosition() {
707698
float raDist = 100.0 - 100.0 * _stepperRA->distanceToGo() / _totalRAMove;
708699
sprintf(scratchBuffer, "R %s %d%%", RAString(LCD_STRING | CURRENT_STRING).c_str(), (int)raDist);
709700
disp = disp + String(scratchBuffer);
710-
_lcdMenu->setCursor(0, 1);
701+
_lcdMenu->setCursor(0, inSerialControl ? 0 : 1);
711702
_lcdMenu->printMenu(String(scratchBuffer));
712703
}
713704
else {
714-
disp = "R:" + String(_stepperRA->currentPosition()) + " D:" + String(_stepperDEC->currentPosition()) ;
705+
#ifdef SUPPORT_SERIAL_CONTROL
706+
if (inSerialControl) {
707+
sprintf(scratchBuffer, " RA: %s", RAString(LCD_STRING | CURRENT_STRING).c_str());
708+
_lcdMenu->setCursor(0, 0);
709+
_lcdMenu->printMenu(scratchBuffer);
710+
sprintf(scratchBuffer, "DEC: %s", DECString(LCD_STRING | CURRENT_STRING).c_str());
711+
_lcdMenu->setCursor(0, 1);
712+
_lcdMenu->printMenu(scratchBuffer);
713+
}
714+
else {
715+
disp = "R:" + String(_stepperRA->currentPosition());
716+
_lcdMenu->setCursor(0, 1);
717+
_lcdMenu->printMenu(disp);
718+
disp = "D:" + String(_stepperDEC->currentPosition()) ;
719+
_lcdMenu->setCursor(8, 1);
720+
_lcdMenu->printMenu(disp);
721+
}
722+
#else
723+
disp = "R:" + String(_stepperRA->currentPosition());
715724
_lcdMenu->setCursor(0, 1);
716725
_lcdMenu->printMenu(disp);
726+
disp = "D:" + String(_stepperDEC->currentPosition()) ;
727+
_lcdMenu->setCursor(8, 1);
728+
_lcdMenu->printMenu(disp);
729+
#endif
717730
}
718731
}
719732

@@ -760,32 +773,19 @@ String Mount::DECString(byte type, byte active) {
760773
/////////////////////////////////
761774
// Return a string of DEC in the given format. For LCDSTRING, active determines where the cursor is
762775
String Mount::RAString(byte type, byte active) {
763-
//Serial.println("RA1: T" + String(type) + " A" + String(active));
764776
DayTime ra;
765-
//Serial.println("RA2:" + ra.ToString());
766777
if ((type & TARGET_STRING) == TARGET_STRING) {
767-
//Serial.println("RA3");
768778
ra = DayTime(_targetRA);
769-
//Serial.println("RA3A:" + ra.ToString());
770779
} else {
771780
ra = DayTime(currentRA());
772781
}
773782

774-
//Serial.println("RA4:" + ra.ToString());
775783
DayTime raDisplay(ra);
776-
//Serial.println("RA5:" + raDisplay.ToString());
777-
778-
//Serial.println("RA6:" + _HACorrection.ToString());
779784
raDisplay.addTime(_HACorrection);
780-
//Serial.println("RA6A:" + raDisplay.ToString());
781785

782786
sprintf(scratchBuffer, formatStringsRA[type & FORMAT_STRING_MASK], raDisplay.getHours(), raDisplay.getMinutes() , raDisplay.getSeconds());
783-
//Serial.println("RA8:" + String(scratchBuffer));
784787
if ((type & FORMAT_STRING_MASK) == LCDMENU_STRING) {
785-
//Serial.println("RA9");
786788
scratchBuffer[active * 4] = '>';
787-
//Serial.println("RA9A:" + String(scratchBuffer));
788789
}
789-
//Serial.println("RAQ");
790790
return String (scratchBuffer);
791791
}

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
=======================================================================================================================================
33
4-
Version 1.6.18
4+
Version 1.6.19
55
66
1. Connect your Arduino, under tools choose "Arduino Uno", set the right Port and set "Arduino ISP" as the Programmer.
77
2. Hit upload (Ctrl-U)
@@ -14,7 +14,13 @@
1414
1515
=======================================================================================================================================
1616
*/
17-
String version = "V1.6.18";
17+
#include "Globals.h"
18+
19+
String version = "V1.6.19";
20+
21+
///////////////////////////////////////////////////////////////////////////
22+
// Please see the Globals.h file for configuration of the firmware.
23+
///////////////////////////////////////////////////////////////////////////
1824

1925
// See NORTHERN_HEMISPHERE in Globals.h if you not in the northern hemisphere
2026

@@ -68,43 +74,3 @@ int PolarisRASecond = 25;
6874
// This changes slightly over weeks, so adjust every couple of months.
6975
// This value is from 27.Nov.19, I suggest next adjustment in mid 2020
7076
// The same could be done for the DEC coordinates but they dont change significantly for the next 5 years
71-
72-
// Comment this out to save some code space
73-
// #define DEBUG_MODE
74-
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-
99-
// Uncomment this to support the heating menu
100-
// NOTE: Heating is currently not supported!
101-
// #define SUPPORT_HEATING
102-
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/Utility.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define UTILITY_H_
33

44
#include <Arduino.h>
5+
#include "Globals.h"
56

67
// LCD shield buttons
78
#define btnRIGHT 0
@@ -70,8 +71,6 @@ class LcdButtons {
7071
_newKey = _currentKey ;
7172
}
7273
}
73-
74-
//Serial.println("KBD: CK-" + String(_currentKey) + " LK-" + String(_lastKey) + " NK-" + String(_newKey) + " LNK-" + String(_lastNewKey));
7574
}
7675

7776
private:

0 commit comments

Comments
 (0)