c
Fork of MyLib by
Nunchuck/Nunchuck.h@11:827d1ccc8bec, 2018-01-14 (annotated)
- Committer:
- kikoaac
- Date:
- Sun Jan 14 01:06:35 2018 +0000
- Revision:
- 11:827d1ccc8bec
- Parent:
- 7:15e3890a6782
?
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 | 3:e7a900958f54 | 7 | #define NUNCHUCK_ANALOGDATA 1 //1 : analog 0 : degital |
kikoaac | 11:827d1ccc8bec | 8 | #define NUNCHUCK_DEADZONE 0 //analog stick's deadzone |
gaku_sigu | 3:e7a900958f54 | 9 | #define NUNCHUCK_ADDR 0xA4 // 0x52 << 1 |
gaku_sigu | 0:a919993ff50f | 10 | |
gaku_sigu | 6:d5b128533dfe | 11 | #define PI 3.14159265358979 |
gaku_sigu | 6:d5b128533dfe | 12 | |
gaku_sigu | 0:a919993ff50f | 13 | class Nunchuck : I2C |
gaku_sigu | 0:a919993ff50f | 14 | { |
gaku_sigu | 0:a919993ff50f | 15 | public: |
gaku_sigu | 0:a919993ff50f | 16 | |
gaku_sigu | 0:a919993ff50f | 17 | Nunchuck(PinName SDA, PinName SCL); |
gaku_sigu | 0:a919993ff50f | 18 | int8_t analogx(); |
gaku_sigu | 0:a919993ff50f | 19 | int8_t analogy(); |
gaku_sigu | 3:e7a900958f54 | 20 | double analograd(); |
gaku_sigu | 5:69e9c81e9490 | 21 | double analogdeg(); |
gaku_sigu | 7:15e3890a6782 | 22 | double analogrange(); |
gaku_sigu | 0:a919993ff50f | 23 | int accx(); |
gaku_sigu | 0:a919993ff50f | 24 | int accy(); |
gaku_sigu | 0:a919993ff50f | 25 | int accz (); |
gaku_sigu | 0:a919993ff50f | 26 | bool buttonc(); |
gaku_sigu | 0:a919993ff50f | 27 | bool buttonz(); |
gaku_sigu | 0:a919993ff50f | 28 | |
gaku_sigu | 0:a919993ff50f | 29 | private: |
gaku_sigu | 0:a919993ff50f | 30 | Timer timer; |
gaku_sigu | 0:a919993ff50f | 31 | bool flag; |
gaku_sigu | 0:a919993ff50f | 32 | bool init(); |
gaku_sigu | 0:a919993ff50f | 33 | char data[6]; |
gaku_sigu | 0:a919993ff50f | 34 | void getdata(); |
gaku_sigu | 0:a919993ff50f | 35 | }; |
gaku_sigu | 0:a919993ff50f | 36 | |
gaku_sigu | 0:a919993ff50f | 37 | #endif |