[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,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
void IrdaAppSceneEditDeleteDone::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();

View File

@@ -1,6 +1,6 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "irda.h"
#include "irda/scene/irda-app-scene.hpp"
#include "irda/scene/irda-app-scene.h"
#include <string>
static void dialog_result_callback(DialogExResult result, void* context) {

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "gui/modules/submenu.h"
static void submenu_callback(void* context, uint32_t index) {

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
void IrdaAppSceneEditRenameDone::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
void IrdaAppSceneEditRename::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "gui/modules/submenu.h"
typedef enum {

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
void IrdaAppSceneLearnDone::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "gui/modules/text_input.h"
void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) {

View File

@@ -1,6 +1,6 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "irda.h"
#include "../irda-app-file-parser.hpp"
#include "../irda-app-file-parser.h"
#include <memory>
static void dialog_result_callback(DialogExResult result, void* context) {
@@ -51,6 +51,10 @@ void IrdaAppSceneLearnSuccess::on_enter(IrdaApp* app) {
bool IrdaAppSceneLearnSuccess::on_event(IrdaApp* app, IrdaAppEvent* event) {
bool consumed = false;
if(event->type == IrdaAppEvent::Type::Tick) {
/* Send event every tick to suppress any switching off green light */
app->notify_green_on();
}
if(event->type == IrdaAppEvent::Type::DialogExSelected) {
switch(event->payload.dialog_ex_result) {

View File

@@ -1,5 +1,5 @@
#include "../irda-app.hpp"
#include "../irda-app-event.hpp"
#include "../irda-app.h"
#include "../irda-app-event.h"
#include <irda_worker.h>
static void signal_received_callback(void* context, IrdaWorkerSignal* received_signal) {
@@ -9,7 +9,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
IrdaApp* app = static_cast<IrdaApp*>(context);
if(irda_worker_signal_is_decoded(received_signal)) {
IrdaAppSignal signal(irda_worker_get_decoded_message(received_signal));
IrdaAppSignal signal(irda_worker_get_decoded_signal(received_signal));
app->set_received_signal(signal);
} else {
const uint32_t* timings;
@@ -19,7 +19,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
app->set_received_signal(signal);
}
irda_worker_set_received_signal_callback(app->get_irda_worker(), NULL);
irda_worker_rx_set_received_signal_callback(app->get_irda_worker(), NULL, NULL);
IrdaAppEvent event;
event.type = IrdaAppEvent::Type::IrdaMessageReceived;
auto view_manager = app->get_view_manager();
@@ -31,9 +31,8 @@ void IrdaAppSceneLearn::on_enter(IrdaApp* app) {
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);
irda_worker_rx_set_received_signal_callback(worker, signal_received_callback, app);
irda_worker_rx_start(worker);
popup_set_icon(popup, 0, 32, &I_IrdaLearnShort_128x31);
popup_set_text(
@@ -58,11 +57,9 @@ bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) {
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:
@@ -73,4 +70,5 @@ bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) {
}
void IrdaAppSceneLearn::on_exit(IrdaApp* app) {
irda_worker_rx_stop(app->get_irda_worker());
}

View File

@@ -1,5 +1,5 @@
#include "../irda-app.hpp"
#include "irda/irda-app-event.hpp"
#include "../irda-app.h"
#include "irda/irda-app-event.h"
void IrdaAppSceneRemoteList::on_enter(IrdaApp* app) {
IrdaAppFileParser file_parser;

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();

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
typedef enum {
SubmenuIndexUniversalLibrary,

View File

@@ -1,12 +1,12 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
#include "assets_icons.h"
#include "gui/modules/button_menu.h"
#include "gui/modules/button_panel.h"
#include "../view/irda-app-brut-view.h"
#include "gui/view.h"
#include "irda/irda-app-event.hpp"
#include "irda/irda-app-view-manager.hpp"
#include "irda/scene/irda-app-scene.hpp"
#include "irda/irda-app-event.h"
#include "irda/irda-app-view-manager.h"
#include "irda/scene/irda-app-scene.h"
void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t index) {
IrdaApp* app = static_cast<IrdaApp*>(context);
@@ -49,10 +49,11 @@ void IrdaAppSceneUniversalCommon::show_popup(IrdaApp* app, int record_amount) {
button_panel_set_popup_input_callback(button_panel, irda_popup_brut_input_callback, app);
}
void IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) {
popup_brut_increase_progress(app->get_view_manager()->get_popup_brut());
bool IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) {
bool result = popup_brut_increase_progress(app->get_view_manager()->get_popup_brut());
auto button_panel = app->get_view_manager()->get_button_panel();
with_view_model_cpp(button_panel_get_view(button_panel), void*, model, { return true; });
return result;
}
bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) {
@@ -63,9 +64,11 @@ 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()) {
progress_popup(app);
} else {
bool result = brute_force.send_next_bruteforce();
if(result) {
result = progress_popup(app);
}
if(!result) {
brute_force.stop_bruteforce();
brute_force_started = false;
remove_popup(app);

View File

@@ -1,5 +1,5 @@
#include "irda/scene/irda-app-scene.hpp"
#include "irda/irda-app.hpp"
#include "irda/scene/irda-app-scene.h"
#include "irda/irda-app.h"
void IrdaAppSceneUniversalTV::on_enter(IrdaApp* app) {
IrdaAppViewManager* view_manager = app->get_view_manager();

View File

@@ -1,4 +1,4 @@
#include "../irda-app.hpp"
#include "../irda-app.h"
typedef enum {
SubmenuIndexUniversalTV,

View File

@@ -1,11 +1,10 @@
#pragma once
#include "../irda-app-event.hpp"
#include "../irda-app-event.h"
#include <furi-hal-irda.h>
#include "irda.h"
#include <vector>
#include <string>
#include "../irda-app-brute-force.hpp"
#include "../irda-app-brute-force.h"
class IrdaApp;
@@ -24,6 +23,7 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
uint32_t submenu_item_selected = 0;
};
@@ -33,6 +33,7 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
uint32_t submenu_item_selected = 0;
};
@@ -70,9 +71,11 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
std::vector<std::string> buttons_names;
uint32_t buttonmenu_item_selected = 0;
bool button_pressed = false;
};
class IrdaAppSceneRemoteList : public IrdaAppScene {
@@ -80,6 +83,7 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
uint32_t submenu_item_selected = 0;
std::vector<std::string> remote_names;
@@ -90,6 +94,7 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
uint32_t submenu_item_selected = 0;
};
@@ -99,6 +104,7 @@ public:
void on_enter(IrdaApp* app) final;
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
private:
std::vector<std::string> buttons_names;
};
@@ -133,16 +139,20 @@ public:
class IrdaAppSceneUniversalCommon : public IrdaAppScene {
bool brute_force_started = false;
protected:
bool on_event(IrdaApp* app, IrdaAppEvent* event) final;
void on_exit(IrdaApp* app) final;
IrdaAppBruteForce brute_force;
void remove_popup(IrdaApp* app);
void show_popup(IrdaApp* app, int record_amount);
void progress_popup(IrdaApp* app);
bool progress_popup(IrdaApp* app);
static void irda_app_item_callback(void* context, uint32_t index);
IrdaAppSceneUniversalCommon(const char* filename) : brute_force(filename) {}
~IrdaAppSceneUniversalCommon() {}
IrdaAppSceneUniversalCommon(const char* filename)
: brute_force(filename) {
}
~IrdaAppSceneUniversalCommon() {
}
};
class IrdaAppSceneUniversalTV : public IrdaAppSceneUniversalCommon {
@@ -151,13 +161,16 @@ public:
IrdaAppSceneUniversalTV()
: IrdaAppSceneUniversalCommon("/ext/irda/universal/tv.ir") {
}
~IrdaAppSceneUniversalTV() {}
~IrdaAppSceneUniversalTV() {
}
};
class IrdaAppSceneUniversalAudio : public IrdaAppSceneUniversalCommon {
public:
void on_enter(IrdaApp* app) final;
IrdaAppSceneUniversalAudio() : IrdaAppSceneUniversalCommon("/ext/irda/universal/audio.ir") {}
~IrdaAppSceneUniversalAudio() {}
IrdaAppSceneUniversalAudio()
: IrdaAppSceneUniversalCommon("/ext/irda/universal/audio.ir") {
}
~IrdaAppSceneUniversalAudio() {
}
};