Skip to content

Commit c767a7b

Browse files
author
Andre Stefanov
committed
Merge remote-tracking branch 'origin/develop' into feature/platformio
# Conflicts: # Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino
2 parents 8d33872 + fed13f2 commit c767a7b

File tree

4 files changed

+74
-40
lines changed

4 files changed

+74
-40
lines changed

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ void Mount::readPersistentData()
126126
{
127127
// Read the magic marker byte and state
128128
int marker = EEPROM.read(4) + EEPROM.read(5) * 256;
129+
#ifdef DEBUG_MODE
130+
logv("EEPROM: Marker: %x ", marker);
131+
#endif
132+
129133
if ((marker & 0xFF01) == 0xBE01) {
130134
_stepsPerRADegree = EEPROM.read(6) + EEPROM.read(7) * 256;
131135
#ifdef DEBUG_MODE
@@ -143,9 +147,9 @@ void Mount::readPersistentData()
143147
float speed = 1.0;
144148
if ((marker & 0xFF04) == 0xBE04) {
145149
int adjust = EEPROM.read(0) + EEPROM.read(3) * 256;
146-
speed = 1.0 + adjust / 10000;
150+
speed = 1.0 + 1.0 * adjust / 10000.0;
147151
#ifdef DEBUG_MODE
148-
logv("EEPROM: Speed Marker OK! Speed adjust is %d", adjust);
152+
logv("EEPROM: Speed Marker OK! Speed adjust is %d, speedFactor is %f", adjust, speed);
149153
#endif
150154
}
151155

@@ -174,6 +178,9 @@ void Mount::writePersistentData(int which, int val)
174178
if (EEPROM.read(5) == 0xBE) {
175179
// ... read the current state ...
176180
flag = EEPROM.read(4);
181+
#ifdef DEBUG_MODE
182+
logv("EEPROM Write: Marker is 0xBE, flag is %x (%d)", flag, flag);
183+
#endif
177184
}
178185
switch (which) {
179186
case RA_STEPS:
@@ -199,6 +206,7 @@ void Mount::writePersistentData(int which, int val)
199206
loByteLocation = 0;
200207
hiByteLocation = 3;
201208
}
209+
break;
202210
case BACKLASH_CORRECTION:
203211
{
204212
// ... set bit 2 to indicate speed factor value has been written to 0/3
@@ -209,6 +217,9 @@ void Mount::writePersistentData(int which, int val)
209217
break;
210218
}
211219

220+
#ifdef DEBUG_MODE
221+
logv("EEPROM Write: New Marker is 0xBE, flag is %x (%d)", flag, flag);
222+
#endif
212223

213224
EEPROMupdate(4, flag);
214225
EEPROMupdate(5, 0xBE);
@@ -309,16 +320,21 @@ float Mount::getSpeedCalibration() {
309320
void Mount::setSpeedCalibration(float val, bool saveToStorage) {
310321
_trackingSpeedCalibration = val;
311322

323+
// The tracker simply needs to rotate at 15degrees/hour, adjusted for sidereal
324+
// time (i.e. the 15degrees is per 23h56m04s. 86164s/86400 = 0.99726852. 3590/3600 is the same ratio) So we only go 15 x 0.99726852 in an hour.
325+
_trackingSpeed = _trackingSpeedCalibration * _stepsPerRADegree * siderealDegreesInHour / 3600.0f;
326+
312327
if (saveToStorage) {
313328
val = (val - 1.0) * 10000;
314329
if (val > 32766) val = 32766;
315330
if (val < -32766) val = -32766;
316331
writePersistentData(SPEED_FACTOR_DECIMALS, (int)floor(val));
317332
}
318333

319-
// The tracker simply needs to rotate at 15degrees/hour, adjusted for sidereal
320-
// time (i.e. the 15degrees is per 23h56m04s. 86164s/86400 = 0.99726852. 3590/3600 is the same ratio) So we only go 15 x 0.99726852 in an hour.
321-
_trackingSpeed = _trackingSpeedCalibration * _stepsPerRADegree * siderealDegreesInHour / 3600.0f;
334+
// If we are currently tracking, update the speed.
335+
if (isSlewingTRK()) {
336+
_stepperTRK->setSpeed(_trackingSpeed);
337+
}
322338
}
323339

324340
/////////////////////////////////
@@ -1150,8 +1166,8 @@ void Mount::loop() {
11501166
bool raStillRunning = false;
11511167
bool decStillRunning = false;
11521168

1153-
// Since the ESP8266 cannot process timer interrupts at the required
1154-
// speed, we'll just stick to deterministic calls here.
1169+
// Since the ESP8266 cannot process timer interrupts at the required
1170+
// speed, we'll just stick to deterministic calls here.
11551171
#ifdef ESP8266
11561172
interruptLoop();
11571173
#endif
@@ -1161,7 +1177,7 @@ void Mount::loop() {
11611177
if (now - _lastMountPrint > 2000) {
11621178
Serial.println(getStatusString());
11631179
_lastMountPrint = now;
1164-
}
1180+
}
11651181
#endif
11661182
if (isGuiding()) {
11671183
if (millis() > _guideEndTime) {
@@ -1532,9 +1548,9 @@ void Mount::displayStepperPosition() {
15321548
_lcdMenu->setCursor(0, 1);
15331549
_lcdMenu->printMenu(scratchBuffer);
15341550
#endif
1535-
}
1551+
}
15361552
#endif
1537-
}
1553+
}
15381554

15391555
/////////////////////////////////
15401556
//

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
1515
=======================================================================================================================================
1616
*/
17-
#pragma once
17+
#include "Globals.h"
1818

19-
#include "Globals.hpp"
20-
21-
String version = "V1.7.02";
19+
String version = "V1.7.04";
2220

2321
///////////////////////////////////////////////////////////////////////////
2422
// Please see the Globals.h file for configuration of the firmware.
@@ -45,7 +43,7 @@ float RAStepsPerRevolution = 4096;
4543
// Your drive pulley tooth count:
4644
#define RAPulleyTeeth 16
4745
// the Circumference of the RA wheel
48-
// V1: 1057.1
46+
// V1: 1057.1
4947
// V2: 1131
5048
#define RACircumference 1131
5149

@@ -65,8 +63,6 @@ float DECStepsPerRevolution = 4096;
6563

6664
int DECStepsPerDegree = (565.5 / (DecPulleyTeeth * 2.0) * DECStepsPerRevolution / 360.0);
6765

68-
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.
69-
7066
int RAspeed = 400; // You can change the speed and acceleration of the steppers here. Max. Speed = 600. High speeds tend to make
7167
int RAacceleration = 600; // these cheap steppers unprecice
7268
int DECspeed = 800;

Software/Arduino code/OpenAstroTracker/Utility.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ float clamp(float current, float minVal, float maxVal)
5454
#ifdef DEBUG_MODE
5555

5656
String formatArg(const char* input, va_list args) {
57+
char* nibble = "0123456789ABCDEF";
5758
char achBuffer[255];
5859
char* p = achBuffer;
5960

@@ -89,6 +90,23 @@ String formatArg(const char* input, va_list args) {
8990
}
9091
break;
9192

93+
case 'x': {
94+
int n = (int)va_arg(args, int);
95+
int shift = 12;
96+
unsigned int mask = 0xF000;
97+
*p++ = '0';
98+
*p++ = 'x';
99+
while (shift >= 0) {
100+
int d=(n & mask) >> shift;
101+
*p++ = *(nibble + d);
102+
mask = mask >> 4;
103+
shift -= 4;
104+
}
105+
106+
*p = 0;
107+
}
108+
break;
109+
92110
case 'l': {
93111
String s = String((long)va_arg(args, long));
94112
strcpy(p, s.c_str());

Software/Arduino code/OpenAstroTracker/c76_menuCAL.hpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
byte calState = HIGHLIGHT_FIRST;
4646

4747
// SPeed adjustment variable. Added to 1.0 after dividing by 10000 to get final speed
48-
float inputcal;
48+
float SpeedCalibration;
4949

5050
// The current delay in ms when changing calibration value. The longer a button is depressed, the smaller this gets.
51-
int calDelay = 150;
51+
int calDelay = 150;
5252

5353
// The index of durations that the user has selected.
5454
byte driftSubIndex = 1;
@@ -94,6 +94,9 @@ void gotoNextHighlightState(int dir) {
9494
else if (calState == HIGHLIGHT_BACKLASH_STEPS) {
9595
BacklashSteps = mount.getBacklashCorrection();
9696
}
97+
else if (calState == HIGHLIGHT_SPEED) {
98+
SpeedCalibration = (mount.getSpeedCalibration() - 1.0) * 10000.0 + 0.5;
99+
}
97100
}
98101

99102
bool processCalibrationKeys() {
@@ -103,19 +106,20 @@ bool processCalibrationKeys() {
103106

104107
if (calState == SPEED_CALIBRATION) {
105108
if (lcdButtons.currentState() == btnUP) {
106-
if (inputcal < 32760) { // Don't overflow 16 bit signed
107-
inputcal += 1; //0.0001;
108-
mount.setSpeedCalibration(speed + inputcal / 10000, false);
109+
if (SpeedCalibration < 32760) { // Don't overflow 16 bit signed
110+
SpeedCalibration += 1; //0.0001;
111+
mount.setSpeedCalibration(1.0 + SpeedCalibration / 10000.0, false);
112+
mount.setSpeedCalibration(1.0 + SpeedCalibration / 10000.0, false);
109113
}
110114

111115
mount.delay(calDelay);
112116
calDelay = max(5, 0.96 * calDelay);
113117
checkForKeyChange = false;
114118
}
115119
else if (lcdButtons.currentState() == btnDOWN) {
116-
if (inputcal > -32760) { // Don't overflow 16 bit signed
117-
inputcal -= 1; //0.0001;
118-
mount.setSpeedCalibration(speed + inputcal / 10000, false);
120+
if (SpeedCalibration > -32760) { // Don't overflow 16 bit signed
121+
SpeedCalibration -= 1; //0.0001;
122+
mount.setSpeedCalibration(1.0 + SpeedCalibration / 10000.0, false);
119123
}
120124

121125
mount.delay(calDelay);
@@ -186,25 +190,25 @@ bool processCalibrationKeys() {
186190
calState = HIGHLIGHT_POLAR;
187191
}
188192
}
189-
break;
193+
break;
190194

191195
case SPEED_CALIBRATION: {
192196
// UP and DOWN are handled above
193197
if (key == btnSELECT) {
194-
int cal = floor(inputcal);
195-
mount.setSpeedCalibration(speed + inputcal / 10000, true);
198+
mount.setSpeedCalibration(1.0 + SpeedCalibration / 10000.0, true);
196199
lcdMenu.printMenu("Speed Stored.");
197200
mount.delay(500);
198201
calState = HIGHLIGHT_SPEED;
199202
}
200203
else if (key == btnRIGHT) {
204+
mount.setSpeedCalibration(1.0 + SpeedCalibration / 10000.0, true);
201205
lcdMenu.setNextActive();
202206
calState = HIGHLIGHT_SPEED;
203207
}
204208
}
205-
break;
209+
break;
206210

207-
case RA_STEP_CALIBRATION:
211+
case RA_STEP_CALIBRATION:
208212
{
209213
// UP and DOWN are handled above
210214
if (key == btnSELECT) {
@@ -273,7 +277,7 @@ bool processCalibrationKeys() {
273277
lcdMenu.setNextActive();
274278
}
275279
}
276-
break;
280+
break;
277281

278282
case POLAR_CALIBRATION_WAIT: {
279283
if (key == btnSELECT) {
@@ -289,7 +293,7 @@ bool processCalibrationKeys() {
289293
calState = HIGHLIGHT_POLAR;
290294
}
291295
}
292-
break;
296+
break;
293297

294298
case HIGHLIGHT_SPEED: {
295299
if (key == btnDOWN) gotoNextHighlightState(1);
@@ -300,7 +304,7 @@ bool processCalibrationKeys() {
300304
calState = HIGHLIGHT_POLAR;
301305
}
302306
}
303-
break;
307+
break;
304308

305309
case HIGHLIGHT_DRIFT: {
306310
if (key == btnDOWN) gotoNextHighlightState(1);
@@ -311,7 +315,7 @@ bool processCalibrationKeys() {
311315
calState = HIGHLIGHT_POLAR;
312316
}
313317
}
314-
break;
318+
break;
315319

316320
case DRIFT_CALIBRATION_WAIT: {
317321
if (key == btnDOWN || key == btnLEFT) {
@@ -333,7 +337,7 @@ bool processCalibrationKeys() {
333337
driftSubIndex = 1;
334338
}
335339
}
336-
break;
340+
break;
337341

338342
case HIGHLIGHT_RA_STEPS: {
339343
if (key == btnDOWN) gotoNextHighlightState(1);
@@ -344,7 +348,7 @@ bool processCalibrationKeys() {
344348
calState = HIGHLIGHT_FIRST;
345349
}
346350
}
347-
break;
351+
break;
348352

349353
case HIGHLIGHT_DEC_STEPS: {
350354
if (key == btnDOWN) gotoNextHighlightState(1);
@@ -355,18 +359,18 @@ bool processCalibrationKeys() {
355359
calState = HIGHLIGHT_FIRST;
356360
}
357361
}
358-
break;
362+
break;
359363

360-
case HIGHLIGHT_BACKLASH_STEPS : {
361-
if (key == btnDOWN) gotoNextHighlightState(1);
364+
case HIGHLIGHT_BACKLASH_STEPS: {
365+
if (key == btnDOWN) gotoNextHighlightState(1);
362366
if (key == btnUP) gotoNextHighlightState(-1);
363367
else if (key == btnSELECT) calState = BACKLASH_CALIBRATION;
364368
else if (key == btnRIGHT) {
365369
lcdMenu.setNextActive();
366370
calState = HIGHLIGHT_FIRST;
367371
}
368372
}
369-
break;
373+
break;
370374
}
371375
}
372376

0 commit comments

Comments
 (0)