RFID_Tag read_rfid(){ int bits[RFID_BIT_COUNT] = {0, 0, 0}, read_bit = 0; enable_rfid(); THREAD_MSleep(100); while(1) { for(int i = 0; i < 4; i++){ THREAD_MSleep(50); read_bit = DIGITALIO_Read(9); if(read_bit != bits[0]){ bits[0] = read_bit; } THREAD_MSleep(50); read_bit = DIGITALIO_Read(10); if(read_bit != bits[1]){ bits[1] = read_bit; } THREAD_MSleep(50); read_bit = DIGITALIO_Read(11); if(read_bit != bits[2]){ bits[2] = read_bit; } } if (bits[0] != 0 || bits[1] != 0 || bits[2] != 0) break; } THREAD_MSleep(200); disable_rfid(); return RFID_Tag(bits); }
int read_bumpers(){ if(DIGITALIO_Read(BMP_FRONT)) return BMP_FRONT; else if(DIGITALIO_Read(BMP_REAR)) return BMP_REAR; else if(DIGITALIO_Read(BMP_LEFT)) return BMP_LEFT; else if(DIGITALIO_Read(BMP_RIGHT)) return BMP_RIGHT; else return 0; }
int read_quiz_buttons(){ if(DIGITALIO_Read(QUIZ_BUTTON_1)) return QUIZ_BUTTON_1; else if(DIGITALIO_Read(QUIZ_BUTTON_2)) return QUIZ_BUTTON_2; else if(DIGITALIO_Read(QUIZ_BUTTON_3)) return QUIZ_BUTTON_3; else if(DIGITALIO_Read(QUIZ_BUTTON_4)) return QUIZ_BUTTON_4; else return 0; }
void mainCapteur() { while (1) { lireCapteurLigne(); capt_bumper = DIGITALIO_Read(12); couleur = lireCouleur(); capt_boutonEssai = lireBoutonPhysiqueEssai(); THREAD_MSleep(20); } }
void testCouleur() { //TODO: un 'if' qui prend la couleur avec le i2c ou analogue dependant du robot //le robot 43 a une pin entre le digital 9 et le Vcc bool estRobot43 = (DIGITALIO_Read(9) == 1); //initialiser le capteur cest important quand on s'appelle robot 43 if(estRobot43) initCapteurI2C(); //ofstream fichier; //fichier.open("couleur.txt"); while(1) { RgbColor readColor; //step 1 if(estRobot43) readColor = getColorI2C(); else readColor = getColorAnalog(); LCD_ClearAndPrint("\nR=%i, G=%i, B=%i", readColor.r, readColor.g, readColor.b); //fichier << "background-color: rgb(" <<readColor.r<<","<<readColor.g<<","<<readColor.b<<")"<< endl; //step 2 HsbColor colorsHSB = RGBtoHSB(readColor); LCD_Printf("\nH=%.4f, S=%.4f, B=%.4f ", colorsHSB.hue, colorsHSB.saturation, colorsHSB.brightness); int laCouleur = currentFloorColor(colorsHSB,estRobot43); LCD_Printf("\n"); switch(laCouleur){ case 0: LCD_Printf("BLANC");break; case 1: LCD_Printf("BLEU");break; case 2: LCD_Printf("ROUGE");break; case 3: LCD_Printf("VERT");break; case 4: LCD_Printf("JAUNE");break; case 5: LCD_Printf("WTF");break; case 6: LCD_Printf("Noir");break; default: LCD_Printf("default");break; } //LCD_Printf("%s",laCouleur.c_str()); /*if(estRobot43) laCouleur = currentFloorColor(colorsHSB);*/ //else //laCouleur = currentFloorColorAnalog(colorsHSB); //LCD_Printf("%s",laCouleur.c_str()); } }