Skip to content

Commit 3a30e83

Browse files
V1.4.1 - Various enhancements
- On boot, the system walks you through initial setup (CTRL, HA). - Moved tracking stepper to its own function. - Changed behavior of SELECT in HA menu to confirm choice instead of zeroing HA. - Added a message to HOME if you are already home and press SELECT - Removed extra empty case statements in the menus. - Changed the buttons that move the rig in CTRL mode. LEFT moves left, RIGHT moves right. SELECT ends CTRL mode - Added a prompt when leaving CTRL mode whether to set home point .
1 parent 169ae92 commit 3a30e83

15 files changed

+301
-132
lines changed

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
=======================================================================================================================================
33
4-
Version 1.4.0
4+
Version 1.4.1
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
@@ -10,7 +10,7 @@
1010
1111
=======================================================================================================================================
1212
*/
13-
String version = "V1.4.0";
13+
String version = "V1.4.1";
1414

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

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ int adc_key_in = 0; // The analog value of the keys
5555

5656
String inString = "";
5757

58+
bool inStartup = true; // Start with a guided startup
59+
5860
int calDelay = 150; // The current delay when changing calibration value. The longer a button is depressed, the samller this gets.
5961

6062
bool waitForButtonRelease = false; // When a button is pressed should we wait for its release before another loop?

