comparison Discovery/Src/tMenuEditSystem.c @ 720:4f70155362d2

Bugfix set date (year): In the previous version the year selection was clipped to a range between 16 and 22. To avoid clipping issues in future the clipping is now done based on the firmware release date as lower limit and release date +10 years as upper limit.
author Ideenmodellierer
date Tue, 03 Jan 2023 19:47:12 +0100
parents b456be1e152d
children 9c65d226f4f6
comparison
equal deleted inserted replaced
719:5ff9ea732cbb 720:4f70155362d2
151 RTC_DateTypeDef Sdate; 151 RTC_DateTypeDef Sdate;
152 RTC_TimeTypeDef Stime; 152 RTC_TimeTypeDef Stime;
153 uint8_t day,month,year,hour,minute, dateFormat, ddmmyy, mmddyy, yymmdd; 153 uint8_t day,month,year,hour,minute, dateFormat, ddmmyy, mmddyy, yymmdd;
154 char text[32]; 154 char text[32];
155 SSettings *pSettings; 155 SSettings *pSettings;
156 SFirmwareData *pFirmwareInfo;
157 pFirmwareInfo = firmwareDataGetPointer();
156 const SDiveState * pStateReal = stateRealGetPointer(); 158 const SDiveState * pStateReal = stateRealGetPointer();
157 159
158 pSettings = settingsGetPointer(); 160 pSettings = settingsGetPointer();
159 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); 161 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate);
160 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); 162 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime);
162 month = Sdate.Month; 164 month = Sdate.Month;
163 day = Sdate.Date; 165 day = Sdate.Date;
164 hour = Stime.Hours; 166 hour = Stime.Hours;
165 minute= Stime.Minutes; 167 minute= Stime.Minutes;
166 168
167 if(year < 16) 169 if(year < pFirmwareInfo->release_year)
168 year = 16; 170 year = pFirmwareInfo->release_year;
169 171
170 if(month < 1) 172 if(month < 1)
171 month = 1; 173 month = 1;
172 174
173 if(day < 1) 175 if(day < 1)
224 { 226 {
225 uint8_t digitContentNew; 227 uint8_t digitContentNew;
226 uint32_t newDay, newMonth, newYear; 228 uint32_t newDay, newMonth, newYear;
227 RTC_DateTypeDef sdatestructure; 229 RTC_DateTypeDef sdatestructure;
228 230
231 SFirmwareData *pFirmwareInfo;
232 pFirmwareInfo = firmwareDataGetPointer();
229 233
230 if(action == ACTION_BUTTON_ENTER) 234 if(action == ACTION_BUTTON_ENTER)
231 { 235 {
232 return digitContent; 236 return digitContent;
233 } 237 }
259 setDate(sdatestructure); 263 setDate(sdatestructure);
260 264
261 tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0); 265 tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0);
262 return UNSPECIFIC_RETURN; 266 return UNSPECIFIC_RETURN;
263 } 267 }
264 if(action == ACTION_BUTTON_NEXT) 268 if(action == ACTION_BUTTON_NEXT) /* clip values to a specific range e.g. 12 months */
265 { 269 {
266 digitContentNew = digitContent + 1; 270 digitContentNew = digitContent + 1;
267 if((blockNumber == 0) && (digitContentNew > '0' + 31)) 271 if((blockNumber == 0) && (digitContentNew > '0' + 31))
268 digitContentNew = '1'; 272 digitContentNew = '1';
269 if((blockNumber == 1) && (digitContentNew > '0' + 12)) 273 if((blockNumber == 1) && (digitContentNew > '0' + 12))
270 digitContentNew = '1'; 274 digitContentNew = '1';
271 // year range 2017-2018 275 if((blockNumber == 2) && (digitContentNew > '0' + pFirmwareInfo->release_year + 10))
272 if((blockNumber == 2) && (digitContentNew > '0' + 22)) 276 digitContentNew = '0' + pFirmwareInfo->release_year;
273 digitContentNew = '0' + 18;
274 return digitContentNew; 277 return digitContentNew;
275 } 278 }
276 if(action == ACTION_BUTTON_BACK) 279 if(action == ACTION_BUTTON_BACK) /* clip values to a specific range e.g. 12 months */
277 { 280 {
278 digitContentNew = digitContent - 1; 281 digitContentNew = digitContent - 1;
279 if((blockNumber == 0) && (digitContentNew < '1')) 282 if((blockNumber == 0) && (digitContentNew < '1'))
280 digitContentNew = '0' + 31; 283 digitContentNew = '0' + 31;
281 if((blockNumber == 1) && (digitContentNew < '1')) 284 if((blockNumber == 1) && (digitContentNew < '1'))
282 digitContentNew = '0' + 12; 285 digitContentNew = '0' + 12;
283 // year range 2016-2018 286 if((blockNumber == 2) && (digitContentNew < '0' + pFirmwareInfo->release_year))
284 if((blockNumber == 2) && (digitContentNew < '0' + 17)) 287 digitContentNew = '0' + pFirmwareInfo->release_year + 10;
285 digitContentNew = '0' + 18;
286 return digitContentNew; 288 return digitContentNew;
287 } 289 }
288 /* 290 /*
289 if(action == ACTION_BUTTON_NEXT) 291 if(action == ACTION_BUTTON_NEXT)
290 { 292 {