From d1fde5198b83419d95f5451f1369fc108d892ab5 Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Wed, 26 Jul 2023 17:59:30 -0500 Subject: [PATCH 1/5] Quick README updates. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 469efa3..03a4d15 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,9 @@ Note the upload may fail a few times, this is normal, try again. If it still fai 5. Reinsert your MicroSD into your Flipper Zero if you took it out. 6. Plug in your ESP32-CAM module to your Flipper Zero. 7. Press the "Power" button on your Flipper Zero to turn it on. -8. Open the application "[ESP32-CAM] Camera Suite": +8. Open the application "[ESP32] Camera Suite": ``` - Applications > GPIO > [ESP32-CAM] Camera Suite + Applications > GPIO > [ESP32] Camera Suite ``` 9. That's it! Follow the on screen instructions to continue. @@ -137,7 +137,7 @@ Note the upload may fail a few times, this is normal, try again. If it still fai ## Attributions -This project is based on/forked from the [Fliper Zero Camera Application][flipperzero-camera] +This project is based on/forked from the [Flipper Zero Camera Application][flipperzero-camera] by [Z4urce][github-profile-z4urce] combined with the [Flipper Zero Boilerplate Application][flipper-zero-fap-boilerplate] by [Dave Lee][github-profile-leedave]. From 57bb16478579995e81c916f7840b1218b4801eb0 Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Wed, 26 Jul 2023 18:02:29 -0500 Subject: [PATCH 2/5] Quick README updates. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03a4d15..59d55db 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Note the upload may fail a few times, this is normal, try again. If it still fai ``` . # The Flipper Zero MicroSD root. ├── apps # The Flipper Zero Applications folder. - | ├── gpio # The Flipper Zero General Purpose Input/Output folder. + | ├── gpio # The Flipper Zero GPIO folder. | | ├── camerasuite.fap # The Camera Suite application. ``` 5. Reinsert your MicroSD into your Flipper Zero if you took it out. From 7d615c87919d2fddae3e2bf446e90032a740abf6 Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Wed, 26 Jul 2023 19:20:02 -0500 Subject: [PATCH 3/5] Add TODO notes. --- src-fap/views/camera_suite_view_camera.c | 72 +++++++++++++++++++++--- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/src-fap/views/camera_suite_view_camera.c b/src-fap/views/camera_suite_view_camera.c index 8dfec2b..be70b8b 100644 --- a/src-fap/views/camera_suite_view_camera.c +++ b/src-fap/views/camera_suite_view_camera.c @@ -42,8 +42,9 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) uint8_t x = p % ROW_BUFFER_LENGTH; // 0 .. 15 uint8_t y = p / ROW_BUFFER_LENGTH; // 0 .. 63 - // Apply rotation int16_t rotated_x, rotated_y; + + // Apply rotation switch(app->orientation) { case 1: // 90 degrees rotated_x = y; @@ -66,27 +67,84 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) for(uint8_t i = 0; i < 8; ++i) { if((model->pixels[p] & (1 << (7 - i))) != 0) { - // Adjust the coordinates based on the new screen dimensions uint16_t screen_x, screen_y; + // Adjust the coordinates based on the new screen dimensions switch(app->orientation) { - case 1: // 90 degrees + /** + * Orientation: 90 degrees + * + * TODO: Fix bug here, the image has horizontal blocks going + * across the screen. Example below: + * ___________________________ + * |------------| | + * |------------| | + * |--PICTURE---| | + * |------------| | + * |------------| | + * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + */ + case 1: { screen_x = rotated_x; screen_y = FRAME_HEIGHT - 8 + (rotated_y * 8) + i; break; - case 2: // 180 degrees + } + + /** + * Orientation: 180 degrees + * + * TODO: Fix bug here, the image has vertial blocks going up + * the screen. Example below: + * ___________________________ + * | | | | | | | | | | | | | | + * | | | | | | | | | | | | | | + * | | | |P|I|C|T|U|R|E| | | | + * | | | | | | | | | | | | | | + * | | | | | | | | | | | | | | + * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + */ + case 2: { screen_x = FRAME_WIDTH - 8 + (rotated_x * 8) + i; screen_y = FRAME_HEIGHT - 1 - rotated_y; break; - case 3: // 270 degrees + } + + /** + * Orientation: 270 degrees + * + * This is working great visually. + * TODO: Fill entire screen. Current: + * ___________________________ + * | | | + * | | | + * | Fill Me | Picture | + * | | | + * | | | + * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + */ + case 3: { screen_x = FRAME_WIDTH - 1 - rotated_x; screen_y = rotated_y * 8 + i; break; - case 0: // 0 degrees - default: + } + /** + * Orientation: 0 degrees (+default). + * + * This is working great visually. + * ___________________________ + * | | + * | | + * | Picture | + * | | + * | | + * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + */ + case 0: + default: { screen_x = rotated_x * 8 + i; screen_y = rotated_y; break; } + } canvas_draw_dot(canvas, screen_x, screen_y); } } From 4c931fd5adf88ff88ac92dd86aaff7087987f84b Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Wed, 26 Jul 2023 19:23:47 -0500 Subject: [PATCH 4/5] Further updates to the inline comments for the TODOs --- src-fap/views/camera_suite_view_camera.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src-fap/views/camera_suite_view_camera.c b/src-fap/views/camera_suite_view_camera.c index be70b8b..d1e6732 100644 --- a/src-fap/views/camera_suite_view_camera.c +++ b/src-fap/views/camera_suite_view_camera.c @@ -71,14 +71,14 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) // Adjust the coordinates based on the new screen dimensions switch(app->orientation) { /** - * Orientation: 90 degrees + * Orientation: 90 degrees. * * TODO: Fix bug here, the image has horizontal blocks going - * across the screen. Example below: + * across the screen. Fill entire screen. Example below: * ___________________________ * |------------| | * |------------| | - * |--PICTURE---| | + * |--PICTURE---| Fill me | * |------------| | * |------------| | * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -88,9 +88,8 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) screen_y = FRAME_HEIGHT - 8 + (rotated_y * 8) + i; break; } - /** - * Orientation: 180 degrees + * Orientation: 180 degrees. * * TODO: Fix bug here, the image has vertial blocks going up * the screen. Example below: @@ -107,16 +106,15 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) screen_y = FRAME_HEIGHT - 1 - rotated_y; break; } - /** - * Orientation: 270 degrees + * Orientation: 270 degrees. * * This is working great visually. * TODO: Fill entire screen. Current: * ___________________________ * | | | * | | | - * | Fill Me | Picture | + * | Fill me | Picture | * | | | * | | | * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ From 545df87b4599b753d1f2a158e035472fc665a623 Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Wed, 26 Jul 2023 22:53:22 -0500 Subject: [PATCH 5/5] Fix issue #16 --- src-fap/views/camera_suite_view_camera.c | 127 +++++------------------ src-fap/views/camera_suite_view_camera.h | 2 +- 2 files changed, 26 insertions(+), 103 deletions(-) diff --git a/src-fap/views/camera_suite_view_camera.c b/src-fap/views/camera_suite_view_camera.c index d1e6732..5d71004 100644 --- a/src-fap/views/camera_suite_view_camera.c +++ b/src-fap/views/camera_suite_view_camera.c @@ -28,7 +28,29 @@ void camera_suite_view_camera_set_callback( instance->context = context; } -static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) { +// Function to draw pixels on the canvas based on camera orientation +static void draw_pixel_by_orientation(Canvas* canvas, uint8_t x, uint8_t y, uint8_t orientation) { + switch(orientation) { + case 0: // Camera rotated 0 degrees (right side up, default) + canvas_draw_dot(canvas, x, y); + break; + case 1: // Camera rotated 90 degrees + canvas_draw_dot(canvas, y, FRAME_WIDTH - 1 - x); + break; + case 2: // Camera rotated 180 degrees (upside down) + canvas_draw_dot(canvas, FRAME_WIDTH - 1 - x, FRAME_HEIGHT - 1 - y); + break; + case 3: // Camera rotated 270 degrees + canvas_draw_dot(canvas, FRAME_HEIGHT - 1 - y, x); + break; + default: + break; + } +} + +static void camera_suite_view_camera_draw(Canvas* canvas, void* _model) { + UartDumpModel* model = _model; + // Clear the screen. canvas_set_color(canvas, ColorBlack); @@ -37,116 +59,17 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model) CameraSuite* app = current_instance->context; - // Draw the pixels with rotation. for(size_t p = 0; p < FRAME_BUFFER_LENGTH; ++p) { uint8_t x = p % ROW_BUFFER_LENGTH; // 0 .. 15 uint8_t y = p / ROW_BUFFER_LENGTH; // 0 .. 63 - int16_t rotated_x, rotated_y; - - // Apply rotation - switch(app->orientation) { - case 1: // 90 degrees - rotated_x = y; - rotated_y = FRAME_WIDTH - 1 - x; - break; - case 2: // 180 degrees - rotated_x = FRAME_WIDTH - 1 - x; - rotated_y = FRAME_HEIGHT - 1 - y; - break; - case 3: // 270 degrees - rotated_x = FRAME_HEIGHT - 1 - y; - rotated_y = x; - break; - case 0: // 0 degrees - default: - rotated_x = x; - rotated_y = y; - break; - } - for(uint8_t i = 0; i < 8; ++i) { if((model->pixels[p] & (1 << (7 - i))) != 0) { - uint16_t screen_x, screen_y; - // Adjust the coordinates based on the new screen dimensions - switch(app->orientation) { - /** - * Orientation: 90 degrees. - * - * TODO: Fix bug here, the image has horizontal blocks going - * across the screen. Fill entire screen. Example below: - * ___________________________ - * |------------| | - * |------------| | - * |--PICTURE---| Fill me | - * |------------| | - * |------------| | - * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - */ - case 1: { - screen_x = rotated_x; - screen_y = FRAME_HEIGHT - 8 + (rotated_y * 8) + i; - break; - } - /** - * Orientation: 180 degrees. - * - * TODO: Fix bug here, the image has vertial blocks going up - * the screen. Example below: - * ___________________________ - * | | | | | | | | | | | | | | - * | | | | | | | | | | | | | | - * | | | |P|I|C|T|U|R|E| | | | - * | | | | | | | | | | | | | | - * | | | | | | | | | | | | | | - * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - */ - case 2: { - screen_x = FRAME_WIDTH - 8 + (rotated_x * 8) + i; - screen_y = FRAME_HEIGHT - 1 - rotated_y; - break; - } - /** - * Orientation: 270 degrees. - * - * This is working great visually. - * TODO: Fill entire screen. Current: - * ___________________________ - * | | | - * | | | - * | Fill me | Picture | - * | | | - * | | | - * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - */ - case 3: { - screen_x = FRAME_WIDTH - 1 - rotated_x; - screen_y = rotated_y * 8 + i; - break; - } - /** - * Orientation: 0 degrees (+default). - * - * This is working great visually. - * ___________________________ - * | | - * | | - * | Picture | - * | | - * | | - * ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - */ - case 0: - default: { - screen_x = rotated_x * 8 + i; - screen_y = rotated_y; - break; - } - } - canvas_draw_dot(canvas, screen_x, screen_y); + draw_pixel_by_orientation(canvas, (x * 8) + i, y, app->orientation); } } } + // Draw the guide if the camera is not initialized. if(!model->initialized) { canvas_draw_icon(canvas, 74, 16, &I_DolphinCommon_56x48); diff --git a/src-fap/views/camera_suite_view_camera.h b/src-fap/views/camera_suite_view_camera.h index a873814..5ccbac7 100644 --- a/src-fap/views/camera_suite_view_camera.h +++ b/src-fap/views/camera_suite_view_camera.h @@ -16,7 +16,7 @@ #pragma once -#define FRAME_WIDTH 129 +#define FRAME_WIDTH 128 #define FRAME_HEIGHT 64 #define FRAME_BIT_DEPTH 1 #define FRAME_BUFFER_LENGTH 1024