[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)

* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Albert Kharisov
2022-01-29 13:20:41 +04:00
committed by GitHub
parent 53e7415d12
commit 84410c83b5
366 changed files with 3646 additions and 1566 deletions

View File

@@ -1,6 +1,5 @@
ADD_SCENE(desktop, main, Main)
ADD_SCENE(desktop, lock_menu, LockMenu)
ADD_SCENE(desktop, locked, Locked)
ADD_SCENE(desktop, debug, Debug)
ADD_SCENE(desktop, first_start, FirstStart)
ADD_SCENE(desktop, hw_mismatch, HwMismatch)

View File

@@ -1,8 +1,11 @@
#include "../desktop_i.h"
#include "../views/desktop_debug.h"
#include <dolphin/dolphin.h>
#include <dolphin/helpers/dolphin_deed.h>
#include "../desktop_i.h"
#include "../views/desktop_debug.h"
#include "desktop_scene.h"
void desktop_scene_debug_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
@@ -31,13 +34,13 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
break;
case DesktopDebugEventDeed:
dolphin_deed(dolphin, DolphinDeedIButtonEmulate);
dolphin_deed(dolphin, DolphinDeedIbuttonEmulate);
desktop_debug_get_dolphin_data(desktop->debug_view);
consumed = true;
break;
case DesktopDebugEventWrongDeed:
dolphin_deed(dolphin, DolphinDeedWrong);
dolphin_deed(dolphin, DolphinDeedIbuttonRead);
desktop_debug_get_dolphin_data(desktop->debug_view);
consumed = true;
break;

View File

@@ -1,3 +1,5 @@
#include <furi_hal.h>
#include "../desktop_i.h"
#define DesktopFaultEventExit 0x00FF00FF

View File

@@ -1,3 +1,6 @@
#include <power/power_service/power.h>
#include <storage/storage.h>
#include "../desktop_i.h"
#include "../views/desktop_first_start.h"
#include "../views/desktop_events.h"

View File

@@ -1,6 +1,9 @@
#include "../desktop_i.h"
#include <gui/scene_manager.h>
#include <furi_hal_version.h>
#include "desktop_scene.h"
#include "../desktop_i.h"
#define HW_MISMATCH_BACK_EVENT (0UL)
void desktop_scene_hw_mismatch_callback(void* context) {
@@ -11,11 +14,14 @@ void desktop_scene_hw_mismatch_callback(void* context) {
void desktop_scene_hw_mismatch_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
furi_assert(!desktop->text_buffer);
Popup* popup = desktop->hw_mismatch_popup;
desktop->text_buffer = furi_alloc(256);
char* text_buffer = furi_alloc(256);
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneHwMismatch, (uint32_t)text_buffer);
snprintf(
desktop->text_buffer,
text_buffer,
256,
"HW target: %d\nFW target: %d",
furi_hal_version_get_hw_target(),
@@ -23,8 +29,7 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
popup_set_context(popup, desktop);
popup_set_header(
popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_text(
popup, desktop->text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_text(popup, text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch);
}
@@ -50,12 +55,13 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)
void desktop_scene_hw_mismatch_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
furi_assert(desktop->text_buffer);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_callback(popup, NULL);
popup_set_context(popup, NULL);
free(desktop->text_buffer);
desktop->text_buffer = NULL;
char* text_buffer =
(char*)scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneHwMismatch);
free(text_buffer);
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneHwMismatch, 0);
}

View File

@@ -0,0 +1,7 @@
#pragma once
typedef enum {
DesktopMainSceneStateUnlocked,
DesktopMainSceneStateLockedWithPin,
DesktopMainSceneStateLockedNoPin,
} DesktopMainSceneState;

View File

