static const char *limit_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    int idx = (long)data;
    struct TelemetryAlarm *alarm = &Model.alarms[idx];
    u8 telem_src = alarm->src;
    if (telem_src == 0) {
        return "----";
    }
    s32 min = TELEMETRY_GetMinValue(telem_src);
    s32 max = TELEMETRY_GetMaxValue(telem_src);
    s32 value = alarm->value;

    u32 small_step = 1;
    u32 big_step = 10;
    if (value > 1000 || (value == 1000 && dir > 0)) {
        small_step = 10;
        big_step = 100;
    }
    if (min >= 50) {  //RPM
        small_step = 50;
        big_step = 500;
    } else if (max > 9999) {
        if (value > 10000 || (value == 10000 && dir > 0)) {
            small_step = 100;
            big_step = 1000;
        }
    } else if (max > 999) {
        small_step = 10;
        big_step = 100;
    }

    alarm->value = GUI_TextSelectHelper(value, min, max, dir, small_step, big_step, NULL);
    TELEMETRY_GetValueStrByValue(tempstring, telem_src, alarm->value);
    if (alarm->threshold > 0) {
        char tmpstr[sizeof(tempstring)];
        strlcpy(tmpstr, tempstring, sizeof(tmpstr));
        snprintf(tempstring, sizeof(tempstring),
            "%ds%s%s", alarm->threshold, ALARM_TH_SPACER, tmpstr);
    }
    return tempstring;
}
Beispiel #2
0
const char * TELEMETRY_GetValueStr(char *str, u8 telem)
{
    s32 value = TELEMETRY_GetValue(telem);
    return TELEMETRY_GetValueStrByValue(str, telem, value);
}