Code for the car to drive in a figure eight motion

Dependencies:   mbed-rtos mbed MODSERIAL mbed-dsp telemetry

Files at this revision

API Documentation at this revision

Comitter:
cheryl_he
Date:
Fri Mar 20 09:49:57 2015 +0000
Parent:
20:53f5e6d3e47b
Commit message:
telemetry stuff is compiling, needs to be debugged

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Mar 20 08:58:27 2015 +0000
+++ b/main.cpp	Fri Mar 20 09:49:57 2015 +0000
@@ -1,11 +1,14 @@
 #include "mbed.h"
 #include "rtos.h"
+#include "MODSERIAL.h"
 #include "telemetry.h"
+#include "telemetry-mbed.h"
 
 // Camera Pins
-DigitalOut clk(PTD5);
+DigitalOut clk(PTA13);
 DigitalOut si(PTD4);
 AnalogIn camData(PTC2);
+
 //Servo, Motor, Serial Pins
 PwmOut servo(PTA5);
 PwmOut motor1(PTA4);
@@ -13,6 +16,16 @@
 DigitalOut break1(PTC12);
 DigitalOut break2(PTC13);
 Serial pc(USBTX, USBRX);
+
+//Telemetry
+MODSERIAL telemetry_serial(PTA2, PTA1);
+telemetry::MbedHal telemetry_hal(telemetry_serial);
+telemetry::Telemetry telemetry_obj(telemetry_hal);
+telemetry::Numeric<uint32_t> tele_time_ms(telemetry_obj, "time", "Time", "ms", 0);
+telemetry::NumericArray<uint16_t, 128> tele_linescan(telemetry_obj, "linescan", "Linescan", "ADC", 0);
+telemetry::Numeric<float> tele_motor_pwm(telemetry_obj, "motor1", "Motor PWM", "%DC", 0);
+
+
 // Interrupt for encoder
 InterruptIn interrupt(PTA13);
 const int maxFrames = 3;
@@ -30,6 +43,8 @@
 
 
 void linecam_thread(void const *args){
+    tele_motor_pwm.set_limits(0, 1);
+    telemetry_obj.transmit_header();
     while(1){
         //line_mutex.lock();
         pc.printf("[");
@@ -121,8 +136,12 @@
                     
             }
             else if (integrationCounter > 129){
-                
-                
+               //uint16_t * data = camData.read_u16();
+               for (uint16_t i =0; i < 128; i++) {
+                   tele_linescan[i] = camData.read_u16();
+               }
+                telemetry_obj.do_io(); 
+                motor1.write(tele_motor_pwm);
                 integrationCounter = 150;
             }
             else{