1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
class Easy_Motor
{
public:
Easy_Motor (byte byMtrA_1_pin,
byte byMtrA_2_pin,
byte byMtr_Encoder_DO_pin,
byte byMtr_Encoder_CSn_pin,
byte byMtr_Encoder_CLK_pin,
byte bySwitch_Home_pin,
byte bySwitch_Limit_pin,
boolean bSwitch_HI_LO,
int _iEncoder_Counts_per_REV
);
void setHomeAngle (float fHomeAngle);
void direction (boolean);
void toggle_dir ();
boolean getMtrDirection ();
void speed (int);
int getMtrSpeed ();
float getMtrAngle ();
SwitchState getSwitchState ();
void start ();
void stop (boolean);
void toggle_run (boolean);
boolean isRunning ();
Location whereAmI ();
float moveToA_degree (float fAngle);
float moveToR_degree (float fAngle);
float moveTo_revs (float fRevs_Target);
private:
// References to composite objects that will be initialized in the
// constructor using an initialization list.
Mtr_DRV8833 _MyMtr;
Encoder_AS5045 _MyEncoder;
SwitchState _MySwitchState;
byte _byEncoderCLKpin,
_byEncoderCSNpin,
_byEncoderDOpin,
_byMtrA_1pin,
_byMtrA_2pin,
_bySwitchHomepin,
_bySwitchLimitpin;
};
Easy_Motor::Easy_Motor (
byte byMtrA_1_pin,
byte byMtrA_2_pin,
byte byMtr_Encoder_DO_pin,
byte byMtr_Encoder_CSn_pin,
byte byMtr_Encoder_CLK_pin,
byte bySwitch_Home_pin,
byte bySwitch_Limit_pin,
boolean bSwitch_HI_LO,
int _iEncoder_Counts_per_REV
) : _MyMtr(byMtrA_1_pin, byMtrA_2_pin),
_MyEncoder(byMtr_Encoder_CLK_pin,
byMtr_Encoder_CSn_pin,
byMtr_Encoder_DO_pin)
{
... Other Easy_Motor Object Instantiation Code ...
}
|