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

Fix GB Photo! pagination + status image

Esteban Fuentealba 1 год назад
Родитель
Сommit
919081b052
3 измененных файлов с 16 добавлено и 5 удалено
  1. 1 1
      malveke_gb_photo.c
  2. 11 4
      views/boilerplate_scene_1.c
  3. 4 0
      views/boilerplate_scene_1.h

+ 1 - 1
malveke_gb_photo.c

@@ -52,7 +52,7 @@ Boilerplate* boilerplate_app_alloc() {
 
     app->file_path = furi_string_alloc();
     app->camera_ram_sav = storage_file_alloc(app->storage);
-    app->page = 1;
+    app->page = 0;
     app->pos_x = 0;
     app->pos_y = 0;
     app->show_instructions = true;

+ 11 - 4
views/boilerplate_scene_1.c

@@ -79,12 +79,19 @@ void boilerplate_scene_1_draw(Canvas* canvas, BoilerplateScene1Model* model) {
         canvas_set_font(canvas, FontPrimary);
         elements_button_center(canvas, "OK");
     } else {
-        int count = (app->page + 1) * 0x1000;
+        // int count = (app->page) * 0x1000;
+        
+        int count = GB_FIRST_PHOTO_OFFSET + app->page * GB_PHOTO_SIZE;
+
+        FURI_LOG_I(TAG, "Page \"%d\"\n", app->page);
+        FURI_LOG_I(TAG, "Read Index \"%d\" \n", count);
+
+
         if(app->camera_ram_sav) {
-            storage_file_seek(app->camera_ram_sav, count - 0x1b1, true);
+            storage_file_seek(app->camera_ram_sav, (app->page) + 0x11B2, true);
             uint8_t status;
             storage_file_read(app->camera_ram_sav, &status, 1);
-
+            FURI_LOG_I(TAG, "Status/Nº Photo \"%x\"\n", status);
             storage_file_seek(app->camera_ram_sav, count, true);
 
             for(int y = app->pos_y; y < 14; y++) {
@@ -137,7 +144,7 @@ void save_image(void* context) {
         storage_simply_mkdir(app->storage, MALVEKE_APP_FOLDER_PHOTOS);
     }
 
-    int count = (app->page + 1) * 0x1000;
+    int count = GB_FIRST_PHOTO_OFFSET + app->page * GB_PHOTO_SIZE;
     storage_file_seek(app->camera_ram_sav, count, true);
     // create file name
     FuriString* file_name = furi_string_alloc();

+ 4 - 0
views/boilerplate_scene_1.h

@@ -14,6 +14,10 @@
 #define FRAME_WIDTH 128
 #define FRAME_HEIGTH 64
 
+#define GB_FIRST_PHOTO_OFFSET	0x2000
+#define GB_PHOTO_SIZE			0x1000
+
+
 typedef struct BoilerplateScene1 BoilerplateScene1;
 
 typedef void (*BoilerplateScene1Callback)(BoilerplateCustomEvent event, void* context);