Procházet zdrojové kódy

CameraSuite: Icons, GPIO channel

Willy-JL před 2 roky
rodič
revize
cd6dc6a5a3

+ 0 - 1
.modules/camera_suite/fap/application.fam

@@ -7,7 +7,6 @@ App(
     fap_category="GPIO",
     fap_category="GPIO",
     fap_description="A camera suite application for the Flipper Zero ESP32-CAM module.",
     fap_description="A camera suite application for the Flipper Zero ESP32-CAM module.",
     fap_icon="icons/camera_suite.png",
     fap_icon="icons/camera_suite.png",
-    fap_libs=["assets"],
     fap_version="1.3",
     fap_version="1.3",
     fap_weburl="https://github.com/CodyTolene/Flipper-Zero-Cam",
     fap_weburl="https://github.com/CodyTolene/Flipper-Zero-Cam",
     name="[ESP32] Camera Suite",
     name="[ESP32] Camera Suite",

+ 25 - 17
.modules/camera_suite/fap/views/camera_suite_view_camera.c

@@ -193,11 +193,11 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
         case InputKeyBack: {
         case InputKeyBack: {
             // Set the camera flash to off.
             // Set the camera flash to off.
             uint8_t flash_off = 'f';
             uint8_t flash_off = 'f';
-            furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_off, 1);
+            furi_hal_uart_tx(UART_CH, &flash_off, 1);
             furi_delay_ms(50);
             furi_delay_ms(50);
             // Stop camera stream.
             // Stop camera stream.
             uint8_t stop_camera = 's';
             uint8_t stop_camera = 's';
-            furi_hal_uart_tx(FuriHalUartIdUSART1, &stop_camera, 1);
+            furi_hal_uart_tx(UART_CH, &stop_camera, 1);
             // Go back to the main menu.
             // Go back to the main menu.
             with_view_model(
             with_view_model(
                 instance->view,
                 instance->view,
@@ -292,11 +292,11 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
                     // Save picture directly to ESP32-CAM.
                     // Save picture directly to ESP32-CAM.
                     // @todo - Add this functionality.
                     // @todo - Add this functionality.
                     // data[0] = 'P';
                     // data[0] = 'P';
-                    // furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+                    // furi_hal_uart_tx(UART_CH, data, 1);
 
 
                     // if(model->flash) {
                     // if(model->flash) {
                     //     data[0] = 'F';
                     //     data[0] = 'F';
-                    //     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+                    //     furi_hal_uart_tx(UART_CH, data, 1);
                     //     furi_delay_ms(50);
                     //     furi_delay_ms(50);
                     // }
                     // }
 
 
@@ -320,7 +320,7 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
 
 
         if(data[0] != 'X') {
         if(data[0] != 'X') {
             // Send `data` to the ESP32-CAM.
             // Send `data` to the ESP32-CAM.
-            furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+            furi_hal_uart_tx(UART_CH, data, 1);
         }
         }
     }
     }
     return true;
     return true;
@@ -331,12 +331,12 @@ static void camera_suite_view_camera_exit(void* context) {
 
 
     // Set the camera flash to off.
     // Set the camera flash to off.
     uint8_t flash_off = 'f';
     uint8_t flash_off = 'f';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_off, 1);
+    furi_hal_uart_tx(UART_CH, &flash_off, 1);
     furi_delay_ms(50);
     furi_delay_ms(50);
 
 
     // Stop camera stream.
     // Stop camera stream.
     uint8_t stop_camera = 's';
     uint8_t stop_camera = 's';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &stop_camera, 1);
+    furi_hal_uart_tx(UART_CH, &stop_camera, 1);
     furi_delay_ms(50);
     furi_delay_ms(50);
 }
 }
 
 
@@ -351,28 +351,28 @@ static void camera_suite_view_camera_enter(void* context) {
 
 
     // Start camera stream.
     // Start camera stream.
     uint8_t start_camera = 'S';
     uint8_t start_camera = 'S';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &start_camera, 1);
+    furi_hal_uart_tx(UART_CH, &start_camera, 1);
     furi_delay_ms(75);
     furi_delay_ms(75);
 
 
     // Get/set dither type.
     // Get/set dither type.
     uint8_t dither_type = instance_context->dither;
     uint8_t dither_type = instance_context->dither;
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &dither_type, 1);
+    furi_hal_uart_tx(UART_CH, &dither_type, 1);
     furi_delay_ms(75);
     furi_delay_ms(75);
 
 
     // Make sure the camera is not inverted.
     // Make sure the camera is not inverted.
     uint8_t invert_camera = 'i';
     uint8_t invert_camera = 'i';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &invert_camera, 1);
