[FL-1652, FL-1554] IRDA: Continuous transmitting (#636)

* [FL-1652] IRDA: Continuous transmitting
* continuous encoding and sending signals by pressing button on menu
* fast buttons scrolling in remote menu
* bruteforce: stop reading file if progress == 100%
* IRDA: .hpp -> .h
* [FL-1554] IRDA: xTaskNotify -> osEventsFlagSet
* IRDA: some stability fixes
* Irda: minor cleanup, api-hal to furi-hal rename.

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Albert Kharisov
2021-08-11 20:51:06 +03:00
committed by GitHub
parent 8696355556
commit 5ed9bdbc37
43 changed files with 804 additions and 218 deletions

View File

@@ -1,5 +1,7 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "gui/modules/button_menu.h"
#include "input/input.h"
#include "irda_worker.h"
typedef enum {
ButtonIndexPlus = -2,
@@ -7,22 +9,41 @@ typedef enum {
ButtonIndexNA = 0,
} ButtonIndex;
static void button_menu_callback(void* context, int32_t index) {
static void button_menu_callback(void* context, int32_t index, InputType type) {
IrdaApp* app = static_cast<IrdaApp*>(context);
IrdaAppEvent event;
event.type = IrdaAppEvent::Type::MenuSelected;
if(type == InputTypePress) {
event.type = IrdaAppEvent::Type::MenuSelectedPress;
} else if(type == InputTypeRelease) {
event.type = IrdaAppEvent::Type::MenuSelectedRelease;
} else if(type == InputTypeShort) {
event.type = IrdaAppEvent::Type::MenuSelected;
} else {
furi_assert(0);
}
event.payload.menu_index = index;
app->get_view_manager()->send_event(&event);
}
static void irda_app_message_sent_callback(void* context) {
IrdaApp* app = static_cast<IrdaApp*>(context);
app->notify_blink_green();
}
void IrdaAppSceneRemote::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();
ButtonMenu* button_menu = view_manager->get_button_menu();
auto remote_manager = app->get_remote_manager();
int i = 0;
button_pressed = false;
irda_worker_tx_set_get_signal_callback(
app->get_irda_worker(), irda_worker_tx_get_signal_steady_callback, app);
irda_worker_tx_set_signal_sent_callback(
app->get_irda_worker(), irda_app_message_sent_callback, app);
buttons_names = remote_manager->get_button_list();
i = 0;
@@ -48,24 +69,49 @@ void IrdaAppSceneRemote::on_enter(IrdaApp* app) {
bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) {
bool consumed = true;
if(event->type == IrdaAppEvent::Type::MenuSelected) {
if((event->type == IrdaAppEvent::Type::MenuSelected) ||
(event->type == IrdaAppEvent::Type::MenuSelectedPress) ||
(event->type == IrdaAppEvent::Type::MenuSelectedRelease)) {
switch(event->payload.menu_index) {
case ButtonIndexPlus:
furi_assert(event->type == IrdaAppEvent::Type::MenuSelected);
app->notify_click();
buttonmenu_item_selected = event->payload.menu_index;
app->set_learn_new_remote(false);
app->switch_to_next_scene(IrdaApp::Scene::Learn);
break;
case ButtonIndexEdit:
furi_assert(event->type == IrdaAppEvent::Type::MenuSelected);
app->notify_click();
buttonmenu_item_selected = event->payload.menu_index;
app->switch_to_next_scene(IrdaApp::Scene::Edit);
break;
default:
app->notify_click_and_blink();
auto remote_manager = app->get_remote_manager();
auto signal = remote_manager->get_button_data(event->payload.menu_index);
signal.transmit();
furi_assert(event->type != IrdaAppEvent::Type::MenuSelected);
bool pressed = (event->type == IrdaAppEvent::Type::MenuSelectedPress);
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()) {
irda_worker_set_raw_signal(
app->get_irda_worker(),
button_signal.get_raw_signal().timings,
button_signal.get_raw_signal().timings_cnt);
} else {
irda_worker_set_decoded_signal(
app->get_irda_worker(), &button_signal.get_message());
}
irda_worker_tx_start(app->get_irda_worker());
} else if(!pressed && button_pressed) {
button_pressed = false;
irda_worker_tx_stop(app->get_irda_worker());
app->notify_green_off();
}
break;
}
} else if(event->type == IrdaAppEvent::Type::Back) {
@@ -79,6 +125,8 @@ bool IrdaAppSceneRemote::on_event(IrdaApp* app, IrdaAppEvent* event) {
}
void IrdaAppSceneRemote::on_exit(IrdaApp* app) {
irda_worker_tx_set_get_signal_callback(app->get_irda_worker(), nullptr, nullptr);
irda_worker_tx_set_signal_sent_callback(app->get_irda_worker(), nullptr, nullptr);
IrdaAppViewManager* view_manager = app->get_view_manager();
ButtonMenu* button_menu = view_manager->get_button_menu();