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.
Fork of MyLib by
Nunchuck/Nunchuck.h@0:a919993ff50f, 2017-05-10 (annotated)
- Committer:
- gaku_sigu
- Date:
- Wed May 10 15:12:02 2017 +0000
- Revision:
- 0:a919993ff50f
- Child:
- 3:e7a900958f54
mylibrary
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gaku_sigu | 0:a919993ff50f | 1 | #ifndef NUNCHUCK_H |
gaku_sigu | 0:a919993ff50f | 2 | #define NUNCHUCK_H |
gaku_sigu | 0:a919993ff50f | 3 | |
gaku_sigu | 0:a919993ff50f | 4 | |
gaku_sigu | 0:a919993ff50f | 5 | #include "mbed.h" |
gaku_sigu | 0:a919993ff50f | 6 | |
gaku_sigu | 0:a919993ff50f | 7 | #define ANALOGDATA 1 //1 : analog 0 : degital |
gaku_sigu | 0:a919993ff50f | 8 | #define DEADZONE 6 //analog stick's deadzone |
gaku_sigu | 0:a919993ff50f | 9 | #define ADDR 0xA4 // 0x52 << 1 |
gaku_sigu | 0:a919993ff50f | 10 | |
gaku_sigu | 0:a919993ff50f | 11 | class Nunchuck : I2C |
gaku_sigu | 0:a919993ff50f | 12 | { |
gaku_sigu | 0:a919993ff50f | 13 | public: |
gaku_sigu | 0:a919993ff50f | 14 | |
gaku_sigu | 0:a919993ff50f | 15 | Nunchuck(PinName SDA, PinName SCL); |
gaku_sigu | 0:a919993ff50f | 16 | int8_t analogx(); |
gaku_sigu | 0:a919993ff50f | 17 | int8_t analogy(); |
gaku_sigu | 0:a919993ff50f | 18 | int accx(); |
gaku_sigu | 0:a919993ff50f | 19 | int accy(); |
gaku_sigu | 0:a919993ff50f | 20 | int accz (); |
gaku_sigu | 0:a919993ff50f | 21 | bool buttonc(); |
gaku_sigu | 0:a919993ff50f | 22 | bool buttonz(); |
gaku_sigu | 0:a919993ff50f | 23 | |
gaku_sigu | 0:a919993ff50f | 24 | private: |
gaku_sigu | 0:a919993ff50f | 25 | Timer timer; |
gaku_sigu | 0:a919993ff50f | 26 | bool flag; |
gaku_sigu | 0:a919993ff50f | 27 | bool init(); |
gaku_sigu | 0:a919993ff50f | 28 | char data[6]; |
gaku_sigu | 0:a919993ff50f | 29 | void getdata(); |
gaku_sigu | 0:a919993ff50f | 30 | }; |
gaku_sigu | 0:a919993ff50f | 31 | |
gaku_sigu | 0:a919993ff50f | 32 | #endif |