Skip to content

Commit 0fe0b5a

Browse files
V1.5.11 - Updates
1 parent 5179fbf commit 0fe0b5a

File tree

6 files changed

+197
-33
lines changed

6 files changed

+197
-33
lines changed

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,29 @@
1414
1515
=======================================================================================================================================
1616
*/
17-
String version = "V1.5.10";
17+
String version = "V1.5.11";
1818

1919
boolean north = true; // change this to 'false' if youre in the southern hemisphere
2020

2121
float speed = 1.000; // Use this value to slightly increase or decrese tracking speed. The values from the "CAL" menu will be added to this.
2222

23-
int RAsteps = 330; // adjust this value to calibrate RA movement
24-
int DECsteps = 163;
23+
24+
// Belt moves 40mm for one rev (2mm pitch, 20 teeth).
25+
// RA wheel is 2 x Pi x 180mm circumference which is 1130.97mm
26+
// One RA revolution needs 28.27 (1131mm/40mm) stepper revolutions
27+
// which means 115814 steps (28.27 x 4096) moves 360 degrees
28+
// So 321.7 steps/ degree (115814 / 360)
29+
int RAStepsPerDegree = 330; // adjust this value to calibrate RA movement
30+
31+
// Belt moves 40mm for one rev (2mm pitch, 20 teeth).
32+
// DEC wheel is 2 x Pi x 90mm circumference which is 565.5mm
33+
// So 14.13 stepper revs (14.13 x 4096 = 57906 steps) moves 360degrees
34+
// So 160.85 steps/ degree (57906/360)
35+
int DECStepsPerDegree = 163; // Number of steps needed to move DEC motor 1 degree.
2536

2637
// This is how many steps your 28BYJ-48 stepper needs for a full rotation. It is almost always 4096.
2738
// This code drives the steppers in halfstep mode
28-
float RevSteps = 4096;
39+
float StepsPerRevolution = 4096;
2940

3041
int RAspeed = 400; // You can change the speed and acceleration of the steppers here. Max. Speed = 600. High speeds tend to make
3142
int RAacceleration = 600; // these cheap steppers unprecice

Software/Arduino code/OpenAstroTracker/b0_functions.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int adjustWrap(int current, int adjustBy, int minVal, int maxVal)
1616
current += adjustBy;
1717
if (current > maxVal) current -= (maxVal + 1 - minVal);
1818
if (current < minVal) current += (maxVal + 1 - minVal
19-
);
19+
);
2020
return current;
2121
}
2222

@@ -80,7 +80,7 @@ void logv(const char* input, ...) {
8080
Serial.println(formatArg(input, argp));
8181
Serial.flush();
8282
va_end(argp);
83-
83+
8484
}
8585

8686
String format(const char* input, ...) {
@@ -152,4 +152,4 @@ String formatArg(const char* input, va_list args) {
152152
*p = '\0';
153153
return String(achBuffer);
154154
}
155-
#endif
155+
#endif

Software/Arduino code/OpenAstroTracker/c5_calcStepperPos.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ void handleDECandRACalculations()
77
hourPos = hourPos - 24;
88
}
99

10-
// How many steps moves the RA ring one hour along (15degrees?)
11-
stepsPerHour = (float(RAsteps) / 288.0) * RevSteps;
10+
// How many steps moves the RA ring one hour along (15degrees?) No idea what 288 is?
11+
stepsPerHour = (float(RAStepsPerDegree) / 288.0) * StepsPerRevolution;
1212

13-
// Where do ww want to move RA to?
13+
// Where do we want to move RA to? Why divided by 2?
1414
float moveRA = hourPos * stepsPerHour / 2;
1515

1616
// Where do we want to move DEC to?
1717
// the variable degreeDEC is 0deg for the celestial pole (90deg), and goes negative only.
18-
moveDEC = (degreeDEC * float(DECsteps) + minDEC * (float(DECsteps) / 60.0f) + secDEC * (float(DECsteps) / 3600.0f));
18+
moveDEC = (degreeDEC * float(DECStepsPerDegree) + minDEC * (float(DECStepsPerDegree) / 60.0f) + secDEC * (float(DECStepsPerDegree) / 3600.0f));
1919

