Esempio n. 1
0
int8_t cmd_head(uint8_t argc, char **argv)
{
    int16_t heading;
    int8_t rc = NRK_OK, rc_node = NRK_OK;
#if ENABLE_COMPASS_RPC
    node_id_t node;
    uint8_t i;
#endif

    if (!(argc == 1 || argc >= 2)) {
        OUT("usage: head [<node>...]\r\n");
        return NRK_ERROR;
    }

    if (have_compass) {
        rc_node = get_heading(&heading);
        if (rc_node != NRK_OK)
            rc = rc_node;
    }

    OUT("node: heading [x y z] (uT)\r\n");

    if (have_compass) {
        OUTP("%d: ", this_node_id);
        show_heading(rc == NRK_OK ? &heading : NULL);
    }

    if (argc >= 2) {
#if ENABLE_COMPASS_RPC
        for (i = 1; i < argc; ++i) {
            node = atoi(argv[i]);

            rc_node = rpc_heading(node, &heading);
            if (rc_node != NRK_OK)
                rc = rc_node;

            OUTP("%d: ", node);
            show_heading(rc == NRK_OK ? &heading : NULL);
        }
#else
        OUT("ERROR: COMPASS_RPC not linked in\r\n");
        return NRK_ERROR;
#endif
    }
    return rc;
}
Esempio n. 2
0
void cockpit_init()
{
	initscr();			/* Start curses mode 		*/
	cbreak();

	if(has_colors() == FALSE)
		{	endwin();
			printf("Your terminal does not support color\n");
			exit(1);
		}
	start_color();			// Start color
	init_pair(1, COLOR_BLUE, COLOR_BLACK);
	init_pair(2, COLOR_RED, COLOR_BLACK);
	init_pair(3, COLOR_RED, COLOR_WHITE);
	init_pair(4, COLOR_BLACK, COLOR_RED);

	//check if the screen is big enough
	if((LINES < MIN_ROW)| (COLS < MIN_COL)){
        endwin();
        printf("your screen is too small %d x %d ,please resize it !\n",LINES,COLS);
        exit(1);
    }

	//generate separating line
	attron(COLOR_PAIR(1));
	mvhline(COCKPIT_HEIGHT+1,0,'=',COLS);
	attroff(COLOR_PAIR(1));
	refresh();

	roll=newwin(ROLL_HEIGHT,ROLL_WIDTH, ROLL_Y,ROLL_X);
	show_roll(roll,0);
	pitch=newwin(PITCH_HEIGHT,PITCH_WIDTH, PITCH_Y,PITCH_X);
	show_pitch(pitch,0);
	yaw=newwin(YAW_HEIGHT,YAW_WIDTH, YAW_Y,YAW_X);
    show_yaw(yaw,0);
	heading=newwin(HEAD_HEIGHT,HEAD_WIDTH,HEAD_Y,HEAD_X);
    show_heading(heading,0);

    other=newwin(OTHER_HEIGHT,OTHER_WIDTH,OTHER_Y,OTHER_X);

	console=create_newwin(CONSOLE_HEIGHT,COLS, COCKPIT_HEIGHT+2,0);

    keypad(console,TRUE);
	scrollok(console,TRUE);
	printx(console,"please enter the COM name,enter 'y' to use default /dev/ttyUSB0:");
    wrefresh(console);
}
Esempio n. 3
0
static void periodic_heading_process(bool enabled,
    nrk_time_t *next_event, nrk_sig_mask_t *wait_mask)
{
    int16_t heading;
    int8_t rc;
    nrk_time_t now;

    if (!enabled)
        return;

    rc = get_heading(&heading);
    OUT("heading: ");
    show_heading(rc == NRK_OK ? &heading : NULL);

    nrk_time_get(&now);
    nrk_time_add(next_event, now, heading_period);
}
Esempio n. 4
0
void cockpit_display(flying_status_s *flying_status)
{
    show_roll(roll,flying_status->roll*180/PI);
    show_pitch(pitch,flying_status->pitch*180/PI);
    show_yaw(yaw,flying_status->yaw*180/PI);
    show_heading(heading,flying_status->heading/100000);
    //wclear(other);
    //wmove(other,0,0);
    mvwprintw(other,0,0,"Height_Baro:%7.3fm   Height_GPS :%7.3fm\n",(float)(flying_status->b_h)/100,flying_status->g_h);
    mvwprintw(other,1,0,"Sonar      :%7.3fcm  Next_Destin:%5d\n",(float)(flying_status->sonar_h)/58,flying_status->waypoint_dest);
    mvwprintw(other,2,0,"Volt_Batter:%7.3fV   Temp_CPU   :%4dC\n",flying_status->voltage,flying_status->cpu_temp);
    mvwprintw(other,3,0,"Longitude:%12.8f  Latitude:%12.8f\n",flying_status->Long,flying_status->lat);

    switch(flying_status->status)
    {
    case AIRCRAFT_PREPARING:
    	mvwprintw(other,4,0,"Plane_Stat :Preparing %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_READY:
    	mvwprintw(other,4,0,"Plane_Stat :Ready to go %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_TAKEOFF:
    	mvwprintw(other,4,0,"Plane_Stat :takeoff %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_LANDING:
    	mvwprintw(other,4,0,"Plane_Stat :landing %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_FLYING:
    	mvwprintw(other,4,0,"Plane_Stat :flying %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_TASK:
    	mvwprintw(other,4,0,"Plane_Stat :task %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_REMOTE1:
    	mvwprintw(other,4,0,"Plane_Stat :Remote1 %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_REMOTE2:
    	mvwprintw(other,4,0,"Plane_Stat :Remote2 %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_HOVERING:
    	mvwprintw(other,4,0,"Plane_Stat :%8x Hovering\n",flying_status->status);
    	break;
    case AIRCRAFT_RETURN:
    	mvwprintw(other,4,0,"Plane_Stat :Return %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_OBS_AVOIDING:
    	mvwprintw(other,4,0,"Plane_Stat :Obstacle avoidance %5x \n",flying_status->status);
    	break;
    case AIRCRAFT_MANUAL_MODE:
    	mvwprintw(other,4,0,"Plane_Stat :Manual %5x\n",flying_status->status);
    	break;
    case AIRCRAFT_FAULT:
    	mvwprintw(other,4,0,"Plane_Stat :Fault %5x\n",flying_status->status);
    	break;
    default:
    	break;
    }
    mvwprintw(other,5,0,"CPU_Status :%4d\n",flying_status->cpu_s);
    wrefresh(other);

}