E=MC / Mbed 2 deprecated figure_eight

Dependencies:   mbed-rtos mbed MODSERIAL mbed-dsp telemetry

Files at this revision

API Documentation at this revision

Comitter:
ericoneill
Date:
Fri Mar 20 04:04:04 2015 +0000
Parent:
12:45e6cb021301
Child:
14:09d61b20b102
Child:
16:fa13ac00f583
Commit message:
bugs squashed

Changed in this revision

encoder.cpp Show annotated file Show diff for this revision Revisions of this file
encoder.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
telemetry-master.lib Show diff for this revision Revisions of this file
--- a/encoder.cpp	Fri Mar 20 03:34:38 2015 +0000
+++ b/encoder.cpp	Fri Mar 20 04:04:04 2015 +0000
@@ -12,8 +12,10 @@
 const float TUNE_AMT = 0.1f;
 
 
-Encoder::Encoder(){
+Encoder::Encoder(Timer t1){
     
+    //set timer
+    t = t1;
     //Initialize Intervals used during encoder data collection to measure velocity
     interval1=0;
     interval2=0;
@@ -73,7 +75,7 @@
     return avg_avg_speed/num_samples;
 }
 
-void Encoder::velocity_control(float duty_cyc, float tuning_const) {
+float Encoder::velocity_control(float duty_cyc, float tuning_const) {
     
     avg_speed = get_avg_speed(num_samples_small, delay_small);
     
@@ -90,10 +92,8 @@
         tuning_val = 1;
         stall_check = avg_speed;
     }
-    motor.pulsewidth(.0025 * duty_cyc * tuning_val);
+    return .0025 * duty_cyc * tuning_val;
     
-    pc.printf("speed: %f\n\rtuning val: %f\n\r", avg_speed, tuning_val);
-    wait(.2);
 }
 void Encoder::fallInterrupt(){
     
--- a/encoder.h	Fri Mar 20 03:34:38 2015 +0000
+++ b/encoder.h	Fri Mar 20 04:04:04 2015 +0000
@@ -1,7 +1,12 @@
 #ifndef ENCODER_H
 #define ENCODER_H
 
+#include "mbed.h"
+
+
 class Encoder{
+    Timer t;
+    
     //Intervals used during encoder data collection to measure velocity
     int interval1;
     int interval2;
@@ -31,8 +36,8 @@
     float large_avg_speed_list [100];
     float small_avg_speed_list [10];
 public:
-    Encoder();
-    void velocity_control(float duty_cyc, float tuning_const);
+    Encoder(Timer t);
+    float velocity_control(float duty_cyc, float tuning_const);
     void fallInterrupt();
     void riseInterrupt();
 private:
--- a/main.cpp	Fri Mar 20 03:34:38 2015 +0000
+++ b/main.cpp	Fri Mar 20 04:04:04 2015 +0000
@@ -1,5 +1,4 @@
 #include "mbed.h"
-#include "telemetry.h"
 #include "rtos.h"
 
 // Camera Pins
@@ -20,14 +19,23 @@
 Mutex line_mutex;
 
 void linecam_thread(void const *args){
-    while
-    line_mutex.lock();
+    while(1){
+        line_mutex.lock();
+        pc.printf("[");
+        for(int i=0; i<128; i++){
+            pc.printf("%f",line[i]);
+            pc.printf(" ");
+        }
+        pc.printf("]");
+    }
     
 }
 
 
 int main() {
     Thread thread(linecam_thread);
+    thread.set_priority(osPriorityIdle);
+    //thread.set_priority(-3);
     
     while(1) {
         
--- a/telemetry-master.lib	Fri Mar 20 03:34:38 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/EMC/code/telemetry-master/#9541d7e0c80d