RTC and SD logs #4556

only:no more LCD this time around
This commit is contained in:
Andrey 2024-08-28 20:51:43 -04:00
parent f950b74fcb
commit 8c020e39fb
2 changed files with 27 additions and 25 deletions

View File

@ -89,16 +89,16 @@ RTCDateTime convertRtcDateTimeFromEfi(efidatetime_t const * const dateTime) {
// TODO(nms): move to e.g. efitime ?
static void put2(int offset, char *lcd_str, int value) {
static void putTwoSymbolDecimal(int offset, char *destination, int value) {
static char buff[_MAX_FILLER];
efiAssertVoid(ObdCode::CUSTOM_ERR_6666, value >=0 && value <100, "value");
itoa10(buff, value);
if (value < 10) {
lcd_str[offset] = '0';
lcd_str[offset + 1] = buff[0];
destination[offset] = '0';
destination[offset + 1] = buff[0];
} else {
lcd_str[offset] = buff[0];
lcd_str[offset + 1] = buff[1];
destination[offset] = buff[0];
destination[offset + 1] = buff[1];
}
}
#endif // EFI_RTC
@ -107,47 +107,49 @@ static void put2(int offset, char *lcd_str, int value) {
/**
* @return true if we seem to know current date, false if no valid RTC state
*/
bool dateToStringShort(char *lcd_str) {
bool dateToStringShort(char *destination) {
#if EFI_RTC
strcpy(lcd_str, "000000_000000\0");
strcpy(destination, "000000_000000\0");
efidatetime_t dateTime = getRtcDateTime();
if (dateTime.year < 2016 || dateTime.year > 2030) {
// 2016 to 2030 is the valid range
lcd_str[0] = 0;
destination[0] = 0;
return false;
}
put2(0, lcd_str, dateTime.year % 100); // year, format as just the last two digits
put2(2, lcd_str, dateTime.month); // month 1-12
put2(4, lcd_str, dateTime.day); // day of the month 1-31
putTwoSymbolDecimal(0, destination, dateTime.year % 100); // year, format as just the last two digits
putTwoSymbolDecimal(2, destination, dateTime.month); // month 1-12
putTwoSymbolDecimal(4, destination, dateTime.day); // day of the month 1-31
put2(7, lcd_str, dateTime.hour); // hours since midnight 0-23
put2(9, lcd_str, dateTime.minute); // minutes
put2(11, lcd_str, dateTime.second); // seconds
putTwoSymbolDecimal(7, destination, dateTime.hour); // hours since midnight 0-23
putTwoSymbolDecimal(9, destination, dateTime.minute); // minutes
putTwoSymbolDecimal(11, destination, dateTime.second); // seconds
return true;
#else // EFI_RTC
lcd_str[0] = 0;
destination[0] = 0;
return false;
#endif // EFI_RTC
}
void dateToString(char *lcd_str) {
/*
void dateToString(char *destination) {
#if EFI_RTC
// todo:
// re-implement this along the lines of chvprintf("%04u-%02u-%02u %02u:%02u:%02u\r\n", timp.tm_year + 1900, timp.tm_mon + 1, timp.tm_mday, timp.tm_hour,
// timp.tm_min, timp.tm_sec);
// this would require a temporary mem stream - see datalogging and other existing usages
strcpy(lcd_str, "00/00 00:00:00\0");
strcpy(destination, "00/00 00:00:00\0");
efidatetime_t dateTime = getRtcDateTime();
put2(0, lcd_str, dateTime.month);
put2(3, lcd_str, dateTime.day);
put2(6, lcd_str, dateTime.hour);
put2(9, lcd_str, dateTime.minute);
put2(12, lcd_str, dateTime.second);
putTwoSymbolDecimal(0, destination, dateTime.month);
putTwoSymbolDecimal(3, destination, dateTime.day);
putTwoSymbolDecimal(6, destination, dateTime.hour);
putTwoSymbolDecimal(9, destination, dateTime.minute);
putTwoSymbolDecimal(12, destination, dateTime.second);
#else // EFI_RTC
lcd_str[0] = 0;
destination[0] = 0;
#endif // EFI_RTC
}
*/

View File

@ -21,5 +21,5 @@ efidatetime_t convertRtcDateTimeToEfi(const RTCDateTime * const timespec);
RTCDateTime convertRtcDateTimeFromEfi(const efidatetime_t * const dateTime);
#endif // EFI_RTC
void dateToString(char *buffer);
//void dateToString(char *buffer);
bool dateToStringShort(char *lcd_str);