Treehopper C++ API
SeeedGroveI2cMotorDriver.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "I2c.h"
5 #include "SMBusDevice.h"
6 
7 namespace Treehopper {
8  namespace Libraries {
9  namespace Motors {
11  public:
12  enum class Registers {
13  MotorSpeedSet = 0x82,
14  PwmFrequencySet = 0x84,
15  DirectionSet = 0xaa,
16  MotorSetA = 0xa1,
17  MotorSetB = 0xa5,
18  Nothing = 0x01
19  };
20 
21  enum class MotorSetDirection {
22  BothClockwise = 0x0a,
23  BothCounterClockwise = 0x05,
24  Motor1ClockwiseMotor2CounterClockwise = 0x06,
25  Motor1CounterClockwiseMotor2Clockwise = 0x09
26  };
27 
31  enum class PrescalerFrequency {
32  Freq_31372Hz = 0x01,
33  Freq_3921Hz = 0x02,
34  Freq_490Hz = 0x03,
35  Freq_122Hz = 0x04,
36  Freq_30Hz = 0x05
37  };
38 
47  SeeedGroveI2cMotorDriver(I2c &i2c, bool a1, bool a2, bool a3, bool a4);
48 
54  SeeedGroveI2cMotorDriver(I2c &i2c, uint8_t address = 0x0f);
55 
57  PrescalerFrequency frequency();
58 
60  void frequency(PrescalerFrequency value);
61 
63  double motor1();
64 
66  void motor1(double speed);
67 
69  double motor2();
70 
72  void motor2(double speed);
73 
74  private:
75  double m1 = 0;
76  double m2 = 0;
77  PrescalerFrequency freq;
78  SMBusDevice dev;
79 
80  void update();
81  };
82  }
83  }
84 }
Base I2c interface.
Definition: I2c.h:10
Definition: SMBusDevice.h:7
PrescalerFrequency
The prescaler frequencies
Definition: SeeedGroveI2cMotorDriver.h:31
MotorSetDirection
Definition: SeeedGroveI2cMotorDriver.h:21
Definition: SeeedGroveI2cMotorDriver.h:10
#define LIBRARIES_API
Definition: Treehopper.Libraries.h:17
Definition: AdcPin.h:3