コード例 #1
0
ファイル: _main_page.c プロジェクト: DeviationTX/deviation
const char *show_box_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    u8 idx = (long)data;
    #if HAS_RTC
        if (idx <= NUM_RTC) {
            u32 time = RTC_GetValue();
            idx == 1 ? RTC_GetTimeFormatted(tempstring, time) : RTC_GetDateFormatted(tempstring, time);
            return tempstring;
        }
    #endif
    if (idx - NUM_RTC <= NUM_TIMERS) {
        TIMER_SetString(tempstring, TIMER_GetValue(idx - NUM_RTC - 1));
    } else if(idx - NUM_RTC - NUM_TIMERS <= NUM_TELEM) {
        TELEMETRY_GetValueStr(tempstring, idx - NUM_RTC - NUM_TIMERS);
    } else {
        unsigned channel = idx - (NUM_RTC + NUM_TIMERS + NUM_TELEM + 1);
        s16 val_raw = MIXER_GetChannel(channel, APPLY_SAFETY | APPLY_SCALAR);
        s16 val_scale = MIXER_GetChannelDisplayScale(channel);
        const char* val_format = MIXER_GetChannelDisplayFormat(channel);

        sprintf(tempstring, val_format, val_raw/val_scale);
    }
    return tempstring;
}
コード例 #2
0
ファイル: rtc_config.c プロジェクト: TheSFReader/deviation
static const char *rtc_text_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    unsigned int idx = (long)data;
    if (idx <= (sizeof(Rtc.value) / sizeof(Rtc.value[0]))) {
        GUI_DrawBackground(X(idx/3, 32) + ((idx%3 == 2) ? 67 : 0) - ((idx%3 == 0) ? 67 : 0), 84, 64, 16);
        idx = order[idx];
    }
    switch (idx) {
        case SECOND:     return _tr("Second");
        case MINUTE:     return _tr("Minute");
        case HOUR:       return _tr("Hour");
        case DAY:        return _tr("Day");
        case MONTH:      return _tr("Month");
        case YEAR:       return _tr("Year");
        case ACTTIME: {
            RTC_GetTimeFormatted(tempstring, RTC_GetValue());
            return tempstring;
        }
        case ACTDATE: {
            RTC_GetDateFormatted(tempstring, RTC_GetValue());
            return tempstring;
        }
        case NEWTIME: {
            RTC_GetTimeFormatted(tempstring, RTC_GetSerial(Rtc.value[YEAR], Rtc.value[MONTH], Rtc.value[DAY], Rtc.value[HOUR], Rtc.value[MINUTE], Rtc.value[SECOND]));
            return tempstring;
        }
        case NEWDATE: {
            RTC_GetDateFormatted(tempstring, RTC_GetSerial(Rtc.value[YEAR], Rtc.value[MONTH], Rtc.value[DAY], Rtc.value[HOUR], Rtc.value[MINUTE], Rtc.value[SECOND]));
            return tempstring;
        }
        case TIMEBUTTON:   return _tr("Set time");
        case DATEBUTTON:   return _tr("Set date");
        case TIMELABEL:    return _tr("Time format");
        case DATELABEL:    return _tr("Date format");
        case SETLABEL:     return _tr("value to set");
        case RESULTLABEL:  return _tr("resulting value");
    }
    return _tr("Unknown");
}
コード例 #3
0
ファイル: _main_page.c プロジェクト: Chen-Leon/DeviationX
const char *show_box_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    u8 idx = (long)data;
    #if HAS_RTC
        if (idx <= NUM_RTC) {
            u32 time = RTC_GetValue();
            idx == 1 ? RTC_GetTimeFormatted(tempstring, time) : RTC_GetDateFormatted(tempstring, time);
            return tempstring;
        }
    #endif
    if (idx - NUM_RTC <= NUM_TIMERS) {
        TIMER_SetString(tempstring, TIMER_GetValue(idx - NUM_RTC - 1));
    } else if(idx - NUM_RTC - NUM_TIMERS <= NUM_TELEM) {
        TELEMETRY_GetValueStr(tempstring, idx - NUM_RTC - NUM_TIMERS);
    } else {
        sprintf(tempstring, "%3d%%", RANGE_TO_PCT(MIXER_GetChannel(idx - (NUM_RTC + NUM_TIMERS + NUM_TELEM + 1), APPLY_SAFETY | APPLY_SCALAR)));
    }
    return tempstring;
}