00001 #ifndef __BIOLOIDSERVO_H__ 00002 #define __BIOLOIDSERVO_H__ 00003 00004 #include "global.h" 00005 #include "BoardController.h" 00006 00007 #define BIOLOID_MAX_PARAM 8 00008 #define BIOLOID_MAX_PACKETLEN BIOLOID_MAX_PARAM+5 00009 #define SERVO_X 0 00010 #define SERVO_Y 1 00011 00012 #define lowbyte(w) ((unsigned char) w) 00013 #define highbyte(w) ((unsigned char) (w >> 8)) 00014 00015 00016 typedef struct 00017 { 00018 unsigned char id; 00019 unsigned char paramLen; 00020 unsigned char instruction; 00021 unsigned char param[ BIOLOID_MAX_PARAM ]; 00022 } BioloidPacket; 00023 00024 00025 00026 class BioloidServo { 00027 00028 public: 00029 void setPosition(unsigned char _pos, unsigned char _scal); 00030 BioloidServo(unsigned char _id, unsigned int _minPos, unsigned int _maxPos); 00031 static void TxPacket(BioloidPacket* bPacket, unsigned int milliDelay); 00032 static unsigned char RxPacket(BioloidPacket* bPacket); 00033 static bool RxByte(unsigned char* data); 00034 static bool pingServo(unsigned char _id); 00035 static void scanBioloidBus(); 00036 //static void setBroadcastReturnDelayTime(); 00037 00038 00039 00040 private: 00041 unsigned int minPos, maxPos; 00042 unsigned char servoId; 00043 00044 00045 //unsigned char getServoId(unsigned char _id); 00046 00047 }; 00048 00049 00050 #endif