-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMount.cpp
More file actions
4188 lines (3819 loc) · 138 KB
/
Mount.cpp
File metadata and controls
4188 lines (3819 loc) · 138 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "../Configuration.hpp"
#include "Utility.hpp"
#include "EPROMStore.hpp"
#include "LcdMenu.hpp"
#include "HallSensorHoming.hpp"
#include "EndSwitches.hpp"
#include "Mount.hpp"
#include "Sidereal.hpp"
#include "libs/MappedDict/MappedDict.hpp"
PUSH_NO_WARNINGS
#ifdef NEW_STEPPER_LIB
#ifdef __AVR_ATmega2560__
#include "InterruptAccelStepper.h"
#include "StepperConfiguration.hpp"
#endif
#endif
#if (INFO_DISPLAY_TYPE == INFO_DISPLAY_TYPE_I2C_SSD1306_128x64)
#include "SSD1306_128x64_Display.hpp"
#endif
#include <AccelStepper.h>
#if (RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART) || (DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART) \
|| (AZ_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART) || (ALT_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART) \
|| (FOCUS_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
#include <TMCStepper.h> // If you get an error here, download the TMCstepper library from "Tools > Manage Libraries"
#endif
POP_NO_WARNINGS
// slewStatus()
#define SLEWING_DEC B00000010
#define SLEWING_RA B00000001
#define SLEWING_BOTH B00000011
#define SLEWING_TRACKING B00001000
#define NOT_SLEWING B00000000
#define SLEW_MASK_ANY B1111
#define UART_CONNECTION_TEST_RETRIES 5
const char *formatStringsDEC[] = {
"",
" {d}@ {m}' {s}\"", // LCD Menu w/ cursor
"{d}*{m}'{s}#", // Meade
"{d} {m}'{s}\"", // Print
"{d}@{m}'{s}\"", // LCD display only
"{d}{m}{s}", // Compact
};
const char *formatStringsRA[] = {
"",
" %02dh %02dm %02ds", // LCD Menu w/ cursor
"%02d:%02d:%02d#", // Meade
"%02dh %02dm %02ds", // Print
"%02dh%02dm%02ds", // LCD display only
"%02d%02d%02d", // Compact
};
const float siderealDegreesInHour = 14.95904348958;
/////////////////////////////////
//
// CTOR
//
/////////////////////////////////
Mount::Mount(LcdMenu *lcdMenu)
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE) || (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
: _azAltWasRunning(false)
#endif
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE)
,
_stepsPerAZDegree(AZIMUTH_STEPS_PER_REV / 360)
#endif
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
,
_stepsPerALTDegree(ALTITUDE_STEPS_PER_REV / 360)
#endif
{
_commandReceived = 0;
#if (INFO_DISPLAY_TYPE != INFO_DISPLAY_TYPE_NONE)
_loops = 0;
#endif
_lcdMenu = lcdMenu;
initializeVariables();
}
void Mount::initializeVariables()
{
// We are now defaulting to northern hemisphere at 45deg. Switching is now supported
// at runtime when the Latitude is received via Meade command.
inNorthernHemisphere = NORTHERN_HEMISPHERE == 1;
_stepsPerRADegree = RA_STEPS_PER_DEGREE; // u-steps per degree when slewing
_stepsPerDECDegree = DEC_STEPS_PER_DEGREE; // u-steps per degree when slewing
_mountStatus = 0;
_lastDisplayUpdate = 0;
_stepperWasRunning = false;
_latitude = Latitude(inNorthernHemisphere ? 45.0f : -45.0f);
_longitude = Longitude(100.0);
_zeroPosDEC = 0.0f;
_compensateForTrackerOff = false;
_trackerStoppedAt = 0;
_totalDECMove = 0;
_totalRAMove = 0;
_moveRate = 4;
_backlashCorrectionSteps = 0;
_correctForBacklash = false;
_slewingToHome = false;
_slewingToPark = false;
_decLowerLimit = 0;
_decUpperLimit = 0;
#if USE_GYRO_LEVEL == 1
_pitchCalibrationAngle = 0;
_rollCalibrationAngle = 0;
#endif
_localUtcOffset = 0;
_localStartDate.year = 2021;
_localStartDate.month = 1;
_localStartDate.day = 1;
_localStartTimeSetMillis = -1;
_lastTRKCheck = 0;
}
/////////////////////////////////
//
// clearConfiguration
//
/////////////////////////////////
void Mount::clearConfiguration()
{
EEPROMStore::clearConfiguration();
initializeVariables();
readConfiguration();
}
/////////////////////////////////
//
// readConfiguration
//
/////////////////////////////////
void Mount::readConfiguration()
{
LOG(DEBUG_INFO, "[MOUNT]: Reading configuration data from EEPROM");
readPersistentData();
LOG(DEBUG_INFO, "[MOUNT]: Done reading configuration data from EEPROM");
}
/////////////////////////////////
//
// readPersistentData
//
/////////////////////////////////
void Mount::readPersistentData()
{
// EEPROMStore will always return valid data, even if no data is present in the store
int16_t lastFlashed = EEPROMStore::getLastFlashedVersion();
// Calculate this running firmwares version.
String sVersion = String(VERSION);
int firstDot = sVersion.indexOf(".");
int secondDot = sVersion.indexOf(".", firstDot + 1);
int16_t version = 10000 * sVersion.substring(1, firstDot).toInt();
version += 100 * sVersion.substring(firstDot + 1, secondDot).toInt();
version += sVersion.substring(secondDot + 1).toInt();
if (lastFlashed != version)
{
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: New Flash detected! Flashed from %d to %d.", lastFlashed, version);
// Write upgrade code here if needed. lastFlashed is 0 if we have never flashed V1.14.x and beyond
EEPROMStore::storeLastFlashedVersion(version);
if (lastFlashed < 11307)
{
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: First time post 1.13.6, setting AZ and ALT home to 0");
// Introduced these two in 1.13.7
EEPROMStore::storeALTPosition(0);
EEPROMStore::storeAZPosition(0);
}
}
else
{
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Same firmware version as last boot %d.", version);
}
_stepsPerRADegree = EEPROMStore::getRAStepsPerDegree();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: RA steps/deg is %f", _stepsPerRADegree);
_stepsPerDECDegree = EEPROMStore::getDECStepsPerDegree();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: DEC steps/deg is %f", _stepsPerDECDegree);
float speed = EEPROMStore::getSpeedFactor();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Speed factor is %f", speed);
setSpeedCalibration(speed, false);
_backlashCorrectionSteps = EEPROMStore::getBacklashCorrectionSteps();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Backlash correction is %d", _backlashCorrectionSteps);
_latitude = EEPROMStore::getLatitude();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Latitude is %s", _latitude.ToString());
_longitude = EEPROMStore::getLongitude();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Longitude is %s", _longitude.ToString());
_localUtcOffset = EEPROMStore::getUtcOffset();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: UTC offset is %d", _localUtcOffset);
#if USE_GYRO_LEVEL == 1
_pitchCalibrationAngle = EEPROMStore::getPitchCalibrationAngle();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Pitch Offset is %f", _pitchCalibrationAngle);
_rollCalibrationAngle = EEPROMStore::getRollCalibrationAngle();
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: Roll Offset is %f", _rollCalibrationAngle);
#endif
_decLowerLimit = static_cast<long>(-(EEPROMStore::getDECLowerLimit() * _stepsPerDECDegree));
if (_decLowerLimit == 0 && DEC_LIMIT_DOWN != 0)
{
_decLowerLimit = static_cast<long>(-(DEC_LIMIT_DOWN * _stepsPerDECDegree));
}
_decUpperLimit = static_cast<long>((EEPROMStore::getDECUpperLimit() * _stepsPerDECDegree));
if (_decUpperLimit == 0 && DEC_LIMIT_UP != 0)
{
_decUpperLimit = static_cast<long>(DEC_LIMIT_UP * _stepsPerDECDegree);
}
LOG(DEBUG_INFO, "[MOUNT]: EEPROM: DEC limits read as %l -> %l", _decLowerLimit, _decUpperLimit);
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
long altPos = EEPROMStore::getALTPosition();
_stepperALT->setCurrentPosition(altPos);
#endif
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE)
long azPos = EEPROMStore::getAZPosition();
_stepperAZ->setCurrentPosition(azPos);
#endif
configureHemisphere(_latitude.getTotalHours() > 0);
}
/////////////////////////////////
//
// configureHemisphere
//
/////////////////////////////////
void Mount::configureHemisphere(bool inNorthern, bool force)
{
if ((inNorthernHemisphere != inNorthern) || force)
{
bool wasTracking = isSlewingTRK();
LOG(DEBUG_ANY, "[SYSTEM]: Hemisphere changed (or forced update) to %s.", inNorthern ? "northern" : "southern");
LOG(DEBUG_ANY, "[SYSTEM]: Stopping all steppers.");
stopSlewing(ALL_DIRECTIONS | TRACKING);
waitUntilStopped(ALL_DIRECTIONS);
inNorthernHemisphere = inNorthern;
bool invertDir = inNorthernHemisphere ? (RA_INVERT_DIR == 1) : (RA_INVERT_DIR != 1);
LOG(DEBUG_ANY, "[SYSTEM]: Configured RA steppers, DIR Invert is %d", invertDir);
_stepperRA->setPinsInverted(invertDir, false, false);
_stepperTRK->setPinsInverted(invertDir, false, false);
LOG(DEBUG_ANY, "[SYSTEM]: Reset RA and TRK positions to 0");
_stepperTRK->setCurrentPosition(0);
_stepperRA->setCurrentPosition(0);
if (wasTracking)
{
LOG(DEBUG_ANY, "[SYSTEM]: Restarting TRK since it was on.");
startSlewing(TRACKING);
}
}
else
{
LOG(DEBUG_ANY, "[SYSTEM]: Already in %s hemisphere, no action taken.", inNorthernHemisphere ? "northern" : "southern");
}
}
/////////////////////////////////
//
// configureRAStepper
//
/////////////////////////////////
void Mount::configureRAStepper(byte pin1, byte pin2, uint32_t maxSpeed, uint32_t maxAcceleration)
{
#ifdef NEW_STEPPER_LIB
_stepperRA = new StepperRaSlew(AccelStepper::DRIVER, pin1, pin2);
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
_stepperTRK = new StepperRaTrk(AccelStepper::DRIVER, pin1, pin2);
#else
_stepperRA = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
_stepperTRK = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
#endif
_stepperRA->setMaxSpeed(maxSpeed);
_stepperRA->setAcceleration(maxAcceleration);
_maxRASpeed = maxSpeed;
_maxRAAcceleration = maxAcceleration;
_stepperTRK->setMaxSpeed(5000);
_stepperTRK->setAcceleration(15000);
}
/////////////////////////////////
//
// configureDECStepper
//
/////////////////////////////////
void Mount::configureDECStepper(byte pin1, byte pin2, uint32_t maxSpeed, uint32_t maxAcceleration)
{
#ifdef NEW_STEPPER_LIB
_stepperDEC = new StepperDecSlew(AccelStepper::DRIVER, pin1, pin2);
// Use another AccelStepper to run the DEC motor as well. This instance is used for guiding.
_stepperGUIDE = new StepperDecTrk(AccelStepper::DRIVER, pin1, pin2);
#else
_stepperDEC = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
// Use another AccelStepper to run the DEC motor as well. This instance is used for guiding.
_stepperGUIDE = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
#endif
_stepperDEC->setMaxSpeed(maxSpeed);
_stepperDEC->setAcceleration(maxAcceleration);
_maxDECSpeed = maxSpeed;
_maxDECAcceleration = maxAcceleration;
_stepperGUIDE->setMaxSpeed(maxSpeed);
_stepperGUIDE->setAcceleration(maxAcceleration);
#if DEC_INVERT_DIR == 1
_stepperDEC->setPinsInverted(true, false, false);
_stepperGUIDE->setPinsInverted(true, false, false);
#endif
_stepperGUIDE->setCurrentPosition(0);
}
/////////////////////////////////
//
// configureAZStepper / configureALTStepper
//
/////////////////////////////////
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE)
void Mount::configureAZStepper(byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
{
#ifdef NEW_STEPPER_LIB
_stepperAZ = new StepperAzSlew(AccelStepper::DRIVER, pin1, pin2);
#else
_stepperAZ = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
#endif
_stepperAZ->setMaxSpeed(maxSpeed);
_stepperAZ->setAcceleration(maxAcceleration);
_maxAZSpeed = maxSpeed;
_maxAZAcceleration = maxAcceleration;
#if AZ_INVERT_DIR == 1
_stepperAZ->setPinsInverted(true, false, false);
#endif
}
#endif
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
void Mount::configureALTStepper(byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
{
#ifdef NEW_STEPPER_LIB
_stepperALT = new StepperAltSlew(AccelStepper::DRIVER, pin1, pin2);
#else
_stepperALT = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
#endif
_stepperALT->setMaxSpeed(maxSpeed);
_stepperALT->setAcceleration(maxAcceleration);
_maxALTSpeed = maxSpeed;
_maxALTAcceleration = maxAcceleration;
#if ALT_INVERT_DIR == 1
_stepperALT->setPinsInverted(true, false, false);
#endif
}
#endif
/////////////////////////////////
//
// configureFocusStepper
//
/////////////////////////////////
#if (FOCUS_STEPPER_TYPE != STEPPER_TYPE_NONE)
void Mount::configureFocusStepper(byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
{
#ifdef NEW_STEPPER_LIB
_stepperFocus = new StepperFocusSlew(AccelStepper::DRIVER, pin1, pin2);
#else
_stepperFocus = new AccelStepper(AccelStepper::DRIVER, pin1, pin2);
#endif
_stepperFocus->setMaxSpeed(maxSpeed);
_stepperFocus->setAcceleration(maxAcceleration);
_stepperFocus->setSpeed(0);
_stepperFocus->setCurrentPosition(50000);
_maxFocusSpeed = maxSpeed;
_maxFocusAcceleration = maxAcceleration;
_maxFocusRateSpeed = maxSpeed;
}
#endif
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART || DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART \
|| AZ_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART || ALT_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART \
|| FOCUS_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
#if (UART_CONNECTION_TEST_TXRX == 1) || (TEST_VERIFY_MODE == 1)
bool Mount::connectToDriver(const String &driverKind, uint16_t *rmsCurrent)
{
MappedDict<String, TMC2209Stepper *>::DictEntry_t lookupTable[] = {
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
{"RA", _driverRA},
#endif
#if DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
{"DEC", _driverDEC},
#endif
#if ALT_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
{"ALT", _driverALT},
#endif
#if AZ_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
{"AZ", _driverAZ},
#endif
#if FOCUS_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
{"FOC", _driverFocus},
#endif
};
auto driverLookup = MappedDict<String, TMC2209Stepper *>(lookupTable, ARRAY_SIZE(lookupTable));
TMC2209Stepper *driver = nullptr;
driverLookup.tryGet(driverKind, &driver);
if (driver != nullptr)
{
LOG(DEBUG_STEPPERS, "[STEPPERS]: Testing UART Connection to %s driver...", driverKind.c_str());
for (int i = 0; i < UART_CONNECTION_TEST_RETRIES; i++)
{
if (driver->test_connection() == 0)
{
LOG(DEBUG_STEPPERS, "[STEPPERS]: UART connection to %s driver successful.", driverKind.c_str());
if (rmsCurrent != nullptr)
{
*rmsCurrent = driver->rms_current();
}
return true;
}
else
{
delay(500);
}
}
LOG(DEBUG_STEPPERS, "[STEPPERS]: UART connection to %s driver failed.", driverKind.c_str());
}
if (rmsCurrent != nullptr)
{
*rmsCurrent = 0;
}
return false;
}
#endif
#endif
/////////////////////////////////
//
// configureRAdriver
// TMC2209 UART only
/////////////////////////////////
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
#if SW_SERIAL_UART == 0
void Mount::configureRAdriver(Stream *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverRA = new TMC2209Stepper(serial, rsense, driveraddress);
_driverRA->begin();
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("RA");
if (!UART_Rx_connected)
{
digitalWrite(RA_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverRA->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverRA->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested RA motor rms_current: %d mA", rmscurrent);
_driverRA->rms_current(rmscurrent, 1.0f); //holdMultiplier = 1 to set ihold = irun
_driverRA->toff(1);
_driverRA->en_spreadCycle(RA_UART_STEALTH_MODE == 0);
_driverRA->blank_time(24);
_driverRA->microsteps(RA_TRACKING_MICROSTEPPING == 1 ? 0 : RA_TRACKING_MICROSTEPPING); // System starts in tracking mode
_driverRA->fclktrim(4);
_driverRA->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverRA->semin(0); //disable CoolStep so that current is consistent
_driverRA->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA motor rms_current: %d mA", _driverRA->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA CS value: %d", _driverRA->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA vsense: %d", _driverRA->vsense());
}
}
#elif SW_SERIAL_UART == 1
void Mount::configureRAdriver(uint16_t RA_SW_RX, uint16_t RA_SW_TX, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverRA = new TMC2209Stepper(RA_SW_RX, RA_SW_TX, rsense, driveraddress);
_driverRA->beginSerial(19200);
_driverRA->mstep_reg_select(true);
_driverRA->pdn_disable(true);
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("RA");
if (!UART_Rx_connected)
{
digitalWrite(RA_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverRA->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverRA->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested RA motor rms_current: %d mA", rmscurrent);
_driverRA->rms_current(rmscurrent, 1.0f); //holdMultiplier = 1 to set ihold = irun
_driverRA->toff(1);
_driverRA->en_spreadCycle(RA_UART_STEALTH_MODE == 0);
_driverRA->blank_time(24);
_driverRA->semin(0); //disable CoolStep so that current is consistent
_driverRA->microsteps(RA_TRACKING_MICROSTEPPING == 1 ? 0 : RA_TRACKING_MICROSTEPPING); // System starts in tracking mode
_driverRA->fclktrim(4);
_driverRA->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverRA->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA motor rms_current: %d mA", _driverRA->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA CS value: %d", _driverRA->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual RA vsense: %d", _driverRA->vsense());
}
}
#endif
#endif
/////////////////////////////////
//
// configureDECdriver
// TMC2209 UART only
/////////////////////////////////
#if DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
#if SW_SERIAL_UART == 0
void Mount::configureDECdriver(Stream *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverDEC = new TMC2209Stepper(serial, rsense, driveraddress);
_driverDEC->begin();
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("DEC");
if (!UART_Rx_connected)
{
digitalWrite(DEC_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverDEC->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverDEC->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested DEC motor rms_current: %d mA", rmscurrent);
_driverDEC->rms_current(rmscurrent, 1.0f); //holdMultiplier = 1 to set ihold = irun
_driverDEC->toff(1);
_driverDEC->en_spreadCycle(DEC_UART_STEALTH_MODE == 0);
_driverDEC->blank_time(24);
_driverDEC->microsteps(
DEC_GUIDE_MICROSTEPPING == 1 ? 0 : DEC_GUIDE_MICROSTEPPING); // If 1 then disable microstepping. Start with Guide microsteps.
_driverDEC->TCOOLTHRS(0xFFFFF);
_driverDEC->semin(0); //disable CoolStep so that current is consistent
_driverDEC->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC motor rms_current: %d mA", _driverDEC->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC CS value: %d", _driverDEC->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC vsense: %d", _driverDEC->vsense());
}
}
#elif SW_SERIAL_UART == 1
void Mount::configureDECdriver(uint16_t DEC_SW_RX, uint16_t DEC_SW_TX, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverDEC = new TMC2209Stepper(DEC_SW_RX, DEC_SW_TX, rsense, driveraddress);
_driverDEC->beginSerial(19200);
_driverDEC->mstep_reg_select(true);
_driverDEC->pdn_disable(true);
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("DEC");
if (!UART_Rx_connected)
{
digitalWrite(DEC_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverDEC->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverDEC->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested DEC motor rms_current: %d mA", rmscurrent);
_driverDEC->rms_current(rmscurrent, 1.0f); //holdMultiplier = 1 to set ihold = irun
_driverDEC->toff(1);
_driverDEC->en_spreadCycle(DEC_UART_STEALTH_MODE == 0);
_driverDEC->blank_time(24);
_driverDEC->microsteps(
DEC_GUIDE_MICROSTEPPING == 1 ? 0 : DEC_GUIDE_MICROSTEPPING); // If 1 then disable microstepping. Start with Guide microsteps
_driverDEC->TCOOLTHRS(0xFFFFF);
_driverDEC->semin(0); //disable CoolStep so that current is consistent
_driverDEC->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC motor rms_current: %d mA", _driverDEC->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC CS value: %d", _driverDEC->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual DEC vsense: %d", _driverDEC->vsense());
}
}
#endif
#endif
/////////////////////////////////
//
// configureAZdriver
// TMC2209 UART only
/////////////////////////////////
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE) && (AZ_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
#if SW_SERIAL_UART == 0
void Mount::configureAZdriver(Stream *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverAZ = new TMC2209Stepper(serial, rsense, driveraddress);
_driverAZ->begin();
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("AZ");
if (!UART_Rx_connected)
{
digitalWrite(AZ_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverAZ->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverAZ->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested AZ motor rms_current: %d mA", rmscurrent);
_driverAZ->rms_current(rmscurrent, AZ_MOTOR_HOLD_SETTING / 100.0); //holdMultiplier = 1 to set ihold = irun
_driverAZ->toff(1);
_driverAZ->en_spreadCycle(0);
_driverAZ->blank_time(24);
_driverAZ->microsteps(AZ_MICROSTEPPING == 1 ? 0 : AZ_MICROSTEPPING); // If 1 then disable microstepping
_driverAZ->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverAZ->semin(0); //disable CoolStep so that current is consistent
_driverAZ->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ motor rms_current: %d mA", _driverAZ->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ CS value: %d", _driverAZ->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ vsense: %d", _driverAZ->vsense());
}
}
#elif SW_SERIAL_UART == 1
void Mount::configureAZdriver(uint16_t AZ_SW_RX, uint16_t AZ_SW_TX, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverAZ = new TMC2209Stepper(AZ_SW_RX, AZ_SW_TX, rsense, driveraddress);
_driverAZ->beginSerial(19200);
_driverAZ->mstep_reg_select(true);
_driverAZ->pdn_disable(true);
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("AZ");
if (!UART_Rx_connected)
{
digitalWrite(AZ_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverAZ->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverAZ->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested AZ motor rms_current: %d mA", rmscurrent);
_driverAZ->rms_current(rmscurrent, AZ_MOTOR_HOLD_SETTING / 100.0); //holdMultiplier = 1 to set ihold = irun
_driverAZ->toff(1);
_driverAZ->en_spreadCycle(0);
_driverAZ->blank_time(24);
_driverAZ->microsteps(AZ_MICROSTEPPING == 1 ? 0 : AZ_MICROSTEPPING); // If 1 then disable microstepping
_driverAZ->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverAZ->semin(0); //disable CoolStep so that current is consistent
_driverAZ->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ motor rms_current: %d mA", _driverAZ->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ CS value: %d", _driverAZ->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual AZ vsense: %d", _driverAZ->vsense());
}
}
#endif
#endif
/////////////////////////////////
//
// configureALTdriver
// TMC2209 UART only
/////////////////////////////////
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE) && (ALT_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
#if SW_SERIAL_UART == 0
void Mount::configureALTdriver(Stream *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverALT = new TMC2209Stepper(serial, rsense, driveraddress);
_driverALT->begin();
bool UART_Rx_connected = false;
#if UART_CONNECTION_TEST_TXRX == 1
UART_Rx_connected = connectToDriver("ALT");
if (!UART_Rx_connected)
{
digitalWrite(ALT_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverALT->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverALT->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested ALT motor rms_current: %d mA", rmscurrent);
_driverALT->rms_current(rmscurrent, ALT_MOTOR_HOLD_SETTING / 100.0); //holdMultiplier = 1 to set ihold = irun
_driverALT->toff(1);
_driverALT->en_spreadCycle(0);
_driverALT->blank_time(24);
_driverALT->microsteps(ALT_MICROSTEPPING == 1 ? 0 : ALT_MICROSTEPPING); // If 1 then disable microstepping
_driverALT->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverALT->semin(0); //disable CoolStep so that current is consistent
_driverALT->SGTHRS(stallvalue);
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT motor rms_current: %d mA", _driverALT->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT CS value: %d", _driverALT->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT vsense: %d", _driverALT->vsense());
}
}
#elif SW_SERIAL_UART == 1
void Mount::configureALTdriver(uint16_t ALT_SW_RX, uint16_t ALT_SW_TX, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverALT = new TMC2209Stepper(ALT_SW_RX, ALT_SW_TX, rsense, driveraddress);
_driverALT->beginSerial(19200);
_driverALT->mstep_reg_select(true);
_driverALT->pdn_disable(true);
#if UART_CONNECTION_TEST_TXRX == 1
bool UART_Rx_connected = false;
UART_Rx_connected = connectToDriver("ALT");
if (!UART_Rx_connected)
{
digitalWrite(ALT_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverALT->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverALT->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS, "[MOUNT]: Requested ALT motor rms_current: %d mA", rmscurrent);
_driverALT->rms_current(rmscurrent, ALT_MOTOR_HOLD_SETTING / 100.0); //holdMultiplier = 1 to set ihold = irun
_driverALT->toff(1);
_driverALT->en_spreadCycle(0);
_driverALT->blank_time(24);
_driverALT->microsteps(ALT_MICROSTEPPING == 1 ? 0 : ALT_MICROSTEPPING); // If 1 then disable microstepping
_driverALT->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverALT->semin(0); //disable CoolStep so that current is consistent
_driverALT->SGTHRS(stallvalue);
#if UART_CONNECTION_TEST_TXRX == 1
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT motor rms_current: %d mA", _driverALT->rms_current());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT CS value: %d", _driverALT->cs_actual());
LOG(DEBUG_STEPPERS, "[MOUNT]: Actual ALT vsense: %d", _driverALT->vsense());
}
#endif
}
#endif
#endif
/////////////////////////////////
//
// configureFocusdriver
// TMC2209 UART only
/////////////////////////////////
#if (FOCUS_STEPPER_TYPE != STEPPER_TYPE_NONE) && (FOCUS_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
#if SW_SERIAL_UART == 0
void Mount::configureFocusDriver(Stream *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverFocus = new TMC2209Stepper(serial, rsense, driveraddress);
_driverFocus->begin();
#if UART_CONNECTION_TEST_TXRX == 1
bool UART_Rx_connected = false;
UART_Rx_connected = connectToDriver("FOC");
if (!UART_Rx_connected)
{
digitalWrite(FOCUS_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverFocus->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverFocus->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Requested Focus motor rms_current: %d mA", rmscurrent);
_driverFocus->rms_current(rmscurrent, FOCUSER_MOTOR_HOLD_SETTING / 100.f); //holdMultiplier = 1 to set ihold = irun
_driverFocus->toff(1);
_driverFocus->en_spreadCycle(FOCUS_UART_STEALTH_MODE == 0);
_driverFocus->blank_time(24);
_driverFocus->microsteps(FOCUS_MICROSTEPPING == 1 ? 0 : FOCUS_MICROSTEPPING); // If 1 then disable microstepping
_driverFocus->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverFocus->semin(0); //disable CoolStep so that current is consistent
_driverFocus->SGTHRS(stallvalue);
#if UART_CONNECTION_TEST_TXRX == 1
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus motor rms_current: %d mA", _driverFocus->rms_current());
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus CS value: %d", _driverFocus->cs_actual());
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus vsense: %d", _driverFocus->vsense());
}
#endif
#if FOCUSER_ALWAYS_ON == 1
LOG(DEBUG_FOCUS, "[FOCUS]: Always on -> TMC2209U enabling driver pin.");
digitalWrite(FOCUS_EN_PIN, LOW); // Logic LOW to enable driver
#endif
}
#elif SW_SERIAL_UART == 1
void Mount::configureFocusDriver(
uint16_t FOCUS_SW_RX, uint16_t FOCUS_SW_TX, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
{
_driverFocus = new TMC2209Stepper(FOCUS_SW_RX, FOCUS_SW_TX, rsense, driveraddress);
_driverFocus->beginSerial(19200);
_driverFocus->mstep_reg_select(true);
_driverFocus->pdn_disable(true);
#if UART_CONNECTION_TEST_TXRX == 1
bool UART_Rx_connected = false;
UART_Rx_connected = connectToDriver("FOC");
if (!UART_Rx_connected)
{
digitalWrite(FOCUS_EN_PIN,
HIGH); //Disable motor for safety reasons if UART connection fails to avoid operating at incorrect rms_current
}
#endif
_driverFocus->toff(0);
#if USE_VREF == 0 //By default, Vref is ignored when using UART to specify rms current.
_driverFocus->I_scale_analog(false);
#endif
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Requested Focus motor rms_current: %d mA", rmscurrent);
_driverFocus->rms_current(rmscurrent, FOCUSER_MOTOR_HOLD_SETTING / 100.f); //holdMultiplier = 1 to set ihold = irun
_driverFocus->toff(1);
_driverFocus->en_spreadCycle(FOCUS_UART_STEALTH_MODE == 0);
_driverFocus->blank_time(24);
_driverFocus->microsteps(FOCUS_MICROSTEPPING == 1 ? 0 : FOCUS_MICROSTEPPING); // If 1 then disable microstepping
_driverFocus->TCOOLTHRS(0xFFFFF); //xFFFFF);
_driverFocus->semin(0); //disable CoolStep so that current is consistent
_driverFocus->SGTHRS(stallvalue);
#if UART_CONNECTION_TEST_TXRX == 1
if (UART_Rx_connected)
{
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus motor rms_current: %d mA", _driverFocus->rms_current());
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus CS value: %d", _driverFocus->cs_actual());
LOG(DEBUG_STEPPERS | DEBUG_FOCUS, "[FOCUS]: Actual Focus vsense: %d", _driverFocus->vsense());
}
#endif
#if FOCUSER_ALWAYS_ON == 1
LOG(DEBUG_FOCUS, "[FOCUS]: Always on -> TMC2209U enabling driver pin.");
digitalWrite(FOCUS_EN_PIN, LOW); // Logic LOW to enable driver
#endif
}
#endif
#endif
/////////////////////////////////
//
// getSpeedCalibration
//
/////////////////////////////////
float Mount::getSpeedCalibration()
{
return _trackingSpeedCalibration;
}
/////////////////////////////////
//
// setSpeedCalibration
//
/////////////////////////////////
void Mount::setSpeedCalibration(float val, bool saveToStorage)
{
LOG(DEBUG_MOUNT, "[MOUNT]: Updating speed calibration from %f to %f", _trackingSpeedCalibration, val);
_trackingSpeedCalibration = val;
LOG(DEBUG_MOUNT, "[MOUNT]: Current tracking speed is %f steps/sec", _trackingSpeed);
// Tracking speed has to be exactly the rotation speed of the earth. The earth rotates 360° per astronomical day.
// This is 23h 56m 4.0905s, therefore the dimensionless _trackingSpeedCalibration = (23h 56m 4.0905s / 24 h) * mechanical calibration factor
// Also compensate for higher precision microstepping in tracking mode (_stepsPerRADegree uses slewing MS for calculations)
_trackingSpeed = _trackingSpeedCalibration * _stepsPerRADegree * (RA_TRACKING_MICROSTEPPING / RA_SLEW_MICROSTEPPING) * 360.0f
/ SIDEREAL_SECONDS_PER_DAY; // (fraction of day) * u-steps/deg * (u-steps/u-steps) * deg / (sec/day) = u-steps / sec
LOG(DEBUG_MOUNT, "[MOUNT]: RA steps per degree is %f steps/deg", _stepsPerRADegree);
LOG(DEBUG_MOUNT, "[MOUNT]: New tracking speed is %f steps/sec", _trackingSpeed);
LOG(DEBUG_MOUNT, "[MOUNT]: FactorToSpeed : %s, %s", String(val, 6).c_str(), String(_trackingSpeed, 6).c_str());
if (saveToStorage)
EEPROMStore::storeSpeedFactor(_trackingSpeedCalibration);
// If we are currently tracking, update the speed. No need to update microstepping mode
if (isSlewingTRK())
{
LOG(DEBUG_STEPPERS, "[MOUNT]: SpeedCalibration TRK.setSpeed(%f)", _trackingSpeed);
_stepperTRK->setSpeed(_trackingSpeed);
}
}
#if USE_GYRO_LEVEL == 1
/////////////////////////////////
//
// getPitchCalibrationAngle
//
// The pitch value at which the mount is level
/////////////////////////////////
float Mount::getPitchCalibrationAngle()
{
return _pitchCalibrationAngle;
}
/////////////////////////////////
//
// setPitchCalibrationAngle
//
/////////////////////////////////
void Mount::setPitchCalibrationAngle(float angle)
{
_pitchCalibrationAngle = angle;
EEPROMStore::storePitchCalibrationAngle(_pitchCalibrationAngle);
}
/////////////////////////////////
//
// getRollCalibration
//
// The roll value at which the mount is level
/////////////////////////////////
float Mount::getRollCalibrationAngle()
{
return _rollCalibrationAngle;
}
/////////////////////////////////
//
// setRollCalibration
//
/////////////////////////////////
void Mount::setRollCalibrationAngle(float angle)
{
_rollCalibrationAngle = angle;
EEPROMStore::storeRollCalibrationAngle(_rollCalibrationAngle);
}
#endif
/////////////////////////////////
//
// getStepsPerDegree
//
/////////////////////////////////
float Mount::getStepsPerDegree(StepperAxis which)
{
if (which == RA_STEPS)
{
return _stepsPerRADegree; // u-steps/degree
}
if (which == DEC_STEPS)
{
return _stepsPerDECDegree; // u-steps/degree
}
return 0;
}
/////////////////////////////////
//
// setStepsPerDegree
//
/////////////////////////////////