Device to measure angle and get IMU measurements.
Dependencies: mbed commands BLE_API nRF51822
Diff: Controller.cpp
- Revision:
- 6:75263c93daf7
- Parent:
- 5:46947b447701
- Child:
- 8:c6345e8d607c
diff -r 46947b447701 -r 75263c93daf7 Controller.cpp --- a/Controller.cpp Sun Jun 07 14:11:26 2015 +0000 +++ b/Controller.cpp Sun Jun 07 21:58:02 2015 +0000 @@ -6,25 +6,26 @@ Controller::Controller() { - this->modeList.push_back(new TrainingCommand()); - this->modeList.push_back(new OfflineCommand()); - this->modeList.push_back(new ReadCommand()); - this->modeList.push_back(new IdleCommand()); - this->modeList.push_back(new SleepCommand()); + this->sensors = new Sensors(); + this->storage = new Storage(); + + this->modeList.push_back(new TrainingCommand(sensors)); + this->modeList.push_back(new OfflineCommand(sensors, storage)); + this->modeList.push_back(new ReadCommand(storage)); + this->modeList.push_back(new IdleCommand(sensors)); + this->modeList.push_back(new SleepCommand(sensors)); button.fall(this, &Controller::buttonInt); imu.fall(this, &Controller::imuInt); //Set idle command at startup this->currentMode = 3; - - while(Sensors::getInstance()->getFs() != 100) { - Sensors::getInstance()->setupIMU(); - wait(0.01); - Sensors::getInstance()->disableIMU(); - } - + + sensors->setupIMU(); + sensors->disableIMU(); + wait(0.1); this->modeList[currentMode]->initialize(); + } void Controller::setCommand(int n) @@ -47,9 +48,6 @@ void Controller::run() { - Sensors::getInstance()->setupIMU(); - Sensors::getInstance()->disableIMU(); - pc.baud(19200); while(1) { @@ -60,24 +58,18 @@ switch(command) { case '1': - pc.printf("een\n"); setCommand(0); - break; case '2': - pc.printf("twee\n"); setCommand(1); break; case '3': - pc.printf("drie\n"); setCommand(2); break; case '4': - pc.printf("vier\n"); setCommand(3); break; case '5': - pc.printf("vijf\n"); setCommand(4); break; }