/******************************************************************* * Function: void checkIR(void) * Input Variables: none * Output Return: none * Overview: This function update all of the infrared range * finding sensor values sequentially ********************************************************************/ void checkIR( void ) { // Update all IR values ftIR = getFrontIR(); bkIR = getBackIR(); ltIR = getLeftIR(); rtIR = getRightIR(); }
void getIR() { ft = getFrontIR(); bk = getBackIR(); rt = getRightIR(); lt = getLeftIR(); frontRight = ATTINY_get_IR_state(ATTINY_IR_RIGHT); frontLeft = ATTINY_get_IR_state(ATTINY_IR_LEFT); }
/* * a function that can test that sensor data can be output * to the LCD display in a meaningful manner and the normal * printf still works correctly */ void pixel_sensor_test(void) { while(checkNoBtns()) { TMRSRVC_delay(100); LCD_clear(); float leftIR = getLeftIR(); float rightIR = getRightIR(); float trimLeftIR = trim(2*leftIR, 0, LCD_PIX_WIDTH/2); float trimRightIR = trim(2*rightIR, 0, LCD_PIX_WIDTH/2); for(unsigned char i = 0; i < LCD_PIX_HEIGHT; i++) { LCD_set_pixel(i, LCD_PIX_WIDTH/2, i & 1); LCD_set_pixel(i, LCD_PIX_WIDTH/2 - trimLeftIR, 1); LCD_set_pixel(i, LCD_PIX_WIDTH/2-1 + trimRightIR, 1); } LCD_set_RC( 0, 0 ); LCD_printf("%.1f", (double)leftIR); LCD_set_RC( 0, 16 ); LCD_printf("%.1f", (double)rightIR); } }
bool IR::detectLeft() { //Detects white on the left return getLeftIR()>THRESHOLD; }