示例#1
0
文件: speed.c 项目: ArduPilot/alceosd
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;

    /* modes
       0) gauge
       1) text */
    switch (w->cfg->props.mode) {
        case 0:
        default:
            priv->range = 20*5;
            w->ca.width = X_SIZE;
            w->ca.height = Y_SIZE;
            break;
        case 1:
            w->ca.width = X_SIZE_TEXT;
            w->ca.height = 20;
            break;
    }

    add_timer(TIMER_WIDGET, 250, render_timer, w);
    return 0;
}
示例#2
0
文件: gps.c 项目: ljalves/alceosd-1
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->size + 2) * 2;
    w->ca.width = f->size * 13;
    
    if (w->cfg->props.source == 0)
        add_mavlink_callback(MAVLINK_MSG_ID_GPS_RAW_INT, mav_callback, CALLBACK_WIDGET, w);
    else
        add_mavlink_callback(MAVLINK_MSG_ID_GPS2_RAW, mav_callback2, CALLBACK_WIDGET, w);
    return 0;
}
示例#3
0
文件: radar.c 项目: ljalves/alceosd
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->home = get_home_data();
    priv->stats = get_flight_stats();

    if (w->cfg->props.mode & 1) {
        w->ca.width = 84*2;
        w->ca.height = 84*2;
    } else {
        w->ca.width = 84;
        w->ca.height = 84;
    }

    add_mavlink_callback(MAVLINK_MSG_ID_VFR_HUD, mav_callback, CALLBACK_WIDGET, w);
    add_mavlink_callback(MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, mav_callback_nav, CALLBACK_WIDGET, w);
    add_mavlink_callback(MAVLINK_MSG_ID_MISSION_CURRENT, mav_callback_wp_seq, CALLBACK_WIDGET, w);

    /* refresh rate of 0.2 sec */
    add_timer(TIMER_WIDGET, 2, timer_callback, w);
    return 0;
}
示例#4
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->home = get_home_data();

    switch (get_units(w->cfg)) {
        case UNITS_METRIC:
        default:
            priv->range = 20*5;
            break;
        case UNITS_IMPERIAL:
            priv->range = 100*5;
            break;
    }

    add_mavlink_callback(MAVLINK_MSG_ID_GPS_RAW_INT, mav_callback, CALLBACK_WIDGET, w);
    w->ca.width = X_SIZE;
    w->ca.height = Y_SIZE;
    return 0;
}
示例#5
0
文件: tabs.c 项目: 381426068/alceosd
static struct widget* load_widget(struct widget_config *w_cfg)
{
    const struct widget_ops *w_ops;
    struct widget *w;
    
    w_ops = get_widget_ops(w_cfg->widget_id);
    if (w_ops == NULL)
        return NULL;

    w = (struct widget*) widget_malloc(sizeof(struct widget));
    if (w == NULL) {
        DTABS("load_tab: no mem for widget %d exiting load tabs\n", w_cfg->widget_id);
        return NULL;
    }
    w->ops = w_ops;
    w->cfg = w_cfg;
    w->status = 0;
    if (w_ops->open(w))
        return NULL;

    alloc_canvas(&w->ca, w->cfg);
    schedule_widget(w);

    return w;
}
示例#6
0
文件: speed.c 项目: Elios007/alceosd
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;
}
示例#7
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;
}
示例#8
0
文件: ils.c 项目: ArduPilot/alceosd
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;

        
    w->ca.width = X_SIZE;
    w->ca.height = Y_SIZE;
    
    
    
    add_timer(TIMER_WIDGET, 50, pre_render, w);
    return 0;
}
示例#9
0
文件: horizon.c 项目: ljalves/alceosd
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;
}
示例#10
0
static int open(struct widget *w)
{
    struct widget_priv *priv;
    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;

    if (mavdata_age(MAVLINK_MSG_ID_RC_CHANNELS) < 5000) {
        mavlink_rc_channels_t *rc = mavdata_get(MAVLINK_MSG_ID_RC_CHANNELS);
        priv->total_ch = rc->chancount;
        priv->ch = &rc->chan1_raw;
    } else {
        mavlink_rc_channels_raw_t *rc_raw = mavdata_get(MAVLINK_MSG_ID_RC_CHANNELS_RAW);
        priv->total_ch = 8;
        priv->ch = &rc_raw->chan1_raw;
    }
    
    /* 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;
    add_timer(TIMER_WIDGET, 250, pre_render, w);
    return 0;
}
示例#11
0
文件: wind.c 项目: ljalves/alceosd
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;
}
示例#12
0
文件: gps.c 项目: 381426068/alceosd
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;
}
示例#13
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;
}
示例#14
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;
}
示例#15
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;
}