Exemplo n.º 1
0
static const char *throhold_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    (void)data;
    u8 changed = 1;
    u8 throhold_state = 0;
    if (Model.limits[mapped_std_channels.throttle].safetysw)
        throhold_state = 1; // here we set it either 1 or 0
    throhold_state = GUI_TextSelectHelper(throhold_state, 0, 1, dir, 1, 1, &changed);
    if (changed) {
        if (throhold_state == 1) {
            Model.limits[mapped_std_channels.throttle].safetysw = // bug fix: must use inverse position for hold switch
                    mapped_std_channels.switches[SWITCHFUNC_HOLD]
                         ? 0x80 | mapped_std_channels.switches[SWITCHFUNC_HOLD] // inverse of '0'
                         : 0;
            if (Model.limits[mapped_std_channels.throttle].safetyval == 0)
                Model.limits[mapped_std_channels.throttle].safetyval = -110;
        } else
            Model.limits[mapped_std_channels.throttle].safetysw = 0;
    }
    if (throhold_state == 1) {
        strcpy(mp->tmpstr, (const char *)_tr("On"));
        GUI_TextSelectEnable(&gui->value, 1);
    }
    else {
        strcpy(mp->tmpstr, (const char *)_tr("Off"));
        GUI_TextSelectEnable(&gui->value, 0);
    }
    return mp->tmpstr;
}
Exemplo n.º 2
0
static void _update_rate_widgets(u8 idx)
{
    u8 mix = idx + 1;
    guiObject_t *link = GUI_GetScrollableObj(&gui->scrollable, idx ? EXPO_LINK2 : EXPO_LINK1, 0);
    guiObject_t *curve = GUI_GetScrollableObj(&gui->scrollable, idx ? EXPO_CURVE2 : EXPO_CURVE1, 0);
    guiObject_t *scale = GUI_GetScrollableObj(&gui->scrollable, idx ? EXPO_SCALE2 : EXPO_SCALE1, 0);
    if (MIXER_SRC(mp->mixer[mix].sw)) {
        if(link)
            GUI_ButtonEnable(link, 1);
        if(curve) {
            if(mp->link_curves & mix ) {
                GUI_TextSelectEnable((guiTextSelect_t *)curve, 0);
            } else {
                GUI_TextSelectEnable((guiTextSelect_t *)curve, 1);
            }
        }
        if(scale)
            GUI_TextSelectEnable((guiTextSelect_t *)scale, 1);
    } else {
        if(link)
            GUI_ButtonEnable(link, 0);
        if(curve)
            GUI_TextSelectEnable((guiTextSelect_t *)curve, 0);
        if(scale)
            GUI_TextSelectEnable((guiTextSelect_t *)scale, 0);
    }
}
Exemplo n.º 3
0
void set_selected_for_move(int idx)
{
    lp->selected_for_move = idx;
    int state = idx >= 0 ? 1 : 0;
    GUI_SetHidden((guiObject_t *)&gui->editelem, !state);
    GUI_TextSelectEnable(&gui->x, state);
    GUI_TextSelectEnable(&gui->y, state);
}
Exemplo n.º 4
0
static int row_cb(int absrow, int relrow, int y, void *data)
{
    (void)data;
    void * tgl = NULL;
    void * label_cb = NULL;
    const void * label = NULL;
    void * disp = NULL;
    void * value = NULL;
    switch(absrow) {
        case ITEM_REVERSE:
            label = _tr("Reverse");
            tgl = toggle_reverse_cb; disp = reverse_cb; value = (void *)((long)mp->channel);
            break;
        case ITEM_FAILSAFE:
            label = _tr("Fail-safe");
            tgl = toggle_failsafe_cb; disp = set_failsafe_cb;
            break;
        case ITEM_SAFETY:
            label = _tr("Safety");
            tgl = sourceselect_cb; disp = set_source_cb; value = &mp->limit.safetysw;
            break;
        case ITEM_SAFEVAL:
            label = _tr("Safe Val");
            disp = set_safeval_cb;
            break;
        case ITEM_MINLIMIT:
            label = _tr("Min Limit");
            disp = set_limits_cb; value = &mp->limit.min;
            break;
        case ITEM_MAXLIMIT:
            label = _tr("Max Limit");        
            disp = set_limits_cb; value = &mp->limit.max;
            break;
        case ITEM_SCALEPOS:
            label_cb = scalestring_cb; label = (void *)1L;
            disp = set_limitsscale_cb; value = &mp->limit.servoscale;
            break;
        case ITEM_SCALENEG:
            label_cb = scalestring_cb; label = (void *)0L;
            disp = set_limitsscale_cb; value = &mp->limit.servoscale_neg;
            break;
        case ITEM_SUBTRIM:
            label = _tr("Subtrim");
            disp = set_trimstep_cb; value = &mp->limit.subtrim;
            break;
        case ITEM_SPEED:
            label = _tr("Speed");
            disp = set_limits_cb; value = &mp->limit.speed;
            break;
    }
    labelDesc.style = LABEL_LEFTCENTER;
    GUI_CreateLabelBox(&gui->label[relrow], 0, y, 60, LINE_HEIGHT, &labelDesc, label_cb, NULL, label);
    labelDesc.style = LABEL_CENTER;
    GUI_CreateTextSelectPlate(&gui->value[relrow], 60, y, 60, LINE_HEIGHT, &labelDesc, tgl, disp, value);

    if(absrow == ITEM_SAFEVAL)
        GUI_TextSelectEnable(&gui->value[relrow], mp->limit.safetysw);

    return 1;
}
Exemplo n.º 5
0
static void update_swashmixes()
{
    u8 state = 1;
    if (Model.swash_type ==  SWASH_TYPE_NONE)
        state = 0;
    for (u8 i = 0; i < 3; i++) {
        GUI_TextSelectEnable(&gui->mix[i], state);
    }
}
Exemplo n.º 6
0
static const char *auto_dimmer_time_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    (void)data;
    u8 changed;
    u16 dimmer_timmer = Transmitter.auto_dimmer.timer/1000;
    dimmer_timmer = GUI_TextSelectHelper(dimmer_timmer,
            MIN_BACKLIGHT_DIMTIME, MAX_BACKLIGHT_DIMTIME, dir, 5, 10, &changed);
    if (changed)
        Transmitter.auto_dimmer.timer = dimmer_timmer * 1000;
    guiObject_t *dimobj = _get_obj(ITEM_DIMVAL, 0);
    if (dimmer_timmer == 0) {
        if(dimobj)
            GUI_TextSelectEnable((guiTextSelect_t *)dimobj, 0);
        return _tr("Off");
    }
    if (dimobj)
        GUI_TextSelectEnable((guiTextSelect_t *)dimobj, 1);
    TIMER_SetString(tempstring, Transmitter.auto_dimmer.timer);
    return tempstring;
}
Exemplo n.º 7
0
static const char *set_trimstep_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    int i = (long)data;
    u8 *value = &Model.trims[i].step;
    //place switches before 0.1 on the spinbox
    u8 v = ((int)*value + TRIM_SWITCH_TYPES - 1) % (190 + TRIM_SWITCH_TYPES);
    v = GUI_TextSelectHelper(v, 0, 190 + TRIM_SWITCH_TYPES - 1, dir, 1, 5, NULL);
    *value = ((int)v + 190) % (190 + TRIM_SWITCH_TYPES) + 1;

    guiObject_t *negtrimObj = _get_obj(i, TRIM_MINUS);
    guiObject_t *switchObj  = _get_obj(i, TRIM_SWITCH);

    int hide_trim = 0;
    int hide_switch = 0;
    if (*value == TRIM_MOMENTARY) {
        strcpy(tp->tmpstr, _tr("Momentary"));
        hide_trim = 1; hide_switch = 1;
    } else if (*value == TRIM_TOGGLE) {
        strcpy(tp->tmpstr, _tr("Toggle"));
        hide_trim = 1; hide_switch = 1;
    } else if (*value == TRIM_ONOFF) {
        strcpy(tp->tmpstr, _tr("On/Off"));
        hide_switch = 1;
    } else if (*value < 100) {
        sprintf(tp->tmpstr, "%d.%d", *value / 10, *value % 10);
    } else {
        sprintf(tp->tmpstr, "%d", *value - 90);
    }
    if (negtrimObj) {
        if (negtrimObj->Type == TextSelect)
            GUI_TextSelectEnable((guiTextSelect_t *)negtrimObj, ! hide_trim);
        else
            GUI_Redraw(negtrimObj);
    }
    if (switchObj)
        GUI_TextSelectEnable((guiTextSelect_t *)switchObj, ! hide_switch);
    return tp->tmpstr;
}
Exemplo n.º 8
0
static void set_src_enable(int curve_type)
{
    int state;
    if(curve_type != CURVE_FIXED) {
        state = 1;
    } else if(mp->cur_template != MIXERTEMPLATE_EXPO_DR) {
        state = 0;
    } else if(CURVE_TYPE(&mp->mixer[0].curve) == CURVE_FIXED &&
       (! mp->mixer[1].src || CURVE_TYPE(&mp->mixer[1].curve) == CURVE_FIXED) &&
       (! mp->mixer[2].src || CURVE_TYPE(&mp->mixer[2].curve) == CURVE_FIXED))
    {
        state = 0;
    } else {
        state = 1;
    }
    guiObject_t *src = _get_obj(COMMON_SRC, 0);
    if (src) {
        GUI_TextSelectEnable((guiTextSelect_t *)src, state);
        GUI_TextSelectEnablePress((guiTextSelect_t *)src, state);
    }
}
Exemplo n.º 9
0
static int expo_row_cb(int absrow, int relrow, int y, void *data)
{
    const char *label = NULL;
    int underline = 0;
    void * label_cb = NULL;
    void *tgl = NULL;
    void *value = NULL;
    data = NULL;
    void *but_tgl = NULL;
    void *but_txt = NULL;
    void *but_data = NULL;
    int disable = 0;

    int x = 0;
    int w = LEFT_VIEW_WIDTH;
    switch(absrow) {
        case COMMON_SRC:
            label = _tr("Src");
            tgl = sourceselect_cb; value = set_source_cb; data = &mp->cur_mixer->src;
            break;
        case COMMON_CURVE:
            label = _tr("High-Rate");
            tgl = curveselect_cb; value = set_curvename_cb; data = &mp->mixer[0];
            break;
        case COMMON_SCALE:
            label = (void *)0; label_cb = scalestring_cb;
            value = set_number100_cb; data = &mp->mixer[0].scalar;
            break;
        case EXPO_SWITCH1:
            label = _tr("Switch1"); underline = 1;
            tgl = sourceselect_cb; value = set_drsource_cb; data = &mp->mixer[1].sw;
            break;
        case EXPO_LINK1:
            but_tgl = toggle_link_cb; but_txt = show_rate_cb; but_data = (void *)0;
            if(! MIXER_SRC(mp->mixer[1].sw))
                disable = 1;
            break;
        case EXPO_CURVE1:
            tgl = curveselect_cb; value = set_curvename_cb; data = &mp->mixer[1];
            if(! MIXER_SRC(mp->mixer[1].sw) || mp->link_curves & 0x01)
                disable = 1;
            break;
        case EXPO_SCALE1:
            label = (void *)1; label_cb = scalestring_cb;
            value = set_number100_cb; data = &mp->mixer[1].scalar;
            if(! MIXER_SRC(mp->mixer[1].sw))
                disable = 1;
            break;
        case EXPO_SWITCH2:
            label = _tr("Switch2"); underline = 1;
            tgl = sourceselect_cb; value = set_drsource_cb; data = &mp->mixer[2].sw;
            break;
        case EXPO_LINK2:
            but_tgl = toggle_link_cb; but_txt = show_rate_cb; but_data = (void *)1;
            if(! MIXER_SRC(mp->mixer[2].sw))
                disable = 1;
            break;
        case EXPO_CURVE2:
            tgl = curveselect_cb; value = set_curvename_cb; data = &mp->mixer[2];
            if(! MIXER_SRC(mp->mixer[2].sw) || mp->link_curves & 0x02)
                disable = 1;
            break;
        case EXPO_SCALE2:
            label = (void *)2; label_cb = scalestring_cb;
            value = set_number100_cb; data = &mp->mixer[2].scalar;
            if(! MIXER_SRC(mp->mixer[2].sw))
                disable = 1;
            break;
    }
    if(label || label_cb) {
        labelDesc.style = LABEL_LEFTCENTER;
        GUI_CreateLabelBox(&gui->label[relrow], x, y, w, ITEM_HEIGHT,
            &labelDesc, label_cb, NULL, label);
        if(underline)
            GUI_CreateRect(&gui->rect1, x, y, LEFT_VIEW_WIDTH, 1, &labelDesc);
        y += ITEM_HEIGHT + 1;
    }
    labelDesc.style = LABEL_CENTER;
    if(but_tgl) {
        GUI_CreateButtonPlateText(&gui->value[relrow].but, x, y,
            w, ITEM_HEIGHT, &labelDesc, but_txt, 0xffff, but_tgl, but_data);
        if(disable) {
            GUI_ButtonEnable((guiObject_t *)&gui->value[relrow].but, 0);
        }
    } else {
        GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y,
            w, ITEM_HEIGHT, &labelDesc, tgl, value, data);
        if(disable) {
            GUI_TextSelectEnable(&gui->value[relrow].ts, 0);
        }
    }
    return 1;
}