forked from RogueMaster/flipperzero-firmware-wPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FL-2556] Update complete screen (flipperdevices#1332)
* Desktop: slideshow implementation * Updater: handling splashscreen installation; added format version field to slideshow binary * Desktop: added bidirectional slideshow navigation + instant cancel by "back" button; Updater: rebalanced update stages weights * Updater: fixed missing field init; fixed potential loop when baking slideshows * Assets: fixed "update complete" image to match original * Desktop: added check for slideshow file version * Scripts: slideshow.py cleanup * Desktop: removed first start intro sequence * Desktop: removed first start remnants
- Loading branch information
Showing
23 changed files
with
437 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#include "slideshow.h" | ||
|
||
#include <stddef.h> | ||
#include <storage/storage.h> | ||
#include <gui/icon.h> | ||
#include <gui/icon_i.h> | ||
#include <furi/dangerous_defines.h> | ||
|
||
#define SLIDESHOW_MAGIC 0x72676468 | ||
#define SLIDESHOW_MAX_SUPPORTED_VERSION 1 | ||
|
||
struct Slideshow { | ||
Icon icon; | ||
uint32_t current_frame; | ||
}; | ||
|
||
#pragma pack(push, 1) | ||
|
||
typedef struct { | ||
uint32_t magic; | ||
uint8_t version; | ||
uint8_t width; | ||
uint8_t height; | ||
uint8_t frame_count; | ||
} SlideshowFileHeader; | ||
_Static_assert(sizeof(SlideshowFileHeader) == 8, "Incorrect SlideshowFileHeader size"); | ||
|
||
typedef struct { | ||
uint16_t size; | ||
} SlideshowFrameHeader; | ||
_Static_assert(sizeof(SlideshowFrameHeader) == 2, "Incorrect SlideshowFrameHeader size"); | ||
|
||
#pragma pack(pop) | ||
|
||
Slideshow* slideshow_alloc() { | ||
Slideshow* ret = malloc(sizeof(Slideshow)); | ||
return ret; | ||
} | ||
|
||
void slideshow_free(Slideshow* slideshow) { | ||
Icon* icon = &slideshow->icon; | ||
if(icon) { | ||
for(int frame_idx = 0; frame_idx < icon->frame_count; ++frame_idx) { | ||
uint8_t* frame_data = (uint8_t*)icon->frames[frame_idx]; | ||
free(frame_data); | ||
} | ||
free((uint8_t**)icon->frames); | ||
} | ||
free(slideshow); | ||
} | ||
|
||
bool slideshow_load(Slideshow* slideshow, const char* fspath) { | ||
Storage* storage = furi_record_open("storage"); | ||
File* slideshow_file = storage_file_alloc(storage); | ||
bool load_success = false; | ||
do { | ||
if(!storage_file_open(slideshow_file, fspath, FSAM_READ, FSOM_OPEN_EXISTING)) { | ||
break; | ||
} | ||
SlideshowFileHeader header; | ||
if((storage_file_read(slideshow_file, &header, sizeof(header)) != sizeof(header)) || | ||
(header.magic != SLIDESHOW_MAGIC) || | ||
(header.version > SLIDESHOW_MAX_SUPPORTED_VERSION)) { | ||
break; | ||
} | ||
Icon* icon = &slideshow->icon; | ||
FURI_CONST_ASSIGN(icon->frame_count, header.frame_count); | ||
FURI_CONST_ASSIGN(icon->width, header.width); | ||
FURI_CONST_ASSIGN(icon->height, header.height); | ||
icon->frames = malloc(header.frame_count * sizeof(uint8_t*)); | ||
for(int frame_idx = 0; frame_idx < header.frame_count; ++frame_idx) { | ||
SlideshowFrameHeader frame_header; | ||
if(storage_file_read(slideshow_file, &frame_header, sizeof(frame_header)) != | ||
sizeof(frame_header)) { | ||
break; | ||
} | ||
FURI_CONST_ASSIGN_PTR(icon->frames[frame_idx], malloc(frame_header.size)); | ||
uint8_t* frame_data = (uint8_t*)icon->frames[frame_idx]; | ||
if(storage_file_read(slideshow_file, frame_data, frame_header.size) != | ||
frame_header.size) { | ||
break; | ||
} | ||
load_success = (frame_idx + 1) == header.frame_count; | ||
} | ||
} while(false); | ||
storage_file_free(slideshow_file); | ||
furi_record_close("storage"); | ||
return load_success; | ||
} | ||
|
||
bool slideshow_advance(Slideshow* slideshow) { | ||
uint8_t next_frame = slideshow->current_frame + 1; | ||
if(next_frame < slideshow->icon.frame_count) { | ||
slideshow->current_frame = next_frame; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void slideshow_goback(Slideshow* slideshow) { | ||
if(slideshow->current_frame > 0) { | ||
slideshow->current_frame--; | ||
} | ||
} | ||
|
||
void slideshow_draw(Slideshow* slideshow, Canvas* canvas, uint8_t x, uint8_t y) { | ||
furi_assert(slideshow->current_frame < slideshow->icon.frame_count); | ||
canvas_draw_bitmap( | ||
canvas, | ||
x, | ||
y, | ||
slideshow->icon.width, | ||
slideshow->icon.height, | ||
slideshow->icon.frames[slideshow->current_frame]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <gui/canvas.h> | ||
|
||
typedef struct Slideshow Slideshow; | ||
|
||
Slideshow* slideshow_alloc(); | ||
|
||
void slideshow_free(Slideshow* slideshow); | ||
bool slideshow_load(Slideshow* slideshow, const char* fspath); | ||
void slideshow_goback(Slideshow* slideshow); | ||
bool slideshow_advance(Slideshow* slideshow); | ||
void slideshow_draw(Slideshow* slideshow, Canvas* canvas, uint8_t x, uint8_t y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
ADD_SCENE(desktop, main, Main) | ||
ADD_SCENE(desktop, lock_menu, LockMenu) | ||
ADD_SCENE(desktop, debug, Debug) | ||
ADD_SCENE(desktop, first_start, FirstStart) | ||
ADD_SCENE(desktop, hw_mismatch, HwMismatch) | ||
ADD_SCENE(desktop, fault, Fault) | ||
ADD_SCENE(desktop, locked, Locked) | ||
ADD_SCENE(desktop, pin_input, PinInput) | ||
ADD_SCENE(desktop, pin_timeout, PinTimeout) | ||
ADD_SCENE(desktop, slideshow, Slideshow) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <storage/storage.h> | ||
|
||
#include "../desktop_i.h" | ||
#include "../views/desktop_view_slideshow.h" | ||
#include "../views/desktop_events.h" | ||
|
||
void desktop_scene_slideshow_callback(DesktopEvent event, void* context) { | ||
Desktop* desktop = (Desktop*)context; | ||
view_dispatcher_send_custom_event(desktop->view_dispatcher, event); | ||
} | ||
|
||
void desktop_scene_slideshow_on_enter(void* context) { | ||
Desktop* desktop = (Desktop*)context; | ||
DesktopSlideshowView* slideshow_view = desktop->slideshow_view; | ||
|
||
desktop_view_slideshow_set_callback(slideshow_view, desktop_scene_slideshow_callback, desktop); | ||
|
||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdSlideshow); | ||
} | ||
|
||
bool desktop_scene_slideshow_on_event(void* context, SceneManagerEvent event) { | ||
Desktop* desktop = (Desktop*)context; | ||
bool consumed = false; | ||
Storage* storage = NULL; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
switch(event.event) { | ||
case DesktopSlideshowCompleted: | ||
storage = furi_record_open("storage"); | ||
storage_common_remove(storage, "/int/slideshow"); | ||
furi_record_close("storage"); | ||
scene_manager_previous_scene(desktop->scene_manager); | ||
consumed = true; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
return consumed; | ||
} | ||
|
||
void desktop_scene_slideshow_on_exit(void* context) { | ||
UNUSED(context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.