2022-02-24 11:59:36 +00:00
|
|
|
#include <gui/modules/button_menu.h>
|
|
|
|
#include <input/input.h>
|
2022-02-25 15:22:58 +00:00
|
|
|
#include <infrared_worker.h>
|
[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>
2022-01-29 09:20:41 +00:00
|
|
|
#include <dolphin/dolphin.h>
|
2022-02-25 15:22:58 +00:00
|
|
|
#include "../infrared_app.h"
|
|
|
|
#include "../infrared_app_view_manager.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ButtonIndexPlus = -2,
|
|
|
|
ButtonIndexEdit = -1,
|
2021-06-09 13:04:49 +00:00
|
|
|
ButtonIndexNA = 0,
|
2021-06-02 15:16:05 +00:00
|
|
|
} ButtonIndex;
|
|
|
|
|
2021-08-11 17:51:06 +00:00
|
|
|
static void button_menu_callback(void* context, int32_t index, InputType type) {
|
2022-02-25 15:22:58 +00:00
|
|
|
InfraredApp* app = static_cast<InfraredApp*>(context);
|
|
|
|
InfraredAppEvent event;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2021-08-11 17:51:06 +00:00
|
|
|
if(type == InputTypePress) {
|
2022-02-25 15:22:58 +00:00
|
|
|
event.type = InfraredAppEvent::Type::MenuSelectedPress;
|
2021-08-11 17:51:06 +00:00
|
|
|
} else if(type == InputTypeRelease) {
|
2022-02-25 15:22:58 +00:00
|
|
|
event.type = InfraredAppEvent::Type::MenuSelectedRelease;
|
2021-08-11 17:51:06 +00:00
|
|
|
} else if(type == InputTypeShort) {
|
2022-02-25 15:22:58 +00:00
|
|
|
event.type = InfraredAppEvent::Type::MenuSelected;
|
2021-08-11 17:51:06 +00:00
|
|
|
} else {
|
|
|
|
furi_assert(0);
|
|
|
|
}
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
event.payload.menu_index = index;
|
|
|
|
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneRemote::on_enter(InfraredApp* app) {
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
ButtonMenu* button_menu = view_manager->get_button_menu();
|
|
|
|
auto remote_manager = app->get_remote_manager();
|
|
|
|
int i = 0;
|
2021-08-11 17:51:06 +00:00
|
|
|
button_pressed = false;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
infrared_worker_tx_set_get_signal_callback(
|
|
|
|
app->get_infrared_worker(), infrared_worker_tx_get_signal_steady_callback, app);
|
|
|
|
infrared_worker_tx_set_signal_sent_callback(
|
|
|
|
app->get_infrared_worker(), InfraredApp::signal_sent_callback, app);
|
2021-06-02 15:16:05 +00:00
|
|
|
buttons_names = remote_manager->get_button_list();
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
for(auto& name : buttons_names) {
|
|
|
|
button_menu_add_item(
|
|
|
|
button_menu, name.c_str(), i++, button_menu_callback, ButtonMenuItemTypeCommon, app);
|
|
|
|
}
|
|
|
|
|
|
|
|
button_menu_add_item(
|
|
|
|
button_menu, "+", ButtonIndexPlus, button_menu_callback, ButtonMenuItemTypeControl, app);
|
|
|
|
button_menu_add_item(
|
|
|
|
button_menu, "Edit", ButtonIndexEdit, button_menu_callback, ButtonMenuItemTypeControl, app);
|
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
app->set_text_store(0, "%s", remote_manager->get_remote_name().c_str());
|
2021-06-02 15:16:05 +00:00
|
|
|
button_menu_set_header(button_menu, app->get_text_store(0));
|
2021-06-09 13:04:49 +00:00
|
|
|
if(buttonmenu_item_selected != ButtonIndexNA) {
|
|
|
|
button_menu_set_selected_item(button_menu, buttonmenu_item_selected);
|
|
|
|
buttonmenu_item_selected = ButtonIndexNA;
|
|
|
|
}
|
2022-02-25 15:22:58 +00:00
|
|
|
view_manager->switch_to(InfraredAppViewManager::ViewId::ButtonMenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
bool InfraredAppSceneRemote::on_event(InfraredApp* app, InfraredAppEvent* event) {
|
2021-06-02 15:16:05 +00:00
|
|
|
bool consumed = true;
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
if((event->type == InfraredAppEvent::Type::MenuSelected) ||
|
|
|
|
(event->type == InfraredAppEvent::Type::MenuSelectedPress) ||
|
|
|
|
(event->type == InfraredAppEvent::Type::MenuSelectedRelease)) {
|
2021-06-02 15:16:05 +00:00
|
|
|
switch(event->payload.menu_index) {
|
|
|
|
case ButtonIndexPlus:
|
2022-02-25 15:22:58 +00:00
|
|
|
furi_assert(event->type == InfraredAppEvent::Type::MenuSelected);
|
2021-06-09 13:04:49 +00:00
|
|
|
app->notify_click();
|
|
|
|
buttonmenu_item_selected = event->payload.menu_index;
|
|
|
|
app->set_learn_new_remote(false);
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::Learn);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
case ButtonIndexEdit:
|
2022-02-25 15:22:58 +00:00
|
|
|
furi_assert(event->type == InfraredAppEvent::Type::MenuSelected);
|
2021-06-09 13:04:49 +00:00
|
|
|
app->notify_click();
|
|
|
|
buttonmenu_item_selected = event->payload.menu_index;
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::Edit);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-02-25 15:22:58 +00:00
|
|
|
furi_assert(event->type != InfraredAppEvent::Type::MenuSelected);
|
|
|
|
bool pressed = (event->type == InfraredAppEvent::Type::MenuSelectedPress);
|
2021-08-11 17:51:06 +00:00
|
|
|
|
|
|
|
if(pressed && !button_pressed) {
|
|
|
|
button_pressed = true;
|
|
|
|
app->notify_click_and_green_blink();
|
|
|
|
|
|
|
|
auto button_signal =
|
|
|
|
app->get_remote_manager()->get_button_data(event->payload.menu_index);
|
|
|
|
if(button_signal.is_raw()) {
|
2022-02-25 15:22:58 +00:00
|
|
|
infrared_worker_set_raw_signal(
|
|
|
|
app->get_infrared_worker(),
|
2021-08-11 17:51:06 +00:00
|
|
|
button_signal.get_raw_signal().timings,
|
|
|
|
button_signal.get_raw_signal().timings_cnt);
|
|
|
|
} else {
|
2022-02-25 15:22:58 +00:00
|
|
|
infrared_worker_set_decoded_signal(
|
|
|
|
app->get_infrared_worker(), &button_signal.get_message());
|
2021-08-11 17:51:06 +00:00
|
|
|
}
|
|
|
|
|
[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>
2022-01-29 09:20:41 +00:00
|
|
|
DOLPHIN_DEED(DolphinDeedIrSend);
|
2022-02-25 15:22:58 +00:00
|
|
|
infrared_worker_tx_start(app->get_infrared_worker());
|
2021-08-11 17:51:06 +00:00
|
|
|
} else if(!pressed && button_pressed) {
|
|
|
|
button_pressed = false;
|
2022-02-25 15:22:58 +00:00
|
|
|
infrared_worker_tx_stop(app->get_infrared_worker());
|
2021-08-11 17:51:06 +00:00
|
|
|
app->notify_green_off();
|
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-02-25 15:22:58 +00:00
|
|
|
} else if(event->type == InfraredAppEvent::Type::Back) {
|
2021-12-13 23:52:13 +00:00
|
|
|
if(!button_pressed) {
|
|
|
|
app->search_and_switch_to_previous_scene(
|
2022-02-25 15:22:58 +00:00
|
|
|
{InfraredApp::Scene::Start, InfraredApp::Scene::RemoteList});
|
2021-12-13 23:52:13 +00:00
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
} else {
|
|
|
|
consumed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneRemote::on_exit(InfraredApp* app) {
|
|
|
|
infrared_worker_tx_set_get_signal_callback(app->get_infrared_worker(), nullptr, nullptr);
|
|
|
|
infrared_worker_tx_set_signal_sent_callback(app->get_infrared_worker(), nullptr, nullptr);
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
ButtonMenu* button_menu = view_manager->get_button_menu();
|
|
|
|
|
2022-01-21 17:32:03 +00:00
|
|
|
button_menu_reset(button_menu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|