working commands. singleton deleted
Revision 5:47cb37923f58, committed 2015-06-11
- Comitter:
- dkester
- Date:
- Thu Jun 11 20:57:59 2015 +0000
- Parent:
- 4:f81029197ab2
- Commit message:
- working 11 jun
Changed in this revision
IdleCommand.cpp | Show annotated file Show diff for this revision Revisions of this file |
TrainingCommand.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f81029197ab2 -r 47cb37923f58 IdleCommand.cpp --- a/IdleCommand.cpp Thu Jun 11 10:42:50 2015 +0000 +++ b/IdleCommand.cpp Thu Jun 11 20:57:59 2015 +0000 @@ -1,29 +1,30 @@ #include "IdleCommand.h" - -IdleCommand::IdleCommand(Sensors* sensors, GonioService* gonioService) { - this->sensors = sensors; - this->gonioService = gonioService; - } - -void IdleCommand::initialize(){ - + +IdleCommand::IdleCommand(Sensors* sensors, GonioService* gonioService) +{ + this->sensors = sensors; + this->gonioService = gonioService; +} + +void IdleCommand::initialize() +{ + printf("IdleCommand\n"); sensors->disableIMU(); setTicker(0.5); - } - -void IdleCommand::execute(){} - -void IdleCommand::button(){ - printf("**** BUTTON: IdleCommand *****\n"); - int16_t angle = (sensors->getAngle(0) << 8) + sensors->getAngle(1); - +} + +void IdleCommand::execute() {} + +void IdleCommand::button() +{ + int16_t angle = (sensors->getAngle(0) << 8) + sensors->getAngle(1); + //printf("%.2f,%d\n", ((float)angle) * 0.087912087, angle); - + sensors->updateAngle(); sensors->updateIMU(); - - + int16_t accel[3] = {0,0,0}; int16_t gyro[3] = {0,0,0}; @@ -33,19 +34,20 @@ gyro[0] = (sensors->getIMU(6)<<8)+sensors->getIMU(7); gyro[1] = (sensors->getIMU(8)<<8)+sensors->getIMU(9); gyro[2] = (sensors->getIMU(10)<<8)+sensors->getIMU(11); - - - if(gonioService->isConnected()){ + + + if(gonioService->isConnected()) { gonioService->updateGonio(angle,gyro[0],accel[0]); } - } - -void IdleCommand::finish(){ +} + +void IdleCommand::finish() +{ detachTicker(); setLed(0); - } - +} +
diff -r f81029197ab2 -r 47cb37923f58 TrainingCommand.cpp --- a/TrainingCommand.cpp Thu Jun 11 10:42:50 2015 +0000 +++ b/TrainingCommand.cpp Thu Jun 11 20:57:59 2015 +0000 @@ -2,14 +2,20 @@ int16_t dummyAngle = 0; +DigitalOut blue(p15); +DigitalOut data(p13); + TrainingCommand::TrainingCommand(Sensors* sensors, GonioService* gonioService) { this->sensors = sensors; this->gonioService = gonioService; + blue = 0; + data = 0; + } void TrainingCommand::initialize() -{ +{ dummyAngle = 1; setTicker(0.1); } @@ -34,7 +40,7 @@ //printf(" FREE FALL "); } //printf("status: %d\n", statusInt); - } + } if (readInt & 0x01) { //sensors->updateAngle(); @@ -45,12 +51,25 @@ peak = 0; } */ + + data = 1; + sensors->updateAngle(); + sensors->updateIMU(); + + int16_t angle = (sensors->getAngle(0) << 8) + sensors->getAngle(1); + //int16_t angle = (sensors->getAngleDummy(0) << 8) + sensors->getAngleDummy(1); + //__disable_irq(); + data = 0; - //sensors->updateAngle(); - //sensors->updateIMU(); - int16_t angle = (sensors->getAngleDummy(0) << 8) + sensors->getAngleDummy(1); - gonioService->updateGonio(angle,angle,angle); - dummyAngle++; + wait(0.001); + + if(gonioService->isConnected()) { + blue = 1; + gonioService->updateGonio(angle,angle,angle); + blue = 0; + } + + //__enable_irq(); } void TrainingCommand::button()