a simple library to control an animatronic head

Revision:
1:c5edd3b18b79
Parent:
0:8474cbec06bd
Child:
2:3920d79c79b1
--- a/Alex.cpp	Sun Dec 12 14:15:07 2010 +0000
+++ b/Alex.cpp	Wed Dec 15 15:07:10 2010 +0000
@@ -1,8 +1,6 @@
 #include "Alex.h"
-Serial pc(USBTX, USBRX); // tx, rx => serialize mBed with the pc
-PwmOut Led(LED1);
 
-Alex::Alex(SRF05 s, Servo e, Servo m, Servo l, Servo r):S(s), E(e), M(m), L(l), R(r)
+Alex::Alex(SRF05 s, Servo e, Servo m, Servo l, Servo r):S(s), E(e), M(m), L(l), R(r), Led(LED1), pc(USBTX, USBRX)
 {
 }
 Alex::~Alex()
@@ -52,4 +50,25 @@
         R=i;
         wait(0.1);
     }
+}
+void Alex::Simulate_Talking(int length)
+{
+     for(int i=0; i<length; i++)
+    {
+        Move_mouth(100);
+        wait(0.01);
+    }
+}
+
+void Alex::Presence_too_far()
+{
+    if(Testpresence()==1)
+    {
+        pc.printf("You are too far, I can't see you !");
+        Simulate_Talking(4);
+        wait(3);
+        pc.printf("Is there somebody ?");
+        Simulate_Talking(4);
+        wait(3);
+    }
 }
\ No newline at end of file