diff --git a/Src/main.c b/Src/main.c index af5b33c..bcaf246 100644 --- a/Src/main.c +++ b/Src/main.c @@ -1,4 +1,4 @@ -/* USER CODE BEGIN Header */ + /* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c @@ -814,10 +814,26 @@ void Write_intostime(){ void Eeprom_loadsettings(){ for(uint8_t i=0 ; i < 7 ; i++){ - sSetStart[i].Hours = (uint8_t) (readEEPROMHalfWord(2*i) >> 8); - sSetStart[i].Minutes = (uint8_t) readEEPROMHalfWord(2*i); - sSetEnd[i].Hours = (uint8_t) (readEEPROMHalfWord(2*i + 14) >> 8); - sSetEnd[i].Minutes = (uint8_t) readEEPROMHalfWord(2*i + 14); + if((uint8_t) (readEEPROMHalfWord(2*i) >> 8) >= 0 && (uint8_t) (readEEPROMHalfWord(2*i) >> 8) < 24){ + sSetStart[i].Hours = (uint8_t) (readEEPROMHalfWord(2*i) >> 8); + }else{ + sSetStart[i].Hours = 0; + } + if((uint8_t) readEEPROMHalfWord(2*i) >= 0 && (uint8_t) readEEPROMHalfWord(2*i) < 60){ + sSetStart[i].Minutes = (uint8_t) readEEPROMHalfWord(2*i); + }else{ + sSetStart[i].Minutes = 0; + } + if((uint8_t) (readEEPROMHalfWord(2*i + 14) >> 8) >= 0 && (uint8_t) (readEEPROMHalfWord(2*i + 14) >> 8) < 24){ + sSetEnd[i].Hours = (uint8_t) (readEEPROMHalfWord(2*i + 14) >> 8); + }else{ + sSetEnd[i].Hours = 0; + } + if((uint8_t) readEEPROMHalfWord(2*i + 14) >= 0 && (uint8_t) readEEPROMHalfWord(2*i + 14) < 60){ + sSetEnd[i].Minutes = (uint8_t) readEEPROMHalfWord(2*i + 14); + }else{ + sSetEnd[i].Minutes = 0; + } } }