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

Make flash a configurable option. Update readme.

Cody Tolene 2 лет назад
Родитель
Сommit
aa46a5da93

+ 3 - 1
README.md

@@ -122,7 +122,7 @@ Note the upload may fail a few times, this is normal, try again. If it still fai
 
 ▶️ = Toggle dithering on/off.
 
-⚪ = Cycle Floyd–Steinberg/Jarvis-Judice-Ninke/Stucki dithering types.
+⚪ = Take a picture and save to the "DCIM" folder at the root of your SD card. Image will be saved as a bitmap file with a timestamp as the filename ("YYYYMMDD-HHMMSS.bmp"). If flash is on in the settings (enabled by default) the ESP32-CAM onboard LED will light up when the picture is taken.
 
 ↩️ = Go back.
 
@@ -130,6 +130,8 @@ Note the upload may fail a few times, this is normal, try again. If it still fai
 
 **Orientation** = Rotate the camera image 90 degrees counter-clockwise starting at zero by default (0, 90, 180, 270). This is useful if you have your camera module mounted in a different orientation than the default.
 
+**Dithering Type** Change between the Cycle Floyd–Steinberg, Jarvis-Judice-Ninke, and Stucki dithering types.
+
 **Haptic FX** = Toggle haptic feedback on/off.
 
 **Sound FX** = Toggle sound effects on/off.

+ 1 - 1
src-fap/application.fam

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

+ 4 - 3
src-fap/camera_suite.c

@@ -45,9 +45,10 @@ CameraSuite* camera_suite_app_alloc() {
     // Set defaults, in case no config loaded
     app->orientation = 0; // Orientation is "portrait", zero degrees by default.
     app->dither = 0; // Dither algorithm is "Floyd Steinberg" by default.
-    app->haptic = 1; // Haptic is on by default
-    app->speaker = 1; // Speaker is on by default
-    app->led = 1; // LED is on by default
+    app->flash = 1; // Flash is enabled by default.
+    app->haptic = 1; // Haptic is enabled by default
+    app->speaker = 1; // Speaker is enabled by default
+    app->led = 1; // LED is enabled by default
 
     // Load configs
     camera_suite_read_settings(app);

+ 6 - 0
src-fap/camera_suite.h

@@ -31,6 +31,7 @@ typedef struct {
     CameraSuiteViewGuide* camera_suite_view_guide;
     uint32_t orientation;
     uint32_t dither;
+    uint32_t flash;
     uint32_t haptic;
     uint32_t speaker;
     uint32_t led;
@@ -58,6 +59,11 @@ typedef enum {
     CameraSuiteDitherJarvisJudiceNinke,
 } CameraSuiteDitherState;
 
+typedef enum {
+    CameraSuiteFlashOff,
+    CameraSuiteFlashOn,
+} CameraSuiteFlashState;
+
 typedef enum {
     CameraSuiteHapticOff,
     CameraSuiteHapticOn,

+ 7 - 3
src-fap/docs/CHANGELOG.md

@@ -1,11 +1,15 @@
 ## Roadmap
 
-- Save image support.
 - Full screen 90 degree and 270 degree fill.
-- Camera flash support.
 - In-camera GUI.
 
-## v1.1 (current)
+## v1.2 (current)
+
+- Save image support. When the center button is pressed take a picture and save it to the "DCIM" folder at the root of your SD card. The image will be saved as a bitmap file with a timestamp as the filename ("YYYYMMDD-HHMMSS.bmp").
+- Camera flash support. Flashes the ESP32-CAM onboard LED when a picture is taken if enabled in the settings.
+- Move the camera dithering type to the settings scene as a new configurable option.
+
+## v1.1
 
 - Support and picture stabilization for all camera orientations (0 degree, 90 degree, 180 degree, and 270 degree).
 - Rename "Scene 1" to "Camera". No UX changes there.

+ 3 - 1
src-fap/docs/README.md

@@ -18,7 +18,7 @@ Button mappings:
 
 **Right** = Toggle dithering on/off.
 
-**Center** = Cycle Floyd–Steinberg/Jarvis-Judice-Ninke/Stucki dithering types.
+**Center** = Take a picture and save to the "DCIM" folder at the root of your SD card. Image will be saved as a bitmap file with a timestamp as the filename ("YYYYMMDD-HHMMSS.bmp"). If flash is on in the settings (enabled by default) the ESP32-CAM onboard LED will light up when the picture is taken.
 
 **Back** = Go back.
 
@@ -26,6 +26,8 @@ Settings:
 
 **Orientation** = Rotate the camera image 90 degrees counter-clockwise starting at zero by default (0, 90, 180, 270). This is useful if you have your camera module mounted in a different orientation than the default.
 
+**Dithering Type** Change between the Cycle Floyd–Steinberg, Jarvis-Judice-Ninke, and Stucki dithering types.
+
 **Haptic FX** = Toggle haptic feedback on/off.
 
 **Sound FX** = Toggle sound effects on/off.

+ 2 - 0
src-fap/helpers/camera_suite_storage.c

@@ -50,6 +50,7 @@ void camera_suite_save_settings(void* context) {
     flipper_format_write_header_cstr(fff_file, BOILERPLATE_SETTINGS_HEADER, BOILERPLATE_SETTINGS_FILE_VERSION);
     flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_ORIENTATION, &app->orientation, 1);
     flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_DITHER, &app->dither, 1);
+    flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_FLASH, &app->flash, 1);
     flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
     flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
     flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);
