Device to measure angle and get IMU measurements.
Dependencies: mbed commands BLE_API nRF51822
Diff: main.cpp
- Revision:
- 1:b44bd62c542f
- Parent:
- 0:1c5088dae6e1
- Child:
- 2:871b5efb2043
--- a/main.cpp Wed May 20 08:44:35 2015 +0000 +++ b/main.cpp Wed May 20 11:45:38 2015 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "Sensors.h" +#include "Storage.h" Serial pc(USBTX, USBRX); @@ -22,22 +23,43 @@ led = !led; } +void motion(void) +{ + //Sensors::getInstance()->setDMP(0x11); + pc.printf("Checking motion -> "); + if (Sensors::getInstance()->checkDMP()) { + led = 1; + pc.printf("MOTION! "); + } else { + led = 0; + } + + pc.printf("int enable: %d, ",Sensors::getInstance()->readRegister(0x38)); + pc.printf("th: %d, ",Sensors::getInstance()->readRegister(0x1f)); + pc.printf("status: %d ", Sensors::getInstance()->readRegister(0x61)); + pc.printf("int status: %d\n",Sensors::getInstance()->readRegister(0x3a)); + + printSensors(); + +} + +void memory(void) +{ + pc.printf("%d\n", Storage::getInstance()->setup()); +} + int main(void) { pc.baud(19200); led = 0; - - - ticker.attach(&printSensors,0.1); - button.fall(&buttonInt); + + Sensors::getInstance()->setDMP(0x1a); + + ticker.attach(&motion,0.1); + //button.fall(&buttonInt); while(true) { - /* - if(led == 1) { - printSensors(); - } - */ - wait(0.01); + wait(0.001); } }