[FL-1505] Add RAW format (#576)
* Add RAW format * F5 stubs for build to pass * Fix saving decoded signal error * Irda: set ISR before starting timer, remove explicit NVIC configuration Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -20,17 +20,26 @@ void IrdaAppSceneEditDelete::on_enter(IrdaApp* app) {
|
||||
auto remote_manager = app->get_remote_manager();
|
||||
|
||||
if(app->get_edit_element() == IrdaApp::EditElement::Button) {
|
||||
auto message = remote_manager->get_button_data(app->get_current_button());
|
||||
auto signal = remote_manager->get_button_data(app->get_current_button());
|
||||
dialog_ex_set_header(dialog_ex, "Delete button?", 64, 6, AlignCenter, AlignCenter);
|
||||
app->set_text_store(
|
||||
0,
|
||||
"%s\n%s\nA=0x%0*lX C=0x%0*lX",
|
||||
remote_manager->get_button_name(app->get_current_button()).c_str(),
|
||||
irda_get_protocol_name(message->protocol),
|
||||
irda_get_protocol_address_length(message->protocol),
|
||||
message->address,
|
||||
irda_get_protocol_command_length(message->protocol),
|
||||
message->command);
|
||||
if(!signal.is_raw()) {
|
||||
auto message = &signal.get_message();
|
||||
app->set_text_store(
|
||||
0,
|
||||
"%s\n%s\nA=0x%0*lX C=0x%0*lX",
|
||||
remote_manager->get_button_name(app->get_current_button()).c_str(),
|
||||
irda_get_protocol_name(message->protocol),
|
||||
irda_get_protocol_address_length(message->protocol),
|
||||
message->address,
|
||||
irda_get_protocol_command_length(message->protocol),
|
||||
message->command);
|
||||
} else {
|
||||
app->set_text_store(
|
||||
0,
|
||||
"%s\nRAW\n%ld samples",
|
||||
remote_manager->get_button_name(app->get_current_button()).c_str(),
|
||||
signal.get_raw_signal().timings_cnt);
|
||||
}
|
||||
} else {
|
||||
dialog_ex_set_header(dialog_ex, "Delete remote?", 64, 6, AlignCenter, AlignCenter);
|
||||
app->set_text_store(
|
||||
|
@@ -5,15 +5,20 @@ void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) {
|
||||
IrdaAppViewManager* view_manager = app->get_view_manager();
|
||||
TextInput* text_input = view_manager->get_text_input();
|
||||
|
||||
auto transceiver = app->get_transceiver();
|
||||
auto message = transceiver->get_last_message();
|
||||
auto signal = app->get_received_signal();
|
||||
|
||||
app->set_text_store(
|
||||
0,
|
||||
"%.4s_%0*lX",
|
||||
irda_get_protocol_name(message->protocol),
|
||||
irda_get_protocol_command_length(message->protocol),
|
||||
message->command);
|
||||
if(!signal.is_raw()) {
|
||||
auto message = &signal.get_message();
|
||||
app->set_text_store(
|
||||
0,
|
||||
"%.4s_%0*lX",
|
||||
irda_get_protocol_name(message->protocol),
|
||||
irda_get_protocol_command_length(message->protocol),
|
||||
message->command);
|
||||
} else {
|
||||
auto raw_signal = signal.get_raw_signal();
|
||||
app->set_text_store(0, "RAW_%d", raw_signal.timings_cnt);
|
||||
}
|
||||
|
||||
text_input_set_header_text(text_input, "Name the key");
|
||||
text_input_set_result_callback(
|
||||
@@ -31,14 +36,13 @@ bool IrdaAppSceneLearnEnterName::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
|
||||
if(event->type == IrdaAppEvent::Type::TextEditDone) {
|
||||
auto remote_manager = app->get_remote_manager();
|
||||
auto transceiver = app->get_transceiver();
|
||||
bool result = false;
|
||||
if(app->get_learn_new_remote()) {
|
||||
result = remote_manager->add_remote_with_button(
|
||||
app->get_text_store(0), transceiver->get_last_message());
|
||||
app->get_text_store(0), app->get_received_signal());
|
||||
} else {
|
||||
result = remote_manager->add_button(
|
||||
app->get_text_store(0), transceiver->get_last_message());
|
||||
result =
|
||||
remote_manager->add_button(app->get_text_store(0), app->get_received_signal());
|
||||
}
|
||||
|
||||
if(!result) {
|
||||
|
@@ -17,19 +17,26 @@ void IrdaAppSceneLearnSuccess::on_enter(IrdaApp* app) {
|
||||
|
||||
app->notify_green_on();
|
||||
|
||||
auto transceiver = app->get_transceiver();
|
||||
auto message = transceiver->get_last_message();
|
||||
auto signal = app->get_received_signal();
|
||||
|
||||
if(!signal.is_raw()) {
|
||||
auto message = &signal.get_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);
|
||||
} else {
|
||||
dialog_ex_set_header(dialog_ex, "Unknown", 95, 10, AlignCenter, AlignCenter);
|
||||
app->set_text_store(0, "%d samples", signal.get_raw_signal().timings_cnt);
|
||||
dialog_ex_set_text(dialog_ex, app->get_text_store(0), 75, 23, AlignLeft, AlignTop);
|
||||
}
|
||||
|
||||
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_center_button_text(dialog_ex, "Send");
|
||||
@@ -50,9 +57,8 @@ bool IrdaAppSceneLearnSuccess::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
break;
|
||||
case DialogExResultCenter: {
|
||||
app->notify_space_blink();
|
||||
auto transceiver = app->get_transceiver();
|
||||
auto message = transceiver->get_last_message();
|
||||
irda_send(message, 1);
|
||||
auto signal = app->get_received_signal();
|
||||
signal.transmit();
|
||||
break;
|
||||
}
|
||||
case DialogExResultRight:
|
||||
|
@@ -1,14 +1,40 @@
|
||||
#include "../irda-app.hpp"
|
||||
#include "../irda-app-event.hpp"
|
||||
#include <irda_worker.h>
|
||||
|
||||
static void signal_received_callback(void* context, IrdaWorkerSignal* received_signal) {
|
||||
furi_assert(context);
|
||||
furi_assert(received_signal);
|
||||
|
||||
IrdaApp* app = static_cast<IrdaApp*>(context);
|
||||
|
||||
if(irda_worker_signal_is_decoded(received_signal)) {
|
||||
IrdaAppSignal signal(irda_worker_get_decoded_message(received_signal));
|
||||
app->set_received_signal(signal);
|
||||
} else {
|
||||
const uint32_t* timings;
|
||||
size_t timings_cnt;
|
||||
irda_worker_get_raw_signal(received_signal, &timings, &timings_cnt);
|
||||
IrdaAppSignal signal(timings, timings_cnt);
|
||||
app->set_received_signal(signal);
|
||||
}
|
||||
|
||||
irda_worker_set_received_signal_callback(app->get_irda_worker(), NULL);
|
||||
IrdaAppEvent event;
|
||||
event.type = IrdaAppEvent::Type::IrdaMessageReceived;
|
||||
auto view_manager = app->get_view_manager();
|
||||
view_manager->send_event(&event);
|
||||
}
|
||||
|
||||
void IrdaAppSceneLearn::on_enter(IrdaApp* app) {
|
||||
auto view_manager = app->get_view_manager();
|
||||
auto transceiver = app->get_transceiver();
|
||||
auto event_queue = view_manager->get_event_queue();
|
||||
|
||||
transceiver->capture_once_start(event_queue);
|
||||
|
||||
auto popup = view_manager->get_popup();
|
||||
|
||||
auto worker = app->get_irda_worker();
|
||||
irda_worker_set_context(worker, app);
|
||||
irda_worker_set_received_signal_callback(worker, signal_received_callback);
|
||||
irda_worker_start(worker);
|
||||
|
||||
popup_set_icon(popup, 0, 32, &I_IrdaLearnShort_128x31);
|
||||
popup_set_text(
|
||||
popup, "Point the remote at IR port\nand push the button", 5, 10, AlignLeft, AlignCenter);
|
||||
@@ -24,19 +50,27 @@ void IrdaAppSceneLearn::on_enter(IrdaApp* app) {
|
||||
bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == IrdaAppEvent::Type::Tick) {
|
||||
switch(event->type) {
|
||||
case IrdaAppEvent::Type::Tick:
|
||||
consumed = true;
|
||||
app->notify_red_blink();
|
||||
}
|
||||
if(event->type == IrdaAppEvent::Type::IrdaMessageReceived) {
|
||||
break;
|
||||
case IrdaAppEvent::Type::IrdaMessageReceived:
|
||||
app->notify_success();
|
||||
app->switch_to_next_scene_without_saving(IrdaApp::Scene::LearnSuccess);
|
||||
irda_worker_stop(app->get_irda_worker());
|
||||
break;
|
||||
case IrdaAppEvent::Type::Back:
|
||||
consumed = true;
|
||||
irda_worker_stop(app->get_irda_worker());
|
||||
app->switch_to_previous_scene();
|
||||
break;
|
||||
default:
|
||||
furi_assert(0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void IrdaAppSceneLearn::on_exit(IrdaApp* app) {
|
||||
auto transceiver = app->get_transceiver();
|
||||
transceiver->capture_stop();
|
||||
}
|
||||
|
@@ -64,8 +64,8 @@ bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
default:
|
||||
app->notify_click_and_blink();
|
||||
auto remote_manager = app->get_remote_manager();
|
||||
auto message = remote_manager->get_button_data(event->payload.menu_index);
|
||||
app->get_transceiver()->send_message(message);
|
||||
auto signal = remote_manager->get_button_data(event->payload.menu_index);
|
||||
signal.transmit();
|
||||
break;
|
||||
}
|
||||
} else if(event->type == IrdaAppEvent::Type::Back) {
|
||||
|
@@ -63,7 +63,7 @@ bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
auto view_manager = app->get_view_manager();
|
||||
IrdaAppEvent tick_event = {.type = IrdaAppEvent::Type::Tick};
|
||||
view_manager->send_event(&tick_event);
|
||||
if(brute_force.send_next_bruteforce(*app->get_transceiver())) {
|
||||
if(brute_force.send_next_bruteforce()) {
|
||||
progress_popup(app);
|
||||
} else {
|
||||
brute_force.stop_bruteforce();
|
||||
|
Reference in New Issue
Block a user