Ejemplo n.º 1
0
// for big boxes only these will fit
void RTC_GetTimeFormattedBigbox(char *str, u32 time)
{
    unsigned am = ((time % DAYSEC) / 3600) < 12;
    unsigned hour = _RTC_GetHour(time);
    if (hour == 12) hour = 0;
    sprintf(str, "%2d:%02d:%02d", hour + (am ? 0 : 12), _RTC_GetMinute(time), _RTC_GetSecond(time));
}
Ejemplo n.º 2
0
void RTC_GetTimeFormatted(char *str, u32 time)
{
    // which format to use?
    unsigned format = Transmitter.rtcflags & TIMEFMT;
    // make sure that the number is correct; use default otherwise
    if (format >= sizeof(timeformats) / sizeof(timeformats[0])) format = 0;
    switch (format) {
        case 0: // "default" = ISO8601 = hh:mm:ss
            sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time));
            break;
        case 1: // a.m. / p.m. = hh:mm:ss am/pm
        {
            unsigned am = ((time % DAYSEC) / 3600) < 12;
            sprintf(str, "%2d:%02d:%02d %s", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time), (am) ? "AM" : "PM");
            break;
        }
    }
}
Ejemplo n.º 3
0
void RTC_GetTimeGTM(struct gtm *t)
{
    uint32_t value = RTC_GetValue();
    t->tm_sec  = _RTC_GetSecond(value);
    t->tm_min  = _RTC_GetMinute(value);
    t->tm_hour = _RTC_GetHour(value);
    t->tm_mday = _RTC_GetDay(value);
    t->tm_year = _RTC_GetYear(value) - 1900;
}
Ejemplo n.º 4
0
// format time string
void RTC_GetTimeStringShort(char *str, u32 value)
{
    sprintf(str, "%2d:%02d", _RTC_GetHour(value), _RTC_GetMinute(value));
}
Ejemplo n.º 5
0
// for big boxes only these will fit
void RTC_GetTimeFormattedBigbox(char *str, u32 time)
{
    sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time));
}
Ejemplo n.º 6
0
// format time string
void RTC_GetTimeString(char *str, uint32_t value)
{
    sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(value), _RTC_GetMinute(value), _RTC_GetSecond(value));
}