Пример #1
0
void CONFIG_WriteTx()
{
    int i;
    FILE *fh;
    struct Transmitter *t = &Transmitter;
    fh = fopen("tx.ini", "w");
    if (! fh) {
        printf("Couldn't open tx.ini\n");
        return;
    }
    CONFIG_EnableLanguage(0);
    fprintf(fh, "%s=%d\n", CURRENT_MODEL, Transmitter.current_model);
    fprintf(fh, "%s=%d\n", LANGUAGE, Transmitter.language);
    fprintf(fh, "%s=%d\n", MUSIC_SHUTD, Transmitter.music_shutdown);
    fprintf(fh, "%s=%d\n", MODE, Transmitter.mode);
    fprintf(fh, "%s=%d\n", BRIGHTNESS, Transmitter.brightness);
    fprintf(fh, "%s=%d\n", CONTRAST, Transmitter.contrast);
    fprintf(fh, "%s=%d\n", VOLUME, Transmitter.volume);
    fprintf(fh, "%s=%d\n", VIBRATION, Transmitter.vibration_state);
    fprintf(fh, "%s=%d\n", POWER_ALARM, Transmitter.power_alarm);
    fprintf(fh, "%s=%d\n", BATT_ALARM, Transmitter.batt_alarm);
    fprintf(fh, "%s=%d\n", BATT_CRITICAL, Transmitter.batt_critical);
    fprintf(fh, "%s=%d\n", BATT_WARNING_INTERVAL, Transmitter.batt_warning_interval);
    fprintf(fh, "%s=%d\n", SPLASH_DELAY, Transmitter.splash_delay);
#if HAS_RTC
    fprintf(fh, "%s=%d\n", TIME_FORMAT, Transmitter.rtcflags & TIMEFMT);
    fprintf(fh, "%s=%d\n", DATE_FORMAT, (Transmitter.rtcflags & DATEFMT) >> 4);
#endif
    for(i = 0; i < INP_HAS_CALIBRATION; i++) {
        fprintf(fh, "[%s%d]\n", SECTION_CALIBRATE, i+1);
        fprintf(fh, "  %s=%d\n", CALIBRATE_MAX, t->calibration[i].max);
        fprintf(fh, "  %s=%d\n", CALIBRATE_MIN, t->calibration[i].min);
        fprintf(fh, "  %s=%d\n", CALIBRATE_ZERO, t->calibration[i].zero);
    }
    fprintf(fh, "[%s]\n", SECTION_TOUCH);
    fprintf(fh, "  %s=%d\n", TOUCH_XSCALE, (int)t->touch.xscale);
    fprintf(fh, "  %s=%d\n", TOUCH_YSCALE, (int)t->touch.yscale);
    fprintf(fh, "  %s=%d\n", TOUCH_XOFFSET, (int)t->touch.xoffset);
    fprintf(fh, "  %s=%d\n", TOUCH_YOFFSET, (int)t->touch.yoffset);
    fprintf(fh, "[%s]\n", SECTION_AUTODIMMER);
    fprintf(fh, "%s=%u\n", AUTODIMMER_TIME, (unsigned int)t->auto_dimmer.timer);
    fprintf(fh, "%s=%u\n", AUTODIMMER_DIMVALUE, t->auto_dimmer.backlight_dim_value);
    fprintf(fh, "[%s]\n", SECTION_TIMERSETTINGS);
    fprintf(fh, "%s=%u\n", TIMERSETTINGS_PREALERT_TIME, (unsigned int)t->countdown_timer_settings.prealert_time);
    fprintf(fh, "%s=%u\n", TIMERSETTINGS_PREALERT_INTERVAL, t->countdown_timer_settings.prealert_interval);
    fprintf(fh, "%s=%u\n", TIMERSETTINGS_TIMEUP_INTERVAL, t->countdown_timer_settings.timeup_interval);

    fprintf(fh, "[%s]\n", SECTION_TELEMETRY);
    fprintf(fh, "%s=%s\n", TELEM_TEMP, TELEM_TEMP_VAL[(t->telem & TELEMUNIT_FAREN) ? 1 : 0]);
    fprintf(fh, "%s=%s\n", TELEM_LENGTH, TELEM_LENGTH_VAL[(t->telem & TELEMUNIT_FEET) ? 1 : 0]);

    CONFIG_EnableLanguage(1);
    fclose(fh);
}
Пример #2
0
static const char *channum_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    long ch = (long)data;
    if (cp->type) {
        char *p = cp->tmpstr;
        if (ch & 0x01) {
            *p = '\n';
            p++;
        }
        CONFIG_EnableLanguage(0);  //Disable translation because tiny font is limitied in character set
        INPUT_SourceName(p, ch+1);
        CONFIG_EnableLanguage(1);
        if (! (ch & 0x01)) {
            sprintf(p + strlen(p), "\n");
        }
    } else {
       sprintf(cp->tmpstr, "\n%d", (int)ch+1);
    }
    return cp->tmpstr;
}
Пример #3
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;
}