Skip to content

Commit 5179fbf

Browse files
Merge pull request #1 from ClutchplateDude/moreoop
Merging all changes up to 1.5.10 into master
2 parents f883690 + a849086 commit 5179fbf

File tree

12 files changed

+1139
-770
lines changed

12 files changed

+1139
-770
lines changed

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/*
22
=======================================================================================================================================
33
4-
Version 1.4.4
4+
Version 1.5.10
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)
88
99
You might need to download the "AccelStepper" library by Mike McCauley
1010
11-
Authors: /u/intercipere
11+
Authors: /u/intercipere
1212
/u/clutchplate
1313
/u/EorEquis
14-
14+
1515
=======================================================================================================================================
1616
*/
17-
String version = "V1.4.4";
17+
String version = "V1.5.10";
1818

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

@@ -32,14 +32,14 @@ int RAacceleration = 600; // these cheap steppers unprecice
3232
int DECspeed = 800;
3333
int DECacceleration = 400;
3434

35-
// Define some stepper limits to prevent physical damage to the tracker. This assumes that the home
35+
// Define some stepper limits to prevent physical damage to the tracker. This assumes that the home
3636
// point (zero point) has been correctly set to be pointing at the celestial pole.
3737
float RAStepperLimit = 15500; // Going much more than this each direction will make the ring fall off the bearings.
3838

39-
// These are for 47N, so they will need adjustment if you're a lot away from that.
40-
// You can use the CTRL menu to find the limits and place them here. I moved it
41-
// down until my lens was horizontal. Note the DEC number. Then move it up until
42-
// the lens is horizontal and note that number. Put those here. Always watch your
39+
// These are for 47N, so they will need adjustment if you're a lot away from that.
40+
// You can use the CTRL menu to find the limits and place them here. I moved it
41+
// down until my lens was horizontal. Note the DEC number. Then move it up until
42+
// the lens is horizontal and note that number. Put those here. Always watch your
4343
// tracker and hit RESET if it approaches a dangerous area.
4444
float DECStepperDownLimit = 10000; // Going much more than this will make the lens collide with the ring
4545
float DECStepperUpLimit = -22000; // Going much more than this is going below the horizon.
@@ -58,3 +58,6 @@ int s = 25;
5858

5959
// Uncomment this to support the heating menu
6060
//#define SUPPORT_HEATING
61+
62+
// Uncomment to run a key diagnostic
63+
// #define LCD_BUTTON_TEST

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,25 @@ LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
4343
#define Home_Menu 7
4444
#define POI_Menu 8
4545

