this version 10/17

Dependencies:   mbed

Fork of linearMirrorMotion by Alvaro Cassinelli

Revision:
19:8e9fe7d25b9c
Parent:
18:6f86abfae754
Child:
20:8475768fc2f7
--- a/main.cpp	Mon May 20 09:31:29 2013 +0000
+++ b/main.cpp	Fri May 24 06:37:58 2013 +0000
@@ -1,13 +1,13 @@
 #include "mbed.h"
+#include <string>
 #include <vector>
 #include "renderclass.h"
 #include "laserProjectorHardware.h"
-#define PI 3.141592
 
 render myRender;
 
-InterruptIn clockEncoderPin(p14);
-DigitalIn directionPin(p15);
+InterruptIn clockEncoderPin(p14);   //blue
+DigitalIn directionPin(p15);    //green
 
 void processSerial();
 Timer timer_v;          // for shearing
@@ -38,12 +38,21 @@
 vector<letter> alphabet;   // letter library
 vector<letter> myText;
 
+/*
+string textString="H";
 
+void createTextPoints(string& _str) {
+    myText.clear();
+    for (int i=0; i<_str.length(); i++) {
+        myText.push_back(alphabet[(int)_str[i]-'a']);
+    }
+}
+*/
 
 ////for culculate rotary velocity --------------------------------------------------------
 
-volatile float angleIncrement = 2.0*PI / 128; // when in Sign/Magnitude mode
-float radious = 700, attachSecond = 500;
+volatile float angleIncrement = 2.0*PI / 360; // when in Sign/Magnitude mode
+float radious = 700, attachSecond = 10000;
 
 // a ticker function to compute the speed periodically-------------------------------------------------------------
 #define PERIODIC_COMPUTE 10000 // in us
@@ -64,6 +73,7 @@
     // We know exactly how much time passed since we last computed the speed, this is PERIODIC_COMPUTE in microseconds
     angularSpeed =  1000000.0 * (float)(angle-oldAngle) / (float)(PERIODIC_COMPUTE); // in rad/sec
     oldAngle=angle;
+    myRender.updateSpeed(angularSpeed,angle);
 }
 
 
@@ -104,6 +114,7 @@
     timer.start();
 
     //using renderclass.cpp ----------------------------------------------------------
+    //createTextPoints(textString);
     myRender.setRender(&myText);
     myRender.startRender();
 
@@ -124,11 +135,11 @@
         if(1/*start*/) {
             timer_v.reset();
             wait_us(5000);
-            // send the speed on the serial port every 30 ms:
-            if (timer.read_ms()>30) {
+            /* send the speed on the serial port every 30 ms:
+            if (timer.read_ms()>300000) {
                 pc.printf("Angular Speed = %4.2f\t Cumulative Angle = %4.2f\n" , angularSpeed, angle);
                 timer.reset();
-            }
+            }*/
         }
     }
 }
@@ -149,14 +160,18 @@
                 stringData[indexStringData] = val;
                 indexStringData++;
             } else if ((val >= 'a') && (val <= 'z')) { // this is 45 to 57 (included)
-                myText.push_back(alphabet['a'-1]);
+                myText.push_back(alphabet[val - 'a']);
                 //inputletters.push_back(val);
             }
 
-            /*else if (val == '/') {
-                makeBuffer();
-            }*/ else if (val == '.') {
+            else if (val == '/') {
+                myRender.stopRender();
+                myRender.setRender(&myText);
+                myRender.startRender();
+            } else if (val == '.') {
+                myRender.stopRender();
                 myText.clear();
+                myRender.setRender(&myText);
                 //inputletters.clear();
             }