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.
Dependents: robocon2017mbed_control_R
Fork of MyLib by
Diff: Nunchuck/Nunchuck.cpp
- Revision:
- 3:e7a900958f54
- Parent:
- 2:7b7821addb45
- Child:
- 4:ae9dc8d5c37e
--- a/Nunchuck/Nunchuck.cpp Thu May 11 07:10:17 2017 +0000
+++ b/Nunchuck/Nunchuck.cpp Thu May 11 07:31:39 2017 +0000
@@ -13,7 +13,7 @@
bool Nunchuck::init()
{
unsigned char cmd[] = {0x40, 0x00};
- if (I2C::write(ADDR, (const char*)cmd, sizeof(cmd)) == 0)
+ if (I2C::write(NUNCHUCK_ADDR, (const char*)cmd, sizeof(cmd)) == 0)
return 1;
else
return 0;
@@ -49,8 +49,8 @@
getdata();
int8_t temp;
temp = data[0] - 128;
-#if ANALOGDATA
- if(-1*(DEADZONE) < temp && temp < DEADZONE)
+#if NUNCHUCK_ANALOGDATA
+ if(-1*(NUNCHUCK_DEADZONE) < temp && temp < NUNCHUCK_DEADZONE)
temp = 0;
#else
if(-50 < temp && temp < 50)
@@ -69,8 +69,8 @@
getdata();
int8_t temp;
temp = data[1] - 128;
-#if ANALOGDATA
- if(-1*(DEADZONE) < temp && temp < DEADZONE)
+#if NUNCHUCK_ANALOGDATA
+ if(-1*(NUNCHUCK_DEADZONE) < temp && temp < NUNCHUCK_DEADZONE)
temp = 0;
#else
if(-50 < temp && temp < 50)
@@ -84,6 +84,14 @@
}
+double Nunchuck::analograd()
+{
+ double x = analogx();
+ double y = analogy();
+
+ return atan2(y,x);
+}
+
int Nunchuck::accx()
{
getdata();
