#include <HBridgeSetter.h>
Public Member Functions | |
HBridgeSetter (Setter *targetA, Setter *targetB) | |
void | setTargets (Setter *targetA, Setter *targetB) |
virtual void | input (int value) |
virtual void | failsafe () |
A HBridge is used to drive a motor in forward and reverse directions. It requires 2 Setters as output: one to drive the motor forwards and one to drive it in reverse. When driving forward the reverse output is 0 and vice versa.
Typically the outputs would be AnalogSetters to control a motor through a pair of analog outputs, but could be ServoSetter, AccelStepperSpeedSetter or AccelStepperPositionSetter or any other combination.
Set or change the output pin
[in] | targetA | The Setter to use for output A. |
[in] | targetB | The Setter to use for output B. |
References Setter::setTarget().
void HBridgeSetter::input | ( | int | value | ) | [virtual] |
Input the value to be used to set the 2 output Setters. Input of 127 produces 0 on both outputs (stopped) Input of 128 to 255 translates to output Setter A from 0 to 256 and output Setter B at 0 (forward). Input of 127 to 0 translates to output Setter B from 0 to 254 and output Setter A at 0 (reverse).
[in] | value | The input value to set. |
Reimplemented from Setter.
References Setter::input().
void HBridgeSetter::failsafe | ( | ) | [virtual] |
Called when the source of input data is lost, and the Setter is required to fail in a safe way. Calls the failsafes of targetA and targetB
Reimplemented from Setter.
References Setter::failsafe().