Roboid Control for C++ 0.4
Loading...
Searching...
No Matches
DRV8833.h
1#pragma once
2
3#include <Arduino.h>
4#include "Participants/IsolatedParticipant.h"
5#include "Thing.h"
6#include "Things/DifferentialDrive.h"
7#include "Things/Motor.h"
8
9namespace RoboidControl {
10namespace Arduino {
11
12class DRV8833Motor;
13
14class DRV8833 : public Thing {
15 public:
16 struct Configuration {
17 int AIn1;
18 int AIn2;
19 int BIn1;
20 int BIn2;
21 int standby = 255;
22 };
23
25 DRV8833(Configuration config, Thing* parent = Thing::LocalRoot());
26
27 DRV8833Motor* motorA = nullptr;
28 DRV8833Motor* motorB = nullptr;
29
30 protected:
31 unsigned char pinStandby = 255;
32
33 public:
34 class DifferentialDrive;
35};
36
37#pragma region Differential drive
38
39class DRV8833::DifferentialDrive : public RoboidControl::DifferentialDrive {
40 public:
41 DifferentialDrive(DRV8833::Configuration config, Thing* parent = Thing::LocalRoot());
42
43 virtual void Update(bool recurse = false) override;
44
45 protected:
46 DRV8833 drv8833;
47};
48
49#pragma endregion Differential drive
50
51#pragma region Motor
52
54class DRV8833Motor : public Motor {
55 public:
60 DRV8833Motor(DRV8833* driver,
61 unsigned char pinIn1,
62 unsigned char pinIn2,
63 bool reverse = false);
64 // void SetMaxRPM(unsigned int rpm);
65
66 // virtual void SetAngularVelocity(Spherical velocity) override;
67 virtual void SetTargetVelocity(float targetSpeed) override;
68 // bool reverse = false;
69
70 protected:
71 unsigned char pinIn1 = 255;
72 unsigned char pinIn2 = 255;
73 // unsigned int maxRpm = 200;
74
75#if (ESP32)
76 uint8_t in1Ch;
77 uint8_t in2Ch;
78 static uint8_t nextAvailablePwmChannel;
79#endif
80};
81
82#pragma endregion Motor
83
84} // namespace Arduino
85} // namespace RoboidControl
Support for a DRV8833 motor controller.
Definition DRV8833.h:54
A thing which can move itself using a differential drive system.
Definition DifferentialDrive.h:11
DifferentialDrive(Thing *parent=Thing::LocalRoot())
Create a new child differential drive.
Definition DifferentialDrive.cpp:7
static Thing * LocalRoot()
The root thing for the local participant.
Definition Thing.cpp:23