Explorar el Código

Fix inversion issue.

Cody Tolene hace 2 años
padre
commit
593799b67c
Se han modificado 4 ficheros con 50 adiciones y 42 borrados
  1. 4 4
      arduino-cli.yaml
  2. 36 37
      fap/views/camera_suite_view_camera.c
  3. 1 1
      firmware/firmware.ino
  4. 9 0
      firware-flash.bat

+ 4 - 4
arduino-cli.yaml

@@ -1,15 +1,15 @@
 board_manager:
   additional_urls:
-  - https://dl.espressif.com/dl/package_esp32_index.json
+    - https://dl.espressif.com/dl/package_esp32_index.json
 build_cache:
   compilations_before_purge: 10
   ttl: 720h0m0s
 daemon:
   port: "50051"
 directories:
-  data: C:\Users\NULL\AppData\Local\Temp\arduino-cli\data
-  downloads: C:\Users\NULL\AppData\Local\Temp\arduino-cli\downloads
-  user: C:\Users\NULL\AppData\Local\Temp\arduino-cli\user
+  data: C:\temp\arduino-cli\data
+  downloads: C:\temp\arduino-cli\downloads
+  user: C:\temp\arduino-cli\user
 library:
   enable_unsafe_install: false
 logging:

+ 36 - 37
fap/views/camera_suite_view_camera.c

@@ -130,44 +130,27 @@ static void save_image(void* _model) {
     // If the file was opened successfully, write the bitmap header and the
     // image data.
     if(result) {
-        CameraSuite* app = current_instance->context;
-        if(app->flash) {
-            if(app->jpeg) {
-                // Turn on local jpeg save. When this is enabled the ESP32-CAM
-                // will save the image to the SD card and saving the image to
-                // the Flipper SD card will be disabled/skipped.
-                unsigned char jpeg_on = 'J';
-                furi_hal_uart_tx(FuriHalUartIdUSART1, &jpeg_on, 1);
-            } else {
-                unsigned char jpeg_off = 'j';
-                // Turn off local jpeg save.
-                furi_hal_uart_tx(FuriHalUartIdUSART1, &jpeg_off, 1);
-            }
-            // Initiate the onboard ESP32-CAM picture sequence. So far this
-            // includes turning on the flash and alternatively saving jpeg
-            // locally to the ESP32-CAM SD card if enabled.
-            unsigned char take_picture = 'P';
-            furi_hal_uart_tx(FuriHalUartIdUSART1, &take_picture, 1);
-        }
-        // If saving jpeg is enabled locally to the ESP32-CAM SD card, skip
-        // writing the image data to the Flipper Zero SD card.
-        if(!app->jpeg) {
-            // Write locally to the Flipper Zero SD card in the DCIM folder.
-            int8_t row_buffer[ROW_BUFFER_LENGTH];
-            if(is_inverted) {
-                for(size_t i = 64; i > 0; --i) {
-                    for(size_t j = 0; j < ROW_BUFFER_LENGTH; ++j) {
-                        row_buffer[j] = model->pixels[((i - 1) * ROW_BUFFER_LENGTH) + j];
-                    }
-                    storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
+        // Write BMP Header
+        storage_file_write(file, bitmap_header, BITMAP_HEADER_LENGTH);
+
+        // @todo - Add a function for saving the image directly from the
+        // ESP32-CAM to the Flipper Zero SD card.
+
+        // Write locally to the Flipper Zero SD card in the DCIM folder.
+        int8_t row_buffer[ROW_BUFFER_LENGTH];
+        if(is_inverted) {
+            for(size_t i = 0; i < 64; ++i) {
+                for(size_t j = 0; j < ROW_BUFFER_LENGTH; ++j) {
+                    row_buffer[j] = model->pixels[i * ROW_BUFFER_LENGTH + j];
                 }
-            } else {
-                for(size_t i = 0; i < 64; ++i) {
-                    for(size_t j = 0; j < ROW_BUFFER_LENGTH; ++j) {
-                        row_buffer[j] = model->pixels[i * ROW_BUFFER_LENGTH + j];
-                    }
-                    storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
+                storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
+            }
+        } else {
+            for(size_t i = 64; i > 0; --i) {
+                for(size_t j = 0; j < ROW_BUFFER_LENGTH; ++j) {
+                    row_buffer[j] = model->pixels[((i - 1) * ROW_BUFFER_LENGTH) + j];
                 }
+                storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
             }
         }
     }
@@ -343,7 +326,23 @@ static void camera_suite_view_camera_enter(void* context) {
         break;
     }
 
-    // Send `data` to the ESP32-CAM
+    // Send `data` as the dither type to the ESP32-CAM
+    furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+
+    // Wait for 50ms to make sure dither is set before sending any other commands.
+    furi_delay_ms(50);
+
+    // Initialize the camera with the selected flash option from options.
+    switch(instanceContext->flash) {
+    case 0: // Flash OFF
+        data[0] = 'f';
+        break;
+    case 1: // Flash ON
+        data[0] = 'F';
+        break;
+    }
+
+    // Send `data` as the flash bool to the ESP32-CAM
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
 
     with_view_model(

+ 1 - 1
firmware/firmware.ino

@@ -79,7 +79,7 @@ void loop()
       // Return the frame buffer back to the camera driver.
       esp_camera_fb_return(frame_buffer);
     }
-    delay(50);
+    delay(25);
   }
   // Handle any available serial input commands.
   handleSerialInput();

+ 9 - 0
firware-flash.bat

@@ -130,6 +130,15 @@ if !ERRORLEVEL! EQU 0 (
 :uploadSuccess
 echo.
 echo Firmware upload was successful.
+echo Cleaning up...
+echo Restoring default configs...
+arduino-cli %CONFIG_FILE% config set directories.data C:\temp\arduino-cli\data
+arduino-cli %CONFIG_FILE% config set directories.downloads C:\temp\arduino-cli\staging
+arduino-cli %CONFIG_FILE% config set directories.user C:\temp\arduino-cli\user
+set /p DELETE_TEMP="Would you like to delete the temporary files? (Y/N): "
+if /i "!DELETE_TEMP!"=="Y" (
+    rmdir /s /q %CLI_TEMP%
+)
 echo.
 echo Fin. Happy programming friend.
 echo.