Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}