EVShield  v1.3
EVShield Library Reference by mindsensors.com
EVs_NXTServo.h
1 
2 // EVs_NXTServo.h
3 //
4 // This is a class for controlling the NXT Servo Controller, made by Mindsensors.
5 // See http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=93 .
6 
7 // Initial version: 2010-06-17 by Andrew Sylvester.
8 // Modified for EVShield: 2015-02-16 by Michael Giles
9 // Large parts of the code is ported from the NXC library for the device,
10 // written by Deepak Patil.
11 
12 /*
13  This library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU Lesser General Public
15  License as published by the Free Software Foundation; either
16  version 2.1 of the License, or (at your option) any later version.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with this library; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27 
28 #ifndef EVs_NXTServo_H
29 #define EVs_NXTServo_H
30 
31 #define Servo_Command 0x41
32 #define Servo_Voltage 0x41
33 
34 #define Servo_1 1
35 #define Servo_2 2
36 #define Servo_3 3
37 #define Servo_4 4
38 #define Servo_5 5
39 #define Servo_6 6
40 #define Servo_7 7
41 #define Servo_8 8
42 
43 #define Servo_Position_Default 1500
44 #define Servo_Speed_Full 0
45 
46 #define Servo_Position_1 0x5A
47 #define Servo_Position_2 0x5B
48 #define Servo_Position_3 0x5C
49 #define Servo_Position_4 0x5D
50 #define Servo_Position_5 0x5E
51 #define Servo_Position_6 0x5F
52 #define Servo_Position_7 0x60
53 #define Servo_Position_8 0x61
54 
55 #define Servo_Speed_1 0x52
56 #define Servo_Speed_2 0x53
57 #define Servo_Speed_3 0x54
58 #define Servo_Speed_4 0x55
59 #define Servo_Speed_5 0x56
60 #define Servo_Speed_6 0x57
61 #define Servo_Speed_7 0x58
62 #define Servo_Speed_8 0x59
63 
64 #include "EVShieldI2C.h"
65 
69 class EVs_NXTServo : public EVShieldI2C
70 {
71 public:
73  EVs_NXTServo(uint8_t i2c_address = 0xb0);
74 
76  uint8_t issueCommand(char command);
77 
79  uint8_t getBatteryVoltage();
80 
82  bool storeInitial(uint8_t number);
83 
85  bool reset();
86 
88  bool haltMacro();
89 
91  bool resumeMacro();
92 
94  bool gotoEEPROM(uint8_t position);
95 
97  bool editMacro();
98 
100  bool pauseMacro();
101 
103  bool setSpeed(uint8_t number, uint8_t speed);
104 
106  bool setPosition(uint8_t number, uint8_t position);
107 
109  void runServo(uint8_t number, uint8_t position, uint8_t speed);
110 
111 };
112 
113 #endif
uint8_t issueCommand(char command)
Definition: EVs_NXTServo.cpp:43
uint8_t getBatteryVoltage()
Definition: EVs_NXTServo.cpp:38
bool setSpeed(uint8_t number, uint8_t speed)
Definition: EVs_NXTServo.cpp:83
bool editMacro()
Definition: EVs_NXTServo.cpp:73
This class interfaces with NXTServo attached to EVShield.
Definition: EVs_NXTServo.h:69
bool storeInitial(uint8_t number)
Definition: EVs_NXTServo.cpp:48
bool resumeMacro()
Definition: EVs_NXTServo.cpp:62
bool gotoEEPROM(uint8_t position)
Definition: EVs_NXTServo.cpp:67
This class implements I2C interfaces used by EVShield.
Definition: EVShieldI2C.h:32
EVs_NXTServo(uint8_t i2c_address=0xb0)
Definition: EVs_NXTServo.cpp:33
bool setPosition(uint8_t number, uint8_t position)
Definition: EVs_NXTServo.cpp:88
bool haltMacro()
Definition: EVs_NXTServo.cpp:57
void runServo(uint8_t number, uint8_t position, uint8_t speed)
Definition: EVs_NXTServo.cpp:93
bool reset()
Definition: EVs_NXTServo.cpp:53
bool pauseMacro()
Definition: EVs_NXTServo.cpp:79