NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
PFMate.h
1 
2 // PFMate.h
3 //
4 // This is a class for controlling the PF Motor Controller, made by Mindsensors.
5 // See http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=107 .
6 
7 // Initial version: 2010-06-17 by Andrew Sylvester
8 // Large parts of the code is ported from the NXC library for the device,
9 // written by Deepak Patil.
10 
11 /*
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Lesser General Public
14  License as published by the Free Software Foundation; either
15  version 2.1 of the License, or (at your option) any later version.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Lesser General Public License for more details.
21 
22  You should have received a copy of the GNU Lesser General Public
23  License along with this library; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26 
27 
28 #ifndef PFMate_H
29 #define PFMate_H
30 
31 #define PF_Commmand 0x41
32 
33 #define PF_Channel 0x42
34 #define PF_Channel_1 1
35 #define PF_Channel_2 2
36 #define PF_Channel_3 3
37 #define PF_Channel_4 4
38 
39 #define PF_Control 0x43
40 #define PF_Contol_Both 0
41 #define PF_Contol_A 1
42 #define PF_Contol_B 2
43 
44 #define PF_Speed_A 0x45
45 #define PF_Speed_B 0x47
46 #define PF_Speed_Slow 1
47 #define PF_Speed_Medium 4
48 #define PF_Speed_Full 7
49 
50 #define PF_Operation_A 0x44
51 #define PF_Operation_B 0x46
52 #define PF_Operation_Float 0
53 #define PF_Operation_Forward 1
54 #define PF_Operation_Reverse 2
55 #define PF_Operation_Brake 3
56 
57 #include "NXShieldI2C.h"
58 
62 class PFMate : public NXShieldI2C
63 {
64 public:
66  PFMate(uint8_t i2c_address = 0x48);
67 
69  uint8_t issueCommand(char command);
70 
72  bool sendSignal();
73 
75  void controlMotor(uint8_t channel, uint8_t contol, uint8_t operation, uint8_t speed);
76 
78  bool setChannel(uint8_t channel);
79 
81  bool setControl(uint8_t contol);
82 
84  bool setOperationA(uint8_t operation);
85 
87  bool setOperationB(uint8_t operation);
88 
90  bool setSpeedA(uint8_t speed);
91 
93  bool setSpeedB(uint8_t speed);
94 };
95 
96 #endif
This class implements I2C interfaces used by NXShield.
Definition: NXShieldI2C.h:32
bool setSpeedB(uint8_t speed)
Definition: PFMate.cpp:71
bool setOperationB(uint8_t operation)
Definition: PFMate.cpp:61
bool sendSignal()
Definition: PFMate.cpp:41
bool setChannel(uint8_t channel)
Definition: PFMate.cpp:46
uint8_t issueCommand(char command)
Definition: PFMate.cpp:36
void controlMotor(uint8_t channel, uint8_t contol, uint8_t operation, uint8_t speed)
Definition: PFMate.cpp:76
PFMate(uint8_t i2c_address=0x48)
Definition: PFMate.cpp:32
This class interfaces with PFMate attached to NXShield.
Definition: PFMate.h:62
bool setOperationA(uint8_t operation)
Definition: PFMate.cpp:56
bool setSpeedA(uint8_t speed)
Definition: PFMate.cpp:66
bool setControl(uint8_t contol)
Definition: PFMate.cpp:51