Dependents: HoverboardTest RobotArmControl
WiiNunchuck.h
00001 #ifndef WII_NUNCHUCK_H 00002 #define WII_NUNCHUCK_H 00003 00004 #include "mbed.h" 00005 00006 // I2C 00007 #define NUNCHUCK_ADDR 0xA4 // 0x52 << 1 00008 #define NUNCHUCK_REGADDR 0x40 // 00009 #define NUNCHUCK_READLEN 0x06 // 00010 #define I2C_ACK 0 00011 #define I2C_READ_DELAY 0.01 00012 00013 #define Joy_X 0 00014 #define Joy_Y 1 00015 #define Acc_X 2 00016 #define Acc_Y 3 00017 #define Acc_Z 4 00018 #define Button 5 00019 00020 class WiiNunchuck { 00021 public: 00022 WiiNunchuck(PinName p_sda, PinName p_scl); 00023 //read(); 00024 unsigned char joyx(); 00025 unsigned char joyy(); 00026 int accx(); 00027 int accy(); 00028 int accz(); 00029 bool buttonc(); 00030 bool buttonz(); 00031 private: 00032 I2C i2c; 00033 Timer timer; 00034 bool WiiNunInitFlag; //= false; 00035 char readBuf[NUNCHUCK_READLEN]; 00036 unsigned char joyX, joyY; 00037 int accX, accY, accZ; 00038 bool buttonC, buttonZ; 00039 bool init(); 00040 void read(); 00041 }; 00042 00043 00044 #endif
Generated on Tue Jul 12 2022 21:04:29 by 1.7.2