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.
Dependencies: mbed MODSERIAL telemetry-master
Revision 5:868e652f26af, committed 2015-05-11
- Comitter:
- ericoneill
- Date:
- Mon May 11 03:40:59 2015 +0000
- Parent:
- 4:8ee76f6d32b5
- Commit message:
- cleaned code a little
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon May 11 02:00:33 2015 +0000
+++ b/main.cpp Mon May 11 03:40:59 2015 +0000
@@ -167,10 +167,7 @@
t.start();
- if(dataCol){
- loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime = 0;
- printTimer.start();
- }
+
//uint16_t* data = camData.read();
while(1) {
if(dataCol){
@@ -180,12 +177,7 @@
}
}
if(integrationCounter % 151== 0){
- /*
- //Disable interrupts
- interrupt.fall(NULL);
- interrupt.rise(NULL);
- */
-
+
//Send start of integration signal
si = 1;
clk = 1;
@@ -208,9 +200,6 @@
//Start Timer
//t.start();
- //Enable interrupts
- //interrupt.fall(&fallInterrupt);
- //interrupt.rise(&riseInterrupt);
tele_time_ms = t.read_ms();
for (uint16_t i=0; i<128; i++) {
tele_linescan[i] = (uint8_t) (ADCdata[i] * 128);
@@ -225,7 +214,6 @@
maxLoc = c;
}
}
-
for (int c = 10; c < 118; c++) {
if (ADCdata[c] <= maxVal && maxVal - ADCdata[c] < maxValThresh){
maxAccum += c;
@@ -267,74 +255,24 @@
}
}
}
- /*
- //Check if we need to alter integration time due to brightness
- if (maxVal < 0.15f){
- intTimMod += 10;
- } else if (maxVal >= 1) {
- if (intTimMod > 0) {
- intTimMod -= 10;
- }
- }
- */
-
//Line Crossing Checks
if (space) {
currDir = prevDir;
firstTime = true;
} else {
- approxPos = (float)maxAccum/(float)maxCount;
-
- if(dataCol){
- if(loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime%3==0){
- lineCenters[loopCtr] = approxPos;
- times[loopCtr] = printTimer.read_ms();
- loopCtr++;
- }
- }
-
+ approxPos = (float)maxAccum/(float)maxCount;
currDir = hardLeft + (approxPos)/((float) 118)*(hardRight-hardLeft);
prevApproxPos = approxPos;
- }
-/*
- if (turnSpeedControl){
- //Change speed when turning at different angles
- if(approxPos > 0 && approxPos <= 45){
- motor1.pulsewidth(motorPeriod*(pulsewidth*2.0f));
- motor2.pulsewidth(motorPeriod*(pulsewidth*2.0f));
- } else if (approxPos > 45 && approxPos <= 55){
- motor1.pulsewidth(motorPeriod*pulsewidth*1.5f);
- motor2.pulsewidth(motorPeriod*pulsewidth*1.5f);
- } else if (approxPos > 55 && approxPos <= 85){
- motor1.pulsewidth(motorPeriod*pulsewidth);
- motor2.pulsewidth(motorPeriod*pulsewidth);
- } else if (approxPos > 85 && approxPos <= 95){
- motor1.pulsewidth(motorPeriod*pulsewidth*1.5f);
- motor2.pulsewidth(motorPeriod*pulsewidth*1.5f);
- } else {
- motor1.pulsewidth(motorPeriod*(pulsewidth*2.0f));
- motor2.pulsewidth(motorPeriod*(pulsewidth*2.0f));
- }
- }
-*/
+ }
servo.pulsewidth(currDir);
- //Start Velocity control after requisite number of encoder signals have been collected
- //if(numInterrupts >= 4){
- //velocity_control(0.1f, TUNING_CONSTANT_10);
- //}
-
//Save current direction as previous direction
prevDir = currDir;
//Prepare to start collecting more data
integrationCounter = 150;
- //Disable interrupts
- //interrupt.fall(NULL);
- //interrupt.rise(NULL);
-
//Stop timer
//t.stop();
}
@@ -345,30 +283,10 @@
clk = 0;
}
- //clk = 0;
- integrationCounter++;
- if(dataCol){
- loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime++;
- }
- //camData.
telemetry_obj.do_io();
}
-/*
- if (dataCol){
- //print frame data
- pc.printf("printing frame data\n\r");
- //int frameSize = frames.size();
- //pc.printf("%i",frameSize);
- pc.printf("[");
- for(int i=0; i<numData; i++){
- if(lineCenters > 0){
- pc.printf("%i %i,",lineCenters[i], times[i]);
- }
- }
- pc.printf("]\n\r");
- }
- */
+
}