Changeset 94b751c in pyramid
- Timestamp:
- 10/10/13 03:37:33 (7 years ago)
- Branches:
- master
- Children:
- f1b827c
- Parents:
- 0b675ba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/Puzzlebox_Pyramid/Puzzlebox_Pyramid.ino
r0b675ba r94b751c 37 37 38 38 39 #define DEBUG_OUTPUT 1 //1 for debug39 #define DEBUG_OUTPUT 0 // 1 for debug, 2 for verbose 40 40 41 41 … … 60 60 char _command; 61 61 byte _attention_threshold = 67; //treshold for launching Orbit helicopter 62 63 // Operation mode 64 boolean modeBluetooth = false; 65 boolean modeSerial = false; 66 boolean modeADK = false; 62 67 63 68 ///////////////MindWave Mobile Protocol/////////// … … 81 86 long lastReceivedPacket = 0; 82 87 long lastLoop = 0; 88 long thisLoop = 0; 83 89 boolean bigPacket = false; 84 90 … … 141 147 Serial.flush();//delete? 142 148 Serial1.flush(); 143 } 149 150 151 selectInput(); // Determine method for Pyramid control 152 153 154 } // setup 144 155 145 156 … … 151 162 void loop() { 152 163 153 parseBluetooth(); 154 155 // parseSerialInput(); 164 if (modeBluetooth) 165 parseBluetooth(); 166 167 else if (modeSerial) 168 parseSerialInput(); 169 170 171 //read from button 172 if (digitalRead(BUTTON_PIN)){ 173 RGB_Panel[11][0]=255; 174 RGB_Panel[11][1]=255; 175 RGB_Panel[11][2]=255; 176 digitalWrite(13,HIGH); 177 } 178 else { 179 RGB_Panel[11][0]=0; 180 RGB_Panel[11][1]=0; 181 RGB_Panel[11][2]=0; 182 digitalWrite(13,LOW); 183 } 156 184 157 185 ////Send Flight Command through IR Emitter//// 158 186 if (millis()-lastLoop>_IR_period) { 187 159 188 if(att_buff>_attention_threshold) { 160 189 _throttle=85; … … 166 195 167 196 Serial1.flush(); 197 168 198 } 169 199 200 thisLoop = millis() - lastLoop; 201 170 202 #if DEBUG_OUTPUT 171 Serial.print(" Attention:"); 172 Serial.print(att_buff); 173 Serial.print(" | Time per loop:"); 174 Serial.println(millis() - lastLoop, DEC); 203 Serial.print(" Attention:"); 204 Serial.print(att_buff); 205 Serial.print(" | Time per loop:"); 206 // Serial.println(millis() - lastLoop, DEC); 207 Serial.println(thisLoop); 208 #endif 209 175 210 lastLoop = millis(); 176 #endif177 211 178 212 } // if (millis()-lastLoop>_IR_period) … … 183 217 // ################################################################ 184 218 219 void selectInput() { 220 221 // Determine method for Pyramid control 222 223 while ( (! Serial.available()) & (! Serial1.available()) ); 224 225 if (Serial.available()) 226 modeSerial = true; 227 else if (Serial1.available()) 228 modeBluetooth = true; 229 230 } // selectInput 231 232 233 // ################################################################ 234 185 235 void parseBluetooth() { 186 236 … … 188 238 189 239 if(ReadOneByte() == 170) { 240 241 if (! modeBluetooth) 242 Serial.println("INFO: Bluetooth input command received, setting modeBluetooth"); 243 modeBluetooth = true; 190 244 191 245 if(ReadOneByte() == 170) { … … 239 293 240 294 if(bigPacket) { 241 Serial.print(" PoorQuality: ");295 Serial.print("SignalQuality: "); 242 296 Serial.print(poorQuality, DEC); 243 297 Serial.print(" Attention: "); … … 280 334 else { 281 335 #if DEBUG_OUTPUT 282 Serial.println("Checksum Error!");283 // Checksum Error336 Serial.println("Checksum Error!"); 337 // Checksum Error 284 338 #endif 285 339 } // end if else for checksum 286 340 } // end if read 0xAA byte (170) 287 341 } // end if read 0xAA byte (170) 288 289 //read from button290 if (digitalRead(BUTTON_PIN)){291 RGB_Panel[11][0]=255;292 RGB_Panel[11][1]=255;293 RGB_Panel[11][2]=255;294 digitalWrite(13,HIGH);295 }296 else {297 RGB_Panel[11][0]=0;298 RGB_Panel[11][1]=0;299 RGB_Panel[11][2]=0;300 digitalWrite(13,LOW);301 }302 303 342 304 343 } // parseBluetooth … … 762 801 if (Serial.available() > 0) { 763 802 803 if (! modeSerial) 804 Serial.println("INFO: Serial input command received, setting modeSerial"); 805 modeSerial = true; 806 764 807 // Serial.print("Serial.available(): "); 765 808 // Serial.println(Serial.available()); … … 789 832 } 790 833 } 834 835 sendCode(formCode(_throttle,_yaw,_pitch)); 836 delay(80); //originally 36, 51, 66, 80 791 837 792 838 } // parseSerialInput() 793 839 840 841 842 843 844
Note: See TracChangeset
for help on using the changeset viewer.