Erwin Ried 3 лет назад
Родитель
Сommit
0bbe57b0ee

+ 0 - 9
esp32_marauder/CommandLine.ino

@@ -325,15 +325,6 @@ void CommandLine::runCommand(String input) {
   }
 #ifdef ESP32_CAM
 
-  else if (cmd_args.get(0) == CAM_STREAM) {
-    preferences.begin("esp32cam", false);
-    preferences.putBool("streaming", true);
-    preferences.putBool("return", false);
-    preferences.end();
-    Serial.print("Press reset to switch to\nstreaming mode. To get\nback, press reset twice\nwaiting a second between\npresses.");
-    for (;;) {}
-  }
-
   else if (cmd_args.get(0) == CAM_FLASHLIGHT) {
     pinMode(4, OUTPUT);
     digitalWrite(4, !digitalRead(4));

+ 9 - 18
esp32_marauder/esp32_marauder.ino

@@ -22,9 +22,6 @@
 #include <Arduino.h>
 #ifdef ESP32_CAM
 
-#include <Preferences.h>
-Preferences preferences;
-
 #include "FS.h"                // SD Card ESP32
 #include "SD_MMC.h"            // SD Card ESP32
 #include "esp_camera.h"
@@ -167,25 +164,19 @@ void setup()
     delay(10);*/
 
   Serial.begin(230400);
-  preferences.begin("esp32cam", false);
-  if (preferences.getBool("streaming", false))
+
+  unsigned long waitForStreamMode = millis() + 1000;
+
+  while (waitForStreamMode > millis())
   {
-    if (preferences.getBool("return", false))
+    if (Serial.available()) // if we receive anything, just switch to stream mode
     {
-      preferences.putBool("streaming", false);
-      preferences.end();
-      ESP.restart();
+      cam_stream_setup();
+      for (;;)
+        cam_stream_loop();
     }
-    preferences.putBool("return", true);
-    preferences.end();
-    delay(2000);
-    preferences.begin("esp32cam", false);
-    preferences.putBool("return", false);
-    preferences.end();
-    cam_stream_setup();
-    for (;;)
-      cam_stream_loop();
   }
+
   //Serial.begin(115200);
 
   //Serial.println("\n\nHello, World!\n");

+ 9 - 2
flipper_companion_apps/applications/plugins/esp32cam_camera/camera.c

@@ -255,6 +255,14 @@ static UartEchoApp* camera_app_alloc() {
     furi_hal_uart_set_br(FuriHalUartIdUSART1, 230400);
     furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, camera_on_irq_cb, app);
 
+    furi_hal_power_disable_external_3_3v();
+    furi_hal_power_disable_otg();
+    furi_delay_ms(100);
+    furi_hal_power_enable_external_3_3v();
+    furi_hal_power_enable_otg();
+    furi_delay_ms(600); 
+    furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){13}, 1); // Just to trigger the stream
+
     return app;
 }
 
@@ -286,8 +294,7 @@ static void camera_app_free(UartEchoApp* app) {
 
 int32_t camera_app(void* p) {
     UNUSED(p);
-    furi_hal_power_enable_otg();
-    furi_delay_ms(300);
+
     UartEchoApp* app = camera_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     camera_app_free(app);

+ 3 - 3
flipper_companion_apps/applications/plugins/esp32cam_marauder_companion/scenes/wifi_marauder_scene_start.c

@@ -112,9 +112,9 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
      FOCUS_CONSOLE_END,
      NO_TIP},
      {"Camera",
-     {"photo", "flashlight", "stream"},
-     3,
-     {"photo", "flashlight", "stream"},
+     {"photo", "flashlight"},
+     2,
+     {"photo", "flashlight"},
      NO_ARGS,
      FOCUS_CONSOLE_END,
      NO_TIP},

+ 4 - 1
flipper_companion_apps/applications/plugins/esp32cam_marauder_companion/wifi_marauder_app.c

@@ -92,8 +92,11 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
 
 int32_t wifi_marauder_app(void* p) {
     UNUSED(p);
+    furi_hal_power_disable_external_3_3v();
+    furi_hal_power_disable_otg();
+    furi_delay_ms(100);
+    furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    furi_delay_ms(300);
 
     WifiMarauderApp* wifi_marauder_app = wifi_marauder_app_alloc();