@@ -1,8 +1,11 @@
#include "../desktop_i.h"
#include "../views/desktop_lock_menu.h"
#include <toolbox/saved_struct.h>
#include <stdbool.h>
#include "../desktop_i.h"
#include "../views/desktop_lock_menu.h"
#include "desktop_scene_i.h"
#include "desktop_scene.h"
void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
@@ -26,17 +29,15 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
switch(event.event) {
case DesktopLockMenuEventLock:
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, DesktopLockedNoPin);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
desktop->scene_manager, DesktopSceneMain, DesktopMainSceneStateLockedNoPin);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
consumed = true;
break;
case DesktopLockMenuEventPinLock:
if(desktop->settings.pincode.length > 0) {
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
furi_hal_usb_disable();
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, DesktopLockedWithPin);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
desktop->scene_manager, DesktopSceneMain, DesktopMainSceneStateLockedWithPin);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
} else {
scene_manager_next_scene(desktop->scene_manager, DesktopScenePinSetup);
}

View File

@@ -1,101 +0,0 @@
#include "../desktop_i.h"
#include "../views/desktop_locked.h"
#include "desktop/views/desktop_main.h"
void desktop_scene_locked_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}
static void desktop_scene_locked_new_idle_animation_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopLockedEventCheckAnimation);
}
void desktop_scene_locked_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopLockedView* locked_view = desktop->locked_view;
animation_manager_set_new_idle_callback(
desktop->animation_manager, desktop_scene_locked_new_idle_animation_callback);
desktop_locked_set_callback(locked_view, desktop_scene_locked_callback, desktop);
desktop_locked_reset_door_pos(locked_view);
desktop_locked_update_hint_timeout(locked_view);
uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopViewLocked);
desktop_locked_with_pin(desktop->locked_view, state == DesktopLockedWithPin);
view_port_enabled_set(desktop->lock_viewport, true);
osTimerStart(locked_view->timer, osKernelGetTickFreq() / 16);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewLocked);
}
static bool desktop_scene_locked_check_pin(Desktop* desktop, DesktopEvent event) {
bool match = false;
size_t length = desktop->pincode_buffer.length;
length = code_input_push(desktop->pincode_buffer.data, length, event);
desktop->pincode_buffer.length = length;
match = code_input_compare(
desktop->pincode_buffer.data,
length,
desktop->settings.pincode.data,
desktop->settings.pincode.length);
if(match) {
desktop->pincode_buffer.length = 0;
furi_hal_usb_enable();
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
desktop_main_unlocked(desktop->main_view);
}
return match;
}
bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
Desktop* desktop = (Desktop*)context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DesktopLockedEventUnlock:
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneMain, DesktopMainEventUnlocked);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
consumed = true;
break;
case DesktopLockedEventUpdate:
desktop_locked_manage_redraw(desktop->locked_view);
consumed = true;
break;
case DesktopLockedEventInputReset:
desktop->pincode_buffer.length = 0;
break;
case DesktopLockedEventCheckAnimation:
animation_manager_check_blocking_process(desktop->animation_manager);
consumed = true;
break;
default:
if(desktop_scene_locked_check_pin(desktop, event.event)) {
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneMain, DesktopMainEventUnlocked);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
consumed = true;
}
break;
}
}
return consumed;
}
void desktop_scene_locked_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
animation_manager_set_new_idle_callback(desktop->animation_manager, NULL);
desktop_locked_reset_counter(desktop->locked_view);
osTimerStop(desktop->locked_view->timer);
}

View File

