Ejemplo 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) {
        tempstring_cpy((const char *)_tr("On"));
        GUI_TextSelectEnable(&gui->value, 1);
    }
    else {
        tempstring_cpy((const char *)_tr("Off"));
        GUI_TextSelectEnable(&gui->value, 0);
    }
    return tempstring;
}
Ejemplo n.º 2
0
static const char *_page_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    tempstring_cpy((const char *)"->");  //this is actually used as an icon don't translate
    if (cp->type == MONITOR_RAWINPUT) {
        tempstring_cpy((const char *)"<-");
    }
    return tempstring;
}
Ejemplo n.º 3
0
const char *show_set_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    tempstring_cpy(_tr("Date / Time"));
    return tempstring;
}
Ejemplo n.º 4
0
static void _changename_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    tempstring_cpy(Model.name);
    callback_result = 1;
    GUI_CreateKeyboard(&gui->keyboard, KEYBOARD_ALPHA, tempstring, sizeof(Model.name)-1, _changename_done_cb, &callback_result);
}
Ejemplo n.º 5
0
static void _changename_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    tempstring_cpy((const char *)Model.name); // Don't change model name directly
    GUI_CreateKeyboard(&gui->keyboard, KEYBOARD_ALPHA, tempstring, 20, // no more than 20 chars is allowed for model name
                       _changename_done_cb, (void *)&callback_result);
}
Ejemplo n.º 6
0
void PAGE_ShowWarning(const char *title, const char *str)
{
    (void)title;
    if (dialog)
        return;
    if (str != tempstring)
        tempstring_cpy(str);
    dialog = GUI_CreateDialog(&gui->dialog, DIALOG3_X, DIALOG3_Y,
                 DIALOG3_WIDTH, DIALOG3_HEIGHT, NULL, NULL, lowbatt_ok_cb, dtOk, tempstring);
}
Ejemplo n.º 7
0
static const char *label_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    FunctionSwitch i = (long)data;
    switch (i) {
    case SWITCHFUNC_FLYMODE:
        tempstring_cpy(_tr("Fly mode"));
        break;
    case SWITCHFUNC_HOLD:
        tempstring_cpy(_tr("Thr hold"));
        break;
    case SWITCHFUNC_GYROSENSE:
        tempstring_cpy(_tr("Gyro sense"));
        break;
    case SWITCHFUNC_DREXP_AIL:
        tempstring_cpy(_tr("D/R&Exp -AIL"));
        break;
    case SWITCHFUNC_DREXP_ELE:
        tempstring_cpy(_tr("D/R&Exp -ELE"));
        break;
    case SWITCHFUNC_DREXP_RUD:
    default:
        tempstring_cpy(_tr("D/R&Exp -RUD"));
        break;
    }
    return tempstring;
}
Ejemplo n.º 8
0
static const char *binding_string_cb(guiObject_t *obj, void *data)
{
    (void)data;
    u32 crc = Crc(tempstring, strlen(tempstring));
    if (obj && crc == dialogcrc)
        return tempstring;
    u32 bind_time = PROTOCOL_Binding();
    tempstring_cpy(_tr("Binding is in progress...\nMake sure model is on!\n\nPressing OK will NOT cancel binding procedure\nbut will allow full control of Tx."));
    u32 len = strlen(tempstring);
    if (bind_time != 0xFFFFFFFF && len < sizeof(tempstring)) {
        snprintf(tempstring + len, sizeof(tempstring) - len, _tr("\n\nBinding will end in %d seconds..."), (int)bind_time / 1000);
    }
    return tempstring;
}
Ejemplo n.º 9
0
static const char * show_icontext_cb(guiObject_t *obj, const void *data)
{
    (void)data;
    (void)obj;
    unsigned int i;
    if(! Model.icon[0])
        return _tr("Default");
    tempstring_cpy(Model.icon+9);
    for(i = 0; i < strlen(tempstring); i++) {
        if(tempstring[i] == '.') {
            tempstring[i] = '\0';
            break;
        }
    }
    return tempstring;
}
Ejemplo n.º 10
0
static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data)
{
    if (!GUI_IsTextSelectEnabled(obj)) {
        tempstring_cpy(_tr("Linked"));
        return tempstring;
    }
    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(tempstring, &mix->curve);
}
Ejemplo n.º 11
0
static const char *set_source_helper(guiObject_t *obj, void *data, int changed) {
    (void) obj;
    u8 *source = (u8 *)data;
    if (!GUI_IsTextSelectEnabled(obj) ) {
        tempstring_cpy(_tr("None"));
        return tempstring;
    }
    if (changed) {
        if(mp->cur_template == MIXERTEMPLATE_COMPLEX) {
            guiObject_t *trim = _get_obj(COMPLEX_TRIM, 0);
            if(trim) {
                if (MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src)))
                    GUI_SetHidden(trim, 0);
                else
                    GUI_SetHidden(trim, 1);
            }
        }
        sync_mixers();
        MIXPAGE_RedrawGraphs();
    }
    GUI_TextSelectEnablePress((guiTextSelect_t *)obj, MIXER_SRC(*source));
    return INPUT_SourceName(tempstring, *source);
}
Ejemplo n.º 12
0
const char *show_text_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    int width; int height;
    u16 txt_w, txt_h;
    tempstring_cpy((const char *)data);
    GUI_GetSize(obj, &width, &height);
    width -=2;
    while(1) {
        LCD_GetStringDimensions((const u8 *)tempstring, &txt_w, &txt_h);
        if (txt_w > width) {
            int len = strlen(tempstring);
            if (tempstring[len-1] == '.')
                len--;
            tempstring[len-3] = '.';
            tempstring[len-2] = '.';
            tempstring[len-1] = '\0';
        } else {
            break;
        }
    }
    return tempstring;
}
Ejemplo n.º 13
0
static void show_button_page()
{
    // show elements where they are located on the real tx
    enum {
        OFFSET_X    = ((LCD_WIDTH - 320) / 2), // center on Devo12-screen
        OFFSET_Y    = ((LCD_HEIGHT - 240) / 2),
    };
    enum {X = 0, Y = 1};
    struct LabelDesc alignRight = {
        .font = DEFAULT_FONT.font,
        .align = ALIGN_RIGHT,
        .font_color = DEFAULT_FONT.font_color,
        .fill_color = DEFAULT_FONT.fill_color,
        .outline_color = DEFAULT_FONT.outline_color
    };

    const int label_pos[NUM_TX_BUTTONS][2] = CHANTEST_BUTTON_PLACEMENT;
    cp->is_locked = 3;
    GUI_CreateLabelBox(&gui->lock, OFFSET_X, 34, 320, 20, &NARROW_FONT, lockstr_cb, NULL, NULL);
    for (int i = 0; i < NUM_TX_BUTTONS; i++) {
        if ((1 << (i + 1)) & Transmitter.ignore_buttons)
            continue;
        GUI_CreateLabelBox(&gui->value[i],
                OFFSET_X + (label_pos[i][X] > 0 ? label_pos[i][X] + 50 : -label_pos[i][X] -20),    // >0? box at left side of label, otherwise right
                OFFSET_Y + label_pos[i][Y],
                16, 16,
                &SMALLBOX_FONT, NULL, NULL, (void *)"");
        GUI_CreateLabelBox(&gui->chan[i],
                OFFSET_X + abs(label_pos[i][X]),                                         // no differencing for the label
                OFFSET_Y + label_pos[i][Y],
                48, 16,
                label_pos[i][X] > 0 ? &alignRight : &DEFAULT_FONT,
                button_str_cb, NULL, (void *)(long)i);
    }
}

