void OmniRobot::gamepadButton(int button, int pressed) { if (pressed == 0) return; switch (omniState) { case INIT_MODE: switch (button) { case 1: movementMode = ROTATE_MAX_MODE; break; case 2: movementMode = ROTATE_POINT_MODE; break; case 3: movementMode = ROTATE_MODE; break; case 5: movementMode = ANDROID_MODE; period = 10; break; } omniState = CONTROL_MODE; startControl(); break; case CONTROL_MODE: qDebug() << "INIT_MODE"; init(); omniState = INIT_MODE; brick.stop(); timer.stop(); disconnect(&timer, SIGNAL(timeout()), this, SLOT(omniControl())); break; default: brick.stop(); timer.stop(); disconnect(&timer, SIGNAL(timeout()), this, SLOT(omniControl())); } }
task main() { while(true) { omniControl(vexRT[Ch3], vexRT[Ch4], vexRT[Ch1]); } }
void OmniRobot::startControl() { brick.stop(); timer.stop(); qDebug() << "CONTROL_MODE"; connect(&timer, SIGNAL(timeout()), this, SLOT(omniControl())); timer.start(period); }
void OmniRobot::getButton(int code, int value) { if (value != 1) return; qDebug() << "INIT_MODE"; omniState = INIT_MODE; init(); brick.stop(); timer.stop(); disconnect(&timer, SIGNAL(timeout()), this, SLOT(omniControl())); }