LCD::LCD() { txt_lcd = 0; brightness = 255; contrast = 110; backlight = 1; CPhidgetTextLCD_create(&txt_lcd); CPhidget_open((CPhidgetHandle)txt_lcd, -1); //PLEASE COMMENT THIS if(CPhidget_waitForAttachment((CPhidgetHandle)txt_lcd, 1000)) { std::cout << "Error attaching Phidget Text LCD." << std::endl; } CPhidgetTextLCD_setBacklight(txt_lcd, backlight); CPhidgetTextLCD_setContrast(txt_lcd, contrast); CPhidgetTextLCD_setBrightness(txt_lcd, brightness); }
int textlcd_simple() { int result; const char *err; //Declare an TextLCD handle CPhidgetTextLCDHandle txt_lcd = 0; //create the TextLCD object CPhidgetTextLCD_create(&txt_lcd); //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error. CPhidget_set_OnAttach_Handler((CPhidgetHandle)txt_lcd, AttachHandler, NULL); CPhidget_set_OnDetach_Handler((CPhidgetHandle)txt_lcd, DetachHandler, NULL); CPhidget_set_OnError_Handler((CPhidgetHandle)txt_lcd, ErrorHandler, NULL); //open the TextLCD for device connections CPhidget_open((CPhidgetHandle)txt_lcd, -1); //get the program to wait for an TextLCD device to be attached printf("Waiting for TextLCD to be attached....\n"); if((result = CPhidget_waitForAttachment((CPhidgetHandle)txt_lcd, 10000))) { CPhidget_getErrorDescription(result, &err); printf("Problem waiting for attachment: %s\n", err); return 0; } //Display the properties of the attached textlcd device display_properties(txt_lcd); //read TextLCD event data printf("Reading.....\n"); //Begin simulation of capabilities //Step 1: Write a simple message to the first row printf("Writing to first row. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setDisplayString (txt_lcd, 0, "Row 1"); //Step 2: write a simple message to the second row printf("Writing to second row. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setDisplayString (txt_lcd, 1, "Row 2"); //Step 3: turn up, turn down, and set back to default the contrast printf("Adjusting contrast up. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setContrast (txt_lcd, 255); //valid range is 0 - 255, default is 0 normal viewable seems to be around 100 printf("Restoring default contrast. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setContrast (txt_lcd, 110); //Step 4: Turn on the cursor printf("Turn on cursor. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setCursorOn (txt_lcd, 1); //Step 5: turn on the cursor blink printf("Turn on cursor blink. Press any key to continue\n"); getchar(); CPhidgetTextLCD_setCursorOn (txt_lcd, 0); CPhidgetTextLCD_setCursorBlink (txt_lcd, 1); //End simulation printf("Press any key to end\n"); getchar(); CPhidgetTextLCD_setCursorBlink (txt_lcd, 0); CPhidgetTextLCD_setDisplayString (txt_lcd, 0, ""); CPhidgetTextLCD_setDisplayString (txt_lcd, 1, ""); //since user input has been read, this is a signal to terminate the program so we will close the phidget and delete the object we created printf("Closing...\n"); CPhidget_close((CPhidgetHandle)txt_lcd); CPhidget_delete((CPhidgetHandle)txt_lcd); //all done, exit return 0; }
int test_interfacekit() { int i,j,kit,k1,k2,macX,macY,macZ,ierr,result; int speed_percent[2],light_value,GREEN,RED,YELLOW; double accX,accY,accZ,acc_calX,acc_calY,acc_calZ; double tiltX,tiltY,tilt_calX,tilt_calY; double amean[3]; const char *err_str; //creation du handler pour le kit interface 1 puis //ouverture du kit interface printf("Attaching Interface kit 1\n"); if(Create_KIT1()!=1)goto exit; printf("Interface kit is attached\n"); printf("Do you want to attach other kit ?\n"); printf("Kit 2 1\n"); printf("Kit 3 2\n"); printf("Kit LCD 3\n"); printf("All kits 10\n"); scanf("%d",&kit); if(kit==1 ||kit==10) { printf("Attaching Interface kit 2\n"); if(Create_KIT2()!=1)goto exit; printf("Interface kit 2 is attached\n"); } if(kit==2 ||kit==10) { printf("Attaching Interface kit 3\n"); if(Create_KIT3()!=1)goto exit; printf("Interface kit 3 is attached\n"); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_rear_left, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_rear_right, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_front_left, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_front_right, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_side_2, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_side_4, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_side_8, 1); CPhidgetInterfaceKit_setOutputState(IFK3,sensor_side_10, 1); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_rear_left, 1); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_rear_right, 1); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_front_left, 0); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_front_right, 0); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_side_2, 0); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_side_4, 0); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_side_8, 0); CPhidgetInterfaceKit_setSensorChangeTrigger( (CPhidgetInterfaceKitHandle)IFK3, sensor_side_10, 0); } if(kit==3|| kit==10) { printf("Attaching Text LCD \n"); if(Create_Text_LCD()!=1)goto exit; printf("Text LCD attached\n"); printf("Attaching LCD kit\n"); if(Create_KITLCD()!=1)goto exit; printf("LCD kit attached\n"); } //creation du handler pour la carte de controle des embrayages if(embrayage_number!=-1) { CPhidgetMotorControl_create(&EmbrayageControl); CPhidget_open((CPhidgetHandle)EmbrayageControl,embrayage_number); } if(encoder1_number!=-1) { CPhidgetEncoder_create(&ENCODER1); CPhidgetEncoder_set_OnPositionChange_Handler (ENCODER1, ENCODER1_PositionChangeHandler , NULL); CPhidget_open((CPhidgetHandle)ENCODER1,encoder1_number); } if(encoder2_number!=-1) { CPhidgetEncoder_create(&ENCODER2); CPhidgetEncoder_set_OnPositionChange_Handler (ENCODER2, ENCODER2_PositionChangeHandler , NULL); CPhidget_open((CPhidgetHandle)ENCODER2,encoder2_number); } if(motorcontrol_number!=-1) { CPhidgetMotorControl_create(&motorControl); CPhidget_open((CPhidgetHandle)motorControl,motorcontrol_number); } if(ir_receiver1!=-1) { CPhidgetIR_create(&ir1); CPhidget_set_OnAttach_Handler((CPhidgetHandle)ir1, AttachHandlerIR,NULL); CPhidget_set_OnDetach_Handler((CPhidgetHandle)ir1, DetachHandlerIR,NULL); CPhidget_set_OnError_Handler((CPhidgetHandle)ir1, ErrorHandlerIR,NULL); CPhidgetIR_set_OnCode_Handler(ir1, CodeHandler, NULL); CPhidget_open((CPhidgetHandle)ir1, ir_receiver1); printf("Waiting for PhidgetIR to be attached.... \n"); if((result = CPhidget_waitForAttachment((CPhidgetHandle)ir1, 10000))) { CPhidget_getErrorDescription(result, &err_str); printf("Problem waiting for attachment IR1: %s\n", err_str); return 0; } } if(ir_receiver2!=-1) { CPhidgetIR_create(&ir2); CPhidget_set_OnAttach_Handler((CPhidgetHandle)ir2, AttachHandlerIR,NULL); CPhidget_set_OnDetach_Handler((CPhidgetHandle)ir2, DetachHandlerIR,NULL); CPhidget_set_OnError_Handler((CPhidgetHandle)ir2, ErrorHandlerIR,NULL); CPhidgetIR_set_OnCode_Handler(ir2, CodeHandler, NULL); CPhidget_open((CPhidgetHandle)ir2, ir_receiver2); printf("Waiting for PhidgetIR to be attached.... \n"); if((result = CPhidget_waitForAttachment((CPhidgetHandle)ir2, 10000))) { CPhidget_getErrorDescription(result, &err_str); printf("Problem waiting for attachment IR2: %s\n", err_str); return 0; } } if(ir_receiver3!=-1) { CPhidgetIR_create(&ir3); CPhidget_set_OnAttach_Handler((CPhidgetHandle)ir3, AttachHandlerIR,NULL); CPhidget_set_OnDetach_Handler((CPhidgetHandle)ir3, DetachHandlerIR,NULL); CPhidget_set_OnError_Handler((CPhidgetHandle)ir3, ErrorHandlerIR,NULL); CPhidgetIR_set_OnCode_Handler(ir3, CodeHandler, NULL); CPhidget_open((CPhidgetHandle)ir3, ir_receiver3); printf("Waiting for PhidgetIR to be attached.... \n"); if((result = CPhidget_waitForAttachment((CPhidgetHandle)ir3, 10000))) { CPhidget_getErrorDescription(result, &err_str); printf("Problem waiting for attachment IR3: %s\n", err_str); return 0; } } while(1) { printf("exit: 0\n"); printf("Embrayage: 1\n"); printf("Buzzer,stop,inhibit 2\n"); printf("Encoder: 3\n"); printf("Moteur: 4\n"); printf("Capteur distance: 5\n"); printf("Capteur de contact: 6\n"); printf("Capteur de lumiere: 7\n"); printf("Capteur de force poignet:8\n"); printf("Radiocommande: 9\n"); printf("Colonne lumineuse: 10\n"); printf("Joystick: 11\n"); printf("etat batterie,LCD 12\n"); printf("accelerometre 13\n"); printf("recepteur IR 14\n"); scanf("%d",&i); if(i==0)goto exit; //embrayage if(i==1) { j=-1; while(j!=0) { printf("clutch motor 1: 1\n"); printf("clutch motor 2: 2\n"); printf("unclutch motor 1: 3\n"); printf("unclutch motor 2: 4\n"); printf("clutch motor 1 and 2: 5\n"); printf("unclutch motor 1 and 2:6\n"); printf("exit :0\n"); scanf("%d",&j); if(j==0)continue; if(j==1) { printf("%% de clutch entre 0 et 100 \n"); scanf("%d",&k1); CPhidgetMotorControl_setVelocity (EmbrayageControl, 0,k1); } if(j==3) { CPhidgetMotorControl_setVelocity (EmbrayageControl, 0,0); } if(j==2) { printf("%% de clutch entre 0 et 100 \n"); scanf("%d",&k1); CPhidgetMotorControl_setVelocity (EmbrayageControl,1,k1); } if(j==4) { CPhidgetMotorControl_setVelocity (EmbrayageControl, 1,0); } if(j==5) { printf("%% de clutch entre 0 et 100 pour embrayage 1 et 2\n"); scanf("%d",&k1); scanf("%d",&k2); CPhidgetMotorControl_setVelocity (EmbrayageControl,0,k1); CPhidgetMotorControl_setVelocity (EmbrayageControl,0,k2); } if(j==6) { Embraye_Debraye(0); } } } //buzzer, stop, inhibit if(i==2) { j=-1; while(j!=0) { printf("exit :0\n"); printf("run buzzer: 1\n"); printf("stop buzzer: 2\n"); printf("etat bouton stop: 3\n"); printf("etat bouton inhibit: 4\n"); scanf("%d",&j); if(j==0){Mesure_Stop=-1;continue;} if(j==1) CPhidgetInterfaceKit_setOutputState(IFK,buzzer_number, 1); if(j==2) CPhidgetInterfaceKit_setOutputState(IFK,buzzer_number, 0); if(j==3) { CPhidgetInterfaceKit_getInputState(IFK,inhibit2_number,&k1); printf("Bouton stop: %d\n",k1); Mesure_Stop=1; } if(j==4) { CPhidgetInterfaceKit_getInputState(IFK,inhibit1_number,&k1); printf("Bouton inhibit: %d\n",k1); Mesure_Stop=1; } } } //codeur if(i==3) { j=-1; while(j!=0) { printf("exit 0\n"); printf("get encoder 1: 1\n"); printf("get encoder 2: 2\n"); printf("get encoder 1,2: 3\n"); scanf("%d",&j); if(j==0)continue; if(j==1) { wheelPos[0]=8*atan2(1.,1.)*10*encoderPos[0]/ (encoder1_reduction*encoder1_pulse_perturn); printf("position encoder 1: %d roue:%f\n",encoderPos[0], wheelPos[0]); } if(j==2) { wheelPos[1]=8*atan2(1.,1.)*10*encoderPos[1]/ (encoder2_reduction*encoder2_pulse_perturn); printf("position encoder 2: %d roue:%f\n",encoderPos[1], wheelPos[1]); } if(j==3) { wheelPos[0]=8*atan2(1.,1.)*10*encoderPos[0]/ (encoder1_reduction*encoder1_pulse_perturn); wheelPos[1]=8*atan2(1.,1.)*10*encoderPos[1]/ (encoder2_reduction*encoder2_pulse_perturn); printf("position encoder 1: %d roue:%f\n",encoderPos[0], wheelPos[0]); printf("position encoder 2: %d roue:%f\n",encoderPos[1], wheelPos[1]); } } } //moteur if(i==4) { j=-1; while(j!=0) { printf("exit 0\n"); printf("control motor 1: 1\n"); printf("control motor 2: 2\n"); printf("control motor 1,2: 3\n"); scanf("%d",&j); if(j==0)continue; if(j==1) { CPhidgetMotorControl_setAcceleration (motorControl, 0, 50.00); speed_percent[0]=-1; while(speed_percent[0]<0 || speed_percent[0]>100) { printf("vitesse en %%, entier ?\n"); scanf("%d",&speed_percent[0]); if(speed_percent[0]<0 || speed_percent[0]>100) { printf("incorrect speed\n"); continue; } } CPhidgetMotorControl_setVelocity (motorControl, 0, speed_percent[0]); } if(j==2) { CPhidgetMotorControl_setAcceleration (motorControl, 1, 50.00); speed_percent[1]=-1; while(speed_percent[1]<0 || speed_percent[1]>100) { printf("vitesse en %%, entier ?\n"); scanf("%d",&speed_percent[1]); if(speed_percent[1]<0 || speed_percent[1]>100) { printf("incorrect speed\n"); continue; } } CPhidgetMotorControl_setVelocity (motorControl, 1, speed_percent[1]); } if(j==3) { CPhidgetMotorControl_setAcceleration (motorControl, 0, 50.00); CPhidgetMotorControl_setAcceleration (motorControl, 1, 50.00); speed_percent[0]=-1; while(speed_percent[0]<0 || speed_percent[0]>100) { printf("vitesse 1 en %%, entier ?\n"); scanf("%d",&speed_percent[0]); if(speed_percent[0]<0 || speed_percent[0]>100) { printf("incorrect speed\n"); continue; } } speed_percent[1]=-1; while(speed_percent[1]<0 || speed_percent[1]>100) { printf("vitesse 2 en %%, entier ?\n"); scanf("%d",&speed_percent[1]); if(speed_percent[1]<0 || speed_percent[1]>100) { printf("incorrect speed\n"); continue; } } CPhidgetMotorControl_setVelocity (motorControl, 0, speed_percent[0]); CPhidgetMotorControl_setVelocity (motorControl, 1, speed_percent[1]); } } } //capteur de distance if(i==5) { j=-1; while(j!=0) { remesure: for(k1=0;k1<10;k1++) { amin[k1]=10000.; amax[k1]=-10000.; } for(k1=0;k1<2;k1++) { amin_IR[k1]=10000.; amax_IR[k1]=-10000.; } printf("exit 0\n"); printf("IR 1\n"); printf("US 2\n"); printf("Tous 3\n"); printf("duree mesure (defaut:%d s) 4\n",Time_Mesure); printf("IR rear left 10\n"); printf("IR rear right 11\n"); printf("US front right 12\n"); printf("US front left 13\n"); printf("US side right front 14\n"); printf("US side right rear 15\n"); printf("US side left rear 16\n"); printf("US side left front 17\n"); printf("IR up left 20\n"); printf("IR up left 21\n"); scanf("%d",&j); if(j==0){Mesure_Capteur=-1;continue;} if(j==1){Mesure_Capteur=0;sleep(Time_Mesure);Mesure_Capteur=-1;} if(j==2){Mesure_Capteur=1;sleep(Time_Mesure);Mesure_Capteur=-1;} if(j==3){Mesure_Capteur=2;sleep(Time_Mesure);Mesure_Capteur=-1;} if(j>=10){Mesure_Capteur=j;sleep(Time_Mesure);Mesure_Capteur=-1;} if(j==4) { printf("duree entiere de mesure?\n"); scanf("%d",&Time_Mesure); goto remesure; } } } //capteur de contact if(i==6) { j=-1; Kontact1_old=Kontact2_old=-1; CPhidgetInterfaceKit_getInputState(IFK,contact_front_left,&Kontact1); CPhidgetInterfaceKit_getInputState(IFK,contact_front_right,&Kontact2); if(Kontact1!=Kontact1_old||Kontact2!=Kontact2_old) { if(Kontact1==0 && contact_front_left_type==1) printf("contact front, left: NO CONTACT\n"); if(Kontact1==1 && contact_front_left_type==1) printf("contact front, left: CONTACT\n"); if(Kontact1==0 && contact_front_left_type==0) printf("contact front, left: CONTACT\n"); if(Kontact1==1 && contact_front_left_type==0) printf("contact front, left: NO CONTACT\n"); if(Kontact2==0 && contact_front_right_type==1) printf("contact front, right: NO CONTACT\n"); if(Kontact2==1 && contact_front_right_type==1) printf("contact front, right: CONTACT\n"); if(Kontact2==0 && contact_front_right_type==0) printf("contact front, right: CONTACT\n"); if(Kontact2==1 && contact_front_right_type==0) printf("contact front, right: NO CONTACT\n"); Kontact1_old=Kontact1; Kontact2_old=Kontact2; } printf("exit 0\n"); while(j!=0) { scanf("%d",&j); } } //lumiere if(i==7) { j=-1; while(j!=0) { remesure_light: printf("exit 0\n"); printf("mesure 1\n"); printf("duree mesure (defaut:%d s) 2\n",Time_Mesure); scanf("%d",&j); if(j==0){Mesure_Light=-1;continue;} if(j==1) { CPhidgetInterfaceKit_getSensorValue(IFK,light_port, &light_value); printf("light: %d\n",light_value); Mesure_Light=1; sleep(Time_Mesure); Mesure_Light=-1; } if(j==2) { printf("duree entiere de mesure?\n"); scanf("%d",&Time_Mesure); goto remesure_light; } } } //force if(i==8) { j=-1; while(j!=0) { remesure_force: printf("exit 0\n"); printf("mesure 1\n"); printf("duree mesure (defaut:%d s) 2\n",Time_Mesure); scanf("%d",&j); if(j==0){Mesure_Force=-1;continue;} if(j==1) { CPhidgetInterfaceKit_getSensorValue(IFK,forceL, &light_value); printf("force left: %f",light_value*5/1000.); CPhidgetInterfaceKit_getSensorValue(IFK,forceR, &light_value); printf("force right: %f\n",light_value*5/1000.); Mesure_Force=1; sleep(Time_Mesure); Mesure_Force=-1; } if(j==2) { printf("duree entiere de mesure?\n"); scanf("%d",&Time_Mesure); goto remesure_force; } } } //radiocommande if(i==9) { printf("Allumez l'emetteur puis le recepteur\n"); printf("Marche avant,arriere,gauche,droit par manette gauche\n"); printf("Ramasse cle par manette droite\n"); printf("tapez 1 quand pret\n"); scanf("%d",&j); for(k1=1;k1<4;k1++) { FORWARD_RC[k1]=forward_rc[k1]; TURN_RC[k1]=turn_rc[k1]; } while(j!=0) { remesure_radio: printf("exit 0\n"); printf("test commande 1\n"); printf("duree test (defaut:%d s) 2\n",Time_Mesure_Radio); scanf("%d",&j); if(j==0){Mesure_Radio=-1;continue;} if(j==1) { Mesure_Radio=1; sleep(Time_Mesure); Mesure_Radio=-1; } if(j==2) { printf("duree entiere de mesure?\n"); scanf("%d",&Time_Mesure); goto remesure_radio; } } } //colone lumineuse if(i==10) { j=-1; // CPhidgetInterfaceKit_getOutputState(IFK2,port_24V_number,&k1); // printf("output %d:%d\n",port_24V_number,k1); //mise en route du 24V Init_Colonne_24V(); GREEN=colonne_lumineuse[2]; YELLOW=colonne_lumineuse[3]; RED=colonne_lumineuse[4]; /* CPhidgetInterfaceKit_getOutputState(IFK2,port_24V_number,&k1); printf("output %d:%d\n",port_24V_number,k1); while(k1==0) { CPhidgetInterfaceKit_setOutputState(IFK2,port_24V_number,0); sleep(1); CPhidgetInterfaceKit_setOutputState(IFK2,port_24V_number,1); sleep(1); CPhidgetInterfaceKit_getOutputState(IFK2,port_24V_number,&k1); printf("output %d:%d\n",port_24V_number,k1); } */ while(j!=0) { printf("exit 0\n"); printf("allumage vert : 1\n"); printf("extinction vert : 2\n"); printf("allumage jaune : 3\n"); printf("extinction jaune : 4\n"); printf("allumage rouge : 5\n"); printf("extinction rouge : 6\n"); scanf("%d",&j); if(j==0) { CPhidgetInterfaceKit_setOutputState(IFK2,GREEN,0); CPhidgetInterfaceKit_setOutputState(IFK2,RED,0); CPhidgetInterfaceKit_setOutputState(IFK2,YELLOW,0); Stop_Colonne_24V(); continue; } if(j==1)CPhidgetInterfaceKit_setOutputState(IFK2,GREEN,1); if(j==2)CPhidgetInterfaceKit_setOutputState(IFK2,GREEN,0); if(j==3)CPhidgetInterfaceKit_setOutputState(IFK2,YELLOW,1); if(j==4)CPhidgetInterfaceKit_setOutputState(IFK2,YELLOW,0); if(j==5)CPhidgetInterfaceKit_setOutputState(IFK2,RED,1); if(j==6)CPhidgetInterfaceKit_setOutputState(IFK2,RED,0); } } //joystick if(i==11) { j=-1; for(k1=0;k1<3;k1++) { mid_joystick[k1]=(value_joystick[k1][0]+value_joystick[k1][1])/2.; width_joystick[k1]=value_joystick[k1][1]-value_joystick[k1][0]; } while(j!=0) { printf("exit 0\n"); printf("mesure joystick 1\n"); scanf("%d",&j); if(j==0){Mesure_Joystick=-1;continue;} if(j==1){Mesure_Joystick=1;} } } //batterie if(i==12) { j=-1; while(j!=0) { CPhidgetTextLCD_setContrast (txt_lcd, 110); CPhidgetTextLCD_setDisplayString (txt_lcd, 0, "Welcome to ANG"); printf("Le LCD doit afficher le message 'Welcome to ANG'\n"); printf("exit 0\n"); printf("mesure batterie 1\n"); scanf("%d",&j); if(j==0){Mesure_Batterie=-1;continue;} if(j==1) { CPhidgetInterfaceKit_getSensorValue(IFK_LCD,volt_sensor, &light_value); VOLT=light_value*VOLT_PER_UNIT; CPhidgetInterfaceKit_getSensorValue(IFK_LCD,amp_sensor, &light_value); CURRENT=(light_value/13.2)-37.8787; CONSOM_WATT=VOLT*CURRENT; printf("Voltage: %f Current: %f %f Watt\n",VOLT,CURRENT, CONSOM_WATT); clock_gettime(CLOCK_MONOTONIC, &now); temps_batterie=temps1_batterie=now.tv_sec+1.e-9*now.tv_nsec; temps2_batterie=temps_batterie; Mesure_Batterie=1; } } } //accelerometre if(i==13) { j=-1; while(j!=0) { remesure_acc: for(k1=0;k1<3;k1++) { amin_acc[k1]=10000.; amax_acc[k1]=-10000.; } printf("exit 0\n"); printf("mesure individuelle 1\n"); printf("calibration 2\n"); printf("duree mesure (defaut:%d s) 3\n",Time_Mesure); scanf("%d",&j); if(j==0){Mesure_Accelero=-1;continue;} if(j==2) { printf("laissez le deambulateur au repose pour 10s\n"); amean[0]=amean[1]=amean[2]=0; for(k1=0;k1<10;k1++) { CPhidgetInterfaceKit_getSensorValue(IFK,accelero_X, &light_value); amean[0]+=light_value/10.; CPhidgetInterfaceKit_getSensorValue(IFK,accelero_Y, &light_value); amean[1]+=light_value/10.; CPhidgetInterfaceKit_getSensorValue(IFK,accelero_Z, &light_value); amean[2]+=light_value/10.; sleep(1); } printf("Mesure moyenne %f %f %f\n",amean[0],amean[1],amean[2]); goto remesure_acc; } if(j==1) { CPhidgetInterfaceKit_getSensorValue(IFK,accelero_X, &macX); CPhidgetInterfaceKit_getSensorValue(IFK,accelero_Y, &macY); CPhidgetInterfaceKit_getSensorValue(IFK,accelero_Z, &macZ); Get_Acceleration(&accX,&accY,&accZ,&tiltX,&tiltY, &acc_calX,&acc_calY,&acc_calZ,&tilt_calX, &tilt_calY,macX,macY,macZ); printf("Acceleration non calibree: %f %f %f\n",accX,accY,accZ); printf("Tilt x: %f y: %f\n",tiltX,tiltY); if(has_accelero_calibration==1) { printf("Acceleration calibree: %f %f %f\n",acc_calX, acc_calY,acc_calZ); printf("Tilt calibre x: %f y: %f\n",tilt_calX,tilt_calY); } Mesure_Accelero=1;sleep(Time_Mesure);Mesure_Accelero=-1; } if(j==3) { printf("duree entiere de mesure?\n"); scanf("%d",&Time_Mesure); goto remesure_acc; } } } //recepteur IR if(i==14) { if(nb_touche==0) { printf("donnez le nom du fichier touche\n"); scanf("%s",file_touche); j=Read_IR_File(file_touche,CODE_IR,&nb_touche); if(j==-1) { printf("Pas de fichier touche\n"); continue; } if(j==-2) { printf("Erreur lecture fichier touche\n"); continue; } } j=-1; while(j!=0) { printf("exit 0\n"); printf("nouveau fichier touche 1\n"); printf("attente action 2\n"); scanf("%d",&j); if(j==0){Mesure_IRR=-1;continue;} if(j==1) { printf("donnez le nom du fichier touche\n"); scanf("%s",file_touche); ierr=Read_IR_File(file_touche,CODE_IR,&nb_touche); if(ierr==-1) { printf("Pas de fichier touche\n"); continue; } if(ierr==-2) { printf("Erreur lecture fichier touche\n"); continue; } } if(j==2) { Mesure_IRR=1; } } } } exit: CPhidget_close((CPhidgetHandle)IFK); CPhidget_delete((CPhidgetHandle)IFK); return 0; }
void LCD::setContrast(int contrast) { this->contrast = contrast; CPhidgetTextLCD_setContrast(txt_lcd, contrast); }