2020-12-18 20:15:29 +00:00
|
|
|
#include "dolphin_i.h"
|
2021-03-25 17:48:58 +00:00
|
|
|
#include <stdlib.h>
|
2021-04-13 18:06:25 +00:00
|
|
|
#include "applications.h"
|
|
|
|
|
2021-07-07 08:57:49 +00:00
|
|
|
const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64};
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
static void dolphin_switch_to_app(Dolphin* dolphin, const FlipperApplication* flipper_app) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(dolphin);
|
|
|
|
furi_assert(flipper_app);
|
|
|
|
furi_assert(flipper_app->app);
|
|
|
|
furi_assert(flipper_app->name);
|
|
|
|
|
|
|
|
furi_thread_set_name(dolphin->scene_thread, flipper_app->name);
|
|
|
|
furi_thread_set_stack_size(dolphin->scene_thread, flipper_app->stack_size);
|
|
|
|
furi_thread_set_callback(dolphin->scene_thread, flipper_app->app);
|
|
|
|
furi_thread_start(dolphin->scene_thread);
|
|
|
|
}
|
2021-03-25 17:48:58 +00:00
|
|
|
|
|
|
|
// temporary main screen animation managment
|
2021-07-07 08:57:49 +00:00
|
|
|
void dolphin_scene_handler_set_scene(Dolphin* dolphin, const Icon* icon_data) {
|
2021-03-25 17:48:58 +00:00
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
2021-07-07 08:57:49 +00:00
|
|
|
if(model->animation) icon_animation_free(model->animation);
|
|
|
|
model->animation = icon_animation_alloc(icon_data);
|
|
|
|
icon_animation_start(model->animation);
|
2021-03-25 17:48:58 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void dolphin_scene_handler_switch_scene(Dolphin* dolphin) {
|
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
2021-07-07 08:57:49 +00:00
|
|
|
if(icon_animation_is_last_frame(model->animation)) {
|
|
|
|
if(model->animation) icon_animation_free(model->animation);
|
|
|
|
model->animation = icon_animation_alloc(idle_scenes[model->scene_num]);
|
|
|
|
icon_animation_start(model->animation);
|
|
|
|
model->scene_num = random() % COUNT_OF(idle_scenes);
|
2021-03-25 17:48:58 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
2020-12-18 20:15:29 +00:00
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
bool dolphin_view_first_start_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
2020-12-18 20:15:29 +00:00
|
|
|
Dolphin* dolphin = context;
|
2021-02-10 08:56:05 +00:00
|
|
|
if(event->type == InputTypeShort) {
|
2021-05-05 09:50:03 +00:00
|
|
|
DolphinViewFirstStartModel* model = view_get_model(dolphin->idle_view_first_start);
|
2021-02-10 08:56:05 +00:00
|
|
|
if(event->key == InputKeyLeft) {
|
2021-05-05 09:50:03 +00:00
|
|
|
if(model->page > 0) model->page--;
|
2021-02-10 08:56:05 +00:00
|
|
|
} else if(event->key == InputKeyRight) {
|
2021-05-05 09:50:03 +00:00
|
|
|
uint32_t page = ++model->page;
|
2021-01-08 04:42:48 +00:00
|
|
|
if(page > 8) {
|
|
|
|
dolphin_save(dolphin);
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
}
|
|
|
|
}
|
2021-05-05 09:50:03 +00:00
|
|
|
view_commit_model(dolphin->idle_view_first_start, true);
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
2021-05-05 09:50:03 +00:00
|
|
|
// All evennts cosumed
|
2021-01-08 04:42:48 +00:00
|
|
|
return true;
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
void dolphin_lock_handler(InputEvent* event, Dolphin* dolphin) {
|
2021-01-08 04:42:48 +00:00
|
|
|
furi_assert(event);
|
2021-05-05 09:50:03 +00:00
|
|
|
furi_assert(dolphin);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
|
|
|
model->hint_timeout = HINT_TIMEOUT_L;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
2021-05-05 09:50:03 +00:00
|
|
|
uint32_t press_time = HAL_GetTick();
|
|
|
|
|
|
|
|
// check if pressed sequentially
|
2021-05-18 18:54:56 +00:00
|
|
|
if(press_time - dolphin->lock_lastpress > UNLOCK_RST_TIMEOUT) {
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->lock_lastpress = press_time;
|
|
|
|
dolphin->lock_count = 0;
|
2021-05-18 18:54:56 +00:00
|
|
|
} else if(press_time - dolphin->lock_lastpress < UNLOCK_RST_TIMEOUT) {
|
|
|
|
dolphin->lock_lastpress = press_time;
|
|
|
|
dolphin->lock_count++;
|
2021-05-05 09:50:03 +00:00
|
|
|
}
|
2020-12-18 20:15:29 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
if(dolphin->lock_count == 2) {
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->locked = false;
|
|
|
|
dolphin->lock_count = 0;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
dolphin->view_lockmenu, (DolphinViewLockMenuModel * model) {
|
|
|
|
model->locked = false;
|
2021-05-18 18:54:56 +00:00
|
|
|
model->door_left_x = -57; // move doors to default pos
|
|
|
|
model->door_right_x = 115;
|
2021-05-05 09:50:03 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
2021-05-18 18:54:56 +00:00
|
|
|
model->hint_timeout = HINT_TIMEOUT_L; // "unlocked" hint timeout
|
|
|
|
model->locked = false;
|
2021-05-05 09:50:03 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
view_port_enabled_set(dolphin->lock_viewport, false);
|
2021-01-08 04:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
bool dolphin_view_idle_main_input(InputEvent* event, void* context) {
|
2021-01-08 04:42:48 +00:00
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
2020-12-18 20:15:29 +00:00
|
|
|
Dolphin* dolphin = context;
|
2021-05-05 09:50:03 +00:00
|
|
|
// unlocked
|
|
|
|
if(!dolphin->locked) {
|
|
|
|
if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
|
|
|
with_value_mutex(
|
|
|
|
dolphin->menu_vm, (Menu * menu) { menu_ok(menu); });
|
|
|
|
} else if(event->key == InputKeyUp && event->type == InputTypeShort) {
|
|
|
|
osTimerStart(dolphin->timeout_timer, 40);
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewLockMenu);
|
|
|
|
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
|
|
|
#if 0
|
|
|
|
dolphin_switch_to_app(dolphin, &FAV_APP);
|
|
|
|
#endif
|
|
|
|
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
|
|
|
|
dolphin_switch_to_app(dolphin, &FLIPPER_SCENE);
|
|
|
|
} else if(event->key == InputKeyDown && event->type == InputTypeShort) {
|
2021-05-18 18:54:56 +00:00
|
|
|
dolphin_switch_to_app(dolphin, &FLIPPER_ARCHIVE);
|
2021-05-05 09:50:03 +00:00
|
|
|
} else if(event->key == InputKeyDown && event->type == InputTypeLong) {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewStats);
|
|
|
|
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
}
|
2021-07-23 13:15:25 +00:00
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
|
|
|
model->hint_timeout = 0; // clear hint timeout
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
} else {
|
|
|
|
// locked
|
2020-12-18 20:15:29 +00:00
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin_lock_handler(event, dolphin);
|
|
|
|
dolphin_scene_handler_switch_scene(dolphin);
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
2021-05-05 09:50:03 +00:00
|
|
|
// All events consumed
|
2021-01-08 04:42:48 +00:00
|
|
|
return true;
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
void lock_menu_refresh_handler(void* p) {
|
|
|
|
osMessageQueueId_t event_queue = p;
|
|
|
|
DolphinEvent event;
|
|
|
|
event.type = DolphinEventTypeTick;
|
|
|
|
// Some tick events may lost and we don't care.
|
|
|
|
osMessageQueuePut(event_queue, &event, 0, 0);
|
|
|
|
}
|
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
static void lock_menu_callback(void* context, uint8_t index) {
|
2021-05-05 09:50:03 +00:00
|
|
|
furi_assert(context);
|
2021-03-25 17:48:58 +00:00
|
|
|
Dolphin* dolphin = context;
|
|
|
|
switch(index) {
|
2021-05-05 09:50:03 +00:00
|
|
|
// lock
|
2021-03-25 17:48:58 +00:00
|
|
|
case 0:
|
|
|
|
dolphin->locked = true;
|
2021-05-05 09:50:03 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
with_view_model(
|
|
|
|
dolphin->view_lockmenu, (DolphinViewLockMenuModel * model) {
|
|
|
|
model->locked = true;
|
|
|
|
model->exit_timeout = HINT_TIMEOUT_H;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-05 09:50:03 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
with_view_model(
|
|
|
|
dolphin->idle_view_main, (DolphinViewMainModel * model) {
|
|
|
|
model->locked = true;
|
|
|
|
return true;
|
|
|
|
});
|
2021-03-25 17:48:58 +00:00
|
|
|
break;
|
2021-05-05 09:50:03 +00:00
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lock_icon_callback(Canvas* canvas, void* context) {
|
2021-03-31 18:05:00 +00:00
|
|
|
furi_assert(context);
|
2021-03-25 17:48:58 +00:00
|
|
|
Dolphin* dolphin = context;
|
2021-07-07 08:57:49 +00:00
|
|
|
canvas_draw_icon_animation(canvas, 0, 0, dolphin->lock_icon);
|
2021-03-25 17:48:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool dolphin_view_lockmenu_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
Dolphin* dolphin = context;
|
|
|
|
|
|
|
|
if(event->type != InputTypeShort) return false;
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
DolphinViewLockMenuModel* model = view_get_model(dolphin->view_lockmenu);
|
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
if(event->key == InputKeyUp) {
|
2021-05-05 09:50:03 +00:00
|
|
|
model->idx = CLAMP(model->idx - 1, 2, 0);
|
2021-03-25 17:48:58 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2021-05-05 09:50:03 +00:00
|
|
|
model->idx = CLAMP(model->idx + 1, 2, 0);
|
2021-03-25 17:48:58 +00:00
|
|
|
} else if(event->key == InputKeyOk) {
|
2021-05-05 09:50:03 +00:00
|
|
|
lock_menu_callback(context, model->idx);
|
2021-03-25 17:48:58 +00:00
|
|
|
} else if(event->key == InputKeyBack) {
|
2021-05-05 09:50:03 +00:00
|
|
|
model->idx = 0;
|
2021-03-25 17:48:58 +00:00
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
|
|
|
|
if(random() % 100 > 50)
|
2021-07-07 08:57:49 +00:00
|
|
|
dolphin_scene_handler_set_scene(
|
|
|
|
dolphin, idle_scenes[random() % COUNT_OF(idle_scenes)]);
|
2021-03-25 17:48:58 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
view_commit_model(dolphin->view_lockmenu, true);
|
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-04-19 16:30:25 +00:00
|
|
|
bool dolphin_view_idle_down_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
Dolphin* dolphin = context;
|
2021-05-05 09:50:03 +00:00
|
|
|
DolphinViewStatsScreens current;
|
2021-04-19 16:30:25 +00:00
|
|
|
|
|
|
|
if(event->type != InputTypeShort) return false;
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
DolphinViewStatsModel* model = view_get_model(dolphin->idle_view_dolphin_stats);
|
|
|
|
|
|
|
|
current = model->screen;
|
|
|
|
|
|
|
|
if(event->key == InputKeyDown) {
|
|
|
|
model->screen = (model->screen + 1) % DolphinViewStatsTotalCount;
|
|
|
|
} else if(event->key == InputKeyUp) {
|
|
|
|
model->screen =
|
|
|
|
((model->screen - 1) + DolphinViewStatsTotalCount) % DolphinViewStatsTotalCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
view_commit_model(dolphin->idle_view_dolphin_stats, true);
|
|
|
|
|
|
|
|
if(current == DolphinViewStatsMeta) {
|
|
|
|
if(event->key == InputKeyLeft) {
|
|
|
|
dolphin_deed(dolphin, DolphinDeedWrong);
|
|
|
|
} else if(event->key == InputKeyRight) {
|
|
|
|
dolphin_deed(dolphin, DolphinDeedIButtonRead);
|
|
|
|
} else if(event->key == InputKeyOk) {
|
|
|
|
dolphin_save(dolphin);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-19 16:30:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
}
|
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
return true;
|
2021-04-19 16:30:25 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 20:15:29 +00:00
|
|
|
Dolphin* dolphin_alloc() {
|
|
|
|
Dolphin* dolphin = furi_alloc(sizeof(Dolphin));
|
2021-01-08 04:42:48 +00:00
|
|
|
// Message queue
|
|
|
|
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
|
|
|
|
furi_check(dolphin->event_queue);
|
|
|
|
// State
|
|
|
|
dolphin->state = dolphin_state_alloc();
|
|
|
|
// Menu
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
dolphin->menu_vm = furi_record_open("menu");
|
2021-04-13 18:06:25 +00:00
|
|
|
// Scene thread
|
|
|
|
dolphin->scene_thread = furi_thread_alloc();
|
2021-01-08 04:42:48 +00:00
|
|
|
// GUI
|
2021-04-13 18:06:25 +00:00
|
|
|
dolphin->gui = furi_record_open("gui");
|
|
|
|
// Dispatcher
|
2021-01-08 04:42:48 +00:00
|
|
|
dolphin->idle_view_dispatcher = view_dispatcher_alloc();
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
// First start View
|
|
|
|
dolphin->idle_view_first_start = view_alloc();
|
|
|
|
view_allocate_model(
|
|
|
|
dolphin->idle_view_first_start, ViewModelTypeLockFree, sizeof(DolphinViewFirstStartModel));
|
|
|
|
view_set_context(dolphin->idle_view_first_start, dolphin);
|
|
|
|
view_set_draw_callback(dolphin->idle_view_first_start, dolphin_view_first_start_draw);
|
|
|
|
view_set_input_callback(dolphin->idle_view_first_start, dolphin_view_first_start_input);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
dolphin->idle_view_dispatcher, DolphinViewFirstStart, dolphin->idle_view_first_start);
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
// Main Idle View
|
|
|
|
dolphin->idle_view_main = view_alloc();
|
|
|
|
view_set_context(dolphin->idle_view_main, dolphin);
|
2021-03-25 17:48:58 +00:00
|
|
|
view_allocate_model(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->idle_view_main, ViewModelTypeLockFree, sizeof(DolphinViewMainModel));
|
2021-03-25 17:48:58 +00:00
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
view_set_draw_callback(dolphin->idle_view_main, dolphin_view_idle_main_draw);
|
|
|
|
view_set_input_callback(dolphin->idle_view_main, dolphin_view_idle_main_input);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
dolphin->idle_view_dispatcher, DolphinViewIdleMain, dolphin->idle_view_main);
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
// Lock Menu View
|
|
|
|
dolphin->view_lockmenu = view_alloc();
|
|
|
|
view_set_context(dolphin->view_lockmenu, dolphin);
|
|
|
|
view_allocate_model(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->view_lockmenu, ViewModelTypeLockFree, sizeof(DolphinViewLockMenuModel));
|
2021-03-25 17:48:58 +00:00
|
|
|
view_set_draw_callback(dolphin->view_lockmenu, dolphin_view_lockmenu_draw);
|
|
|
|
view_set_input_callback(dolphin->view_lockmenu, dolphin_view_lockmenu_input);
|
|
|
|
view_set_previous_callback(dolphin->view_lockmenu, dolphin_view_idle_back);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
dolphin->idle_view_dispatcher, DolphinViewLockMenu, dolphin->view_lockmenu);
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
// default doors xpos
|
|
|
|
with_view_model(
|
|
|
|
dolphin->view_lockmenu, (DolphinViewLockMenuModel * model) {
|
|
|
|
model->door_left_x = -57; // defaults
|
|
|
|
model->door_right_x = 115; // defaults
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
dolphin->timeout_timer =
|
|
|
|
osTimerNew(lock_menu_refresh_handler, osTimerPeriodic, dolphin->event_queue, NULL);
|
|
|
|
|
|
|
|
// Stats Idle View
|
|
|
|
dolphin->idle_view_dolphin_stats = view_alloc();
|
|
|
|
view_set_context(dolphin->idle_view_dolphin_stats, dolphin);
|
2021-04-19 16:30:25 +00:00
|
|
|
view_allocate_model(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->idle_view_dolphin_stats, ViewModelTypeLockFree, sizeof(DolphinViewStatsModel));
|
|
|
|
view_set_draw_callback(dolphin->idle_view_dolphin_stats, dolphin_view_idle_down_draw);
|
|
|
|
view_set_input_callback(dolphin->idle_view_dolphin_stats, dolphin_view_idle_down_input);
|
|
|
|
view_set_previous_callback(dolphin->idle_view_dolphin_stats, dolphin_view_idle_back);
|
2021-01-08 04:42:48 +00:00
|
|
|
view_dispatcher_add_view(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->idle_view_dispatcher, DolphinViewStats, dolphin->idle_view_dolphin_stats);
|
2021-02-18 12:49:32 +00:00
|
|
|
// HW Mismatch
|
|
|
|
dolphin->view_hw_mismatch = view_alloc();
|
|
|
|
view_set_draw_callback(dolphin->view_hw_mismatch, dolphin_view_hw_mismatch_draw);
|
|
|
|
view_set_previous_callback(dolphin->view_hw_mismatch, dolphin_view_idle_back);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
dolphin->idle_view_dispatcher, DolphinViewHwMismatch, dolphin->view_hw_mismatch);
|
2020-12-18 20:15:29 +00:00
|
|
|
|
2021-03-25 17:48:58 +00:00
|
|
|
// Lock icon
|
2021-07-07 08:57:49 +00:00
|
|
|
dolphin->lock_icon = icon_animation_alloc(&I_Lock_8x8);
|
2021-03-25 17:48:58 +00:00
|
|
|
dolphin->lock_viewport = view_port_alloc();
|
2021-07-07 08:57:49 +00:00
|
|
|
view_port_set_width(dolphin->lock_viewport, icon_animation_get_width(dolphin->lock_icon));
|
2021-03-25 17:48:58 +00:00
|
|
|
view_port_draw_callback_set(dolphin->lock_viewport, lock_icon_callback, dolphin);
|
|
|
|
view_port_enabled_set(dolphin->lock_viewport, false);
|
|
|
|
|
|
|
|
// Main screen animation
|
2021-07-07 08:57:49 +00:00
|
|
|
dolphin_scene_handler_set_scene(dolphin, idle_scenes[random() % COUNT_OF(idle_scenes)]);
|
2021-03-25 17:48:58 +00:00
|
|
|
|
2021-04-13 18:06:25 +00:00
|
|
|
view_dispatcher_attach_to_gui(
|
|
|
|
dolphin->idle_view_dispatcher, dolphin->gui, ViewDispatcherTypeWindow);
|
|
|
|
gui_add_view_port(dolphin->gui, dolphin->lock_viewport, GuiLayerStatusBarLeft);
|
|
|
|
|
2020-12-18 20:15:29 +00:00
|
|
|
return dolphin;
|
|
|
|
}
|
|
|
|
|
2021-04-13 18:06:25 +00:00
|
|
|
void dolphin_free(Dolphin* dolphin) {
|
|
|
|
furi_assert(dolphin);
|
|
|
|
|
|
|
|
gui_remove_view_port(dolphin->gui, dolphin->lock_viewport);
|
|
|
|
view_port_free(dolphin->lock_viewport);
|
2021-07-07 08:57:49 +00:00
|
|
|
icon_animation_free(dolphin->lock_icon);
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-05-05 09:50:03 +00:00
|
|
|
osTimerDelete(dolphin->timeout_timer);
|
|
|
|
|
2021-04-13 18:06:25 +00:00
|
|
|
view_dispatcher_free(dolphin->idle_view_dispatcher);
|
|
|
|
|
|
|
|
furi_record_close("gui");
|
|
|
|
dolphin->gui = NULL;
|
|
|
|
|
|
|
|
furi_thread_free(dolphin->scene_thread);
|
|
|
|
|
|
|
|
furi_record_close("menu");
|
|
|
|
dolphin->menu_vm = NULL;
|
|
|
|
|
|
|
|
dolphin_state_free(dolphin->state);
|
|
|
|
|
|
|
|
osMessageQueueDelete(dolphin->event_queue);
|
|
|
|
|
|
|
|
free(dolphin);
|
|
|
|
}
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void dolphin_save(Dolphin* dolphin) {
|
|
|
|
furi_assert(dolphin);
|
|
|
|
DolphinEvent event;
|
|
|
|
event.type = DolphinEventTypeSave;
|
|
|
|
furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2020-12-18 20:15:29 +00:00
|
|
|
void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) {
|
2021-01-08 04:42:48 +00:00
|
|
|
furi_assert(dolphin);
|
2020-12-18 20:15:29 +00:00
|
|
|
DolphinEvent event;
|
|
|
|
event.type = DolphinEventTypeDeed;
|
|
|
|
event.deed = deed;
|
|
|
|
furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2021-02-12 17:24:34 +00:00
|
|
|
int32_t dolphin_task() {
|
2020-12-18 20:15:29 +00:00
|
|
|
Dolphin* dolphin = dolphin_alloc();
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
if(dolphin_state_load(dolphin->state)) {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
} else {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewFirstStart);
|
|
|
|
}
|
2021-05-05 09:50:03 +00:00
|
|
|
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
with_view_model(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->idle_view_dolphin_stats, (DolphinViewStatsModel * model) {
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
model->icounter = dolphin_state_get_icounter(dolphin->state);
|
|
|
|
model->butthurt = dolphin_state_get_butthurt(dolphin->state);
|
2021-02-10 09:06:29 +00:00
|
|
|
return true;
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
});
|
2020-12-18 20:15:29 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
furi_record_create("dolphin", dolphin);
|
2020-12-18 20:15:29 +00:00
|
|
|
|
2021-02-18 12:49:32 +00:00
|
|
|
if(!api_hal_version_do_i_belong_here()) {
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewHwMismatch);
|
|
|
|
}
|
2021-05-05 09:50:03 +00:00
|
|
|
|
2020-12-18 20:15:29 +00:00
|
|
|
DolphinEvent event;
|
|
|
|
while(1) {
|
|
|
|
furi_check(osMessageQueueGet(dolphin->event_queue, &event, NULL, osWaitForever) == osOK);
|
2021-05-05 09:50:03 +00:00
|
|
|
|
|
|
|
DolphinViewLockMenuModel* lock_model = view_get_model(dolphin->view_lockmenu);
|
|
|
|
|
|
|
|
if(lock_model->locked && lock_model->exit_timeout == 0 &&
|
|
|
|
osTimerIsRunning(dolphin->timeout_timer)) {
|
|
|
|
osTimerStop(dolphin->timeout_timer);
|
|
|
|
osDelay(1); // smol enterprise delay
|
|
|
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event.type == DolphinEventTypeTick) {
|
|
|
|
view_commit_model(dolphin->view_lockmenu, true);
|
|
|
|
|
|
|
|
} else if(event.type == DolphinEventTypeDeed) {
|
2020-12-18 20:15:29 +00:00
|
|
|
dolphin_state_on_deed(dolphin->state, event.deed);
|
2021-01-08 04:42:48 +00:00
|
|
|
with_view_model(
|
2021-05-05 09:50:03 +00:00
|
|
|
dolphin->idle_view_dolphin_stats, (DolphinViewStatsModel * model) {
|
2021-01-08 04:42:48 +00:00
|
|
|
model->icounter = dolphin_state_get_icounter(dolphin->state);
|
|
|
|
model->butthurt = dolphin_state_get_butthurt(dolphin->state);
|
2021-02-10 09:06:29 +00:00
|
|
|
return true;
|
2021-01-08 04:42:48 +00:00
|
|
|
});
|
|
|
|
} else if(event.type == DolphinEventTypeSave) {
|
|
|
|
dolphin_state_save(dolphin->state);
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-13 18:06:25 +00:00
|
|
|
dolphin_free(dolphin);
|
2021-02-12 17:24:34 +00:00
|
|
|
return 0;
|
2020-12-18 20:15:29 +00:00
|
|
|
}
|