46-
// Stepper control for RA and DEV.
46+
// Stepper control for RA and DEV.
4747
// TRK is used for live tracking and runs in parallel with RA.
4848
// GUIDE is used for Stellarium control
4949
AccelStepper stepperRA(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
5050
AccelStepper stepperDEC(HALFSTEP, motorPin11, motorPin13, motorPin12, motorPin14);
5151
AccelStepper stepperTRK(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4); //yes, this is the same motor as stepperRA, dont ask why
5252
AccelStepper stepperGUIDE(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
5353

54-
int lcd_key = 0; // The current key state
54+
int lcd_key = 0; // The current key state
5555
int adc_key_in = 0; // The analog value of the keys
5656

5757
String inString = "";
5858

5959
bool inStartup = true; // Start with a guided startup
6060

61+
bool inSerialControl = false; // When the serial port is in control
62+
bool serialIsSlewing = false; // When the serial port is slewing the tracker
63+
64+
6165
int calDelay = 150; // The current delay when changing calibration value. The longer a button is depressed, the samller this gets.
6266

6367
bool waitForButtonRelease = false; // When a button is pressed should we wait for its release before another loop?
@@ -128,8 +132,8 @@ int RAheat = 0; // Are we heating the RA stepper?
128132
int DECheat = 0; // Are we heating the DEC stepper?
129133

130134
//Stellarium
131-
char current_RA[9];
132-
char current_DEC[10];
135+
char current_RA[10];
136+
char current_DEC[12];
133137
int HAh_save;
134138
int HAm_save;
135139
float slew_RA;

Software/Arduino code/OpenAstroTracker/b0_functions.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ int read_LCD_buttons() {
33
adc_key_in = analogRead(0);
44
if (adc_key_in > 1000) return btnNONE;
55
if (adc_key_in < 50) return btnRIGHT;
6-
if (adc_key_in < 250) return btnUP;
7-
if (adc_key_in < 450) return btnDOWN;
6+
if (adc_key_in < 240) return btnUP;
7+
if (adc_key_in < 400) return btnDOWN;
88
if (adc_key_in < 600) return btnLEFT;
99
if (adc_key_in < 920) return btnSELECT;
1010
}

Software/Arduino code/OpenAstroTracker/b1_menu.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,16 @@ class LcdMenu {
9494
_activeId = id;
9595
}
9696

97-
// Pass throu utility function
97+
// Pass thru utility function
9898
void setCursor(int col, int row) {
9999
_lcd->setCursor(col, row);
100100
}
101101

102+
// Pass thru utility function
103+
void clear() {
104+
_lcd->clear();
105+
}
106+
102107
// Go to the next menu item from currently active one
103108
void setNextActive() {
104109
// If the last item is active, go to the first.

Software/Arduino code/OpenAstroTracker/c5_calcStepperPos.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,21 @@ void runTracker()
5656
stepperTRK.runSpeed();
5757
}
5858
}
59+
60+
void doCalculations() {
61+
currentSecs = millis() / 1000;
62+
63+
RADisplayTime.set(RATime);
64+
DayTime HACorrection(HATime);
65+
HACorrection.addTime(-h, -m, -s);
66+
RADisplayTime.addTime(HACorrection);
67+
68+
if (!north) {
69+
printdegDEC = degreeDEC - 90;
70+
if (printdegDEC < -90) degreeDEC = 0;
71+
}
72+
else {
73+
printdegDEC = degreeDEC + 90;
74+
if (printdegDEC > 90) degreeDEC = 0;
75+
}
76+
}

Software/Arduino code/OpenAstroTracker/c6_moveTo.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ void moveSteppersToTarget() {
7979
}
8080
display--;
8181
}
82+
83+
// Update resting position
84+
String disp = "D:" + String(stepperDEC.currentPosition()) + " R:" + String( stepperRA.currentPosition());
85+
lcdMenu.printMenu(disp);
8286
}
8387

8488
void startMoveSteppersToTargetAsync() {
@@ -118,6 +122,12 @@ void moveSteppersToTargetAsync() {
118122
}
119123
controlDisplay --;
120124
}
125+
else if (controlDisplay != 499) {
126+
// Make sure we do one last update when the steppers have stopped.
127+
String disp = "D:" + String(stepperDEC.currentPosition()) + " R:" + String( stepperRA.currentPosition());
128+
lcdMenu.printMenu(disp);
129+
controlDisplay = 499;
130+
}
121131
}
122132