Software/Arduino code/OpenAstroTracker/b1_menu.ino

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class LcdMenu {
4242

4343
int _leftArrow = 3;
4444
int _rightArrow = 4;
45+
int _upArrow = 5;
46+
int _downArrow = 6;
4547

4648
public:
4749
// Create a new menu, using the given LCD screen and using the given number of LCD display columns
@@ -54,6 +56,8 @@ class LcdMenu {
5456
_columns = cols;
5557
lcd->createChar(_leftArrow, LeftArr);
5658
lcd->createChar(_rightArrow, RightArr);
59+
lcd->createChar(_upArrow, UpArr);
60+
lcd->createChar(_downArrow, DownArr);
5761
}
5862

5963
// Find a menu item by its ID
@@ -90,6 +94,11 @@ class LcdMenu {
9094
_activeId = id;
9195
}
9296

97+
// Pass throu utility function
98+
void setCursor(int col, int row){
99+
_lcd->setCursor(col,row);
100+
}
101+
93102
// Go to the next menu item from currently active one
94103
void setNextActive() {
95104
// If the last item is active, go to the first.
@@ -137,7 +146,7 @@ class LcdMenu {
137146
// For non-active items, pad with a space.
138147
itemString = " " + item->display() + " ";
139148
}
140-
149+
141150
menuString += itemString;
142151
offset += itemString.length();
143152
item = item->nextItem();
@@ -159,11 +168,11 @@ class LcdMenu {
159168
while (displayString.length() < _columns) {
160169
displayString += " ";
161170
}
162-
171+
163172
printMenu(displayString);
164173
}
165174

166-
// Prints a string to the LCD at the current cursor position, using a printf() style call
175+
// Prints a string to the LCD at the current cursor position, using a printf() style call
167176
void printMenuArg(const char* input, ...) {
168177
va_list args;
169178
va_start(args, input);
@@ -177,6 +186,12 @@ class LcdMenu {
177186
else if (*i == '<') {
178187
_lcd->write(_leftArrow);
179188
}
189+
else if (*i == '^') {
190+
_lcd->write(_upArrow);
191+
}
192+
else if (*i == '~') {
193+
_lcd->write(_downArrow);
194+
}
180195
else {
181196
_lcd->print(*i);
182197
}
@@ -189,7 +204,7 @@ class LcdMenu {
189204
case 'c':
190205
{
191206
byte b = (byte) (va_arg(args, int) && 0x00FF);
192-
_lcd->write((byte)b);
207+
_lcd->write(byte(b));
193208
}
194209
break;
195210
case 's': _lcd->print(va_arg(args, char*)); break;
@@ -200,7 +215,7 @@ class LcdMenu {
200215
}
201216
va_end(args);
202217

203-
// Since we don't know exaclty how many characters teh var_args printed we know the
218+
// Since we don't know exaclty how many characters teh var_args printed we know the
204219
// least count printed and just pad from that (extra spaces are ignored by the LCD).
205220
while (leastCount < _columns) {
206221
_lcd->print(" ");
@@ -219,6 +234,12 @@ class LcdMenu {
219234
else if (line[i] == '<') {
220235
_lcd->write(_leftArrow);
221236
}
237+
else if (line[i] == '^') {
238+
_lcd->write(_upArrow);
239+
}
240+
else if (line[i] == '~') {
241+
_lcd->write(_downArrow);
242+
}
222243
else {
223244
_lcd->print(line[i]);
224245
}
@@ -255,4 +276,25 @@ class LcdMenu {
255276
B00000
256277
};
257278

279+
byte UpArr[8] = {
280+
B00100,
281+
B01110,
282+
B11111,
283+
B00100,
284+
B00100,
285+
B00100,
286+
B00100,
287+
B00100
288+
};
289+
290+
byte DownArr[8] = {
291+
B000100,
292+
B000100,
293+
B000100,
294+
B000100,
295+
B000100,
296+
B011111,
297+
B001110,
298+
B000100
299+
};
258300
};

Software/Arduino code/OpenAstroTracker/b_setup.ino

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,5 @@ void setup() {
7171
lcd.print(" " + version);
7272
delay(1750);
7373

74-
// Start on the CTRL menu (until guided startup)
75-
lcdMenu.setActive(Control_Menu);
76-
lcd.setCursor(0, 0);
77-
lcdMenu.updateDisplay();
74+
7875
}

Software/Arduino code/OpenAstroTracker/c5_calcStepperPos.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ void handleDECandRACalculations()
4949
stepperRA.moveTo(targetRA);
5050
stepperDEC.moveTo(targetDEC);
5151
}
52+
53+
void runTracker()
54+
{
55+
if (tracking == 1) {
56+
stepperTRK.runSpeed();
57+
}
58+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#define StartupIsPointedAtPole 1
2+
#define StartupSetHATime 4
3+
#define StartupWaitForHACompletion 6
4+
#define StartupHAConfirmed 7
5+
#define StartupWaitForPoleCompletion 9
6+
#define StartupPoleConfirmed 10
7+
#define StartupCompleted 20
8+
9+
int startupState = StartupIsPointedAtPole;
10+
int isAtPole = 1;
11+
12+
13+
void startupIsCompleted() {
14+
startupState = StartupCompleted;
15+
inStartup = false;
16+
17+
// Start on the RA menu
18+
lcdMenu.setActive(RA_Menu);
19+
lcdMenu.setCursor(0, 0);
20+
lcdMenu.updateDisplay();
21+
}
22+
23+
void processStartupKeys(int key) {
24+
switch (startupState )
25+
{
26+
case StartupIsPointedAtPole:
27+
{
28+
if (key == btnLEFT) {
29+
isAtPole = adjustWrap(isAtPole, 1, 0, 2);
30+
}
31+
else if (key == btnSELECT) {
32+
if (isAtPole == 1) { // Yes
33+
startupState = StartupSetHATime;
34+
}
35+
else if (isAtPole == 0) { // No
36+
startupState = StartupWaitForPoleCompletion;
37+
inStartup = false;
38+
lcdMenu.setCursor(0, 0);
39+
lcdMenu.printMenu("Use ^~<> to pole");
40+
lcdMenu.setActive(Control_Menu);
41+
42+
// Skip the 'Manual control' prompt
43+
inControlMode = true;
44+
}
45+
else if (isAtPole == 2) { // Cancel
46+
startupIsCompleted();
47+
}
48+
}
49+
}
50+
break;
51+
52+
case StartupSetHATime :
53+
{
54+
inStartup = false;
55+
56+
// Jump to the HA menu
57+
lcdMenu.setCursor(0, 0);
58+
lcdMenu.printMenu("Set current HA");
59+
lcdMenu.setActive(HA_Menu);
60+
startupState = StartupWaitForHACompletion;
61+
62+
}
63+
break;
64+
65+
case StartupHAConfirmed: {
66+
startupIsCompleted();
67+
}
68+
break;
69+
70+
case StartupPoleConfirmed: {
71+
isAtPole = true;
72+
73+
// Ask again to confirm
74+
startupState = StartupIsPointedAtPole;
75+
}
76+
break;
77+
}
78+
}
79+
80+
81+
void prinStartupMenu() {
82+
switch (startupState)
83+
{
84+
case StartupIsPointedAtPole:
85+
{
86+
// 0123456789012345
87+
String choices(" Yes No Cancl ");
88+
if (isAtPole == 1) {
89+
choices.setCharAt(0, '>');
90+
choices.setCharAt(4, '<');
91+
}
92+
if (isAtPole == 0) {
93+
choices.setCharAt(5, '>');
94+
choices.setCharAt(8, '<');
95+
}
96+
if (isAtPole == 2) {
97+
choices.setCharAt(9, '>');
98+
choices.setCharAt(15, '<');
99+
}
100+
lcdMenu.setCursor(0, 0);
101+
lcdMenu.printMenu("Pointed at pole?");
102+
lcdMenu.setCursor(0, 1);
103+
lcdMenu.printMenu(choices);
104+
}
105+
break;
106+
case StartupPoleConfirmed:
107+
break;
108+
case StartupHAConfirmed:
109+
break;
110+
}
111+
}

Software/Arduino code/OpenAstroTracker/c6_moveTo.ino

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ void stopSteppers() {
66
while (stepperRA.isRunning() || stepperDEC.isRunning()) {
77
stepperRA.run();
88
stepperDEC.run();
9-
if (tracking == 1) {
10-
stepperTRK.runSpeed();
11-
}
9+
runTracker();
1210
}
1311
}
1412

@@ -31,18 +29,14 @@ bool stopStepper(int mask, bool useRA) {
3129
while (stepperRA.isRunning()) {
3230
stepperRA.run();
3331
stepperDEC.run();
34-
if (tracking == 1) {
35-
stepperTRK.runSpeed();
36-
}
32+
runTracker();
3733
}
3834
}
3935
else {
4036
while (stepperDEC.isRunning()) {
4137
stepperRA.run();
4238
stepperDEC.run();
43-
if (tracking == 1) {
44-
stepperTRK.runSpeed();
45-
}
39+
runTracker();
4640
}
4741
}
4842

@@ -65,14 +59,12 @@ void moveSteppersToTarget() {
6559
while (stepperDEC.distanceToGo() != 0 || stepperRA.distanceToGo() != 0) {
6660
stepperRA.run();
6761
stepperDEC.run();
68-
69-
// If we're tracking we should run the TRK stepper (same one at slow speed)
70-
if (tracking == 1) {
71-
stepperTRK.runSpeed();
72-
}
62+
63+
// Run the TRK stepper (same one at slow speed)
64+
runTracker();
7365

7466
if (display <= 0) {
75-
lcd.setCursor(0, 1);
67+
lcdMenu.setCursor(0, 1);
7668
String disp = "";
7769
if (decTotal > 0) {
7870
float decDist = 100.0 - 100.0 * abs(stepperDEC.distanceToGo()) / decTotal;
@@ -99,13 +91,12 @@ void moveSteppersToTargetAsync() {
9991
if (stepperDEC.isRunning() || stepperRA.isRunning()) {
10092
stepperRA.run();
10193
stepperDEC.run();
102-
// If we're not moving RA we should run the TRK stepper (same one at slow speed)
103-
if (stepperRA.distanceToGo() == 0) {
104-
stepperTRK.runSpeed();
105-
}
94+
95+
// Run the TRK stepper (same one at slow speed)
96+
runTracker();
10697

10798
if (controlDisplay <= 0) {
108-
lcd.setCursor(0, 1);
99+
lcdMenu.setCursor(0, 1);
109100
String disp ;
110101
if ((totalDECMove == 0) || (totalRAMove == 0)) {
111102
disp = String(format("D:%l R:%l", stepperDEC.currentPosition(), stepperRA.currentPosition()));

Software/Arduino code/OpenAstroTracker/c71_menuDEC.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ void processDECKeys(int key) {
5252
void printDECSubmenu() {
5353

5454
if (DECselect == 0) {
55-
lcdMenu.printMenuArg(">%d%c %d%c %d%c", printdegDEC, 0, minDEC, 1, secDEC, 2);
55+
lcdMenu.printMenuArg(">%d%c %d%c %d%s", printdegDEC, 0, minDEC, 1, secDEC, "\"");
5656
}
5757
if (DECselect == 1) {
58-
lcdMenu.printMenuArg(" %d%c>%d%c %d%c", printdegDEC, 0, minDEC, 1, secDEC, 2);
58+
lcdMenu.printMenuArg(" %d%c>%d%c %d%s", printdegDEC, 0, minDEC, 1, secDEC, "\"");
5959
}
6060
if (DECselect == 2) {
61-
lcdMenu.printMenuArg(" %d%c %d%c>%d%c", printdegDEC, 0, minDEC, 1, secDEC, 2);
61+
lcdMenu.printMenuArg(" %d%c %d%c>%d%s", printdegDEC, 0, minDEC, 1, secDEC, "\"");
6262
}
6363
}

0 commit comments

Comments
 (0)