Beispiel #1
0
void tabs_init(void)
{
    /* add mavlink parameters */
    params_add(params_tabs);
    /* build tab list from config */
    build_tab_list();
    /* 5 seconds on tab 0 */
    load_tab(0);
    add_timer(TIMER_ONCE, 5000, start_tab_switch_task, &config.tab_sw);
}
Beispiel #2
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);
}
Beispiel #3
0
int main(void) {
    extern int __C30_UART; __C30_UART = 2;
    unsigned char i;
    unsigned char in_config = 0;
    char c;

    /* generic hw init */
    hw_init();
    
    /* real time clock init */
    clock_init();

    /* adc init */
    adc_init();

    /* init uart2 */
    uart_init2(UART_PORT_TELEMETRY);

    /* init video driver */
    init_video();

    /* try to load config from flash */
    load_config();

    /* video driver config */
    video_apply_config(&config.video);

    /* init widgets */
    widgets_init();

    /* enable all interrupts */
    SRbits.IPL = 0;
    CORCONbits.IPL3 = 1;

    /* TODO: rework config entry */
    /* check for config entry */
    for (i = 0; i < 8; i++) {
        while (uart_getc2(&c) == 0) {
            widgets_process();
            render_process();
            ClrWdt();
        }
        if (c != '!')
            break;
    }

    if (i == 8) {
        in_config = 1;
        while (in_config) {
            in_config = config_osd();
            widgets_process();
            render_process();
            ClrWdt();
        }
    }

    /* re-build tab list */
    build_tab_list();

    uart_set_baudrate2(config.baudrate);

    init_home_process();
    init_flight_stats_process();

    for (;;) {
        mavlink_process();
        widgets_process();
        render_process();
        clock_process();
        ClrWdt();
    }

    return 0;
}