@@ -1,17 +1,14 @@
#include "../desktop_i.h"
#include "../views/desktop_main.h"
#include "applications.h"
#include "assets_icons.h"
#include "cmsis_os2.h"
#include "desktop/desktop.h"
#include "desktop/views/desktop_events.h"
#include "dolphin/dolphin.h"
#include "furi/pubsub.h"
#include "furi/record.h"
#include "furi/thread.h"
#include "storage/storage_glue.h"
#include <furi.h>
#include <furi_hal.h>
#include <applications.h>
#include <assets_icons.h>
#include <loader/loader.h>
#include <m-list.h>
#include "desktop/desktop_i.h"
#include "desktop/views/desktop_main.h"
#include "desktop_scene.h"
#include "desktop_scene_i.h"
#define MAIN_VIEW_DEFAULT (0UL)
static void desktop_scene_main_app_started_callback(const void* message, void* context) {
@@ -81,17 +78,31 @@ void desktop_scene_main_on_enter(void* context) {
desktop->animation_manager, desktop_scene_main_check_animation_callback);
animation_manager_set_interact_callback(
desktop->animation_manager, desktop_scene_main_interact_animation_callback);
desktop_locked_set_callback(desktop->locked_view, desktop_scene_main_callback, desktop);
furi_assert(osSemaphoreGetCount(desktop->unload_animation_semaphore) == 0);
Loader* loader = furi_record_open("loader");
desktop->app_start_stop_subscription = furi_pubsub_subscribe(
loader_get_pubsub(), desktop_scene_main_app_started_callback, desktop);
loader_get_pubsub(loader), desktop_scene_main_app_started_callback, desktop);
furi_record_close("loader");
desktop_main_set_callback(main_view, desktop_scene_main_callback, desktop);
view_port_enabled_set(desktop->lock_viewport, false);
if(scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneMain) ==
DesktopMainEventUnlocked) {
desktop_main_unlocked(desktop->main_view);
DesktopMainSceneState state =
scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneMain);
if(state == DesktopMainSceneStateLockedNoPin) {
desktop_locked_lock(desktop->locked_view);
view_port_enabled_set(desktop->lock_viewport, true);
} else if(state == DesktopMainSceneStateLockedWithPin) {
LOAD_DESKTOP_SETTINGS(&desktop->settings);
furi_assert(desktop->settings.pincode.length > 0);
desktop_locked_lock_pincode(desktop->locked_view, desktop->settings.pincode);
view_port_enabled_set(desktop->lock_viewport, true);
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
furi_hal_usb_disable();
} else {
furi_assert(state == DesktopMainSceneStateUnlocked);
view_port_enabled_set(desktop->lock_viewport, false);
}
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain);
@@ -120,22 +131,22 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
case DesktopMainEventOpenArchive:
#ifdef APP_ARCHIVE
animation_manager_unload_and_stall_animation(desktop->animation_manager);
desktop_switch_to_app(desktop, &FLIPPER_ARCHIVE);
animation_manager_load_and_continue_animation(desktop->animation_manager);
#endif
consumed = true;
break;
case DesktopMainEventOpenFavorite:
LOAD_DESKTOP_SETTINGS(&desktop->settings);
animation_manager_unload_and_stall_animation(desktop->animation_manager);
if(desktop->settings.favorite < FLIPPER_APPS_COUNT) {
desktop_switch_to_app(desktop, &FLIPPER_APPS[desktop->settings.favorite]);
Loader* loader = furi_record_open("loader");
LoaderStatus status =
loader_start(loader, FLIPPER_APPS[desktop->settings.favorite].name, NULL);
furi_check(status == LoaderStatusOk);
furi_record_close("loader");
} else {
FURI_LOG_E("DesktopSrv", "Can't find favorite application");
}
animation_manager_load_and_continue_animation(desktop->animation_manager);
consumed = true;
break;
@@ -160,6 +171,18 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
animation_manager_load_and_continue_animation(desktop->animation_manager);
consumed = true;
break;
case DesktopMainEventUnlocked:
consumed = true;
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
furi_hal_usb_enable();
view_port_enabled_set(desktop->lock_viewport, false);
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneMain, DesktopMainSceneStateUnlocked);
break;
case DesktopMainEventUpdate:
desktop_locked_update(desktop->locked_view);
consumed = true;
break;
default:
break;
@@ -177,7 +200,9 @@ void desktop_scene_main_on_exit(void* context) {
* is finished, that's why we can be sure there is no task waiting
* for start/stop semaphore
*/
furi_pubsub_unsubscribe(loader_get_pubsub(), desktop->app_start_stop_subscription);
Loader* loader = furi_record_open("loader");
furi_pubsub_unsubscribe(loader_get_pubsub(loader), desktop->app_start_stop_subscription);
furi_record_close("loader");
furi_assert(osSemaphoreGetCount(desktop->unload_animation_semaphore) == 0);
animation_manager_set_new_idle_callback(desktop->animation_manager, NULL);
@@ -185,5 +210,4 @@ void desktop_scene_main_on_exit(void* context) {
animation_manager_set_interact_callback(desktop->animation_manager, NULL);
animation_manager_set_context(desktop->animation_manager, desktop);
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneMain, MAIN_VIEW_DEFAULT);
desktop_main_reset_hint(desktop->main_view);
}