Library to use the wii nunchuk distributed by Nintendo
Revision 2:0a8f43931041, committed 2014-02-25
- Comitter:
- adelino
- Date:
- Tue Feb 25 10:50:05 2014 +0000
- Parent:
- 1:72d62147e2b8
- Commit message:
- start a new acquisition manually without internal Ticker
Changed in this revision
Nunchuk.cpp | Show annotated file Show diff for this revision Revisions of this file |
Nunchuk.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 72d62147e2b8 -r 0a8f43931041 Nunchuk.cpp --- a/Nunchuk.cpp Sun Nov 17 13:35:01 2013 +0000 +++ b/Nunchuk.cpp Tue Feb 25 10:50:05 2014 +0000 @@ -14,16 +14,18 @@ this->btnZ=false; setup(); - - myTicker.attach(this,&Nunchuk::action,periodeTe); + + if(periodeTe>0) + myTicker.attach(this,&Nunchuk::process,periodeTe); } //----------------------- Nunchuk::~Nunchuk(void) { + if(periodeTe>0) myTicker.detach(); } //----------------------- -void Nunchuk::action(void) +void Nunchuk::process(void) { bool res=false; static char datas[6];
diff -r 72d62147e2b8 -r 0a8f43931041 Nunchuk.h --- a/Nunchuk.h Sun Nov 17 13:35:01 2013 +0000 +++ b/Nunchuk.h Tue Feb 25 10:50:05 2014 +0000 @@ -32,10 +32,14 @@ * @param sda I2C channel to use. * @param scl I2C channel * @param mTe the sampling time for the internal Ticker + * if @param mTe=0 start a new acquisition manually without internal Ticker */ - Nunchuk(PinName sda,PinName scl,float mTe); + Nunchuk(PinName sda,PinName scl,float mTe=0); ~Nunchuk(void); + + /// start a new acquisition manually without internal Ticker + void process(void); /// Get the joyStick position /// @returns -1: joyStick in left position @@ -77,6 +81,8 @@ /** @returns The sampling period */ float getPeriodeTe(void); + + protected: I2C myI2C; @@ -89,7 +95,7 @@ // char decode(char data); // - void action(void); + //datas