REmove remaining components from ble

This commit is contained in:
Matt McWilliams 2023-06-28 12:43:24 -04:00
parent b48c498574
commit bf320216cf
1 changed files with 5 additions and 45 deletions

View File

@ -54,12 +54,9 @@ void connectBLE () {
void loop() void loop()
{ {
now = millis(); now = millis();
cmdChar = mc.loop();
cmd(cmdChar);
// Shutter // Shutter
if (digitalRead(SHUTTTER_BTN) == LOW && connected){ if (connected){ //&&
camera(); camera();
} }
@ -68,64 +65,27 @@ void loop()
} }
if (!bleInit && mc.connected && mc.identified) { if (!bleInit && mc.connected && mc.identified) {
mc.log("Initializing BLE..."); //mc.log("Initializing BLE...");
canon_ble.init(); canon_ble.init();
bleInit = true; bleInit = true;
delay(1000); delay(1000);
} }
if (!connected && mc.connected && mc.identified) { if (!connected && mc.connected && mc.identified) {
mc.log("Connecting BLE..."); //mc.log("Connecting BLE...");
connectBLE(); connectBLE();
} }
} }
void cmd (char val) {
if (val == mc.CAMERA && connected) {
camera();
} else if (val == mc.CAMERA_FORWARD) {
camera_direction(true);
} else if (val == mc.CAMERA_BACKWARD) {
camera_direction(false);
} else if (val == mc.STATE) {
state();
}
}
void camera () { void camera () {
long start = now; long start = now;
long end; long end;
digitalWrite(GREEN_LED, HIGH); //mc.log("Shutter pressed");
digitalWrite(RED_LED, HIGH);
mc.log("Shutter pressed");
if(!canon_ble.trigger()){ if(!canon_ble.trigger()){
mc.log("camera() failed"); //mc.log("camera() failed");
} }
end = millis(); end = millis();
delay(cameraFrame - (end - start));
digitalWrite(GREEN_LED, HIGH);
digitalWrite(RED_LED, LOW);
last = millis();
mc.confirm(mc.CAMERA);
} }
//null route direction
void camera_direction (boolean state) {
if (state) {
mc.confirm(mc.CAMERA_FORWARD);
mc.log("camera_direction(true)");
} else {
mc.confirm(mc.CAMERA_BACKWARD);
mc.log("camera_direction(false)");
}
}
void state () {
String stateString = String(mc.CAMERA_EXPOSURE);
stateString += String(cameraFrame);
stateString += String(mc.STATE);
mc.print(stateString);
}