void serve_short(short start) { short task = 0; if(task == 0){ #if MOTOR_MODE == MOTOR_SINGLE Move_motor_number(20, RIGHT_ARM1); #elif MOTOR_MODE == MOTOR_DOUBLE Move_motor_number(20, RIGHT_ARM1); Move_motor_number(-20, RIGHT_ARM2); #endif }else if(task == 1){ Set_GPIO_output(AIR1, HIGH); }else if(task == 2){ #if MOTOR_MODE == MOTOR_SINGLE Move_motor_number(-20, RIGHT_ARM1); #elif MOTOR_MODE == MOTOR_DOUBLE Move_motor_number(-20, RIGHT_ARM1); Move_motor_number(20, RIGHT_ARM1); #endif }else if(task ==3){ if(start != ON){ reset_count_time(4); } if(count_time(4) >= SERVE_TIME){ task = 4; } }else if(task == 4){ Set_GPIO_output(AIR1, LOW); task = 0; } }
/* Fill info structure with data from the id3 tag */ static void mp3_info (const char *file_name, struct file_tags *info, const int tags_sel) { if (tags_sel & TAGS_COMMENTS) { struct id3_tag *tag; struct id3_file *id3file; char *track = NULL; id3file = id3_file_open (file_name, ID3_FILE_MODE_READONLY); if (!id3file) return; tag = id3_file_tag (id3file); if (tag) { info->artist = get_tag (tag, ID3_FRAME_ARTIST); info->title = get_tag (tag, ID3_FRAME_TITLE); info->album = get_tag (tag, ID3_FRAME_ALBUM); track = get_tag (tag, ID3_FRAME_TRACK); if (track) { char *end; info->track = strtol (track, &end, 10); if (end == track) info->track = -1; free (track); } } id3_file_close (id3file); } if (tags_sel & TAGS_TIME) info->time = count_time (file_name); }
/* Fill info structure with data from spx comments */ static void spx_info (const char *file_name, struct file_tags *tags, const int tags_sel) { struct io_stream *s; s = io_open (file_name, 0); if (io_ok(s)) { struct spx_data *data = spx_open_internal (s); if (data->ok) { if (tags_sel & TAGS_COMMENTS) get_comments (data, tags); if (tags_sel & TAGS_TIME) tags->time = count_time (data); } spx_close (data); } }
void debug(void) { robot_information_t robot; target_cam_t target_cam; unsigned char str[10] = "\0"; unsigned short old_sw = 0, start_sw =0, old_limit_sw = 0; float target_degree = 0.00; transmit_usb("[ r : reset] \n\r"); transmit_usb("[ 1 : encoder]\n\r"); transmit_usb("[ 2 : AD]\n\r"); transmit_usb("[ 3 : coordinate]\n\r"); transmit_usb("[ 4 : sonic_waves]\n\r"); transmit_usb("[ 5 : encoder reset]\n\r"); transmit_usb("[ 6 : cam_inf]\n\r"); transmit_usb("[ 7 : target_cam]\n\r"); transmit_usb("[ 8 : inf&target]\n\r"); transmit_usb("[ 9 : start_switch]\n\r"); transmit_usb("[10 : limit_switch]\n\r"); transmit_usb("[11 : motor]\n\r"); transmit_usb("[12 : reverse motor]\n\r"); transmit_usb("[13 : stop motor]\n\r"); transmit_usb("[14 : arm motor]\n\r"); transmit_usb("[15 : reverse arm motor]\n\r"); //transmit_usb("[p : p gain adjustment]\n\r"); //transmit_usb("[d : d gain adjustment]\n\r"); GPIO_ResetBits(ENC_RESET); while(strcmp(str, "r") != 0){ if(usb_available() != 0){ usb_get_string(str); } buzzer_stop(); //sonic_waves(&robot); if(count_time(3) >= INTERRUPT_TIME){ reset_count_time(3); get_robot_inf( &robot ); cam_data(&target_cam, &robot); start_sw =positive_chattering(START_SW,1); robot.sw.limit_sw = negative_chattering(LIMIT_SW,2); robot.ad = get_ADC1_value(0); } if(strcmp(str, "1") == 0){ f_print(PC,"ENCL",robot.enc_cnt.l); f_print(PC,"ENCR",robot.enc_cnt.r); f_print(PC,"ENCF",robot.enc_cnt.f); put_enter(PC); }else if(strcmp(str, "2") == 0){ f_print(PC,"AD",robot.ad); put_enter(PC); }else if(strcmp(str, "3") == 0){ f2_print(PC,"now_coord",robot.coord.c_x, robot.coord.c_y); f_print(PC,"deg",robot.angle.degree); put_enter(PC); }else if(strcmp(str, "4") == 0){ f_print(PC,"time",count_time(2)); f_print(PC,"dis",robot.waves); put_enter(PC); }else if(strcmp(str, "5") == 0){ GPIO_SetBits(ENC_RESET); //str[0] = 'r'; }else if(strcmp(str, "6") == 0){ f2_print(PC, "under", target_cam.under_x, target_cam.under_y ); f2_print(PC, "over", target_cam.over_x, target_cam.over_y ); put_enter(PC); }else if(strcmp(str, "7") == 0){ f2_print(PC, "target_cam", (target_cam.x) * cos(D_TO_R(robot.angle.degree))+robot.coord.c_x, (target_cam.y)*sin(D_TO_R(robot.angle.degree))+robot.coord.c_y); put_enter(PC); }else if(strcmp(str, "8") == 0){ f2_print(PC, "under", target_cam.under_x, target_cam.under_y); f2_print(PC, "over", target_cam.over_x, target_cam.over_y ); target_degree = get_target_degree(ROBO_TO_CENTER - robot.coord.c_x, robot.coord.c_y); f2_print(PC, "target_cam", (target_cam.x) * cos(D_TO_R(target_degree)) + robot.coord.c_x, (target_cam.y) * sin(D_TO_R(target_degree)) + robot.coord.c_y); put_enter(PC); }else if(strcmp(str, "9") == 0){ if(robot.sw.start_sw != old_sw ){ f_print(PC,"sw",start_sw); put_enter(PC); } }else if(strcmp(str, "10") == 0){ if(robot.sw.limit_sw != old_limit_sw ){ f_print(PC,"limit_sw",robot.sw.limit_sw); put_enter(PC); } }else if(strcmp(str, "11") == 0){ move(50, 50, 50); }else if(strcmp(str, "12") == 0){ move(-50, -50, -50); }else if(strcmp(str, "13") == 0){ move(0, 0, 0); move_arm(0); }else if(strcmp(str, "14") == 0){ move_arm(100); }else if(strcmp(str, "15") == 0){ move_arm(-100); } old_limit_sw = robot.sw.start_sw; old_sw = start_sw; } }
void Render_Gioco(void){ float tmp; pointer_pos=cursor_position(); glutSetCursor(GLUT_CURSOR_NONE); glDisable(GL_FOG); drawSkybox(); drawGun(); drawBullet(); drawScore(); glPushMatrix(); gluLookAt(0.f,0.f,3.f,0.f,0.f,-5.f,0.f,1.f,0.f); tmp = 0.0536414; glScalef(tmp, tmp, tmp); glTranslated(-xpos,0.0f,0.0f); //SPOSTAMENTO DELLA CAMERA: float xx=9,yy=0,zz=42; glTranslatef(xx,yy,zz); glRotatef(main_camera.getLocRot().y_rot,0.0f,1.0f,0.0f); glTranslatef(-xx,-yy,-zz); //translo la camera (in realta' translo tutto il resto) glTranslatef(main_camera.getLocRot().x, main_camera.getLocRot().y, main_camera.getLocRot().z); //Fog---------------------- glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode GLfloat fogColor[4]= {0.6f, 0.5f, 0.3f, 1.0f}; glFogfv(GL_FOG_COLOR, fogColor); // Set Fog Color glFogf(GL_FOG_DENSITY, 0.45f); // How Dense Will The Fog Be glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value glFogf(GL_FOG_START, 3.5f); // Fog Start Depth glFogf(GL_FOG_END, 6.0f); // Fog End Depth glEnable(GL_FOG); // Enables GL_FOG //------------------------- if(first == TRUE){ scene_list_case=glGenLists(4); scene_list_target=glGenLists(10); lista_case(scene_list_case,level1_scene.scene,level2_scene.scene,level3_scene.scene,terreno_scene.scene); lista_target(scene_list_target,target_scene.scene); pos=scegli_pos(livello,livelli); first = FALSE; } if(m[pos].stato==2){ m[pos]=reset_motion(m[pos]); pos=scegli_pos(livello,livelli); } ch=render_target(livello,scene_list_target,pos,livelli,m[pos],ch,t.v); render_case(livello,scene_list_case); if(!pause)t=count_time(t); m[pos]=scegli_mov(m[pos],livelli,pos,t.tempoi, t.v, ch_index,ch); glPopMatrix(); drawPointer(pointer_pos); if(pause) DrawMenu(0,0,menuArray[5],true); }