summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/motor/motor.h
blob: 330ce8887c0c7b5794545eae67329a3e916147a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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