1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

datatypes used in eeprom should be a data type that has a given size

This commit is contained in:
Harald Barth 2021-07-25 23:12:12 +02:00
parent cc4de0ad14
commit c292f210a4
2 changed files with 6 additions and 6 deletions

View File

@ -14,9 +14,9 @@ extern ExternalEEPROM EEPROM;
struct EEStoreData{
char id[sizeof(EESTORE_ID)];
int nTurnouts;
int nSensors;
int nOutputs;
uint16_t nTurnouts;
uint16_t nSensors;
uint16_t nOutputs;
};
struct EEStore{

View File

@ -138,7 +138,7 @@ void Output::load(){
// id. If someone uses only pins 0 to 7 of their arduino, they
// loose. This is (if you look at an arduino) however unlikely.
for(int i=0;i<EEStore::eeStore->data.nOutputs;i++){
for(uint16_t i=0;i<EEStore::eeStore->data.nOutputs;i++){
EEPROM.get(EEStore::pointer()+ i*sizeof(struct BrokenOutputData),bdata);
if (bdata.iFlag > 7) { // it's a pin and not an iFlag!
isBroken=0;
@ -146,7 +146,7 @@ void Output::load(){
}
}
if ( isBroken ) {
for(int i=0;i<EEStore::eeStore->data.nOutputs;i++){
for(uint16_t i=0;i<EEStore::eeStore->data.nOutputs;i++){
EEPROM.get(EEStore::pointer(),bdata);
tt=create(bdata.id,bdata.pin,bdata.iFlag);
tt->data.oStatus=bitRead(tt->data.iFlag,1)?bitRead(tt->data.iFlag,2):bdata.oStatus; // restore status to EEPROM value is bit 1 of iFlag=0, otherwise set to value of bit 2 of iFlag
@ -158,7 +158,7 @@ void Output::load(){
} else {
struct OutputData data;
for(int i=0;i<EEStore::eeStore->data.nOutputs;i++){
for(uint16_t i=0;i<EEStore::eeStore->data.nOutputs;i++){
EEPROM.get(EEStore::pointer(),data);
tt=create(data.id,data.pin,data.iFlag);
tt->data.oStatus=bitRead(tt->data.iFlag,1)?bitRead(tt->data.iFlag,2):data.oStatus; // restore status to EEPROM value is bit 1 of iFlag=0, otherwise set to value of bit 2 of iFlag