Device to measure angle and get IMU measurements.
Dependencies: mbed commands BLE_API nRF51822
Diff: main.cpp
- Revision:
- 2:871b5efb2043
- Parent:
- 1:b44bd62c542f
- Child:
- 3:a3e1a06c486d
diff -r b44bd62c542f -r 871b5efb2043 main.cpp --- a/main.cpp Wed May 20 11:45:38 2015 +0000 +++ b/main.cpp Sat May 30 12:26:02 2015 +0000 @@ -1,65 +1,37 @@ #include "mbed.h" -#include "Sensors.h" -#include "Storage.h" +#include "GonioMeter.h" Serial pc(USBTX, USBRX); -DigitalOut led(p21); -InterruptIn button(p23); -Ticker ticker; - -void printSensors(void) -{ - Sensors* sensors = Sensors::getInstance(); - sensors->updateIMU(); - pc.printf("angle: %.2f\n", sensors->getAngle()); - pc.printf("accelerometer x: %d y: %d z: %d\n",sensors->getAccelX(),sensors->getAccelY(),sensors->getAccelZ()); - pc.printf("temperature: %.2f\n", sensors->getTemp()); - pc.printf("gyroscope x: %d y: %d z: %d\n\n",sensors->getGyroX(),sensors->getGyroY(),sensors->getGyroZ()); -} - -void buttonInt( void ) -{ - 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; - Sensors::getInstance()->setDMP(0x1a); - - ticker.attach(&motion,0.1); - //button.fall(&buttonInt); - + GonioMeter* goniometer = new GonioMeter(); + + pc.printf("Chose option\n"); + while(true) { - wait(0.001); + + if(pc.readable()){ + + char command = pc.getc(); + + switch(command){ + case 'a': + pc.printf("een\n"); + goniometer->setMode(0); + break; + case 'b': + pc.printf("twee\n"); + goniometer->setMode(1); + break; + case 'c': + pc.printf("drie\n"); + goniometer->setMode(2); + break; + } + } } }