示例#1
0
const char *rtc_show_val_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    u32 time = RTC_GetValue();
    switch ((long)data) {
        case 0:    // second
            sprintf(rp->tmpstr, "%02d", RTC_GetTimeValue(time) % 60);
            break;
        case 1:    // minute
            sprintf(rp->tmpstr, "%02d", (RTC_GetTimeValue(time) / 60) % 60);
            break;
        case 2:    // hour
            sprintf(rp->tmpstr, "%02d", (RTC_GetTimeValue(time) / 3600) % 24);
            break;
        case 3: // day
            RTC_GetDateStringLong(rp->tmpstr,time);
            rp->tmpstr[rp->tmpstr[1] == '.' ? 1 : 2] = 0;
            break;
        case 4: // month
            RTC_GetDateStringLong(rp->tmpstr,RTC_GetValue());
            int idx = (rp->tmpstr[1] == '.' ? 1 : 2);
            rp->tmpstr[idx+3] = 0;
            return rp->tmpstr + idx + 1;
        case 5: // year
            RTC_GetDateStringLong(rp->tmpstr,RTC_GetValue());
            return rp->tmpstr + (rp->tmpstr[1] == '.' ? 1 : 2) + 4;
    }
    return rp->tmpstr;
}
示例#2
0
void PAGE_RTCInit(int page)
{
    (void)page;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader_ExitOnly(PAGE_GetName(PAGEID_RTC), okcancel_cb);
    u32 time = RTC_GetValue();
    u32 timevalue = RTC_GetTimeValue(time);
    Rtc.value[HOUR] = (u16)(timevalue / 3600);
    Rtc.value[MINUTE] = (u16)(timevalue % 3600) / 60;
    Rtc.value[SECOND] = (u16)(timevalue % 60);
    RTC_GetDateStringLong(tempstring,time);
    int idx = (tempstring[1] == '.' ? 1 : 2);
    tempstring[idx] = 0;
    tempstring[idx+3] = 0;
    Rtc.value[DAY] = atoi(tempstring);
    Rtc.value[MONTH] = atoi(tempstring + idx + 1);
    Rtc.value[YEAR] = atoi(tempstring + idx + 4);
    min[SECOND] = 0;             max[SECOND] = 59;
    min[MINUTE] = 0;             max[MINUTE] = 59;
    min[HOUR]   = 0;             max[HOUR]   = 23;
    min[DAY]    = 1;             max[DAY]    = daysInMonth[Rtc.value[MONTH] - 1] + (((Rtc.value[YEAR] % 4) == 0) && (Rtc.value[MONTH] == 2) ? 1 : 0);
    min[MONTH]  = 1;             max[MONTH]  = 12;
    min[YEAR]   = RTC_STARTYEAR; max[YEAR]   = RTC_STARTYEAR + 67;
    _show_page();
}
示例#3
0
文件: RTC_Basic.c 项目: coocox/Mplib
/* Send RTC Time value to hyperterminal */
void demo1(void)
{
    RTC_GetTimeValue(&Time_Struct);
    /* UART0 Display */
    RTC_Disp_HMS[0] = ' ';
    if (Time_Struct.AmPm == RTC_PM_MODE) {
        RTC_Disp_HMS[1] = 'P';
        RTC_Disp_HMS[2] = 'M';
    } else {
        RTC_Disp_HMS[1] = 'A';
        RTC_Disp_HMS[2] = 'M';
    }
    RTC_Disp_HMS[3] = ' ';
    /* Display hour */
    RTC_Disp_HMS[4] = (Time_Struct.Hour / 10U) + 0x30U;
    RTC_Disp_HMS[5] = (Time_Struct.Hour % 10U) + 0x30U;
    RTC_Disp_HMS[6] = ':';
    /* Display min */
    RTC_Disp_HMS[7] = (Time_Struct.Min / 10U) + 0x30U;
    RTC_Disp_HMS[8] = (Time_Struct.Min % 10U) + 0x30U;
    RTC_Disp_HMS[9] = ':';
    /* Display sec */
    RTC_Disp_HMS[10] = (Time_Struct.Sec / 10U) + 0x30U;
    RTC_Disp_HMS[11] = (Time_Struct.Sec % 10U) + 0x30U;
    RTC_Disp_HMS[12] = ' ';
    RTC_Disp_HMS[13] = '\n';
    RTC_Disp_HMS[14] = '\r';
    RTC_Disp_HMS[15] = '\0';
	UART_Print(UART, RTC_Disp_HMS);
}
示例#4
0
const char *rtc_show_val_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    u32 time = RTC_GetValue();
    switch ((long)data) {
        case SECOND:
            sprintf(tempstring, "%2d", RTC_GetTimeValue(time) % 60);
            break;
        case MINUTE:
            sprintf(tempstring, "%2d", (RTC_GetTimeValue(time) / 60) % 60);
            break;
        case HOUR: {
            u32 value = RTC_GetTimeValue(time) / 3600;
            if (Transmitter.rtcflags & CLOCK12HR) {
                u8 hour = value % 12;
                if (hour == 0)
                    hour = 12;
                sprintf(tempstring, "%2d %s", hour, value > 12? "PM" : "AM");
            } else {
                sprintf(tempstring, "%2d", value % 24);
            }
            break;
        }
        case DAY:
            RTC_GetDateStringLong(tempstring, time);
            tempstring[tempstring[1] == '.' ? 1 : 2] = 0;
            break;
        case MONTH:
            RTC_GetDateStringLong(tempstring, time);
            int idx = (tempstring[1] == '.' ? 1 : 2);
            tempstring[idx+3] = 0;
            if (tempstring[idx + 1] == '0') idx++;
            return tempstring + idx + 1;
        case YEAR:
            RTC_GetDateStringLong(tempstring, time);
            return tempstring + (tempstring[1] == '.' ? 1 : 2) + 4;
    }
    return tempstring;
}
示例#5
0
s32 get_boxval(u8 idx)
{
#if HAS_RTC
    if (idx <= NUM_RTC) {
        u32 time = RTC_GetValue();
        return idx == 1 ? RTC_GetTimeValue(time) : RTC_GetDateValue(time);
    }
#endif
    if (idx - NUM_RTC <= NUM_TIMERS)
        return TIMER_GetValue(idx - NUM_RTC - 1);
    if(idx - NUM_RTC - NUM_TIMERS <= NUM_TELEM)
        return TELEMETRY_GetValue(idx - NUM_RTC - NUM_TIMERS);
    return RANGE_TO_PCT(MIXER_GetChannel(idx - (NUM_RTC + NUM_TIMERS + NUM_TELEM + 1), APPLY_SAFETY | APPLY_SCALAR));
}
示例#6
0
void PAGE_RTCInit(int page)
{
    (void)page;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader_ExitOnly(PAGE_GetName(PAGEID_RTC), okcancel_cb);
    u32 time = RTC_GetValue();
    u32 timevalue = RTC_GetTimeValue(time);
    Rtc.value[2] = (u16)(timevalue / 3600);
    Rtc.value[1] = (u16)(timevalue % 3600) / 60;
    Rtc.value[0] = (u16)(timevalue % 60);
    RTC_GetDateStringLong(rp->tmpstr,time);
    int idx = (rp->tmpstr[1] == '.' ? 1 : 2);
    rp->tmpstr[idx] = 0;
    rp->tmpstr[idx+3] = 0;
    Rtc.value[3] = atoi(rp->tmpstr);
    Rtc.value[4] = atoi(rp->tmpstr + idx + 1);
    Rtc.value[5] = atoi(rp->tmpstr + idx + 4);
    _show_page();
}
示例#7
0
// set date (don't change time)
void RTC_SetDate(u16 year, u16 month, u16 day)
{
    RTC_SetValue(RTC_GetTimeValue(RTC_GetValue()) + _RTC_GetSerialDate((int)year, (int)month, (int)day));
}
示例#8
0
// set date (don't change time)
void RTC_SetDate(uint16_t year, uint16_t month, uint16_t day)
{
    RTC_SetValue(RTC_GetTimeValue(RTC_GetValue()) + _RTC_GetSerialDate((int)year, (int)month, (int)day));
}