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

Merge pull request #17 from CodyTolene/ct/fill-screen

[#16] Resolve blocky pictures & README updates.
Cody Tolene 2 лет назад
Родитель
Сommit
c6d1abb587
3 измененных файлов с 30 добавлено и 51 удалено
  1. 4 4
      README.md
  2. 25 46
      src-fap/views/camera_suite_view_camera.c
  3. 1 1
      src-fap/views/camera_suite_view_camera.h

+ 4 - 4
README.md

@@ -93,15 +93,15 @@ Note the upload may fail a few times, this is normal, try again. If it still fai
    ```
    ```
    .                            # The Flipper Zero MicroSD root.
    .                            # The Flipper Zero MicroSD root.
    ├── apps                     # The Flipper Zero Applications folder.
    ├── 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.
    |   |   ├── camerasuite.fap  # The Camera Suite application.
    ```
    ```
 5. Reinsert your MicroSD into your Flipper Zero if you took it out.
 5. Reinsert your MicroSD into your Flipper Zero if you took it out.
 6. Plug in your ESP32-CAM module to your Flipper Zero.
 6. Plug in your ESP32-CAM module to your Flipper Zero.
 7. Press the "Power" button on your Flipper Zero to turn it on.
 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.
 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 <a name="attributions"></a>
 ## Attributions <a name="attributions"></a>
 
 
-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 [Z4urce][github-profile-z4urce] combined with the [Flipper Zero Boilerplate Application][flipper-zero-fap-boilerplate]
 by [Dave Lee][github-profile-leedave].
 by [Dave Lee][github-profile-leedave].
 
 

+ 25 - 46
src-fap/views/camera_suite_view_camera.c

@@ -28,7 +28,29 @@ void camera_suite_view_camera_set_callback(
     instance->context = context;
     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.
     // Clear the screen.
     canvas_set_color(canvas, ColorBlack);
     canvas_set_color(canvas, ColorBlack);
 
 
@@ -37,60 +59,17 @@ static void camera_suite_view_camera_draw(Canvas* canvas, UartDumpModel* model)
 
 
     CameraSuite* app = current_instance->context;
     CameraSuite* app = current_instance->context;
 
 
-    // Draw the pixels with rotation.
     for(size_t p = 0; p < FRAME_BUFFER_LENGTH; ++p) {
     for(size_t p = 0; p < FRAME_BUFFER_LENGTH; ++p) {
         uint8_t x = p % ROW_BUFFER_LENGTH; // 0 .. 15
         uint8_t x = p % ROW_BUFFER_LENGTH; // 0 .. 15
         uint8_t y = p / ROW_BUFFER_LENGTH; // 0 .. 63
         uint8_t y = p / ROW_BUFFER_LENGTH; // 0 .. 63
 
 
-        // Apply rotation
-        int16_t rotated_x, rotated_y;
-        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) {
         for(uint8_t i = 0; i < 8; ++i) {
             if((model->pixels[p] & (1 << (7 - i))) != 0) {
             if((model->pixels[p] & (1 << (7 - i))) != 0) {
-                // Adjust the coordinates based on the new screen dimensions
-                uint16_t screen_x, screen_y;
-                switch(app->orientation) {
-                case 1: // 90 degrees
-                    screen_x = rotated_x;
-                    screen_y = FRAME_HEIGHT - 8 + (rotated_y * 8) + i;
-                    break;
-                case 2: // 180 degrees
-                    screen_x = FRAME_WIDTH - 8 + (rotated_x * 8) + i;
-                    screen_y = FRAME_HEIGHT - 1 - rotated_y;
-                    break;
-                case 3: // 270 degrees
-                    screen_x = FRAME_WIDTH - 1 - rotated_x;
-                    screen_y = rotated_y * 8 + i;
-                    break;
-                case 0: // 0 degrees
-                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.
     // Draw the guide if the camera is not initialized.
     if(!model->initialized) {
     if(!model->initialized) {
         canvas_draw_icon(canvas, 74, 16, &I_DolphinCommon_56x48);
         canvas_draw_icon(canvas, 74, 16, &I_DolphinCommon_56x48);

+ 1 - 1
src-fap/views/camera_suite_view_camera.h

@@ -16,7 +16,7 @@
 
 
 #pragma once
 #pragma once
 
 
-#define FRAME_WIDTH 129
+#define FRAME_WIDTH 128
 #define FRAME_HEIGHT 64
 #define FRAME_HEIGHT 64
 #define FRAME_BIT_DEPTH 1
 #define FRAME_BIT_DEPTH 1
 #define FRAME_BUFFER_LENGTH 1024
 #define FRAME_BUFFER_LENGTH 1024