Robot Principal 26
Documentation du Club Robot INSA Rennes 2026
Chargement...
Recherche...
Aucune correspondance
Wheeledbase/lib/motors/include/I2CDCDriver.h
1//
2// Created by Romain Pouvreau on 23/04/2026.
3//
4
5#ifndef PAMIS_I2CDCDRIVER_H
6#define PAMIS_I2CDCDRIVER_H
7
8
9#ifdef ARDUINO
10//#error "Not implemented"
11#elif ESP_PLATFORM
12#include "i2cdev.h"
13#include "pca9685.h"
14#include "mathutils.h"
15#endif
16#ifndef ARDUINO
17#include "mathutils.h"
18#include "AbstractDriver.h"
19
20#define PCA9685_HIGH 4096
21#define PCA9685_LOW 0
22
30class I2CDCDriver : public AbstractDriver
31{
32public:
38 I2CDCDriver(int m1_fwd_port, int m1_bck_port, int m1_pwm, int m2_fwd_port, int m2_bck_port, int m2_pwm, int stdby_port);
39
44 void init(i2c_dev_t* dev);
45
51 int attach(AbstractMotor* motor) override;
52
59 int attach(AbstractMotor* motor, uint8_t id) override;
60
67 void setVelocity(float velocity, uint8_t id) override;
68
74 float getVelocity(uint8_t id) const override;
75
80 bool isFaulty() const;
81
86 void setSleep(bool active);
87
88private:
89 int m_m1_fwd_port;
90 int m_m1_bck_port;
91 int m_m1_pwm;
92 int m_m2_fwd_port;
93 int m_m2_bck_port;
94 int m_m2_pwm;
95 int m_stdby_port;
96 i2c_dev_t* m_dev = {};
97 float m_currentVelocity;
98 bool m_lastForward[2];
99};
100
101#endif
102#endif //PAMIS_I2CDCDRIVER_H
Interface abstraite des drivers moteurs.
Représente un driver moteur abstrait.
Definition motors/include/AbstractDriver.h:27
Definition motors/include/AbstractMotors.h:14
Definition motors/include/I2CDCDriver.h:31
int attach(AbstractMotor *motor) override
Attache un moteur au canal disponible (ID 0).
void setSleep(bool active)
Contrôle le mode basse consommation.
int attach(AbstractMotor *motor, uint8_t id) override
Attache un moteur à un ID spécifique.
void setVelocity(float velocity, uint8_t id) override
Définit la vitesse de sortie pour le moteur spécifié.
float getVelocity(uint8_t id) const override
Récupère la dernière vitesse appliquée.
bool isFaulty() const
Vérifie l'état de santé du driver.
I2CDCDriver(int m1_fwd_port, int m1_bck_port, int m1_pwm, int m2_fwd_port, int m2_bck_port, int m2_pwm, int stdby_port)
Constructeur du driver DRV8876.
void init(i2c_dev_t *dev)
Initialise les broches matérielles. Configure les entrées/sorties et réveille le driver si sleepPin e...