2020
// We can move 6 hours in either direction. Outside of that we need to flip directions.
2121
float RALimit = (6.0f * stepsPerHour / 2);
Lines changed: 172 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,200 @@
1-
void processRAKeys(int key) {
2-
switch (key) {
3-
case btnUP: {
4-
if (RAselect == 0) RATime.addHours(1);
5-
if (RAselect == 1) RATime.addMinutes(1);
6-
if (RAselect == 2) RATime.addSeconds(1);
1+
/*
2+
WIP for complete OO-ification of code.
3+
4+
class Processor
5+
{
6+
Processor *_nextProcessor;
7+
int _numSubMenuItems;
8+
int _currentSubMenu;
9+
10+
public:
11+
Processor(int numSubMenuItems)
12+
{
13+
_numSubMenuItems = numSubMenuItems;
14+
_currentSubMenu = 0;
15+
_nextProcessor = nullptr;
16+
}
17+
18+
void setNext(Processor *nextProcessor) {
19+
_nextProcessor = nextProcessor;
20+
}
21+
virtual const char *display() = 0;
22+
virtual void onDownKeyPressed() {}
23+
virtual void onUpKeyPressed() {}
24+
virtual void onLeftKeyPressed() {
25+
adjustSubMenu();
26+
}
27+
virtual void onRightKeyPressed() { }
28+
virtual void onSelectKeyPressed() {}
29+
virtual void onKeyReleased(int key) {}
30+
virtual void onIdle() {}
31+
void adjustSubMenu(int by = 1)
32+
{
33+
_currentSubMenu = adjustWrap(_currentSubMenu, by, 0, _numSubMenuItems);
34+
}
35+
};
36+
37+
class ProcessRA : Processor
38+
{
39+
public:
40+
ProcessRA() : Processor(3)
41+
{
42+
}
43+
const char *display()
44+
{
45+
return "RA";
46+
}
47+
48+
void onDownKeyPressed()
49+
{
50+
}
51+
52+
void onUpKeyPressed()
53+
{
54+
}
55+
56+
void onLeftKeyPressed()
57+
{
58+
}
59+
60+
void onRightKeyPressed()
61+
{
62+
}
63+
64+
void onSelectKeyPressed()
65+
{
66+
}
67+
68+
void onIdle()
69+
{
70+
}
71+
};
72+
73+
class MenuProcessor
74+
{
75+
Processor *_firstProcessor;
76+
Processor *_lastProcessor;
77+
Processor *_activeProcessor;
78+
int _lastKeyState;
79+
80+
public:
81+
MenuProcessor()
82+
{
83+
_firstProcessor = nullptr;
84+
_lastProcessor = nullptr;
85+
_activeProcessor = nullptr;
86+
_lastKeyState = btnNONE;
87+
}
88+
89+
void loop()
90+
{
91+
int keyState = read_LCD_buttons();
92+
if ((_lastKeyState == btnNONE) && (keyState != btnNONE))
93+
{
94+
switch (keyState)
95+
{
96+
case btnUP:
97+
_activeProcessor->onUpKeyPressed();
98+
break;
99+
case btnDOWN:
100+
_activeProcessor->onDownKeyPressed();
101+
break;
102+
case btnLEFT:
103+
_activeProcessor->onLeftKeyPressed();
104+
break;
105+
case btnRIGHT:
106+
_activeProcessor->onRightKeyPressed();
107+
break;
108+
case btnSELECT:
109+
_activeProcessor->onSelectKeyPressed();
110+
break;
111+
}
112+
_lastKeyState = keyState;
113+
}
114+
else if ((_lastKeyState != btnNONE) && (keyState == btnNONE))
115+
{
116+
_activeProcessor->onKeyReleased(_lastKeyState);
117+
}
118+
else if ((_lastKeyState == btnNONE) && (keyState == btnNONE))
119+
{
120+
_activeProcessor->onIdle();
121+
}
122+
}
123+
124+
void addProcessor(Processor *processor)
125+
{
126+
if (_firstProcessor == nullptr)
127+
{
128+
_firstProcessor = processor;
129+
}
130+
else
131+
{
132+
_firstProcessor->setNext(processor);
133+
}
134+
}
135+
};
136+
*/
137+
138+
void processRAKeys(int key)
139+
{
140+
switch (key)
141+
{
142+
case btnUP:
143+
{
144+
if (RAselect == 0)
145+
RATime.addHours(1);
146+
if (RAselect == 1)
147+
RATime.addMinutes(1);
148+
if (RAselect == 2)
149+
RATime.addSeconds(1);
7150

8151
// slow down key repetitions
9152
delay(150);
10153
waitForButtonRelease = false;
11154
}
12155
break;
13156

14-
case btnDOWN: {
15-
if (RAselect == 0) RATime.addHours(-1);
16-
if (RAselect == 1) RATime.addMinutes(-1);
17-
if (RAselect == 2) RATime.addSeconds(-1);
157+
case btnDOWN:
158+
{
159+
if (RAselect == 0)
160+
RATime.addHours(-1);
161+
if (RAselect == 1)
162+
RATime.addMinutes(-1);
163+
if (RAselect == 2)
164+
RATime.addSeconds(-1);
18165

19166
// slow down key repetitions
20167
delay(150);
21168
waitForButtonRelease = false;
22169
}
23170
break;
24171

25-
case btnLEFT: {
172+
case btnLEFT:
173+
{
26174
RAselect = adjustWrap(RAselect, 1, 0, 2);
27175
}
28176
break;
29177

30-
case btnSELECT: {
31-
moveSteppersToTarget() ;
178+
case btnSELECT:
179+
{
180+
moveSteppersToTarget();
32181
}
33182
break;
34183

35-
case btnRIGHT: {
184+
case btnRIGHT:
185+
{
36186
lcdMenu.setNextActive();
37187
}
38188
break;
39189
}
40190
}
41191

42-
void printRASubmenu() {
192+
void printRASubmenu()
193+
{
43194

44195
//Serial.println("HA:" + HATime.ToString() + " HA(corr):" + HACorrection.ToString() + " RA:" + RATime.ToString() + " RA(corr):" + RADisplayTime.ToString());
45-
if (RAselect == 0) {
196+
if (RAselect == 0)
197+
{
46198
lcdMenu.printMenuArg(">%dh %dm %ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
47199

48200
//lcd.print(int(diamCorrection)); //for debugging
@@ -51,11 +203,13 @@ void printRASubmenu() {
51203
//lcd.print(" ");
52204
}
53205

54-
if (RAselect == 1) {
206+
if (RAselect == 1)
207+
{
55208
lcdMenu.printMenuArg(" %dh>%dm %ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
56209
}
57210

58-
if (RAselect == 2) {
211+
if (RAselect == 2)
212+
{
59213
lcdMenu.printMenuArg(" %dh %dm>%ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
60214
}
61215
}

Software/Arduino code/OpenAstroTracker/c_buttons.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ void loop() {
3131

3232
lcd_key = read_LCD_buttons();
3333

34-
trackingspeed = ((((335.1417 / 288.0) * RevSteps) / 3590)) - 1 + float(speedcalibration);
34+
trackingspeed = ((((335.1417 / 288.0) * StepsPerRevolution) / 3590)) - 1 + float(speedcalibration);
3535
stepperTRK.setSpeed(trackingspeed);
3636

37-
if (inSerialControl ) {
37+
if (inSerialControl) {
3838
serialLoop();
3939
}
4040
else {

Software/Arduino code/OpenAstroTracker/f_serial.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void handleMeadeSetInfo(String inCmd) {
5757
Serial.print("0");
5858
return;
5959
}
60-
Serial.println("[" + inCmd + "]");
6160
if (inCmd[0] == 'd') {
6261
// Set DEC
6362
int sgn = inCmd[1] == '+' ? 1 : -1;
@@ -451,7 +450,7 @@ void serialEvent() {
451450
minDEC += slew_DECm;
452451
secDEC += slew_DECs;
453452
Serial.print("1");
454-
slew_DEC = (slew_DECd * float(DECsteps) + slew_DECm * (float(DECsteps) / float(60)) + slew_DECs * (float(DECsteps) / float(3600))) / 2;
453+
slew_DEC = (slew_DECd * float(DECStepsPerDegree) + slew_DECm * (float(DECStepsPerDegree) / float(60)) + slew_DECs * (float(DECStepsPerDegree) / float(3600))) / 2;
455454
456455
stepperDEC.moveTo(slew_DEC);
457456
//inCmd = "";

0 commit comments

Comments
 (0)