/* WiiNun.cpp (c)2012 kou029w - MIT License [http://kou029w.appspot.com/mit-license.txt] */ #if defined(ARDUINO) && ARDUINO >= 100 #include #else #include #endif #include #include "WiiNun.h" void WiiNun::begin(){ Wire.begin(); Wire.beginTransmission(0x52); Wire.write(0x40); // sends memory address Wire.write(0x00); Wire.endTransmission(); } byte WiiNun::_decodeByte(byte x){ x = (x ^ 0x17) + 0x17; return x; } void WiiNun::get(){ byte i=0; Wire.requestFrom(0x52, 6); while(Wire.available() || i<6){ WiiNun::data[i] = WiiNun::_decodeByte(Wire.read()); i++; } Wire.beginTransmission(0x52); Wire.write(0x00); Wire.endTransmission(); }