diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-06-12 12:19:09 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-06-12 13:21:49 +0200 |
commit | f6655dbb1377bc84602c0e7b823a10acc3b8c2b0 (patch) | |
tree | 19fe5aedff08af4a331f3b9c6040afb6645d7355 | |
parent | 758d63ed70e03ecf26c4538b0c452b3fb9251c70 (diff) | |
download | code-f6655dbb1377bc84602c0e7b823a10acc3b8c2b0.tar.gz |
simplify state change from uninit
-rw-r--r-- | Venus_Skeleton/Venus_Skeleton.ino | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/Venus_Skeleton/Venus_Skeleton.ino b/Venus_Skeleton/Venus_Skeleton.ino index 7718d8a..c3832c1 100644 --- a/Venus_Skeleton/Venus_Skeleton.ino +++ b/Venus_Skeleton/Venus_Skeleton.ino @@ -1,6 +1,5 @@ // TODO // -// - limit sendData to x per second // - errorSequence() // - insert into calibration files // - Make sure ENUM piDataType is correct and synced @@ -80,7 +79,7 @@ unsigned long lastCommunication = 0; // Current operation mode opmode_t operationMode = OPMODE_WAIT; -opmode_t operationModeDefault = OPMODE_INITIALSEQUENCE; +boolean initialized = false; unsigned long operationChange = 0; // Location values @@ -191,14 +190,6 @@ void initTurretSequence(int array[], int numOfPositions) { // ** PI COMMUNICATION ** // ********************** -// sendData to Raspberry Pi -void sendData(pi_datatype_t method, int data, int data1, int data2, int data3) { - if (1 == 1) { - lastCommunication = millis(); - } - -} - void interpretData(pi_datatype_t dataType, int message) { switch(dataType) { case PI_DATATYPE_MOVETO: @@ -908,29 +899,27 @@ void loop() { // calculateOrientation(); // calculateLocationOffset(); - if (checkRPiActive()) { - operationModeDefault = (operationModeDefault == OPMODE_INITIALSEQUENCE ? OPMODE_INITIALSEQUENCE : OPMODE_WAIT); - //sendData(PI_DATATYPE_ALL, 'lala', 'lala'); - //readData(); - } else { - // STANDALONE ALGORITHM - operationModeDefault = (operationModeDefault == OPMODE_INITIALSEQUENCE ? OPMODE_INITIALSEQUENCE : OPMODE_MAPPING); - } - dataToPiChangedBits = 0; // Clear changed bits - + // TODO integrate pi communications switch(operationMode) { case OPMODE_WAIT: counterMovement = 0; timerMovementStart = 0; timerMovementStop = 0; - opMode(operationModeDefault); + if (!initialized) { + // whenever the initial sequence to locate the robot has not happened, + // keep performing that sequence + opMode(OPMODE_INITIALSEQUENCE); + } else { + // goto standalone algorithm when idle + opMode(OPMODE_MAPPING); + } turnTurretToNext(); break; case OPMODE_INITIALSEQUENCE: initialSequence(); - operationModeDefault = OPMODE_WAIT; + initialized = true; break; case OPMODE_RANDOM: |