Changeset faaefd5 in pyramid
- Timestamp:
- 10/24/13 19:18:33 (7 years ago)
- Branches:
- master
- Children:
- 33c578b
- Parents:
- 124e727
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/Puzzlebox_Pyramid/Puzzlebox_Pyramid.ino
r124e727 rfaaefd5 54 54 #define BUTTON_PIN 4 55 55 56 // PWM IR_frequency (in Hz) required by IR56 // PWM IR_frequency (in Hz) required by IR 57 57 #define IR_frequency 38400 58 58 byte _IR_period = 40; 59 59 60 // Global variables for controlling Orbit helicopter60 // Global variables for controlling Orbit helicopter 61 61 // variables start with "_" means global variable 62 62 #define DEFAULT_THROTTLE 0 … … 388 388 389 389 if(bigPacket) { 390 Serial.print("SignalQuality: "); 391 Serial.print(poorQuality, DEC); 392 Serial.print(" Attention: "); 393 Serial.print(attention, DEC); 394 Serial.print(" Meditation: "); 395 Serial.print(meditation, DEC); 396 Serial.print(" Time since last packet: "); 397 Serial.print(millis() - lastReceivedPacket, DEC); 390 391 #if DEBUG_OUTPUT 392 Serial.print("SignalQuality: "); 393 Serial.print(poorQuality, DEC); 394 Serial.print(" Attention: "); 395 Serial.print(attention, DEC); 396 Serial.print(" Meditation: "); 397 Serial.print(meditation, DEC); 398 Serial.print(" Time since last packet: "); 399 Serial.print(millis() - lastReceivedPacket, DEC); 400 Serial.print("\n"); 401 #endif 398 402 lastReceivedPacket = millis(); 399 Serial.print("\n");400 403 401 404 … … 1039 1042 void updateFrameADK() { 1040 1043 1041 Serial.print("updateFrameADK(): "); 1042 Serial.print("eegSignal: "); 1043 Serial.print(eegSignal, DEC); 1044 Serial.print(" | eegAttention: "); 1045 Serial.print(eegAttention, DEC); 1046 Serial.print(" | eegMeditation: "); 1047 Serial.print(eegMeditation, DEC); 1048 Serial.print(" | eegPower: "); 1049 Serial.println(eegPower, DEC); 1050 1051 1052 setColorWheel(0, 0, 0); // black 1044 #if DEBUG_OUTPUT 1045 Serial.print("eegSignal: "); 1046 Serial.print(eegSignal, DEC); 1047 Serial.print(" | eegAttention: "); 1048 Serial.print(eegAttention, DEC); 1049 Serial.print(" | eegMeditation: "); 1050 Serial.print(eegMeditation, DEC); 1051 Serial.print(" | eegPower: "); 1052 Serial.println(eegPower, DEC); 1053 Serial.println(); 1054 1055 Serial.print("Thottle: "); 1056 Serial.print(_throttle, DEC); 1057 Serial.print(" | Yaw: "); 1058 Serial.print(_yaw, DEC); 1059 Serial.print(" | Pitch: "); 1060 Serial.println(_pitch, DEC); 1061 #endif 1062 1063 // setColorWheel(0, 0, 0); // black 1053 1064 1054 1065 … … 1059 1070 RGB_Panel[5][2]=0; 1060 1071 } else { 1061 setColorWheel(255, 0, 0); // red 1062 // RGB_Panel[5][0]=0; 1063 // RGB_Panel[5][1]=0; 1064 // RGB_Panel[5][2]=0; 1065 return; 1066 } 1067 1072 RGB_Panel[5][0]=0; 1073 RGB_Panel[5][1]=63; 1074 RGB_Panel[5][2]=0; 1075 // The following two lines can optionally be used 1076 // to set all lights to red to indicate ADK mode 1077 // when the EEG signal quality is insufficient for processing 1078 // setColorWheel(255, 0, 0); // red 1079 // return; 1080 } 1081 1082 1068 1083 int attention = calculateMeter(eegAttention); 1069 1084 int meditation = calculateMeter(eegMeditation); 1070 1071 1072 // for(int i=6; i<=6+attention; i++){1073 // RGB_Panel[i][0]=255;1074 // RGB_Panel[i][1]=0;1075 // RGB_Panel[i][2]=0;1076 // }1077 //1078 // if (meditation==6){1079 // RGB_Panel[11][0]=0;1080 // RGB_Panel[11][1]=0;1081 // RGB_Panel[11][2]=255;1082 // }1083 //1084 // for(int i=4; i>=4-meditation; i--){1085 // RGB_Panel[i][0]=0;1086 // RGB_Panel[i][1]=0;1087 // RGB_Panel[i][2]=255;1088 // }1089 //1090 // if (attention==6)1091 // RGB_Panel[11][0]=255;1092 //1093 // for(int i=6+attention; i<=11; i++){1094 // RGB_Panel[i][0]=0;1095 // RGB_Panel[i][1]=0;1096 // RGB_Panel[i][2]=0;1097 // }1098 //1099 // for(int i=4-meditation; i>=0; i--){1100 // RGB_Panel[i][0]=0;1101 // RGB_Panel[i][1]=0;1102 // RGB_Panel[i][2]=0;1103 // }1104 1085 1105 1086 … … 1110 1091 RGB_Panel[i][2]=0; 1111 1092 } 1112 //for(int i=6+attention; i<11; i++) {1113 //RGB_Panel[i][0]=0;1114 //RGB_Panel[i][1]=0;1115 //RGB_Panel[i][2]=0;1116 //}1093 for(int i=6+attention; i<11; i++) { 1094 RGB_Panel[i][0]=0; 1095 RGB_Panel[i][1]=0; 1096 RGB_Panel[i][2]=0; 1097 } 1117 1098 1118 1099 //light up & dim blue LED according to meditation level … … 1122 1103 RGB_Panel[i][2]=255; 1123 1104 } 1124 //for(int i=4-meditation; i>-1; i--) {1125 //RGB_Panel[i][0]=0;1126 //RGB_Panel[i][1]=0;1127 //RGB_Panel[i][2]=0;1128 //}1105 for(int i=4-meditation; i>-1; i--) { 1106 RGB_Panel[i][0]=0; 1107 RGB_Panel[i][1]=0; 1108 RGB_Panel[i][2]=0; 1109 } 1129 1110 1130 1111 … … 1133 1114 RGB_Panel[11][1]=255; 1134 1115 RGB_Panel[11][2]=255; 1135 _throttle=_throttle_hover;1136 Serial.println("Throttle On");1116 // _throttle=_throttle_hover; 1117 // Serial.println("Throttle On"); 1137 1118 } else { 1138 1119 RGB_Panel[11][0]=0; 1139 1120 RGB_Panel[11][1]=0; 1140 1121 RGB_Panel[11][2]=0; 1141 _throttle=0;1142 Serial.println("Throttle Off");1122 // _throttle=0; 1123 // Serial.println("Throttle Off"); 1143 1124 } // eegPower 1125 1126 1127 sendFrame(0); 1144 1128 1145 1129 … … 1149 1133 // ################################################################ 1150 1134 1151 void setOrbitThrottle(int throttle) {1152 1153 setColorWheel(255,255,0); // Yellow1154 1155 _throttle=throttle;1156 setThrottle();1157 sendCode(formCode(_throttle,_yaw,_pitch));1158 delay(80); // originally 36, 51, 66, 801159 1160 } // setOrbitThrottle()1135 // void setOrbitThrottle(int throttle) { 1136 // 1137 // setColorWheel(255,255,0); // Yellow 1138 // 1139 // _throttle=throttle; 1140 // setThrottle(); 1141 // sendCode(formCode(_throttle,_yaw,_pitch)); 1142 // delay(80); // originally 36, 51, 66, 80 1143 // 1144 // } // setOrbitThrottle() 1161 1145 1162 1146 … … 1187 1171 1188 1172 if (msg[0] == 0x1) { 1189 Serial.println("0x1");1173 // Serial.println("0x1"); 1190 1174 eegSignal = (int)msg[1]; 1191 Serial.println(eegSignal);1175 // Serial.println(eegSignal); 1192 1176 } 1193 1177 1194 1178 else if(msg[0] == 0x2) { 1195 Serial.println("0x2");1196 1179 eegAttention = (int)msg[1]; 1197 Serial.println(eegAttention);1198 1180 } 1199 1181 1200 1182 else if (msg[0] == 0x3) { 1201 Serial.println("0x3");1202 1183 eegMeditation = (int)msg[1]; 1203 Serial.println(eegMeditation);1204 1184 } 1205 1185 1206 1186 else if (msg[0] == 0x4) { 1207 Serial.println("0x4");1208 1187 eegPower = (int)msg[1]; 1209 Serial.println(eegPower);1210 1188 } 1211 1189 1212 1190 else if(msg[0] == 0x5) { 1213 Serial.println("0x5");1214 1191 _throttle = (int)msg[1]; 1215 Serial.println(_throttle);1216 1192 } 1217 1193 1218 1194 else if (msg[0] == 0x6) { 1219 Serial.println("0x6");1220 1195 _yaw = (int)msg[1]; 1221 Serial.println(_yaw);1222 1196 } 1223 1197 1224 1198 else if (msg[0] == 0x7) { 1225 Serial.println("0x7");1226 1199 _pitch = (int)msg[1]; 1227 Serial.println(_pitch);1228 1200 } 1229 1201 1230 1202 else if (msg[0] == 0x8) { 1231 Serial.println("0x8");1232 1203 if (msg[1] == 0x1) 1233 1204 _channel = 'A'; … … 1236 1207 else if (msg[1] == 0x3) 1237 1208 _channel = 'C'; 1238 Serial.println(_channel);1239 1209 } 1240 1210 1241 1211 1242 1212 // Orbit Hover 1243 elseif (msg[0] == 0x9) {1213 if (msg[0] == 0x9) { 1244 1214 1245 1215 if (msg[1] == 0x1) { 1246 setColorWheel(255,255,255); // White1216 setColorWheel(255,255,255); // white 1247 1217 _throttle = _throttle_hover; 1248 1218 _yaw = DEFAULT_YAW; … … 1250 1220 } 1251 1221 else if (msg[1] == 0x0) { 1252 setColorWheel(255,0,0); // Red1222 setColorWheel(255,0,0); // red 1253 1223 _throttle = DEFAULT_THROTTLE; 1254 1224 _yaw = DEFAULT_YAW; … … 1256 1226 } 1257 1227 1228 } else { 1229 // Update the color wheel with all values if not forcing hover mode 1230 updateFrameADK(); 1258 1231 } // Hover 1259 1260 1261 // // updateFrame(eegAttention, eegMeditation, eegSignal); 1262 // updateFrameADK(); 1263 1232 1264 1233 1265 1234 } // len … … 1274 1243 } // parseADK 1275 1244 1245 1246
Note: See TracChangeset
for help on using the changeset viewer.