+    furi_hal_uart_tx(UART_CH, &invert_camera, 1);
     furi_delay_ms(75);
     furi_delay_ms(75);
 
 
     // Toggle flash on or off based on the current state. This will keep the
     // 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.
     // flash on initially. However we're toggling it for now on input.
     uint8_t flash_state = instance_context->flash ? 'F' : 'f';
     uint8_t flash_state = instance_context->flash ? 'F' : 'f';
-    furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_state, 1);
+    furi_hal_uart_tx(UART_CH, &flash_state, 1);
     furi_delay_ms(75);
     furi_delay_ms(75);
 
 
     // Make sure we start with the flash off.
     // Make sure we start with the flash off.
     // uint8_t flash_state = 'f';
     // uint8_t flash_state = 'f';
-    // furi_hal_uart_tx(FuriHalUartIdUSART1, &flash_state, 1);
+    // furi_hal_uart_tx(UART_CH, &flash_state, 1);
     // furi_delay_ms(75);
     // furi_delay_ms(75);
 
 
     with_view_model(
     with_view_model(
@@ -521,13 +521,17 @@ CameraSuiteViewCamera* camera_suite_view_camera_alloc() {
     furi_thread_start(instance->worker_thread);
     furi_thread_start(instance->worker_thread);
 
 
     // Enable uart listener
     // Enable uart listener
-    furi_hal_console_disable();
+    if(UART_CH == UART_CH) {
+        furi_hal_console_disable();
+    } else if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_init(UART_CH, 230400);
+    }
 
 
     // 115200 is the default baud rate for the ESP32-CAM.
     // 115200 is the default baud rate for the ESP32-CAM.
-    furi_hal_uart_set_br(FuriHalUartIdUSART1, 230400);
+    furi_hal_uart_set_br(UART_CH, 230400);
 
 
     // Enable UART1 and set the IRQ callback.
     // Enable UART1 and set the IRQ callback.
-    furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, camera_on_irq_cb, instance);
+    furi_hal_uart_set_irq_cb(UART_CH, camera_on_irq_cb, instance);
 
 
     return instance;
     return instance;
 }
 }
@@ -536,7 +540,7 @@ void camera_suite_view_camera_free(CameraSuiteViewCamera* instance) {
     furi_assert(instance);
     furi_assert(instance);
 
 
     // Remove the IRQ callback.
     // Remove the IRQ callback.
-    furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, NULL, NULL);
+    furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
 
 
     // Free the worker thread.
     // Free the worker thread.
     furi_thread_free(instance->worker_thread);
     furi_thread_free(instance->worker_thread);
@@ -545,7 +549,11 @@ void camera_suite_view_camera_free(CameraSuiteViewCamera* instance) {
     furi_stream_buffer_free(instance->rx_stream);
     furi_stream_buffer_free(instance->rx_stream);
 
 
     // Re-enable the console.
     // Re-enable the console.
-    // furi_hal_console_enable();
+    if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_deinit(UART_CH);
+    } else {
+        furi_hal_console_enable();
+    }
 
 
     with_view_model(
     with_view_model(
         instance->view, UartDumpModel * model, { UNUSED(model); }, true);
         instance->view, UartDumpModel * model, { UNUSED(model); }, true);

+ 6 - 0
.modules/camera_suite/fap/views/camera_suite_view_camera.h

@@ -16,6 +16,12 @@
 #include <storage/filesystem_api_defines.h>
 #include <storage/filesystem_api_defines.h>
 #include <storage/storage.h>
 #include <storage/storage.h>
 
 
+#include <xtreme.h>
+
+#define UART_CH                                                                 \
+    (XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
+                                                          FuriHalUartIdLPUART1)
+
 #define BITMAP_HEADER_LENGTH 62
 #define BITMAP_HEADER_LENGTH 62
 #define FRAME_BIT_DEPTH 1
 #define FRAME_BIT_DEPTH 1
 #define FRAME_BUFFER_LENGTH 1024
 #define FRAME_BUFFER_LENGTH 1024