Ejemplo n.º 1
0
static void notify_cb(guiObject_t * obj)
{
    if(obj && mp->cur_template == MIXERTEMPLATE_EXPO_DR && OBJ_IS_SCROLLABLE(obj)) {
        /* We exploit the fact that each row has only one selecteable object */
        int row_offset = GUI_ScrollableGetObjRowOffset(&gui->scrollable, obj);
        int idx = (row_offset >> 8) + (row_offset & 0xff);
        if(idx >= EXPO_SWITCH1 && idx <= EXPO_SCALE1) {
            if(mp->cur_mixer != &mp->mixer[1]) {
                sync_mixers();
                mp->cur_mixer = &mp->mixer[1];
                GUI_Redraw(&gui->graph);
            }
        } else if(idx >= EXPO_SWITCH2 && idx <= EXPO_SCALE2) {
            if(mp->cur_mixer != &mp->mixer[2]) {
                sync_mixers();
                mp->cur_mixer = &mp->mixer[2];
                GUI_Redraw(&gui->graph);
            }
        } else {
            if(mp->cur_mixer != &mp->mixer[0]) {
                mp->cur_mixer = &mp->mixer[0];
                GUI_Redraw(&gui->graph);
            }
        }
    }
Ejemplo n.º 2
0
static void calibrate_touch(void)
{
    if (cp->state == 0 || cp->state == 3) {
        if (GUI_ObjectNeedsRedraw((guiObject_t *)&guic->msg))
            return;
        draw_target(cp->state ? LCD_WIDTH - XCOORD : XCOORD , cp->state ? LCD_HEIGHT - YCOORD : YCOORD + 32);
        cp->state++;
    } else if (cp->state == 1 || cp->state == 4) {
        if (SPITouch_IRQ()) {
            cp->coords = SPITouch_GetCoords();
            cp->state++;
        }
    } else if (cp->state == 2) {
        if (! SPITouch_IRQ()) {
            cp->coords1 = cp->coords;
            GUI_RemoveObj((guiObject_t *)&guic->msg);
            GUI_CreateLabelBox(&guic->msg, LCD_WIDTH - XCOORD - 5, LCD_HEIGHT - YCOORD - 5,
                                            11, 11, &SMALLBOX_FONT, NULL, NULL, "");
            GUI_Redraw(&guic->msg1);
            cp->state = 3;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if (cp->state == 5) {
        if (! SPITouch_IRQ()) {
            s32 xscale, yscale;
            s32 xoff, yoff;
            printf("T1:(%d, %d)\n", cp->coords1.x, cp->coords1.y);
            printf("T2:(%d, %d)\n", cp->coords.x, cp->coords.y);
            xscale = cp->coords.x - cp->coords1.x;
            xscale = (LCD_WIDTH - 2 * XCOORD) * 0x10000 / xscale;
            yscale = cp->coords.y - cp->coords1.y;
            yscale = (LCD_HEIGHT - 32 - 2 * YCOORD) * 0x10000 / yscale;
            xoff = XCOORD - cp->coords1.x * xscale / 0x10000;
            yoff = YCOORD + 32 - cp->coords1.y * yscale / 0x10000;
            printf("Debug: scale(%d, %d) offset(%d, %d)\n", (int)xscale, (int)yscale, (int)xoff, (int)yoff);
            SPITouch_Calibrate(xscale, yscale, xoff, yoff);
            PAGE_RemoveAllObjects();
            PAGE_SetModal(1);
            PAGE_ShowHeader_ExitOnly(_tr("Touch Test"), okcancel_cb);
            GUI_CreateLabelBox(&guic->msg, (LCD_WIDTH - 150) / 2, (LCD_HEIGHT - 25) / 2, 150, 25, &SMALLBOX_FONT, coords_cb, NULL, NULL);
            memset(&cp->coords, 0, sizeof(cp->coords));
            cp->state = 6;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if(cp->state == 6) {
        struct touch t;
        if (SPITouch_IRQ()) {
            t = SPITouch_GetCoords();
            if (memcmp(&t, &cp->coords, sizeof(t)) != 0) {
                cp->coords = t;
                GUI_Redraw(&guic->msg);
            }
        }
    }
}
Ejemplo n.º 3
0
void PAGE_DrExpCurvesEvent()
{
    if (OBJ_IS_USED(&gui->graph)) {
        if(MIXER_GetCachedInputs(mp->raw, CHAN_MAX_VALUE / 100)) { // +/-1%
            GUI_Redraw(&gui->graph[0]);
            GUI_Redraw(&gui->graph[1]);
            GUI_Redraw(&gui->graph[2]);
        }
    }
}
Ejemplo n.º 4
0
void rtc_set_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    if ((long)data == TIMEBUTTON) {
        RTC_SetTime(Rtc.value[HOUR], Rtc.value[MINUTE], Rtc.value[SECOND]);
        GUI_Redraw(&gui->acttime);
    } else if ((long)data == DATEBUTTON) {
        RTC_SetDate(Rtc.value[YEAR], Rtc.value[MONTH], Rtc.value[DAY]);
        GUI_Redraw(&gui->actdate);
    }
}
Ejemplo n.º 5
0
void PAGE_RTCEvent()
{
    static u32 lastrtcvalue = 0;
    u32 actualrtcvalue = RTC_GetValue();
    if (lastrtcvalue != actualrtcvalue) {
        GUI_Redraw(&gui->secondvalue);
        GUI_Redraw(&gui->minutevalue);
        GUI_Redraw(&gui->hourvalue);
        lastrtcvalue = actualrtcvalue;
    }
}
Ejemplo n.º 6
0
static void _check_voltage(guiLabel_t *obj)
{
    if (CLOCK_getms() > next_scan)  {  // don't need to check battery too frequently, to avoid blink of the battery label
        next_scan = CLOCK_getms() + BATTERY_SCAN_MSEC;
        s16 batt = PWR_ReadVoltage();
        if (batt < Transmitter.batt_alarm) {
            obj->desc.style = LABEL_INVERTED;
            GUI_Redraw(obj);
        }
        if (batt / 10 != mp->battery / 10 && batt / 10 != mp->battery / 10 + 1) {
            mp->battery = batt;
            GUI_Redraw(obj);
        }
    }
}
Ejemplo n.º 7
0
static unsigned _action_cb_calibrate(u32 button, unsigned flags, void *data)
{
    (void)data;
    u8 i;
    if (flags & BUTTON_PRESS)
        return 1;
    if (flags & BUTTON_RELEASE) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            // bug fix: when most users see the "Calibration done", it is very likely tha they will press ext to exit,
            // then all calibration data are rollback, and cause the calibration failed -- what a tough bug!!
            if (calibrate_state == CALI_SUCCESS)
                calibrate_state = CALI_SUCCESSEXIT;
            else
                calibrate_state = CALI_EXIT;
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
            switch (calibrate_state){
            case CALI_CENTER:
                for (i = 0; i < INP_HAS_CALIBRATION; i++) {
                    s32 value = CHAN_ReadRawInput(i + 1);
                    Transmitter.calibration[i].max = 0x0000;
                    Transmitter.calibration[i].min = 0xFFFF;
                    Transmitter.calibration[i].zero = value;
                }
                snprintf(tempstring, sizeof(tempstring), "%s", _tr("Move sticks and knobs\nto max & min positions\nthen press ENT"));
                GUI_Redraw(&guic->msg);
                calibrate_state = CALI_MAXMIN;
                break;
            case CALI_MAXMIN:
                for (i = 0; i < INP_HAS_CALIBRATION; i++) {
                    printf("Input %d: Max: %d Min: %d Zero: %d\n", i+1, Transmitter.calibration[i].max, Transmitter.calibration[i].min, Transmitter.calibration[i].zero);
                }
                GUI_DrawBackground(0, 0, LCD_WIDTH, LCD_HEIGHT);
                snprintf(tempstring, sizeof(tempstring), "%s", _tr("Calibration done.\n \nPress ENT."));
                GUI_Redraw(&guic->msg);
                calibrate_state = CALI_SUCCESS;
                break;
            case CALI_SUCCESS:
                calibrate_state = CALI_SUCCESSEXIT;
                break;
            default: break;
            }
        }else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Ejemplo n.º 8
0
static void configure_bind_button()
{
    guiObject_t *obj = _get_obj(ITEM_PROTO, 1);
    if(obj)
        GUI_Redraw(obj);
    //GUI_SetHidden(mp->obj, PROTOCOL_AutoBindEnabled());
}
Ejemplo n.º 9
0
void PAGE_ShowSafetyDialog()
{
    if (disable_safety) {
        return; // don't show safety dialog when calibrating
    }
    if (dialog) {
        u64 unsafe = PROTOCOL_CheckSafe();
        if (! unsafe) {
            GUI_RemoveObj(dialog);
            dialog = NULL;
            PROTOCOL_Init(0);
        } else {
            safety_string_cb(NULL, NULL);
            u32 crc = Crc(tempstring, strlen(tempstring));
            if (crc != dialogcrc) {
                GUI_Redraw(dialog);
                dialogcrc = crc;
            }
        }
    } else {
        tempstring[0] = 0;
        dialogcrc = 0;
        dialog = GUI_CreateDialog(&gui->dialog, 10 + DLG_XOFFSET, 42 + DLG_YOFFSET, 300, 188, _tr("Safety"), safety_string_cb, safety_ok_cb, dtOk, NULL);
    }
}
Ejemplo n.º 10
0
static void reset_press_cb(struct guiObject *obj, const void *data)
{
    (void)obj;
    (void)data;
    DATALOG_Reset();
    GUI_Redraw(&gui->remaining);
}
Ejemplo n.º 11
0
void PAGE_TelemtestEvent() {
    if (current_page == telemetry_off)
        return;
    static u32 count;
    int flicker = ((++count & 3) == 0);
    struct Telemetry cur_telem = Telemetry;
    int current_row = GUI_ScrollableCurrentRow(&gui->scrollable);
    int visible_rows = GUI_ScrollableVisibleRows(&gui->scrollable);
    const struct telem_layout *ptr = _get_telem_layout2()->layout;
    for (long i = 0; ptr->source; ptr++, i++) {
        if ((ptr->row_type & 0x0f) < current_row)
            continue;
        if ((ptr->row_type & 0x0f) >= current_row + visible_rows)
            break;
        if (!( ptr->row_type & 0x80))
            continue;
        long cur_val = _TELEMETRY_GetValue(&cur_telem, ptr->source);
        long last_val = _TELEMETRY_GetValue(&tp->telem, ptr->source);
        struct LabelDesc *font;
        font = &TELEM_FONT;
        if((TELEMETRY_HasAlarm(ptr->source) && flicker) || ! TELEMETRY_IsUpdated(ptr->source)) {
            font = &TELEM_ERR_FONT;
        } else if (cur_val != last_val) {
            GUI_Redraw(&gui->box[i]);
        }
        GUI_SetLabelDesc(&gui->box[i], font);
    }
    tp->telem = cur_telem;
}
Ejemplo n.º 12
0
static void update_countdown(u8 idx)
{
    u8 hide = Model.timer[idx].type == TIMER_STOPWATCH
              || Model.timer[idx].type == TIMER_STOPWATCH_PROP
              || Model.timer[idx].type == TIMER_PERMANENT;
    GUI_SetHidden((guiObject_t *)&gui->start, hide);
    GUI_SetHidden((guiObject_t *)&gui->startlbl, hide);
    GUI_SetSelectable((guiObject_t *)&gui->start, !hide);

    // Permanent timer do not have reset command
    hide = Model.timer[idx].type == TIMER_PERMANENT
           || Model.mixer_mode == MIXER_STANDARD ;
    GUI_SetHidden((guiObject_t *)&gui->resetsrc, hide);
    GUI_SetSelectable((guiObject_t *)&gui->resetsrc, !hide);
    GUI_SetHidden((guiObject_t *)&gui->resetlbl, hide);

    hide = Model.timer[idx].type == TIMER_STOPWATCH
           || Model.timer[idx].type == TIMER_STOPWATCH_PROP
           || Model.timer[idx].type == TIMER_COUNTDOWN
           || Model.timer[idx].type == TIMER_COUNTDOWN_PROP;
    GUI_SetHidden((guiObject_t *)&gui->resetperm, hide);
    GUI_SetSelectable((guiObject_t *)&gui->resetperm, !hide);
    GUI_SetHidden((guiObject_t *)&gui->resetpermlbl, hide);
// don't include this in Devo7e due to memory restrictions
#if HAS_PERMANENT_TIMER
    GUI_SetHidden((guiObject_t *)&gui->setperm, hide);
    GUI_SetSelectable((guiObject_t *)&gui->setperm, !hide);
#endif

    GUI_Redraw(&gui->switchlbl);
}
Ejemplo n.º 13
0
static const char *gyro_output_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    (void)data;
    u8 changed = 1;
    gyro_output = GUI_TextSelectHelper(gyro_output, GYROOUTPUT_GEAR , GYROOUTPUT_AUX2, dir, 2, 2, &changed);
    if (changed) {  // switch gyro output between the gear and the aux2
        // firstly: dynamically create mixes for target gyro channel
        int i;
        for (i = 0; i < GYROMIXER_COUNT; i ++) {
            if(! mp->mixer_ptr[i])
                break;
            mp->mixer[i] = *mp->mixer_ptr[i];
            mp->mixer[i].dest = gyro_output;
        }
        MIXER_SetTemplate(gyro_output, MIXERTEMPLATE_EXPO_DR);
        // secondly: clear mix for original gyro channel
        MIXER_SetTemplate(gyro_output == GYROOUTPUT_GEAR ? GYROOUTPUT_AUX2 : GYROOUTPUT_GEAR, MIXERTEMPLATE_NONE);
        // save mixers
        MIXER_SetMixers(mp->mixer, i);
        // reload mixers because order may change
        int count = STDMIX_GetMixers(mp->mixer_ptr, gyro_output, GYROMIXER_COUNT);
        convert_output_to_percentile();
        for (i = 0; i < count; i ++) {
            GUI_Redraw(&gui->gyro[i]);
        }
    }
    if (gyro_output == GYROOUTPUT_GEAR)
        snprintf(tempstring, sizeof(tempstring), "%s/%s5", _tr("GEAR"), _tr("Ch"));
    else
        snprintf(tempstring, sizeof(tempstring), "%s/%s7", _tr("AUX2"), _tr("Ch"));
    return tempstring;
}
Ejemplo n.º 14
0
static void update_countdown(u8 timernum)
{
    
    int cur_row = GUI_ScrollableCurrentRow(&gui->scrollable);

    int idx = timernum - cur_row * TIMERCOLUMNS;
    if (idx < 0 || idx >= TIMERS_PER_PAGE)
        return;
    u8 hide = Model.timer[timernum].type == TIMER_STOPWATCH
              || Model.timer[timernum].type == TIMER_STOPWATCH_PROP
              || Model.timer[timernum].type == TIMER_PERMANENT;
    GUI_SetHidden((guiObject_t *)&gui->start[idx], hide);
    GUI_SetHidden((guiObject_t *)&gui->startlbl[idx], hide);
    GUI_SetSelectable((guiObject_t *)&gui->start[idx], !hide);

    // Permanent timer  OR Standard Mixer do not have reset command
    hide = Model.timer[timernum].type == TIMER_PERMANENT || Model.mixer_mode == MIXER_STANDARD ;
    GUI_SetHidden((guiObject_t *)&gui->resetsrc[idx], hide);
    GUI_SetSelectable((guiObject_t *)&gui->resetsrc[idx], !hide);
    GUI_SetHidden((guiObject_t *)&gui->resetlbl[idx], hide);

    hide = Model.timer[timernum].type == TIMER_STOPWATCH
           || Model.timer[timernum].type == TIMER_COUNTDOWN
           || Model.timer[timernum].type == TIMER_STOPWATCH_PROP
           || Model.timer[timernum].type == TIMER_COUNTDOWN_PROP;
    GUI_SetHidden((guiObject_t *)&gui->resetperm[idx], hide);
    GUI_SetSelectable((guiObject_t *)&gui->resetperm[idx], !hide);
    GUI_SetHidden((guiObject_t *)&gui->setperm[idx], hide);
    GUI_SetSelectable((guiObject_t *)&gui->setperm[idx], !hide);
    GUI_SetHidden((guiObject_t *)&gui->resetpermlbl[idx], hide);

    GUI_Redraw(&gui->switchlbl[idx]);
}
Ejemplo n.º 15
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;

    if(! GUI_GetSelected() || lp->selected_for_move < 0 || GUI_IsModal())
        return 0;
    if(CHAN_ButtonIsPressed(button, BUT_EXIT)) {
        gui->elem[lp->selected_for_move].desc.font_color ^= 0xffff;
        gui->elem[lp->selected_for_move].desc.fill_color ^= 0xffff;
        GUI_Redraw((guiObject_t *)&gui->elem[lp->selected_for_move]);
        set_selected_for_move(-1);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        show_config();
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_UP)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_DOWN)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    return 0;
}
Ejemplo n.º 16
0
void PAGE_TelemtestEvent() {
    if (current_page == telemetry_off)
        return;
    struct Telemetry cur_telem = Telemetry;
    int current_row = GUI_ScrollableCurrentRow(&gui->scrollable);
    int visible_rows = GUI_ScrollableVisibleRows(&gui->scrollable);
    const struct telem_layout *ptr = TELEMETRY_Type() == TELEM_DEVO
                                     ? devo_page[current_page].layout
                                     : dsm_page[current_page].layout;
    for (long i = 0; ptr->source; ptr++, i++) {
        if ((ptr->row_type & 0x0f) < current_row)
            continue;
        if ((ptr->row_type & 0x0f) >= current_row + visible_rows)
            break;
        if (!( ptr->row_type & 0x80))
            continue;
        long cur_val = _TELEMETRY_GetValue(&cur_telem, ptr->source);
        long last_val = _TELEMETRY_GetValue(&tp->telem, ptr->source);
        struct LabelDesc *font;
        font = &TELEM_FONT;
        if (cur_val != last_val) {
            GUI_Redraw(&gui->box[i]);
        } else if(! TELEMETRY_IsUpdated(ptr->source)) {
            font = &TELEM_ERR_FONT;
        }
        GUI_SetLabelDesc(&gui->box[i], font);
    }
    tp->telem = cur_telem;
}
Ejemplo n.º 17
0
void sourceselect_cb(guiObject_t *obj, void *data)
{
    u8 *source = (u8 *)data;
    if (MIXER_SRC(*source)) {
        MIXER_SET_SRC_INV(*source, ! MIXER_SRC_IS_INV(*source));
        GUI_Redraw(obj);
        MIXPAGE_RedrawGraphs();
    }
}
Ejemplo n.º 18
0
void toggle_source_cb(guiObject_t *obj, void *data)
{
    u8 idx = (long)data;
    struct Timer *timer = &Model.timer[idx];
    if(MIXER_SRC(timer->src)) {
        MIXER_SET_SRC_INV(timer->src, ! MIXER_SRC_IS_INV(timer->src));
        TIMER_Reset(idx);
        GUI_Redraw(obj);
    }
}
Ejemplo n.º 19
0
void PAGE_DatalogEvent()
{
    if((u16)(CLOCK_getms() / 1000) > next_update) {
        u32 left = DATALOG_Remaining();
        if(remaining != left) {
            remaining = left;
            next_update = (u16)(CLOCK_getms() / 1000) + 5;
            GUI_Redraw(&gui->remaining);
        }
    }
}
Ejemplo n.º 20
0
static void GatherTrainingData()
{


        // Extract training data from the results
        ModelExtractTrainingData();

        // Redraw the image
        GUI_Redraw();

}
Ejemplo n.º 21
0
static const char *protoselect_cb(guiObject_t *obj, int dir, void *data)
{
    (void)data;
    (void)obj;
    u8 changed;
    enum Protocols new_protocol;
    new_protocol = GUI_TextSelectHelper(Model.protocol, PROTOCOL_NONE, PROTOCOL_COUNT-1, dir, 1, 1, &changed);
    if (changed) {
        const u8 *oldmap = ProtocolChannelMap[Model.protocol];
    	// DeInit() the old protocol (Model.protocol unchanged)
        PROTOCOL_DeInit();
        // Load() the new protocol
        Model.protocol = new_protocol;
        PROTOCOL_Load(1);
        TELEMETRY_SetTypeByProtocol(Model.protocol);
        Model.num_channels = PROTOCOL_DefaultNumChannels();
        if (! PROTOCOL_HasPowerAmp(Model.protocol))
            Model.tx_power = TXPOWER_150mW;
        else
            Model.tx_power = mp->last_txpower;
        memset(Model.proto_opts, 0, sizeof(Model.proto_opts));
        guiObject_t *obj = _get_obj(ITEM_NUMCHAN, 0);
        if (obj)
            GUI_Redraw(obj);
        obj = _get_obj(ITEM_TXPOWER, 0);
        if (obj)
            GUI_Redraw(obj);
        if (Model.mixer_mode == MIXER_STANDARD)
            STDMIXER_SetChannelOrderByProtocol();
        else
            RemapChannelsForProtocol(oldmap);
        configure_bind_button();
    }
    GUI_TextSelectEnablePress((guiTextSelect_t *)obj, PROTOCOL_GetOptions() ? 1 : 0);
    if (Model.protocol == 0)
        return _tr("None");
    if(PROTOCOL_HasModule(Model.protocol))
        return ProtocolNames[Model.protocol];
    sprintf(tempstring, "*%s", ProtocolNames[Model.protocol]);
    return tempstring;
}
Ejemplo n.º 22
0
void PAGE_ChantestEvent()
{
    int i;
    if(cp->type == MONITOR_BUTTONTEST) {
        _handle_button_test();
        return;
    }
    volatile s16 *raw = MIXER_GetInputs();
    for(i = 0; i < cp->num_bars; i++) {
        int j = _get_input_idx(i);
        int v = RANGE_TO_PCT(cp->type ? raw[j+1] : Channels[j]);
        if (v != cp->pctvalue[i]) {
            guiObject_t *obj = _get_obj(i, ITEM_GRAPH);
            if (obj) {
                GUI_Redraw(obj);
                GUI_Redraw(_get_obj(i, ITEM_VALUE));
            }
            cp->pctvalue[i] = v;
        }
    }
}
Ejemplo n.º 23
0
static void select_for_move(guiLabel_t *obj)
{
    GUI_SetSelected((guiObject_t *)obj);
    notify_cb((guiObject_t *)obj);
    int idx = guielem_idx((guiObject_t *)obj);
    if (lp->selected_for_move == idx)
        return;
    if (lp->selected_for_move >= 0) {
        GUI_Redraw((guiObject_t *)&gui->elem[lp->selected_for_move]);
    }
    set_selected_for_move(idx);
}
Ejemplo n.º 24
0
void PAGE_ChantestEvent()
{
    if(cp->type == MONITOR_BUTTONTEST) {
        _handle_button_test();
        return;
    }
    volatile s32 *raw = MIXER_GetInputs();
    for(int i = 0; i < cp->num_bars; i++) {
        int ch = get_channel_idx(cur_row * NUM_BARS_PER_ROW + i);
        int v = RANGE_TO_PCT((ch >= NUM_INPUTS && ch < NUM_INPUTS + NUM_OUT_CHANNELS)
                             ? Channels[ch - NUM_INPUTS]
                             : raw[ch + 1]);
        if (v != cp->pctvalue[i]) {
            guiObject_t *obj = _get_obj(i, ITEM_VALUE);
            if (obj) {
                GUI_Redraw(obj);
                GUI_Redraw(_get_obj(i, ITEM_GRAPH));
            }
            cp->pctvalue[i] = v;
        }
    }
}
Ejemplo n.º 25
0
void PAGE_ShowBindingDialog(u8 update)
{
    if (update && ! dialog)
        return;
    binding_string_cb(NULL, NULL);
    u32 crc = Crc(tempstring, strlen(tempstring));
    if (dialog && crc != dialogcrc) {
        GUI_Redraw(dialog);
    } else if(! dialog) {
        dialog = GUI_CreateDialog(&gui->dialog, DIALOG2_X, DIALOG2_Y,
                     DIALOG2_WIDTH, DIALOG2_HEIGHT, NULL, NULL, binding_ok_cb, dtOk, tempstring);
    }
    dialogcrc = crc;
}
Ejemplo n.º 26
0
void PAGE_ShowBindingDialog(u8 update)
{
    if (update && ! dialog)
        return;
    binding_string_cb(NULL, NULL);
    u32 crc = Crc(tempstring, strlen(tempstring));
    if (dialog && crc != dialogcrc) {
        GUI_Redraw(dialog);
    } else if(! dialog) {
        const char *title = Model.name[0] ? Model.name : _tr("Binding");
        dialog = GUI_CreateDialog(&gui->dialog, 10 + DLG_XOFFSET, 42 + DLG_YOFFSET, 300, 188, title, binding_string_cb, binding_ok_cb, dtOk, NULL);
    }
    dialogcrc = crc;
}
Ejemplo n.º 27
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            BUTTON_UnregisterCallback(&action);
            PAGE_RemoveAllObjects();
            rl.return_page(NULL);
        } else if (CHAN_ButtonIsPressed(button, BUT_LEFT) && ((guiObject_t *)&gui->value == GUI_GetSelected())) {
            // catch the left/right keys when r1.textsel is selected
            copy_val_cb(NULL, 1, NULL);
            GUI_Redraw(&gui->value);

        } else if (CHAN_ButtonIsPressed(button, BUT_RIGHT)&& ((guiObject_t *)&gui->value == GUI_GetSelected())) {
            copy_val_cb(NULL, -1, NULL);
            GUI_Redraw(&gui->value);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Ejemplo n.º 28
0
void select_for_move(guiLabel_t *obj)
{
    GUI_SetSelected((guiObject_t *)obj);
    notify_cb((guiObject_t *)obj);
    int idx = guielem_idx((guiObject_t *)obj);
    if (lp->selected_for_move == idx)
        return;
    if (lp->selected_for_move >= 0) {
        gui->elem[lp->selected_for_move].desc.font_color ^= 0xffff;
        gui->elem[lp->selected_for_move].desc.fill_color ^= 0xffff;
        GUI_Redraw((guiObject_t *)&gui->elem[lp->selected_for_move]);
    }
    set_selected_for_move(idx);
    gui->elem[lp->selected_for_move].desc.font_color ^= 0xffff;
    gui->elem[lp->selected_for_move].desc.fill_color ^= 0xffff;
}
Ejemplo n.º 29
0
static void TryAlgorithms()
{
    // Generate the data
    ModelPrepareData();

    // Run the reference algorithm
    ModelRunReferenceAlgo();

    // Run the simple algorithm
    ModelRunSimpleAlgo();

    // Run the Neural Network
    ModelRunAnn();

    // Redraw
    GUI_Redraw();
}
Ejemplo n.º 30
0
void PAGE_ShowSafetyDialog()
{
    if (dialog) {
        u64 unsafe = safety_check();
        if (! unsafe) {
            DialogClose(dialog, 0);
            safety_confirmed();
        } else {
            safety_string_cb(NULL, NULL);
            u32 crc = Crc(tempstring, strlen(tempstring));
            if (crc != dialogcrc) {
                GUI_Redraw(dialog);
                dialogcrc = crc;
            }
        }
    } else {
        tempstring[0] = 0;
        dialogcrc = 0;
        dialog = GUI_CreateDialog(&gui->dialog, DIALOG1_X, DIALOG1_Y,
                 DIALOG1_WIDTH, DIALOG1_HEIGHT, NULL, safety_string_cb, safety_ok_cb, dtOk, NULL);
    }
}