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

Merge pull request #8 from CodyTolene/ct/2-fix-crash-on-backout

[Issue #2] Resolve crash on backing out from the camera scene.
Cody Tolene 2 лет назад
Родитель
Сommit
c144ee3974
2 измененных файлов с 15 добавлено и 1 удалено
  1. 9 0
      src-fap/camera-suite.c
  2. 6 1
      src-fap/views/camera_suite_view_style_1.c

+ 9 - 0
src-fap/camera-suite.c

@@ -1,4 +1,5 @@
 #include "camera-suite.h"
+#include <stdlib.h>
 
 bool camera_suite_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -106,6 +107,14 @@ void camera_suite_app_free(CameraSuite* app) {
     view_dispatcher_free(app->view_dispatcher);
     furi_record_close(RECORD_GUI);
 
+    // Free remaining resources
+    camera_suite_view_start_free(app->camera_suite_view_start);
+    camera_suite_view_style_1_free(app->camera_suite_view_style_1);
+    camera_suite_view_style_2_free(app->camera_suite_view_style_2);
+    camera_suite_view_guide_free(app->camera_suite_view_guide);
+    button_menu_free(app->button_menu);
+    variable_item_list_free(app->variable_item_list);
+
     app->gui = NULL;
     app->notification = NULL;
 

+ 6 - 1
src-fap/views/camera_suite_view_style_1.c

@@ -111,7 +111,7 @@ static bool camera_suite_view_style_1_input(InputEvent* event, void* context) {
         switch(event->key) {
         case InputKeyBack:
             // Stop the camera stream.
-            data[0] = 'S';
+            data[0] = 's';
             // Go back to the main menu.
             with_view_model(
                 instance->view,
@@ -208,6 +208,11 @@ static void camera_suite_view_style_1_enter(void* context) {
     // Assign the current instance to the global variable
     current_instance = instance;
 
+    uint8_t data[1];
+    data[0] = 'S'; // Uppercase `S` to start the camera
+    // Send `data` to the ESP32-CAM
+    furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+
     with_view_model(
         instance->view,
         UartDumpModel * model,