mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-20 17:53:20 +00:00
31c31db479
* Add new IrdaApp (half ready), add ButtonMenu * Fix NEC's extension * clang-format * Fix leak * Add submenu optional header * IRDA: add Edit button * clang-format * IrdaApp: Fix scene flow * Add IRDA NEC extended protocol * IRDA: Add address/command length Co-authored-by: SG <who.just.the.doctor@gmail.com>
63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
#include "../irda-app.hpp"
|
|
#include "irda.h"
|
|
#include <string>
|
|
#include <stdio.h>
|
|
|
|
static void dialog_result_callback(DialogExResult result, void* context) {
|
|
auto app = static_cast<IrdaApp*>(context);
|
|
IrdaAppEvent event;
|
|
|
|
event.type = IrdaAppEvent::Type::DialogExSelected;
|
|
event.payload.dialog_ex_result = result;
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
}
|
|
|
|
void IrdaAppSceneLearnSuccess::on_enter(IrdaApp* app) {
|
|
IrdaAppViewManager* view_manager = app->get_view_manager();
|
|
DialogEx* dialog_ex = view_manager->get_dialog_ex();
|
|
|
|
auto receiver = app->get_receiver();
|
|
auto message = receiver->get_last_message();
|
|
|
|
app->set_text_store(0, "%s", irda_get_protocol_name(message->protocol));
|
|
app->set_text_store(
|
|
1,
|
|
"A: 0x%0*lX\nC: 0x%0*lX\n",
|
|
irda_get_protocol_address_length(message->protocol),
|
|
message->address,
|
|
irda_get_protocol_command_length(message->protocol),
|
|
message->command);
|
|
dialog_ex_set_header(dialog_ex, app->get_text_store(0), 95, 10, AlignCenter, AlignCenter);
|
|
dialog_ex_set_text(dialog_ex, app->get_text_store(1), 75, 23, AlignLeft, AlignTop);
|
|
dialog_ex_set_left_button_text(dialog_ex, "Retry");
|
|
dialog_ex_set_right_button_text(dialog_ex, "Save");
|
|
dialog_ex_set_icon(dialog_ex, 0, 1, I_DolphinExcited_64x63);
|
|
dialog_ex_set_result_callback(dialog_ex, dialog_result_callback);
|
|
dialog_ex_set_context(dialog_ex, app);
|
|
|
|
view_manager->switch_to(IrdaAppViewManager::ViewType::DialogEx);
|
|
}
|
|
|
|
bool IrdaAppSceneLearnSuccess::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == IrdaAppEvent::Type::DialogExSelected) {
|
|
switch(event->payload.dialog_ex_result) {
|
|
case DialogExResultLeft:
|
|
app->switch_to_next_scene_without_saving(IrdaApp::Scene::Learn);
|
|
break;
|
|
case DialogExResultCenter:
|
|
furi_assert(0);
|
|
break;
|
|
case DialogExResultRight:
|
|
app->switch_to_next_scene(IrdaApp::Scene::LearnEnterName);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void IrdaAppSceneLearnSuccess::on_exit(IrdaApp* app) {
|
|
}
|