void _handle_button_test()
{
    if (cp->is_locked == 0 && SPITouch_IRQ()) {
        BUTTON_RegisterCallback(&cp->action, 0xFFFFFFFF,
               BUTTON_PRESS | BUTTON_RELEASE | BUTTON_LONGPRESS | BUTTON_PRIORITY,
               button_capture_cb, NULL);
        GUI_Redraw(&gui->lock); //Textbox
        cp->is_locked++;
    } else if (cp->is_locked == 1 && ! SPITouch_IRQ()) {
        cp->is_locked++;
    } else if (cp->is_locked == 2 && SPITouch_IRQ()) {
        BUTTON_UnregisterCallback(&cp->action);
        GUI_Redraw(&gui->lock); //Textbox
        cp->is_locked++;
    } else if (cp->is_locked == 3 && ! SPITouch_IRQ()) {
        cp->is_locked = 0;
    }
    u32 buttons = ScanButtons();
    for (int i = 0; i < NUM_TX_BUTTONS; i++) {
        GUI_SetLabelDesc(&gui->value[i],
               CHAN_ButtonIsPressed(buttons, i+1)
               ? &SMALLBOXNEG_FONT
               : &SMALLBOX_FONT);
    }
    return;
}

static inline guiObject_t *_get_obj(int chan, int objid)
{
    return objid == ITEM_GRAPH ? (guiObject_t *)&gui->bar[chan] : (guiObject_t *)&gui->value[chan];
}

static const char *channum_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    int disp = (long)data;
    int ch = get_channel_idx(cur_row * NUM_BARS_PER_ROW + disp);
    if (cp->type) {
        char *p = tempstring;
        if (disp & 0x01) {
            *p = '\n';
            p++;
        }
        CONFIG_EnableLanguage(0);  //Disable translation because tiny font is limited in character set
        INPUT_SourceName(p, ch+1);
        CONFIG_EnableLanguage(1);
        if (! (disp & 0x01)) {
            sprintf(p + strlen(p), "\n");
        }
    } else {
        ch -= NUM_INPUTS;
        if (ch < NUM_OUT_CHANNELS) {
            sprintf(tempstring, "\n%d", ch+1);
        } else {
            ch -= NUM_OUT_CHANNELS;
            if (Model.virtname[ch][0]) {
                tempstring_cpy(Model.virtname[ch]) ;
            } else {
                sprintf(tempstring, "%s%d", _tr("Virt"), ch+1);
            }
        }
    }
    return tempstring;
}