Пример #1
0
static int complex_row_cb(int absrow, int relrow, int y, void *data)
{
    const char *label = NULL;
    void *tgl = NULL;
    void *value = NULL;
    data = NULL;
    int x = 0;
    int w = LEFT_VIEW_WIDTH;
    if (absrow + COMMON_LAST == COMPLEX_TRIM) {
        GUI_CreateButtonPlateText(&gui->value[relrow].but, x, y,
            w, ITEM_HEIGHT, &labelDesc, show_trim_cb, 0x0000, toggle_trim_cb, NULL);
        if (! MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src)))
            GUI_SetHidden((guiObject_t *)&gui->label[relrow], 1);
        return 1;
    }
    switch(absrow + COMMON_LAST) {
        case COMPLEX_MIXER:
            label = _tr_noop("Mixers");
            value = set_nummixers_cb;
            break;
        case COMPLEX_PAGE:
            label = _tr_noop("Page");
            tgl = reorder_cb; value = set_mixernum_cb;
            break;
        case COMPLEX_SWITCH:
            label = _tr_noop("Switch");
            tgl = sourceselect_cb; value = set_drsource_cb; data = &mp->cur_mixer->sw;
            break;
        case COMPLEX_MUX:
            label = _tr_noop("Mux");
            value = set_mux_cb;
            break;
        case COMPLEX_SRC:
            label = _tr_noop("Src");
            tgl = sourceselect_cb; value = set_source_cb; data = &mp->cur_mixer->src;
            break;
        case COMPLEX_CURVE:
            label = _tr_noop("Curve");
            tgl = curveselect_cb; value = set_curvename_cb; data = mp->cur_mixer;
            break;
        case COMPLEX_SCALE:
            label = _tr_noop("Scale");
            value = set_number100_cb; data = &mp->cur_mixer->scalar;
            break;
        case COMPLEX_OFFSET:
            label = _tr_noop("Offset");
            value = set_number100_cb; data = &mp->cur_mixer->offset;
            break;
    }
    labelDesc.style = LABEL_LEFTCENTER;
    GUI_CreateLabelBox(&gui->label[relrow], x, y, w, ITEM_HEIGHT,
            &labelDesc, NULL, NULL, _tr(label));
    labelDesc.style = LABEL_CENTER;
    GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y + ITEM_HEIGHT + 1,
            w, ITEM_HEIGHT, &labelDesc, tgl, value, data);
    if (absrow + COMMON_LAST == COMPLEX_SRC)
        set_src_enable(CURVE_TYPE(&mp->cur_mixer->curve));
    return 1;
}
Пример #2
0
void toggle_link_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    if(data) {
        mp->link_curves ^= 0x02;
        if (mp->link_curves & 0x02) { //Redraw graphs when re-linking
            sync_mixers();
            set_src_enable(CURVE_TYPE(&mp->mixer[0].curve));
            MIXPAGE_RedrawGraphs();
        }
    } else {
        mp->link_curves ^= 0x01;
        if (mp->link_curves & 0x01) { //Redraw graphs when re-linking
            sync_mixers();
            set_src_enable(CURVE_TYPE(&mp->mixer[0].curve));
            MIXPAGE_RedrawGraphs();
        }
    }
    _update_rate_widgets(data ? 1 : 0);
}
Пример #3
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);
    }
}
Пример #4
0
void curveselect_cb(guiObject_t *obj, void *data)
{
    (void)obj;
    if (obj && !GUI_IsTextSelectEnabled(obj)) {
        return;
    }
    struct Mixer *mix = (struct Mixer *)data;
    int idx = (mix == &mp->mixer[1]) ? 1 : (mix == &mp->mixer[2]) ? 2 : 0;
    if (CURVE_TYPE(&mix->curve) > CURVE_FIXED
        && (mp->cur_template != MIXERTEMPLATE_EXPO_DR || mix == 0 || ! (mp->link_curves & idx))) {
        MIXPAGE_EditCurves(&mix->curve, graph_cb);
    }
}
Пример #5
0
const char *set_mixernum_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    (void)data;
    u8 cur = (mp->cur_mixer - mp->mixer) + 1;
    u8 changed;
    cur = GUI_TextSelectHelper(cur, 1, mp->num_mixers, dir, 1, 1, &changed);
    if (changed) {
        mp->cur_mixer = mp->mixer + (cur - 1);
        _show_complex(1);
        set_src_enable(CURVE_TYPE(&mp->cur_mixer->curve));
    }
    sprintf(mp->tmpstr, "%d", cur);
    return mp->tmpstr;
}
Пример #6
0
void PAGE_EditCurvesInit(int page)
{
    (void)page;
    struct Curve *curve = edit->curveptr;
    u8 type = CURVE_TYPE(curve);
    PAGE_SetActionCB(action_cb);
    edit->pointnum = 0;
    edit->reverse = MIXER_SRC_IS_INV(pagemem.u.mixer_page.cur_mixer->src);
    if ((type == CURVE_EXPO || type == CURVE_DEADBAND)
        && curve->points[0] == curve->points[1])
    {
        edit->pointnum = -1;
    }
    edit->curve = *curve;

    GUI_CreateTextSelectPlate(&gui->name, NAME_X, 0, NAME_W, HEADER_HEIGHT, &TEXTSEL_FONT, NULL, set_curvename_cb, NULL);
    GUI_CreateButtonPlateText(&gui->save, SAVE_X, 0, SAVE_W, HEADER_WIDGET_HEIGHT, &BUTTON_FONT , NULL, okcancel_cb, (void *)_tr("Save"));
    // Draw a line
    if (UNDERLINE)
        GUI_CreateRect(&gui->rect, 0, HEADER_WIDGET_HEIGHT, LCD_WIDTH, 1, &DEFAULT_FONT);

    u8 space = LINE_SPACE;
    u8 y = space;

    if (type >= CURVE_3POINT) {
        GUI_CreateLabelBox(&gui->smoothlbl, LABEL_X, y, LABEL1_W, LINE_HEIGHT, &LABEL_FONT, NULL, NULL, _tr("Smooth"));
        GUI_CreateTextSelectPlate(&gui->smooth, TEXTSEL1_X, y, TEXTSEL1_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, set_smooth_cb, NULL);
        y += space;
        GUI_CreateLabelBox(&gui->pointlbl, LABEL_X, y , LABEL2_W, LINE_HEIGHT, &LABEL_FONT, NULL, NULL, _tr("Point"));
        GUI_CreateTextSelectPlate(&gui->point, TEXTSEL2_X, y, TEXTSEL2_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, set_pointnum_cb, NULL);
    } else if(type == CURVE_DEADBAND || type == CURVE_EXPO) {
        GUI_CreateLabelBox(&gui->pointlbl, LABEL_X, y , LABEL_W, LINE_HEIGHT, &LABEL_FONT, NULL, NULL, _tr("Pos/Neg"));
        y += space;
        GUI_CreateTextSelectPlate(&gui->point, LABEL_X, y, LABEL_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, set_expopoint_cb, NULL);
    }

    y += space;
    GUI_CreateLabelBox(&gui->valuelbl, LABEL_X, y , LABEL_W, LINE_HEIGHT, &LABEL_FONT, NULL, NULL, _tr("Value"));
    y += VALUE_Y_OFFSET;
    GUI_CreateTextSelectPlate(&gui->value, VALUE_X, y, LABEL_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, set_value_cb, NULL);

    GUI_CreateXYGraph(&gui->graph, GRAPH_X, GRAPH_Y, GRAPH_W, GRAPH_H,
                              CHAN_MIN_VALUE, CHAN_MIN_VALUE,
                              CHAN_MAX_VALUE, CHAN_MAX_VALUE,
                              0, 0, //CHAN_MAX_VALUE / 4, CHAN_MAX_VALUE / 4,
                              show_curve_cb, NULL, touch_cb, &edit->curve);
    GUI_SetSelected((guiObject_t *)&gui->point);
}
Пример #7
0
static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data)
{
    if (!GUI_IsTextSelectEnabled(obj)) {
        strcpy(mp->tmpstr, _tr("Linked"));
        return mp->tmpstr;
    }
    u8 changed;
    struct Mixer *mix = (struct Mixer *)data;
    u8 type = CURVE_TYPE(&mix->curve);
    type = GUI_TextSelectHelper(type, 0, CURVE_MAX, dir, 1, 1, &changed);
    if (changed) {
        CURVE_SET_TYPE(&mix->curve, type);
        sync_mixers();
        set_src_enable(type);
        MIXPAGE_RedrawGraphs();
    }
    GUI_TextSelectEnablePress((guiTextSelect_t *)obj, type > CURVE_FIXED);
    return CURVE_GetName(mp->tmpstr, &mix->curve);
}
Пример #8
0
int MIXER_SetMixers(struct Mixer *mixers, int count)
{
    int i;
    if (count) {
        int mixer_count = 0;
        unsigned dest = mixers[0].dest;
        //Determine if we have enough free mixers
        for (i = 0; i < NUM_MIXERS; i++) {
            if (MIXER_SRC(Model.mixers[i].src) && Model.mixers[i].dest != dest)
                mixer_count++;
        }
        if (mixer_count + count > NUM_MIXERS) {
            printf("Need %d free mixers, but only %d are available\n", count, NUM_MIXERS - mixer_count);
            return 0;
        }
        //Remove all mixers for this channel
        for (i = 0; i < NUM_MIXERS; i++) {
            if (MIXER_SRC(Model.mixers[i].src) && Model.mixers[i].dest == dest)
                Model.mixers[i].src = 0;
        }
    }
    unsigned pos = compact_mixers();
    for (i = 0; i < count; i++) {
        if (! MIXER_SRC(mixers[i].src) && CURVE_TYPE(&mixers[i].curve) == CURVE_FIXED) {
            mixers[i].src = mixers[i].sw || 1;
        }
        if (MIXER_SRC(mixers[i].src)) {
            Model.mixers[pos] = mixers[i];
            if(Model.templates[mixers[i].dest] != MIXERTEMPLATE_COMPLEX) {
                //Always apply the trim if the template is not 'complex'
                MIXER_SET_APPLY_TRIM(&Model.mixers[pos], 1);
            }
            pos++;
        }
    }
    fix_mixer_dependencies(pos);
    return 1;
}
Пример #9
0
void MIXPAGE_ChangeTemplate(int show_header)
{
    if (mp->cur_template != MIXERTEMPLATE_COMPLEX
        || mp->cur_mixer < mp->mixer
        || mp->cur_mixer > mp->mixer + mp->num_mixers)
    {
        mp->cur_mixer = mp->mixer;
    }
    if (Model.type == MODELTYPE_PLANE && mp->cur_template > MIXERTEMPLATE_MAX_PLANE) {
        mp->cur_template = MIXERTEMPLATE_NONE;
    }
    sync_mixers();
    if (show_header) {
        PAGE_RemoveAllObjects();
        _show_titlerow();
    } else {
        GUI_RemoveHierObjects(mp->firstObj); 
    }
    mp->firstObj = NULL;
    switch(mp->cur_template)  {
    case MIXERTEMPLATE_NONE:
    case MIXERTEMPLATE_CYC1:
    case MIXERTEMPLATE_CYC2:
    case MIXERTEMPLATE_CYC3:
        show_none();
        return;
    case MIXERTEMPLATE_SIMPLE:
        _show_simple();
        break;
    case MIXERTEMPLATE_EXPO_DR:
        _show_expo_dr();
        break;
    case MIXERTEMPLATE_COMPLEX:
        _show_complex(0);
        break;
    }
    set_src_enable(CURVE_TYPE(&mp->mixer[0].curve));
}
Пример #10
0
static int row_cb(int absrow, int relrow, int y, void *data)
{
    (void)data;
    u8 idx;
    struct Mixer *mix = MIXER_GetAllMixers();

    int selectable = 2;
    int channel = absrow;
    if (channel >= Model.num_channels)
        channel += (NUM_OUT_CHANNELS - Model.num_channels);
    if (channel < NUM_OUT_CHANNELS) {
        labelDesc.style = LABEL_LEFT;
        GUI_CreateButtonPlateText(&gui->limit[relrow], COL1_X, y, COL1_W, LINE_HEIGHT, &labelDesc, MIXPAGE_ChanNameProtoCB, 0,
                                  limitselect_cb, (void *)((long)channel));
    } else if(! _is_virt_cyclic(channel)) {
        GUI_CreateButtonPlateText(&gui->limit[relrow], COL1_X, y, COL1_W, LINE_HEIGHT, &labelDesc, MIXPAGE_ChanNameProtoCB, 0,
                                  virtname_cb, (void *)((long)channel));
    } else {
        GUI_CreateLabelBox(&gui->name[relrow], COL1_X, y, COL1_W, LINE_HEIGHT, &labelDesc,
                           MIXPAGE_ChanNameProtoCB, NULL, (const void *)((long)channel));
        selectable = 1;
    }
    labelDesc.style = LABEL_CENTER;
    GUI_CreateButtonPlateText(&gui->tmpl[relrow], COL2_X, y, COL2_W, LINE_HEIGHT , &labelDesc, template_name_cb, 0,
                              templateselect_cb, (void *)((long)channel));

    for (idx = 0; idx < NUM_MIXERS; idx++)
        if (mix[idx].src && mix[idx].dest == channel)
            break;
    if (idx != NUM_MIXERS) {
        // don't show source if curve type is fixed, works only for the first mix per channel
        if(CURVE_TYPE(&mix[idx].curve) != CURVE_FIXED) {
            labelDesc.style = LABEL_LEFT;
            GUI_CreateLabelBox(&gui->src[relrow], COL3_X, y, COL3_W , LINE_HEIGHT, &labelDesc, show_source, NULL, &mix[idx].src);
        }
    }
    return selectable;
}
Пример #11
0
void MIXPAGE_EditCurves(struct Curve *curve, void *data)
{
    u8 type = CURVE_TYPE(curve);
    if (type <= CURVE_FIXED)
        return;
    PAGE_RemoveAllObjects();
    edit->parent = (void (*)(void))data;
    edit->pointnum = 0;
    if ((type == CURVE_EXPO || type == CURVE_DEADBAND)
        && curve->points[0] == curve->points[1])
    {
        edit->pointnum = -1;
    }
    edit->curve = *curve;
    edit->curveptr = curve;
    GUI_CreateTextSelect(&gui->name, 8, 8, TEXTSELECT_96, NULL, set_curvename_cb, NULL);
    PAGE_CreateCancelButton(LCD_WIDTH-160, 4, okcancel_cb);
    PAGE_CreateOkButton(LCD_WIDTH-56, 4, okcancel_cb);
    int y = 40;
    if (type >= CURVE_3POINT) {
        GUI_CreateLabel(&gui->smoothlbl, 8, y, NULL, DEFAULT_FONT, _tr("Smooth"));
        GUI_CreateTextSelect(&gui->smooth, 8, y+16, TEXTSELECT_96, NULL, set_smooth_cb, NULL);
        y += 40;
        GUI_CreateLabel(&gui->pointlbl, 8, y, NULL, DEFAULT_FONT, _tr("Point"));
        GUI_CreateTextSelect(&gui->point, 8, y+16, TEXTSELECT_96, NULL, set_pointnum_cb, NULL);
    } else if(type == CURVE_DEADBAND || type == CURVE_EXPO) {
        GUI_CreateLabel(&gui->pointlbl, 8, y, NULL, DEFAULT_FONT, _tr("Pos/Neg"));
        GUI_CreateTextSelect(&gui->point, 8, y+16, TEXTSELECT_96, NULL, set_expopoint_cb, NULL);
    }
    y += 40;
    GUI_CreateLabel(&gui->valuelbl, 8, y, NULL, DEFAULT_FONT, _tr("Value"));
    GUI_CreateTextSelect(&gui->value, 8, y+16, TEXTSELECT_96, NULL, set_value_cb, NULL);
    GUI_CreateXYGraph(&gui->graph, LCD_WIDTH-208-ADDITIONAL_H, 36, 200+ADDITIONAL_H, 200+ADDITIONAL_H,
                              CHAN_MIN_VALUE, CHAN_MIN_VALUE,
                              CHAN_MAX_VALUE, CHAN_MAX_VALUE,
                              CHAN_MAX_VALUE / 4, CHAN_MAX_VALUE / 4,
                              show_curve_cb, NULL, touch_cb, &edit->curve);
}