Skip to content

Commit e04835c

Browse files
V1.6.01 - Updates
- Fixed pin assignment on DEC - Moved key handling to its own class - Added target and current values for RA and DEC to INFO menu - Enabled and fixed Serial code. - Fixed some misnamed variables in the Mount class
1 parent 9d6a331 commit e04835c

24 files changed

+694
-549
lines changed

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DayTime::DayTime(long ms) {
2828
ms = (ms - secs) / 60;
2929
mins = (int)(ms % 60);
3030
ms = (ms - mins) / 60;
31-
hours = (int)(ms % hourWrap);
31+
hours = (int)ms ;
3232
}
3333

3434
DayTime::DayTime(float timeInHours) {
@@ -73,23 +73,31 @@ void DayTime::set(int h, int m, int s) {
7373
hours = h;
7474
mins = m;
7575
secs = s;
76+
checkHours();
7677
}
7778

7879
void DayTime::set(const DayTime& other) {
7980
hours = other.hours;
8081
mins = other.mins;
8182
secs = other.secs;
83+
checkHours();
8284
}
8385

8486
// Add hours, wrapping days (which are not tracked)
8587
void DayTime::addHours(int deltaHours) {
8688
hours += deltaHours;
89+
checkHours();
90+
}
91+
92+
void DayTime::checkHours() {
93+
Serial.println("DtIn: "+String(hours));
8794
while (hours >= hourWrap) {
8895
hours -= hourWrap;
8996
}
9097
while (hours < 0) {
9198
hours += hourWrap;
9299
}
100+
Serial.println("DtOut: "+String(hours));
93101
}
94102

95103
// Add minutes, wrapping hours if needed
@@ -175,16 +183,12 @@ String DayTime::ToString()
175183

176184

177185
DegreeTime::DegreeTime(): DayTime() {
178-
hourWrap = 90;
186+
hourWrap = 180;
179187
}
180188

181-
DegreeTime::DegreeTime(const DegreeTime& other): DayTime(other) {}
189+
DegreeTime::DegreeTime(const DegreeTime& other): DayTime(other) { }
182190
DegreeTime::DegreeTime(int h, int m, int s) : DayTime(h, m, s) { }
183-
DegreeTime::DegreeTime(float inDegrees) : DayTime(inDegrees) {}
184-
185-
void DegreeTime::addHours(int deltaHours) {
186-
hours = NORTHERN_HEMISPHERE ? adjustClamp(hours, deltaHours, -180, 0) : adjustClamp(hours, deltaHours, 0, 180);
187-
}
191+
DegreeTime::DegreeTime(float inDegrees) : DayTime(inDegrees) { }
188192

189193
void DegreeTime::addDegrees(int deltaDegrees) {
190194
addHours(deltaDegrees);
@@ -201,3 +205,15 @@ int DegreeTime::getPrintDegrees() {
201205
float DegreeTime::getTotalDegrees() {
202206
return getTotalHours();
203207
}
208+
209+
void DegreeTime::checkHours() {
210+
if (NORTHERN_HEMISPHERE) {
211+
Serial.println("DgIn: "+String(hours));
212+
if (hours > 0) hours = 0;
213+
if (hours < -180) hours = -180;
214+
Serial.println("DgOut: "+String(hours));
215+
} else {
216+
if (hours > 180) hours = 180;
217+
if (hours < 0) hours = 0;
218+
}
219+
}

Software/Arduino code/OpenAstroTracker/DayTime.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class DayTime {
5757

5858
// Convert to a standard string (like 14:45:06)
5959
String ToString();
60+
//protected:
61+
virtual void checkHours();
6062
};
6163

6264
class DegreeTime : public DayTime {
@@ -66,9 +68,6 @@ class DegreeTime : public DayTime {
6668
DegreeTime(int h, int m, int s);
6769
DegreeTime(float inDegrees);
6870

69-
// Override hours to not wrap, but clamp at +/- 90
70-
virtual void addHours(int deltaHours);
71-
7271
// Add degrees, clamp at 90
7372
void addDegrees(int deltaDegrees);
7473

@@ -80,6 +79,11 @@ class DegreeTime : public DayTime {
8079

8180
// Get total degrees
8281
float getTotalDegrees();
82+
//protected:
83+
virtual void checkHours() override;
84+
85+
private:
86+
void clampDegrees();
8387
};
8488

8589
#endif
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
#include "Globals.h"
2-
3-
int lcd_key = 0; // The current key state
4-
int adc_key_in = 0; // The analog value of the keys

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
// Set to 1 if you are in the northern hemisphere.
44
#define NORTHERN_HEMISPHERE 1
55

6-
// Time in ms between LCD screen updates during slewing operations
7-
#define DISPLAY_UPDATE_TIME 100
8-
9-
10-
// LCD shield buttons
11-
#define btnRIGHT 0
12-
#define btnUP 1
13-
#define btnDOWN 2
14-
#define btnLEFT 3
15-
#define btnSELECT 4
16-
#define btnNONE 5
6+
#define DEBUG_MODE
177

18-
19-
extern int lcd_key; // The current key state
20-
extern int adc_key_in; // The analog value of the keys
8+
// Time in ms between LCD screen updates during slewing operations
9+
#define DISPLAY_UPDATE_TIME 200
2110

2211
#endif

Software/Arduino code/OpenAstroTracker/LcdMenu.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ 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();
90+
//Serial.println("UD+");
91+
//Serial.flush();
9292
_lcd.setCursor(0, 0);
9393
String menuString = "";
9494
byte offsetToActive = 0;
@@ -107,38 +107,38 @@ void LcdMenu::updateDisplay() {
107107
offset += strlen(scratchBuffer);
108108
}
109109

110-
Serial.println("UUD1: [" + menuString + "]");
111-
Serial.flush();
110+
//Serial.println("UUD1: [" + menuString + "]");
111+
//Serial.flush();
112112

113113
// Determine where to place the active menu item. (empty space around longest item divided by two).
114114
int margin = (_columns - (_longestDisplay)) / 2;
115115
int offsetIntoString = offsetToActive - margin;
116116

117-
Serial.println("UD1: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
118-
Serial.flush();
117+
//Serial.println("UD1: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
118+
//Serial.flush();
119119

120120
// Pad the front if we don't have enough to offset the string to the arrow locations (happens on first item(s))
121121
while (offsetIntoString < 0) {
122122
_lcd.print(" ");
123123
offsetIntoString++;
124124
}
125125

126-
Serial.println("UD2a: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
127-
Serial.println("UD2b: [" + menuString + "]");
128-
Serial.flush();
126+
//Serial.println("UD2a: " + String(margin) + " " + String(offsetToActive ) + " " + String(offsetIntoString ));;
127+
//Serial.println("UD2b: [" + menuString + "]");
128+
//Serial.flush();
129129

130130
// Display the actual menu string
131131
String displayString = menuString.substring(offsetIntoString, offsetIntoString + _columns);
132-
Serial.println("UD3: [" + displayString + "]");
133-
Serial.flush();
132+
//Serial.println("UD3: [" + displayString + "]");
133+
//Serial.flush();
134134

135135
// Pad the end with spaces so the display is cleared when getting to the last item(s).
136136
while (displayString.length() < _columns) {
137137
displayString += " ";
138138
}
139139

140-
Serial.println("UD4: [" + displayString + "]");
141-
Serial.flush();
140+
//Serial.println("UD4: [" + displayString + "]");
141+
//Serial.flush();
142142

143143
printMenu(displayString);
144144

0 commit comments

Comments
 (0)