Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- FatCookies
- Date:
- 2016-11-02
- Revision:
- 3:564463c06ffa
- Parent:
- 1:a4883d9c75ec
- Child:
- 4:968036e0940b
File content as of revision 3:564463c06ffa:
#include "mbed.h"
#include "TFC.h"
#define CAM_THRESHOLD 128
DigitalOut myled(LED1);
Serial pc(USBTX,USBRX);
char curr_line[128];
uint8_t curr_left;
uint8_t curr_right;
uint8_t right;
uint8_t left;
uint8_t measured_value;
int main() {
TFC_Init();
pc.baud(57600);
uint32_t i = 0;
while(1) {
//If we have an image ready
if(TFC_LineScanImageReady>0) {
left = 0;
right = 0;
for(i = 63; i > 0; i--) {
curr_left = (int8_t)(TFC_LineScanImage0[i] >> 4) & 0xFF;
if(curr_left < CAM_THRESHOLD) {
left = i;
break;
}
}
for(i = 64; i < 128; i++) {
curr_right = (int8_t)(TFC_LineScanImage0[i] >> 4) & 0xFF;
if(curr_right < CAM_THRESHOLD) {
right = i;
break;
}
}
pc.putc('H');
for(i = 0; i < 128; i++) {
pc.putc((int8_t)(TFC_LineScanImage0[i] >> 4) & 0xFF);
}
measured_value = (64 - ((left+right)/2))/64.f;
//Reset image ready flag
TFC_LineScanImageReady=0;
wait(0.05);
}
}
}