NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
NXTServo.h
1 
2 // 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 // 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 #ifndef NXTServo_H
28 #define NXTServo_H
29 
30 #define Servo_Command 0x41
31 #define Servo_Voltage 0x41
32 
33 #define Servo_1 1
34 #define Servo_2 2
35 #define Servo_3 3
36 #define Servo_4 4
37 #define Servo_5 5
38 #define Servo_6 6
39 #define Servo_7 7
40 #define Servo_8 8
41 
42 #define Servo_Position_Default 1500
43 #define Servo_Speed_Full 0
44 
45 #define Servo_Position_1 0x5A
46 #define Servo_Position_2 0x5B
47 #define Servo_Position_3 0x5C
48 #define Servo_Position_4 0x5D
49 #define Servo_Position_5 0x5E
50 #define Servo_Position_6 0x5F
51 #define Servo_Position_7 0x60
52 #define Servo_Position_8 0x61
53 
54 #define Servo_Speed_1 0x52
55 #define Servo_Speed_2 0x53
56 #define Servo_Speed_3 0x54
57 #define Servo_Speed_4 0x55
58 #define Servo_Speed_5 0x56
59 #define Servo_Speed_6 0x57
60 #define Servo_Speed_7 0x58
61 #define Servo_Speed_8 0x59
62 
63 #include "NXShieldI2C.h"
64 
68 class NXTServo : public NXShieldI2C
69 {
70 public:
72  NXTServo(uint8_t i2c_address = 0xb0);
73 
75  uint8_t issueCommand(char command);
76 
78  uint8_t getBatteryVoltage();
79 
81  bool storeInitial();
82 
84  bool reset();
85 
87  bool haltMacro();
88 
90  bool resumeMacro();
91 
93  bool gotoEEPROM();
94 
96  bool editMacro();
97 
99  bool pauseMacro();
100 
102  bool setSpeed(uint8_t number, uint8_t speed);
103 
105  bool setPosition(uint8_t number, uint8_t position);
106 
108  void runServo(uint8_t number, uint8_t position, uint8_t speed);
109 
110 };
111 
112 #endif
This class implements I2C interfaces used by NXShield.
Definition: NXShieldI2C.h:32
bool setSpeed(uint8_t number, uint8_t speed)
Definition: NXTServo.cpp:79
This class interfaces with NXTServo attached to NXShield.
Definition: NXTServo.h:68
NXTServo(uint8_t i2c_address=0xb0)
Definition: NXTServo.cpp:32
bool editMacro()
Definition: NXTServo.cpp:70
bool haltMacro()
Definition: NXTServo.cpp:55
uint8_t issueCommand(char command)
Definition: NXTServo.cpp:42
bool resumeMacro()
Definition: NXTServo.cpp:60
void runServo(uint8_t number, uint8_t position, uint8_t speed)
Definition: NXTServo.cpp:89
bool storeInitial()
Definition: NXTServo.cpp:47
bool reset()
Definition: NXTServo.cpp:51
bool setPosition(uint8_t number, uint8_t position)
Definition: NXTServo.cpp:84
bool gotoEEPROM()
Definition: NXTServo.cpp:65
uint8_t getBatteryVoltage()
Definition: NXTServo.cpp:37
bool pauseMacro()
Definition: NXTServo.cpp:75