SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: Hardwares/ArduCAM.cpp
- Branch:
- Drift
- Revision:
- 79:bdbac82c979b
- Parent:
- 73:1dcf56e9f1d4
- Child:
- 80:c85cb93713b3
--- a/Hardwares/ArduCAM.cpp Mon Apr 17 16:02:48 2017 +0000 +++ b/Hardwares/ArduCAM.cpp Tue Apr 18 17:43:12 2017 +0000 @@ -33,6 +33,7 @@ static uint8_t black_calibrate = 70; static volatile uint8_t centerLine[CAM_ROI_UPPER_LIMIT * 2]; static volatile uint8_t is_encounter_terminate = 0; +static volatile uint8_t is_border_find = BOTH_NOT_FOUND; //static Thread * m_imgProcessThread = NULL; //static Ticker m_tickerImgProc; @@ -373,6 +374,7 @@ while (!(ardu_cam_spi_read_8(ARDUCHIP_TRIG) & CAP_DONE_MASK)); temp_mid_pos = RESOLUTION_WIDTH / 2; + is_border_find = BOTH_NOT_FOUND; #ifdef CAM_BLK_CAL_ACTIVE static float calTemp = 0.0f; calTemp = 0.0f; @@ -437,6 +439,50 @@ centerLine[CAM_ROI_UPPER_LIMIT - i - 1] = temp_mid_pos; centerLine[(2 * CAM_ROI_UPPER_LIMIT) - i - 1] = isBorderFound; + switch(is_border_find) + { + case BOTH_NOT_FOUND: + switch(isBorderFound) + { + case LEFT_FOUND: + is_border_find = LEFT_FOUND; + break; + case RIGHT_FOUND: + is_border_find = RIGHT_FOUND; + break; + case BOTH_FOUND: + is_border_find = BOTH_FOUND; + break; + default: + break; + } + break; + case LEFT_FOUND: + switch(isBorderFound) + { + case RIGHT_FOUND: + case BOTH_FOUND: + is_border_find = BOTH_FOUND; + break; + default: + break; + } + break; + case RIGHT_FOUND: + switch(isBorderFound) + { + case LEFT_FOUND: + case BOTH_FOUND: + is_border_find = BOTH_FOUND; + break; + default: + break; + } + break; + case BOTH_FOUND: + default: + break; + } } @@ -472,6 +518,11 @@ { return is_encounter_terminate; } + +uint8_t ardu_cam_get_is_border_found() +{ + return is_border_find; +} /* void tick_image_proc() {