Exemple #1
0
static int open(struct widget *w)
{
    struct widget_priv *priv;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    priv->direction = 0;
    priv->speed = 0;
    priv->speed_z = 0;
    
    w->ca.width = X_SIZE;
    w->ca.height = Y_SIZE;

    add_mavlink_callback(MAVLINK_MSG_ID_WIND, mav_callback_wind, CALLBACK_WIDGET, w);
    add_mavlink_callback(MAVLINK_MSG_ID_VFR_HUD, mav_callback_vfr_hud, CALLBACK_WIDGET, w);
    return 0;
}
Exemple #2
0
static int open(struct widget *w)
{
    struct widget_priv *priv;
    unsigned char i;
    const struct font *f = get_font(0);

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    /* set initial values */
    priv->total_ch = 16;
    for (i = 0; i < priv->total_ch; i++)
        priv->ch_raw[i] = 1500;

    /* setup canvas according to widget mode */
    switch (w->cfg->props.mode) {
        case 0:
        default:
            /* raw numbers and bars */
            priv->bar_size = 25;
            w->ca.width = 84;
            w->cfg->props.mode = 0;
            break;
        case 1:
            /* only numbers */
            w->ca.width = 58;
            break;
        case 2:
            /* only bars */
            priv->bar_size = 50;
            w->ca.width = 80;
            break;
    }
    w->ca.height = f->size * priv->total_ch + 2;
    priv->cbk1 = add_mavlink_callback(MAVLINK_MSG_ID_RC_CHANNELS_RAW, mav_callback, CALLBACK_WIDGET, w);
    priv->cbk2 = add_mavlink_callback(MAVLINK_MSG_ID_RC_CHANNELS, mav_callback, CALLBACK_WIDGET, w);
    return 0;
}
Exemple #3
0
static int init(struct widget *w)
{
    struct widget_priv *priv;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    priv->range = 20*5;

    w->cfg->w = X_SIZE;
    w->cfg->h = Y_SIZE;
    add_mavlink_callback(MAVLINK_MSG_ID_VFR_HUD, mav_callback, CALLBACK_WIDGET, w);
    return 0;
}
Exemple #4
0
static int init(struct widget *w)
{
    struct widget_priv *priv;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;


    switch (w->cfg->props.mode) {
        default:
        case 0:
            add_mavlink_callback(MAVLINK_MSG_ID_SYS_STATUS, mav_callback, CALLBACK_WIDGET, w);
            w->cfg->w = X_SIZE;
            w->cfg->h = Y_SIZE;
            break;
        case 1:
            /* adc ch 0 */
            adc_start(1);
            adc_link_ch(0, &priv->adc_raw);
            w->cfg->w = X_SIZE;
            w->cfg->h = 15;
            add_timer(TIMER_WIDGET, 2, timer_callback, w);
            break;
        case 2:
            /* adc ch 1 */
            adc_start(1);
            adc_link_ch(1, &priv->adc_raw);
            w->cfg->w = X_SIZE;
            w->cfg->h = 15;
            add_timer(TIMER_WIDGET, 2, timer_callback, w);
            break;
        case 3:
            /* adc ch 0,1 */
            adc_start(1);
            adc_link_ch(0, &priv->adc_raw);
            adc_link_ch(1, &priv->adc_raw2);
            w->cfg->w = X_SIZE;
            w->cfg->h = 30;
            add_timer(TIMER_WIDGET, 2, timer_callback, w);
            break;
    }

    return 0;
}
Exemple #5
0
void tabs_init(void)
{
    static struct mavlink_callback *mav_cbk = NULL;
    static struct timer *tab_timer = NULL;
    unsigned char msgid;
    void *cbk;

    params_add(params_tabs);

    /* build tab list from config */
    build_tab_list();

    switch (config.tab_change.mode) {
        case TAB_CHANGE_CHANNEL:
        case TAB_CHANGE_TOGGLE:
        default:
            msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW;
            cbk = tab_switch_channel_cbk;
            val = 0;
            break;
        case TAB_CHANGE_FLIGHTMODE:
            msgid = MAVLINK_MSG_ID_HEARTBEAT;
            cbk = tab_switch_flightmode_cbk;
            tmr = TAB_TIMER_IDLE;
        case TAB_CHANGE_DEMO:
            cbk = NULL;
            tmr = 0;
            break;
    }

    /* track required mavlink data */
    if (cbk != NULL) {
        if (mav_cbk == NULL) {
            mav_cbk = add_mavlink_callback(msgid, cbk,
                        CALLBACK_PERSISTENT, &config.tab_change);
        } else {
            mav_cbk->msgid = msgid;
            mav_cbk->cbk = cbk;
        }
    }
    
    /* tab switching task (100ms) */
    if (tab_timer == NULL)
        tab_timer = add_timer(TIMER_ALWAYS, 1, tab_switch_task,
                                &config.tab_change);
}
Exemple #6
0
static int open(struct widget *w)
{
    struct widget_priv *priv;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    priv->roll = 0;
    priv->pitch = 0;
    priv->cos_roll = cos(0);
    priv->sin_roll = sin(0);
    
    add_mavlink_callback(MAVLINK_MSG_ID_ATTITUDE, mav_callback, CALLBACK_WIDGET, w);
    w->ca.width = X_SIZE;
    w->ca.height = Y_SIZE;
    return 0;
}
Exemple #7
0
static int open(struct widget *w)
{
    struct widget_priv *priv;
    unsigned char m = w->cfg->props.mode;
    const struct font *f;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    if (m > 2)
        m = 2;

    priv->font_id = m;
    f = get_font(m);
    w->ca.height = (f->height * 2) + 1;
    w->ca.width = (f->width + f->spacing) * 20;
    add_mavlink_callback(MAVLINK_MSG_ID_GPS_RAW_INT, mav_callback, CALLBACK_WIDGET, w);
    return 0;
}
Exemple #8
0
static int init(struct widget *w)
{
    struct widget_priv *priv;
    unsigned int i;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    /* set initial values */
    for (i = 0; i < 8; i++)
        priv->ch_raw[i] = 1500;

    /* setup canvas according to widget mode */
    switch (w->cfg->props.mode) {
        case 0:
        default:
            /* raw numbers and bars */
            priv->bar_size = 25;
            w->cfg->w = 84;
            w->cfg->props.mode = 0;
            break;
        case 1:
            /* only numbers */
            w->cfg->w = 58;
            break;
        case 2:
            /* only bars */
            priv->bar_size = 50;
            w->cfg->w = 80;
            break;
    }
    w->cfg->h = 64;
    add_mavlink_callback(MAVLINK_MSG_ID_RC_CHANNELS_RAW, mav_callback, CALLBACK_WIDGET, w);
    return 0;
}
Exemple #9
0
static int open(struct widget *w)
{
    struct widget_priv *priv;
    unsigned char m = w->cfg->props.mode;
    const struct font *f;

    priv = (struct widget_priv*) widget_malloc(sizeof(struct widget_priv));
    if (priv == NULL)
        return -1;
    w->priv = priv;

    if (m > 2)
        m = 2;

    priv->font_size = m;

    f = get_font(m);
    w->ca.height = f->size + 2;
    w->ca.width = f->size * 12;

    priv->prev_custom_mode = 0xff;
    add_mavlink_callback(MAVLINK_MSG_ID_HEARTBEAT, mav_callback, CALLBACK_WIDGET, w);
    return 0;
}