JMotor
Loading...
Searching...
No Matches
JMotorDriverDual.h
Go to the documentation of this file.
1#ifndef J_MOTOR_DRIVER_DUAL_H
2#define J_MOTOR_DRIVER_DUAL_H
3#include "JMotorDriver.h"
4#include <Arduino.h>
10public:
14 : m1(_m1)
15 , m2(_m2)
16 {
17 }
18 bool set(float val)
19 {
20 bool m1state = m1.set(val);
21 bool m2state = m2.set(val);
22 return m1state && m2state;
23 }
24 bool setEnable(bool _enable)
25 {
26 bool m1state = m1.setEnable(_enable);
27 bool m2state = m2.setEnable(_enable);
28 return m1state || m2state;
29 }
30 bool getEnable()
31 {
32 bool m1state = m1.getEnable();
33 bool m2state = m2.getEnable();
34 return m1state || m2state;
35 }
37 {
38 return min(m1.getMaxRange(), m2.getMaxRange());
39 }
41 {
42 return max(m1.getMinRange(), m2.getMinRange());
43 }
44};
45#endif
control two JMotorDrivers (of any type) as if they are one driver
Definition JMotorDriverDual.h:9
bool setEnable(bool _enable)
use to enable or disable a motor, and sets up pin states
Definition JMotorDriverDual.h:24
JMotorDriverDual(JMotorDriver &_m1, JMotorDriver &_m2)
Definition JMotorDriverDual.h:13
float getMinRange()
low end of the range
Definition JMotorDriverDual.h:40
JMotorDriver & m1
Definition JMotorDriverDual.h:11
bool set(float val)
set motor power
Definition JMotorDriverDual.h:18
JMotorDriver & m2
Definition JMotorDriverDual.h:12
bool getEnable()
get the enable state of the driver
Definition JMotorDriverDual.h:30
float getMaxRange()
high end of the range
Definition JMotorDriverDual.h:36
defines common interface for all types of JMotorDrivers
Definition JMotorDriver.h:10
virtual bool set(float val)
set motor power
virtual bool setEnable(bool _enable)
use to enable or disable a motor, and sets up pin states
virtual float getMaxRange()
high end of the range
virtual float getMinRange()
low end of the range
virtual bool getEnable()
get the enable state of the driver