Esempio n. 1
0
static void mav_callback(mavlink_message_t *msg, mavlink_status_t *status, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;
    float altitude;
    
    switch (w->cfg->props.mode) {
        case 0:
        default:
            altitude = mavlink_msg_gps_raw_int_get_alt(msg) / 1000.0;
            break;
        case 1:
            if (priv->home->lock == HOME_LOCKED)
                altitude = (long) priv->home->altitude;
            else
                altitude = 0;
            break;
    }

    if (get_units(w->cfg) == UNITS_IMPERIAL)
        altitude *= M2FEET;
    
    priv->altitude = (long) altitude;
    schedule_widget(w);
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
static void timer_callback(struct timer *t, void *d)
{
    struct widget *w = (struct widget*) d;
    struct widget_priv *priv = (struct widget_priv*) w->priv;

    priv->bat_voltage = *(priv->adc_raw) * 18.3 / (1 << 10);
    priv->bat_voltage2 = *(priv->adc_raw2) * 18.3 / (1 << 10);
    schedule_widget(w);
}
Esempio n. 4
0
static void mav_callback_wind(mavlink_message_t *msg, mavlink_status_t *status, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;
    priv->direction = mavlink_msg_wind_get_direction(msg);
    priv->speed = mavlink_msg_wind_get_speed(msg);
    priv->speed_z = mavlink_msg_wind_get_speed_z(msg);
    schedule_widget(w);
}
Esempio n. 5
0
static void mav_callback(mavlink_message_t *msg, mavlink_status_t *status, void *data)
{
    struct widget *w = (struct widget*) data;
    struct widget_priv *priv = (struct widget_priv*) w->priv;

    priv->speed = mavlink_msg_vfr_hud_get_airspeed(msg) * 3600 / 1000.0;
    priv->speed_i = (int) priv->speed;

    schedule_widget(w);
}
Esempio n. 6
0
static void mav_callback(mavlink_message_t *msg, mavlink_status_t *status, void *data)
{
    struct widget *w = (struct widget*) data;
    struct widget_priv *priv = (struct widget_priv*) w->priv;
    
    priv->bat_voltage = mavlink_msg_sys_status_get_voltage_battery(msg) / 1000.0;
    priv->bat_current = mavlink_msg_sys_status_get_current_battery(msg) / 100.0;
    priv->bat_remaining = (int) mavlink_msg_sys_status_get_battery_remaining(msg);

    schedule_widget(w);
}
Esempio n. 7
0
static void pre_render(struct timer *t, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;
    
    mavlink_attitude_t *att = mavdata_get(MAVLINK_MSG_ID_ATTITUDE);
    mavlink_vfr_hud_t *hud = mavdata_get(MAVLINK_MSG_ID_VFR_HUD);
    
    
    schedule_widget(w);
}
Esempio n. 8
0
static void mav_callback2(mavlink_message_t *msg, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;

    priv->gps_lat = mavlink_msg_gps2_raw_get_lat(msg) / 10000000.0;
    priv->gps_lon = mavlink_msg_gps2_raw_get_lon(msg) / 10000000.0;
    priv->gps_fix_type = mavlink_msg_gps2_raw_get_fix_type(msg);
    priv->gps_nrsats = mavlink_msg_gps2_raw_get_satellites_visible(msg);
    priv->gps_eph = (float) mavlink_msg_gps2_raw_get_eph(msg) / 100.0;

    schedule_widget(w);
}
Esempio n. 9
0
static void mav_callback(mavlink_message_t *msg, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;

    priv->custom_mode = mavlink_msg_heartbeat_get_custom_mode(msg);
    if (priv->custom_mode == priv->prev_custom_mode)
        return;

    priv->mav_type = mavlink_msg_heartbeat_get_type(msg);
    priv->prev_custom_mode = priv->custom_mode;
    schedule_widget(w);
}
Esempio n. 10
0
static void mav_callback(mavlink_message_t *msg, mavlink_status_t *status, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;

    priv->pitch = mavlink_msg_attitude_get_pitch(msg);
    priv->pitch_deg = RAD2DEG(priv->pitch * SCALE);

    priv->roll = mavlink_msg_attitude_get_roll(msg);
    priv->roll_deg  = RAD2DEG(priv->roll);
    priv->cos_roll = cos(priv->roll);
    priv->sin_roll = -1 * sin(priv->roll);

    schedule_widget(w);
}
Esempio n. 11
0
static void mav_callback(mavlink_message_t *msg, mavlink_status_t *status, void *data)
{
    struct widget *w = (struct widget*) data;
    struct widget_priv *priv = (struct widget_priv*) w->priv;

    priv->ch_raw[0] = mavlink_msg_rc_channels_raw_get_chan1_raw(msg);
    priv->ch_raw[1] = mavlink_msg_rc_channels_raw_get_chan2_raw(msg);
    priv->ch_raw[2] = mavlink_msg_rc_channels_raw_get_chan3_raw(msg);
    priv->ch_raw[3] = mavlink_msg_rc_channels_raw_get_chan4_raw(msg);
    priv->ch_raw[4] = mavlink_msg_rc_channels_raw_get_chan5_raw(msg);
    priv->ch_raw[5] = mavlink_msg_rc_channels_raw_get_chan6_raw(msg);
    priv->ch_raw[6] = mavlink_msg_rc_channels_raw_get_chan7_raw(msg);
    priv->ch_raw[7] = mavlink_msg_rc_channels_raw_get_chan8_raw(msg);

    schedule_widget(w);
}
Esempio n. 12
0
static void mav_callback(mavlink_message_t *msg, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;
    unsigned char i;

    if (msg->msgid == MAVLINK_MSG_ID_RC_CHANNELS_RAW) {
        priv->total_ch = 8;
    } else {
        priv->total_ch = mavlink_msg_rc_channels_get_chancount(msg);
    }
    
    for (i = 0; i < priv->total_ch; i++)
        priv->ch_raw[i] = mavlink_msg_rc_channels_raw_get_chan(msg, i);

    schedule_widget(w);
}
Esempio n. 13
0
static void render_timer(struct timer *t, void *d)
{
    struct widget *w = d;
    struct widget_priv *priv = w->priv;
    mavlink_vfr_hud_t *vfr_hud = mavdata_get(MAVLINK_MSG_ID_VFR_HUD);

    /* sources:
       0) airspeed
       1) groundspeed */
    switch (w->cfg->props.source) {
        case 0:
        default:
            priv->speed = vfr_hud->airspeed;
            break;
        case 1:
            priv->speed = vfr_hud->groundspeed;
            break;
    }

    schedule_widget(w);
}
Esempio n. 14
0
static void timer_callback(struct timer *t, void *d)
{
    struct widget *w = (struct widget*) d;
    schedule_widget(w);
}
Esempio n. 15
0
static void render_timer(struct timer *t, void *d)
{
    struct widget *w = d;
    schedule_widget(w);
}