summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/motor/motor.h
diff options
context:
space:
mode:
Diffstat (limited to '2003/i/buzz/src/motor/motor.h')
-rw-r--r--2003/i/buzz/src/motor/motor.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/2003/i/buzz/src/motor/motor.h b/2003/i/buzz/src/motor/motor.h
new file mode 100644
index 0000000..330ce88
--- /dev/null
+++ b/2003/i/buzz/src/motor/motor.h
@@ -0,0 +1,40 @@
+#ifndef motor_h
+#define motor_h
+// motor.h
+// buzz - Programme du robot Efrei Robotique I1-I2 2003
+// Copyright (C) 2003 Nicolas Schodet
+
+#include "serial/serial.h"
+
+class Motor
+{
+ Serial m_serial;
+ // Buffer d'entrée.
+ char m_recv_buf[64];
+ int m_recv_n;
+ // Paramètre vitesse/acceleration.
+ int m_accel, m_speed;
+ int m_raccel, m_rspeed;
+ // Operations en cours.
+ bool running;
+ public:
+ // Constructeur.
+ Motor (void);
+ // Destructeur.
+ ~Motor (void);
+ // Avance d'une distance d, à la vitesse s.
+ void goDistance (int d, int s = -1);
+ // Tourne d'un angle d, à la vitesse s.
+ void turnAngle (int d, int s = -1);
+ // Retourne true si la commande est terminée.
+ bool finnish (void) { readMsg (); return !running; }
+ // Traite les message entrants.
+ void readMsg (void);
+ private:
+ // Envoie une commande.
+ void send (char com, int a1 = -1, int a2 = -1, int a3 = -1);
+ // Traite des éventuels retours, retourne true si commande finie.
+ bool recv (void);
+};
+
+#endif // motor_h