Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Nunchuk.h
- Revision:
- 0:37e9a0644485
- Child:
- 1:72d62147e2b8
diff -r 000000000000 -r 37e9a0644485 Nunchuk.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Nunchuk.h Fri Nov 15 14:45:23 2013 +0000
@@ -0,0 +1,95 @@
+#ifndef NUNCHUK_H
+#define NUNCHUK_H
+
+#include "mbed.h"
+
+/** Class to interface with a Nintendo wii Nunchuk.
+ */
+
+class Nunchuk
+{
+
+public:
+ /** Construct a Nunchuk object.
+ *
+ * @param sda I2C channel to use.
+ * @param scl I2C channel
+ * @param mTe the sampling time for the internal Ticker
+ */
+ Nunchuk(PinName sda,PinName scl,float mTe);
+
+ ~Nunchuk(void);
+
+ /** Get the joyStick position
+ returns -1: joyStick in left position
+ returns +1: joyStick in righ position
+ returns 0: center position
+
+ */
+ signed char getJoyX(void);
+
+ /** Get the joyStick position
+ returns -1: joyStick in left position
+ returns +1: joyStick in righ position
+ returns 0: center position
+
+ */
+ signed char getJoyY(void);
+
+ /** Get the acceleration in axis X (10 bits)
+ */
+ int getAccX(void);
+
+ /** Get the acceleration in axis Y (10 bits)
+ */
+ int getAccY(void);
+
+ /** Get the acceleration in axis Z (10 bits)
+ */
+ int getAccZ(void);
+ /** Get the Button C state
+ *returns true if button pressed
+ */
+ bool getBtnC(void);
+
+ /** Get the Button Z state
+ *returns true if button pressed
+ */
+ bool getBtnZ(void);
+
+ /** returns the sampling period
+ */
+ float getPeriodeTe(void);
+
+protected:
+ I2C myI2C;
+ //
+ Ticker myTicker;
+ //
+ bool setup(void);
+ //
+ bool request(void);
+ //
+ char decode(char data);
+ //
+ void action(void);
+
+
+//datas
+ static const int ADRESSE=0xA4;
+ signed char joyX; //-1 0 +1
+ signed char joyY; //-1 0 +1
+
+ int accX;
+ int accY;
+ int accZ;
+
+ bool btnC;
+ bool btnZ;
+
+ float periodeTe;
+
+
+};
+
+#endif
\ No newline at end of file