RCKit
Main Page
Classes
Files
Examples
File List
File Members
HBridgeSetter.h
1
// HBridgeSetter.h
2
//
3
// Setter class that outputs its value to a HBridge configured on 2 analog output pins
4
/// \author Mike McCauley (mikem@airspayce.com)
5
///
6
// Copyright (C) 2010 Mike McCauley
7
// $Id: HBridgeSetter.h,v 1.3 2010/06/28 00:56:10 mikem Exp $
8
9
#ifndef HBridgeSetter_h
10
#define HBridgeSetter_h
11
12
#include "Setter.h"
13
#include <inttypes.h>
14
15
/////////////////////////////////////////////////////////////////////
16
/// \class HBridgeSetter HBridgeSetter.h <HBridgeSetter.h>
17
/// \brief Setter class that outputs its value to a HBridge configured on 2 output Setter
18
///
19
/// A HBridge is used to drive a motor in forward and reverse directions. It requires 2 Setters as output:
20
/// one to drive the motor forwards and one to drive it in reverse. When driving forward the reverse
21
/// output is 0 and vice versa.
22
///
23
/// Typically the outputs would be AnalogSetters to control a motor through a pair of analog outputs,
24
/// but could be ServoSetter, AccelStepperSpeedSetter
25
/// or AccelStepperPositionSetter or any other combination.
26
///
27
class
HBridgeSetter
:
public
Setter
28
{
29
public
:
30
/// \param[in] targetA The Setter to use for output A.
31
/// \param[in] targetB The Setter to use for output B.
32
HBridgeSetter
(
Setter
* targetA,
Setter
* targetB);
33
34
/// Set or change the output pin
35
/// \param[in] targetA The Setter to use for output A.
36
/// \param[in] targetB The Setter to use for output B.
37
void
setTargets
(
Setter
* targetA,
Setter
* targetB);
38
39
/// Input the value to be used to set the 2 output Setters.
40
/// Input of 127 produces 0 on both outputs (stopped)
41
/// Input of 128 to 255 translates to output Setter A from 0 to 256
42
/// and output Setter B at 0 (forward).
43
/// Input of 127 to 0 translates to output Setter B from 0 to 254
44
/// and output Setter A at 0 (reverse).
45
/// \param[in] value The input value to set.
46
virtual
void
input
(
int
value);
47
48
/// Called when the source of input data is lost, and the Setter is required to fail in a safe way.
49
/// Calls the failsafes of targetA and targetB
50
virtual
void
failsafe
();
51
52
protected
:
53
54
private
:
55
/// The B output Setter. targetA is the setter that is included in the Setter class
56
Setter
* _targetB;
57
};
58
59
#endif g
Generated by
1.8.1