car using PID from centre line
Dependencies: FRDM-TFC mbed CBuffer XBEE mbed_angular_speed motor2 MMA8451Q
Fork of KL25Z_Camera_Test by
Diff: main.cpp
- Revision:
- 0:566127ca8048
- Child:
- 1:a4883d9c75ec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 14 10:56:56 2016 +0000 @@ -0,0 +1,68 @@ +#include "mbed.h" +#include "TFC.h" +#define CAM_THRESHOLD 3000 + + +DigitalOut myled(LED1); + +int main() { + TFC_Init(); + + uint32_t i,t = 0; + //uint32_t width = 0; + char curr_line[129]; + + /* Ensure string is null terminated */ + curr_line[128] = 0; + + + printf("Starting camera test program\n"); + + while(1) { + //If we have an image ready + if(TFC_LineScanImageReady>0) + { + //Reset image ready flag + TFC_LineScanImageReady=0; + printf("\r\n"); + //printf("L:"); + + //Strange thing that cycles the battery indicator + //Leaving in as this is a good indicator that the camera test program is running + if(t==4) + t=0; + else + t++; + TFC_SetBatteryLED_Level(t); + + for(i = 0; i < 128; i++) { + curr_line[i] = (int8_t)(TFC_LineScanImage0[i] >> 4) & 0xFF; + printf("%02x", curr_line[i]); + } + printf("\n"); + //printf("0x%x\n", curr_line); + /* + //Loop through camera pixels + for(i=0;i<128;i++) + { + //If the pixel value exceeds our threshold, print a 1 + if (TFC_LineScanImage0[i] > CAM_THRESHOLD) + { + curr_line[i] = '1'; + width++; //Increment the width value + } + //Else, print a 0 + else + { + curr_line[i] = '0'; + } + } + printf("%s\n",curr_line); + + printf("Width: %d\n", width); + width = 0; + */ + + } + } +} \ No newline at end of file