Skip to content

Commit 3f5c2b2

Browse files
Enhance EEPROM handling by adding checks for disabled stepper axes in AZ and ALT steps storage and retrieval
1 parent cc68896 commit 3f5c2b2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.pio
22
.vscode
33
venv
4+
.venv
5+
__pycache__
46
.idea
57
cmake-*
68
CMakeLists.txt

src/EPROMStore.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,14 @@ float EEPROMStore::getAZStepsPerDegree()
477477

478478
if (isPresentExtended(AZ_NORM_STEPS_MARKER_FLAG))
479479
{
480+
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE)
480481
// Latest version stores 100x steps/deg for 256 MS
481482
const float factor = SteppingStorageNormalized / AZ_MICROSTEPPING;
482483
azStepsPerDegree = readInt32(AZ_NORM_STEPS_DEGREE_ADDR) / factor;
483484
LOG(DEBUG_EEPROM, "[EEPROM]: AZ Normed Marker Present! AZ steps/deg is %f", azStepsPerDegree);
485+
#else
486+
LOG(DEBUG_EEPROM, "[EEPROM]: AZ marker present but AZ axis disabled; ignoring stored value");
487+
#endif
484488
}
485489
else
486490
{
@@ -494,13 +498,18 @@ float EEPROMStore::getAZStepsPerDegree()
494498
void EEPROMStore::storeAZStepsPerDegree(float azStepsPerDegree)
495499
{
496500
// Store steps as 100x steps/deg at 256 MS.
501+
#if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE)
497502
const float factor = SteppingStorageNormalized / AZ_MICROSTEPPING;
498503
int32_t val = azStepsPerDegree * factor;
499504
LOG(DEBUG_EEPROM, "[EEPROM]: Storing AZ steps to %l (%f)", val, azStepsPerDegree);
500505

501506
updateInt32(AZ_NORM_STEPS_DEGREE_ADDR, val);
502507
updateFlagsExtended(AZ_NORM_STEPS_MARKER_FLAG);
503508
commit(); // Complete the transaction
509+
#else
510+
LOG(DEBUG_EEPROM, "[EEPROM]: Skipping AZ steps store; AZ axis disabled");
511+
(void) azStepsPerDegree;
512+
#endif
504513
}
505514

506515
// Return the ALT steps per degree (actually microsteps per degree).
@@ -515,10 +524,14 @@ float EEPROMStore::getALTStepsPerDegree()
515524

516525
if (isPresentExtended(ALT_NORM_STEPS_MARKER_FLAG))
517526
{
527+
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
518528
// Latest version stores 100x steps/deg for 256 MS
519529
const float factor = SteppingStorageNormalized / ALT_MICROSTEPPING;
520530
azStepsPerDegree = readInt32(ALT_NORM_STEPS_DEGREE_ADDR) / factor;
521531
LOG(DEBUG_EEPROM, "[EEPROM]: ALT Normed Marker Present! ALT steps/deg is %f", azStepsPerDegree);
532+
#else
533+
LOG(DEBUG_EEPROM, "[EEPROM]: ALT marker present but ALT axis disabled; ignoring stored value");
534+
#endif
522535
}
523536
else
524537
{
@@ -532,13 +545,18 @@ float EEPROMStore::getALTStepsPerDegree()
532545
void EEPROMStore::storeALTStepsPerDegree(float azStepsPerDegree)
533546
{
534547
// Store steps as 100x steps/deg at 256 MS.
548+
#if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE)
535549
const float factor = SteppingStorageNormalized / ALT_MICROSTEPPING;
536550
int32_t val = azStepsPerDegree * factor;
537551
LOG(DEBUG_EEPROM, "[EEPROM]: Storing ALT steps to %l (%f)", val, azStepsPerDegree);
538552

539553
updateInt32(ALT_NORM_STEPS_DEGREE_ADDR, val);
540554
updateFlagsExtended(ALT_NORM_STEPS_MARKER_FLAG);
541555
commit(); // Complete the transaction
556+
#else
557+
LOG(DEBUG_EEPROM, "[EEPROM]: Skipping ALT steps store; ALT axis disabled");
558+
(void) azStepsPerDegree;
559+
#endif
542560
}
543561

544562
int16_t EEPROMStore::getLastFlashedVersion()

0 commit comments

Comments
 (0)