this version 10/17

Dependencies:   mbed

Fork of linearMirrorMotion by Alvaro Cassinelli

Revision:
9:4db47b8eb750
Parent:
8:617dbd2b6512
Child:
10:a3dd8ec4be60
diff -r 617dbd2b6512 -r 4db47b8eb750 main.cpp
--- a/main.cpp	Fri Mar 01 08:08:28 2013 +0000
+++ b/main.cpp	Wed Mar 06 06:59:06 2013 +0000
@@ -38,6 +38,7 @@
 
 struct point2d {
     int x,y;
+    int laserSwitch;   // laser {1: on 0:off} until next step
 };
 struct letter {
     int pointnum;
@@ -89,11 +90,12 @@
 
 int main(){
 
-    FILE *fp = fopen("/local/test.txt", "r");
+    FILE *fp = fopen("/local/text.txt", "r");
     if(!fp) {
         IO.setGreenPower(1);
         exit(1);
-    }
+    }   
+    
     int letternum;
     fscanf(fp, "%d", &letternum);
     for(int i=0; i<letternum; i++) {
@@ -103,6 +105,7 @@
             point2d bufp;
             fscanf(fp, "%d", &bufp.x);
             fscanf(fp, "%d", &bufp.y);
+            fscanf(fp, "%d", &bufp.laserSwitch);
             bufl.letpoints.push_back(bufp);
         }
         libletter.push_back(bufl);
@@ -116,8 +119,7 @@
 
     // Set displaying laser powers:
     IO.setRedPower(0);
-    IO.setGreenPower(0);//turn on the green (displaying) laser
-
+    IO.setGreenPower(0);
     wait_ms(100);
 
     X = beforeX = CENTER_AD_MIRROR_X;
@@ -132,9 +134,9 @@
         timer.reset();
         wait_us(5000);
         for(int i=0; i<inputletters.size(); i++) {
-    
+        
+            for(int j=0; j<libletter[inputletters[i]-'a'].letpoints.size(); j++) {
             
-            for(int j=0; j<libletter[inputletters[i]-'a'].letpoints.size(); j++) {
                 if (pc.readable()>0) processSerial();
                 
                 int x = -0.8*((libletter[inputletters[i]-'a'].letpoints[j].x ) - sqrtf(vx*vx+vy*vy)*timer.read_us()/st*j/100); //this ZURE should be modifyed not by dt but Timer.
@@ -142,10 +144,10 @@
                 IO.writeOutXY(X+cost*x - sint*y,Y + sint*x + cost*y);
                 timer.reset();
                 wait_us(dt);
-                IO.setRGBPower(3);//on
+                IO.setRedPower(libletter[inputletters[i]-'a'].letpoints[j].laserSwitch);//on
             }
-            IO.setRGBPower(1); //off
-            wait_us(dt_betwords/sqrtf(vx*vx+vy*vy)*100000);
+            IO.setRedPower(0); //off
+            wait_us(dt_betwords);//sqrtf(vx*vx+vy*vy)*100000);
 
         }