@@ -102,6 +103,7 @@ void camera_suite_read_settings(void* context) {
     // Read settings
     flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_ORIENTATION, &app->orientation, 1);
     flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_DITHER, &app->dither, 1);
+    flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_FLASH, &app->flash, 1);
     flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
     flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
     flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);

+ 1 - 0
src-fap/helpers/camera_suite_storage.h

@@ -11,6 +11,7 @@
 #define BOILERPLATE_SETTINGS_HEADER "Camera Suite Config File"
 #define BOILERPLATE_SETTINGS_KEY_ORIENTATION "Orientation"
 #define BOILERPLATE_SETTINGS_KEY_DITHER "Dither"
+#define BOILERPLATE_SETTINGS_KEY_FLASH "Flash"
 #define BOILERPLATE_SETTINGS_KEY_HAPTIC "Haptic"
 #define BOILERPLATE_SETTINGS_KEY_LED "Led"
 #define BOILERPLATE_SETTINGS_KEY_SPEAKER "Speaker"

+ 25 - 0
src-fap/scenes/camera_suite_scene_settings.c

@@ -29,6 +29,16 @@ const uint32_t dither_value[4] = {
     CameraSuiteDitherJarvisJudiceNinke,
 };
 
+const char* const flash_text[2] = {
+    "OFF",
+    "ON",
+};
+
+const uint32_t flash_value[2] = {
+    CameraSuiteFlashOff,
+    CameraSuiteFlashOn,
+};
+
 const char* const haptic_text[2] = {
     "OFF",
     "ON",
@@ -75,6 +85,14 @@ static void camera_suite_scene_settings_set_camera_dither(VariableItem* item) {
     app->dither = dither_value[index];
 }
 
+static void camera_suite_scene_settings_set_flash(VariableItem* item) {
+    CameraSuite* app = variable_item_get_context(item);
+    uint8_t index = variable_item_get_current_value_index(item);
+
+    variable_item_set_current_value_text(item, flash_text[index]);
+    app->flash = flash_value[index];
+}
+
 static void camera_suite_scene_settings_set_haptic(VariableItem* item) {
     CameraSuite* app = variable_item_get_context(item);
     uint8_t index = variable_item_get_current_value_index(item);
@@ -129,6 +147,13 @@ void camera_suite_scene_settings_on_enter(void* context) {
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, dither_text[value_index]);
 
+    // Flash ON/OFF
+    item = variable_item_list_add(
+        app->variable_item_list, "Flash:", 2, camera_suite_scene_settings_set_flash, app);
+    value_index = value_index_uint32(app->flash, flash_value, 2);
+    variable_item_set_current_value_index(item, value_index);
+    variable_item_set_current_value_text(item, flash_text[value_index]);
+
     // Haptic FX ON/OFF
     item = variable_item_list_add(
         app->variable_item_list, "Haptic FX:", 2, camera_suite_scene_settings_set_haptic, app);

+ 11 - 7
src-fap/views/camera_suite_view_camera.c

@@ -249,13 +249,16 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
                 },
                 true);
             break;
-        case InputKeyOk:
-            // Camera: Initialize take picture mode.
-            data[0] = 'P';
-            // Initialize the ESP32-CAM onboard torch immediately.
-            furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
-            // Delay for 500ms to make sure flash is on before taking picture.
-            furi_delay_ms(500);
+        case InputKeyOk: {
+            CameraSuite* app = current_instance->context;
+            // If flash is enabled, flash the onboard ESP32-CAM LED.
+            if(app->flash) {
+                data[0] = 'P';
+                // Initialize the ESP32-CAM onboard torch immediately.
+                furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+                // Delay for 500ms to make sure flash is on before taking picture.
+                furi_delay_ms(500);
+            }
             // Take picture.
             with_view_model(
                 instance->view,
@@ -269,6 +272,7 @@ static bool camera_suite_view_camera_input(InputEvent* event, void* context) {
                 },
                 true);
             return true;
+        }  
         case InputKeyMAX:
             break;
         }