Skip to content

Commit aaec992

Browse files
Merge pull request #93 from OpenAstroTech/parking-pos
Parking position
2 parents a152058 + be48a4d commit aaec992

File tree

7 files changed

+336
-104
lines changed

7 files changed

+336
-104
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define VERSION "V1.8.34"
1+
#define VERSION "V1.8.35"

Software/Arduino code/OpenAstroTracker/src/EPROMStore.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,32 @@ void EPROMStore::updateInt16(int loByteAddr, int hiByteAddr, int16_t value)
6565

6666
int16_t EPROMStore::readInt16(int loByteAddr, int hiByteAddr)
6767
{
68-
uint8_t valLo=EPROMStore::read(loByteAddr);
69-
uint8_t valHi=EPROMStore::read(hiByteAddr);
68+
uint8_t valLo = EPROMStore::read(loByteAddr);
69+
uint8_t valHi = EPROMStore::read(hiByteAddr);
7070
uint16_t uValue = (uint16_t)valLo + (uint16_t)valHi * 256;
7171
int16_t value = static_cast<int16_t>(uValue);
7272
//LOGV4(DEBUG_VERBOSE, F("EEPROM: Read16 %d from %d, %d"), value, loByteAddr, hiByteAddr);
7373
return value;
7474
}
75+
76+
void EPROMStore::updateInt32(int lowestByteAddr, int32_t value)
77+
{
78+
LOGV4(DEBUG_VERBOSE, F("EEPROM: Writing32 %l to %d-%d"), value, lowestByteAddr, lowestByteAddr + 3);
79+
update(lowestByteAddr, value & 0x00FF);
80+
update(lowestByteAddr + 1, (value >> 8) & 0x00FF);
81+
update(lowestByteAddr + 2, (value >> 16) & 0x00FF);
82+
update(lowestByteAddr + 3, (value >> 24) & 0x00FF);
83+
}
84+
85+
int32_t EPROMStore::readInt32(int lowestByteAddr)
86+
{
87+
uint8_t val1 = EPROMStore::read(lowestByteAddr);
88+
uint8_t val2 = EPROMStore::read(lowestByteAddr + 1);
89+
uint8_t val3 = EPROMStore::read(lowestByteAddr + 2);
90+
uint8_t val4 = EPROMStore::read(lowestByteAddr + 3);
91+
LOGV5(DEBUG_INFO, F("EEPROM: Read32 read these bytes: %x %x %x %x"), val1, val2, val3, val4);
92+
uint32_t uValue = (uint32_t)val1 + (uint32_t)val2 * 256 + (uint32_t)val3 * 256 * 256 + (uint32_t)val4 * 256 * 256 * 256;
93+
int32_t value = static_cast<int32_t>(uValue);
94+
LOGV4(DEBUG_INFO, F("EEPROM: Read32 which is %l from %d-%d"), value, lowestByteAddr, lowestByteAddr + 3);
95+
return value;
96+
}

Software/Arduino code/OpenAstroTracker/src/EPROMStore.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ class EPROMStore {
1616

1717
static void updateInt16(int loByteAddr, int hiByteAddr, int16_t value);
1818
static int16_t readInt16(int loByteAddr, int hiByteAddr);
19+
20+
static void updateInt32(int lowestByteAddr, int32_t value);
21+
static int32_t readInt32(int lowestByteAddr);
1922
};
2023

0 commit comments

Comments
 (0)