123133
void ShowStatusMessage(String message) {
Lines changed: 110 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,123 @@
1+
void BTin();
2+
13
void loop() {
4+
#ifdef LCD_BUTTON_TEST
5+
6+
lcdMenu.setCursor(0, 0);
7+
lcdMenu.printMenu("Key Diagnostic");
8+
lcd_key = read_LCD_buttons();
9+
10+
lcdMenu.setCursor(0, 1);
11+
char buf[128];
12+
sprintf(buf, "ADC:%4d >", adc_key_in);
13+
String state = String(buf);
14+
switch (lcd_key )
15+
{
16+
case btnNONE: state += "None"; break;
17+
case btnSELECT: state += "Select"; break;
18+
case btnLEFT: state += "Left"; break;
19+
case btnRIGHT: state += "Right"; break;
20+
case btnUP: state += "Up"; break;
21+
case btnDOWN: state += "Down"; break;
22+
}
23+
24+
lcdMenu.printMenu(state);
25+
26+
return;
27+
28+
#endif
29+
30+
lcdMenu.setCursor(0, 1);
231

332
lcd_key = read_LCD_buttons();
433

534
trackingspeed = ((((335.1417 / 288.0) * RevSteps) / 3590)) - 1 + float(speedcalibration);
635
stepperTRK.setSpeed(trackingspeed);
736

8-
waitForButtonRelease = true;
9-
lcd.setCursor(0, 1);
10-
11-
// Handle the keys
12-
if (inStartup) {
13-
processStartupKeys(lcd_key);
37+
if (inSerialControl ) {
38+
serialLoop();
1439
}
1540
else {
16-
switch (lcdMenu.getActive()) {
17-
case RA_Menu:
18-
handleDECandRACalculations();
19-
processRAKeys(lcd_key);
20-
break;
21-
case DEC_Menu:
22-
handleDECandRACalculations();
23-
processDECKeys(lcd_key);
24-
break;
25-
case POI_Menu:
26-
processPOIKeys(lcd_key);
27-
break;
28-
case Home_Menu:
29-
processHomeKeys(lcd_key);
30-
break;
31-
case HA_Menu:
32-
processHAKeys(lcd_key);
33-
break;
34-
case Polaris_Menu:
35-
processPolarisKeys(lcd_key);
36-
break;
37-
case Heat_Menu:
38-
processHeatKeys(lcd_key);
39-
break;
40-
case Control_Menu:
41-
processControlKeys(lcd_key);
42-
break;
43-
case Calibration_Menu:
44-
processCalibrationKeys(lcd_key);
45-
break;
41+
waitForButtonRelease = true;
42+
43+
// Handle the keys
44+
if (inStartup) {
45+
processStartupKeys(lcd_key);
46+
}
47+
else {
48+
switch (lcdMenu.getActive()) {
49+
case RA_Menu:
50+
handleDECandRACalculations();
51+
processRAKeys(lcd_key);
52+
break;
53+
case DEC_Menu:
54+
handleDECandRACalculations();
55+
processDECKeys(lcd_key);
56+
break;
57+
case POI_Menu:
58+
processPOIKeys(lcd_key);
59+
break;
60+
case Home_Menu:
61+
processHomeKeys(lcd_key);
62+
break;
63+
case HA_Menu:
64+
processHAKeys(lcd_key);
65+
break;
66+
case Polaris_Menu:
67+
processPolarisKeys(lcd_key);
68+
break;
69+
case Heat_Menu:
70+
processHeatKeys(lcd_key);
71+
break;
72+
case Control_Menu:
73+
processControlKeys(lcd_key);
74+
break;
75+
case Calibration_Menu:
76+
processCalibrationKeys(lcd_key);
77+
break;
78+
}
4679
}
47-
}
4880

49-
if (waitForButtonRelease && (lcd_key != btnNONE)) {
50-
while (read_LCD_buttons() != btnNONE) {
51-
// Make sure tracker can still run while fiddling with menus....
52-
runTracker();
81+
if (waitForButtonRelease && (lcd_key != btnNONE)) {
82+
while (read_LCD_buttons() != btnNONE) {
83+
// Make sure tracker can still run while fiddling with menus....
84+
runTracker();
85+
}
5386
}
54-
}
5587

56-
runTracker();
88+
runTracker();
89+
doCalculations();
90+
91+
if (!pcControl) {
92+
93+
lcd.setCursor(0, 1);
94+
95+
if (inStartup) {
96+
prinStartupMenu();
97+
}
98+
else {
99+
switch (lcdMenu.getActive()) {
100+
case RA_Menu: printRASubmenu(); break;
101+
case DEC_Menu: printDECSubmenu(); break;
102+
case POI_Menu: printPOISubmenu(); break;
103+
case HA_Menu: printHASubmenu(); break;
104+
case Home_Menu: printHomeSubmenu(); break;
105+
case Polaris_Menu: printPolarisSubmenu(); break;
106+
case Heat_Menu: printHeatSubmenu(); break;
107+
case Control_Menu: printControlSubmenu(); break;
108+
case Calibration_Menu: printCalibrationSubmenu(); break;
109+
}
110+
}
111+
112+
//tracking menu ----------------------
113+
/*if (lcdMenu.getActive() == TRK_Menu) {
114+
lcd.print("Tracking ON OFF");
115+
lcd.print(" ");
116+
}*/
117+
} else {
118+
moveSteppersToTargetAsync();
119+
}
120+
121+
BTin();
122+
}
123+
}

Software/Arduino code/OpenAstroTracker/d_calculations.ino

Lines changed: 0 additions & 16 deletions
This file was deleted.

Software/Arduino code/OpenAstroTracker/e_printout.ino

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)