Просмотр исходного кода

Bit of cleanup. Doesn't fix issue yet.

Cody Tolene 2 лет назад
Родитель
Сommit
5b49505a69
3 измененных файлов с 17 добавлено и 37 удалено
  1. 6 5
      camera_suite.h
  2. 1 0
      helpers/camera_suite_storage.h
  3. 10 32
      views/camera_suite_view_camera.c

+ 6 - 5
camera_suite.h

@@ -1,10 +1,5 @@
 #pragma once
 
-#include "helpers/camera_suite_storage.h"
-#include "scenes/camera_suite_scene.h"
-#include "views/camera_suite_view_guide.h"
-#include "views/camera_suite_view_start.h"
-#include "views/camera_suite_view_camera.h"
 #include <furi.h>
 #include <furi_hal.h>
 #include <gui/gui.h>
@@ -17,6 +12,12 @@
 #include <notification/notification_messages.h>
 #include <stdlib.h>
 
+#include "scenes/camera_suite_scene.h"
+#include "views/camera_suite_view_guide.h"
+#include "views/camera_suite_view_start.h"
+#include "views/camera_suite_view_camera.h"
+#include "helpers/camera_suite_storage.h"
+
 #define TAG "Camera Suite"
 
 typedef struct {

+ 1 - 0
helpers/camera_suite_storage.h

@@ -2,6 +2,7 @@
 #include <string.h>
 #include <storage/storage.h>
 #include <flipper_format/flipper_format_i.h>
+
 #include "../camera_suite.h"
 
 #define BOILERPLATE_SETTINGS_FILE_VERSION 1

+ 10 - 32
views/camera_suite_view_camera.c

@@ -290,22 +290,12 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
                     camera_suite_led_set_rgb(instance->context, 0, 0, 255);
 
                     // Save picture directly to ESP32-CAM.
-                    // @todo - Add this functionality.
+                    // @todo - Future functionality.
                     // data[0] = 'P';
                     // furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
 
-                    // if(model->flash) {
-                    //     data[0] = 'F';
-                    //     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
-                    //     furi_delay_ms(50);
-                    // }
-
                     // Take a picture.
                     save_image(model);
-
-                    // if(model->flash) {
-                    //     data[0] = 'f';
-                    // }
                     instance->callback(CameraSuiteCustomEventSceneCameraOk, instance->context);
                 },
                 true);
@@ -329,11 +319,6 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
 static void camera_suite_view_camera_exit(void* context) {
     UNUSED(context);
 
-    // Set the camera flash to off.
-    uint8_t flash_off = 'f';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_off, 1);
-    furi_delay_ms(50);
-
     // Stop camera stream.
     uint8_t stop_camera = 's';
     furi_hal_uart_tx(FuriHalUartIdUSART1, &stop_camera, 1);
@@ -357,23 +342,16 @@ static void camera_suite_view_camera_enter(void* context) {
     // Get/set dither type.
     uint8_t dither_type = instance_context->dither;
     furi_hal_uart_tx(FuriHalUartIdUSART1, &dither_type, 1);
-    furi_delay_ms(75);
-
-    // Make sure the camera is not inverted.
-    uint8_t invert_camera = 'i';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &invert_camera, 1);
-    furi_delay_ms(75);
-
-    // Toggle flash on or off based on the current state. This will keep the
-    // flash on initially. However we're toggling it for now on input.
-    uint8_t flash_state = instance_context->flash ? 'F' : 'f';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_state, 1);
-    furi_delay_ms(75);
+    furi_delay_ms(50);
 
-    // Make sure we start with the flash off.
-    // uint8_t flash_state = 'f';
-    // furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_state, 1);
-    // furi_delay_ms(75);
+    // The camera always starts `S` with the flash off. Check to see if the
+    // flash is enabled and send the appropriate command to the ESP32-CAM.
+    // The flash will stay on the entire time the user is in the camera view.
+    if(instance_context->flash) {
+        uint8_t flash_on = 'F';
+        furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_on, 1);
+        furi_delay_ms(50);
+    }
 
     with_view_model(
         instance->view,