case NEW_DATA:
/* Stupid way of controlling the robot by
* pluggin in and out start connector. */
- if (instance->start) {
- robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
- } else {
- robot.hw_status[STATUS_STA] = HW_STATUS_OK;
- }
switch (robot.state) {
case POWER_ON:
+ if (instance->start) {
+ robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
+ } else {
+ robot.hw_status[STATUS_STA] = HW_STATUS_OK;
+ }
if (!instance->start) {
robot.state = START_PLUGGED_IN;
printf("START_PLUGGED_IN\n");
break;
case START_PLUGGED_IN:
+ robot.hw_status[STATUS_STA] = HW_STATUS_OK;
/* Competition starts when plugged out */
if (instance->start) {
FSM_SIGNAL(MAIN, EV_START, NULL);
}
break;
- case COMPETITION_STARTED:
+ case COMPETITION_STARTED: {
/* Subsequent plug-in stops the robot */
+ static int num = 0;
if (!instance->start) {
- //robot_exit();
+ robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
+ if (++num == 10)
+ robot_exit();
}
break;
+ }
}
last_instance = *instance;
break;