static void RestoreRtc(void) { CheckResetCode(); if (niReset == NORMAL_RESET_CODE && ToBin(RtcHour) < 24 && ToBin(RtcMin) < 60) { RTCYEAR = RtcYear; RTCMON = RtcMon; RTCDAY = RtcDay; RTCDOW = RtcDow; RTCHOUR = RtcHour; RTCMIN = RtcMin; RTCSEC = RtcSec; } else { RTCYEARH = 0x20; RTCYEARL = 0x13; RTCMON = 0x05; RTCDAY = 0x23; RTCDOW = 0x05; RTCHOUR = 0x11; RTCMIN = 0x58; RTCSEC = 0x0; } }
void _Save(TerminalTagSet *obj, XMLCfgFile &cfg) { for (auto it = obj->begin(); it != obj->end(); ++it) { cfg.Add("TLV", it->ToBin().ToHex().c_str()); } cfg.Save(); }
void UpdateLog(unsigned char MsgType, unsigned char MsgOpt) { if (MsgType == ButtonStateMsg || MsgType == WriteBufferMsg) return; // get rtc, convert to log format unsigned int Timestamp = ToBin(To12H(RTCHOUR)) << 12; Timestamp += ToBin(RTCMIN) << 6; Timestamp += ToBin(RTCSEC); // PrintE("Log I:%u %u:%u:%u", niLogIndex, Timestamp >> 12, (Timestamp & 0x0FC0) >> 6, Timestamp & 0x003F); niLog[niLogBuffer.Index].Timestamp = Timestamp; niLog[niLogBuffer.Index].MsgType = MsgType; niLog[niLogBuffer.Index].MsgOpt = MsgOpt; // PrintF("%s %02X", MsgInfo[MsgType].MsgStr, MsgOpt); if (niLogBuffer.Num < RESET_LOG_NUM) niLogBuffer.Num ++; if (++niLogBuffer.Index >= RESET_LOG_NUM) niLogBuffer.Index = 0; }
static unsigned char IncBCD(unsigned char Rtc, unsigned char Index) { Rtc = ToBin(Rtc) + 1; if (Rtc > MaxRtc[Index]) Rtc = (Index == RTC_MIN || Index == RTC_DOW || Index == RTC_SEC) ? 0 : 1; return ToBCD(Rtc); }