[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:
@@ -1,6 +1,7 @@
|
||||
#include "button_menu.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/elements.h"
|
||||
#include "input/input.h"
|
||||
#include <m-array.h>
|
||||
#include <furi.h>
|
||||
#include <stdint.h>
|
||||
@@ -23,6 +24,7 @@ ARRAY_DEF(ButtonMenuItemArray, ButtonMenuItem, M_POD_OPLIST);
|
||||
|
||||
struct ButtonMenu {
|
||||
View* view;
|
||||
bool freeze_input;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -158,7 +160,7 @@ static void button_menu_process_down(ButtonMenu* button_menu) {
|
||||
});
|
||||
}
|
||||
|
||||
static void button_menu_process_ok(ButtonMenu* button_menu) {
|
||||
static void button_menu_process_ok(ButtonMenu* button_menu, InputType type) {
|
||||
furi_assert(button_menu);
|
||||
|
||||
ButtonMenuItem* item = NULL;
|
||||
@@ -168,11 +170,22 @@ static void button_menu_process_ok(ButtonMenu* button_menu) {
|
||||
if(model->position < (ButtonMenuItemArray_size(model->items))) {
|
||||
item = ButtonMenuItemArray_get(model->items, model->position);
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
if(item && item->callback) {
|
||||
item->callback(item->callback_context, item->index);
|
||||
if(item->type == ButtonMenuItemTypeControl) {
|
||||
if(type == InputTypeShort) {
|
||||
if(item && item->callback) {
|
||||
item->callback(item->callback_context, item->index, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item->type == ButtonMenuItemTypeCommon) {
|
||||
if((type == InputTypePress) || (type == InputTypeRelease)) {
|
||||
if(item && item->callback) {
|
||||
item->callback(item->callback_context, item->index, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +195,19 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) {
|
||||
ButtonMenu* button_menu = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyOk) {
|
||||
if((event->type == InputTypeRelease) || (event->type == InputTypePress)) {
|
||||
consumed = true;
|
||||
button_menu->freeze_input = (event->type == InputTypePress);
|
||||
button_menu_process_ok(button_menu, event->type);
|
||||
} else if(event->type == InputTypeShort) {
|
||||
consumed = true;
|
||||
button_menu_process_ok(button_menu, event->type);
|
||||
}
|
||||
}
|
||||
|
||||
if(!button_menu->freeze_input &&
|
||||
((event->type == InputTypeRepeat) || (event->type == InputTypeShort))) {
|
||||
switch(event->key) {
|
||||
case InputKeyUp:
|
||||
consumed = true;
|
||||
@@ -192,10 +217,6 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) {
|
||||
consumed = true;
|
||||
button_menu_process_down(button_menu);
|
||||
break;
|
||||
case InputKeyOk:
|
||||
consumed = true;
|
||||
button_menu_process_ok(button_menu);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -272,6 +293,7 @@ ButtonMenu* button_menu_alloc(void) {
|
||||
return true;
|
||||
});
|
||||
|
||||
button_menu->freeze_input = false;
|
||||
return button_menu;
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ typedef struct ButtonMenu ButtonMenu;
|
||||
typedef struct ButtonMenuItem ButtonMenuItem;
|
||||
|
||||
/* Callback for any button menu actions */
|
||||
typedef void (*ButtonMenuItemCallback)(void* context, int32_t index);
|
||||
typedef void (*ButtonMenuItemCallback)(void* context, int32_t index, InputType type);
|
||||
|
||||
/* Type of button. Difference in drawing buttons. */
|
||||
typedef enum {
|
||||
|
@@ -19,7 +19,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
|
||||
Cli* cli = (Cli*)context;
|
||||
|
||||
if(irda_worker_signal_is_decoded(received_signal)) {
|
||||
const IrdaMessage* message = irda_worker_get_decoded_message(received_signal);
|
||||
const IrdaMessage* message = irda_worker_get_decoded_signal(received_signal);
|
||||
buf_cnt = sniprintf(
|
||||
buf,
|
||||
sizeof(buf),
|
||||
@@ -54,16 +54,15 @@ static void irda_cli_start_ir_rx(Cli* cli, string_t args, void* context) {
|
||||
}
|
||||
|
||||
IrdaWorker* worker = irda_worker_alloc();
|
||||
irda_worker_set_context(worker, cli);
|
||||
irda_worker_start(worker);
|
||||
irda_worker_set_received_signal_callback(worker, signal_received_callback);
|
||||
irda_worker_rx_start(worker);
|
||||
irda_worker_rx_set_received_signal_callback(worker, signal_received_callback, cli);
|
||||
|
||||
printf("Receiving IRDA...\r\nPress Ctrl+C to abort\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
delay(50);
|
||||
}
|
||||
|
||||
irda_worker_stop(worker);
|
||||
irda_worker_rx_stop(worker);
|
||||
irda_worker_free(worker);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "irda-app-brute-force.hpp"
|
||||
#include "irda/irda-app-file-parser.hpp"
|
||||
#include "irda-app-brute-force.h"
|
||||
#include "irda/irda-app-file-parser.h"
|
||||
#include "m-string.h"
|
||||
#include <file-worker-cpp.h>
|
||||
#include <memory>
|
||||
@@ -47,7 +47,6 @@ void IrdaAppBruteForce::stop_bruteforce() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: [FL-1418] replace with timer-chained consequence of messages.
|
||||
bool IrdaAppBruteForce::send_next_bruteforce(void) {
|
||||
furi_assert(current_record.size());
|
||||
furi_assert(file_parser);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "furi/check.h"
|
||||
#include <unordered_map>
|
||||
#include "irda-app-file-parser.hpp"
|
||||
#include "irda-app-file-parser.h"
|
||||
#include <memory>
|
||||
|
||||
class IrdaAppBruteForce {
|
||||
@@ -28,7 +28,9 @@ public:
|
||||
bool start_bruteforce(int index, int& record_amount);
|
||||
void add_record(int index, const char* name);
|
||||
|
||||
IrdaAppBruteForce(const char* filename) : universal_db_filename (filename) {}
|
||||
~IrdaAppBruteForce() {}
|
||||
IrdaAppBruteForce(const char* filename)
|
||||
: universal_db_filename(filename) {
|
||||
}
|
||||
~IrdaAppBruteForce() {
|
||||
}
|
||||
};
|
||||
|
@@ -9,6 +9,8 @@ public:
|
||||
Exit,
|
||||
Back,
|
||||
MenuSelected,
|
||||
MenuSelectedPress,
|
||||
MenuSelectedRelease,
|
||||
DialogExSelected,
|
||||
NextScene,
|
||||
IrdaMessageReceived,
|
||||
@@ -24,4 +26,3 @@ public:
|
||||
|
||||
Type type;
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "irda-app-file-parser.hpp"
|
||||
#include "irda-app-file-parser.h"
|
||||
#include "furi/check.h"
|
||||
#include "irda-app-remote-manager.hpp"
|
||||
#include "irda-app-remote-manager.h"
|
||||
#include "irda-app-signal.h"
|
||||
#include "m-string.h"
|
||||
#include <text-store.h>
|
||||
|
@@ -26,8 +26,16 @@ public:
|
||||
std::string make_name(const std::string& full_name) const;
|
||||
|
||||
private:
|
||||
size_t stringify_message(const IrdaAppSignal& signal, const char* name, char* content, size_t content_len);
|
||||
size_t stringify_raw_signal(const IrdaAppSignal& signal, const char* name, char* content, size_t content_len);
|
||||
size_t stringify_message(
|
||||
const IrdaAppSignal& signal,
|
||||
const char* name,
|
||||
char* content,
|
||||
size_t content_len);
|
||||
size_t stringify_raw_signal(
|
||||
const IrdaAppSignal& signal,
|
||||
const char* name,
|
||||
char* content,
|
||||
size_t content_len);
|
||||
std::unique_ptr<IrdaFileSignal> parse_signal(const std::string& str) const;
|
||||
std::unique_ptr<IrdaFileSignal> parse_signal_raw(const std::string& str) const;
|
||||
std::string make_full_name(const std::string& name) const;
|
||||
@@ -41,4 +49,3 @@ private:
|
||||
char file_buf[128];
|
||||
size_t file_buf_cnt = 0;
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "irda-app-remote-manager.hpp"
|
||||
#include "irda-app-remote-manager.h"
|
||||
#include <storage/storage.h>
|
||||
#include "furi.h"
|
||||
#include "furi/check.h"
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "irda-app-file-parser.hpp"
|
||||
#include "irda-app-file-parser.h"
|
||||
|
||||
static const std::string default_remote_name = "remote";
|
||||
|
||||
|
@@ -12,21 +12,27 @@ class IrdaAppRemoteButton {
|
||||
friend class IrdaAppRemoteManager;
|
||||
std::string name;
|
||||
IrdaAppSignal signal;
|
||||
|
||||
public:
|
||||
IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
|
||||
: name(name), signal (signal) {}
|
||||
~IrdaAppRemoteButton() {}
|
||||
: name(name)
|
||||
, signal(signal) {
|
||||
}
|
||||
~IrdaAppRemoteButton() {
|
||||
}
|
||||
};
|
||||
|
||||
class IrdaAppRemote {
|
||||
friend class IrdaAppRemoteManager;
|
||||
std::vector<IrdaAppRemoteButton> buttons;
|
||||
std::string name;
|
||||
public:
|
||||
IrdaAppRemote(const std::string& name) : name(name) {}
|
||||
|
||||
IrdaAppRemote& operator=(std::string& new_name) noexcept
|
||||
{
|
||||
public:
|
||||
IrdaAppRemote(const std::string& name)
|
||||
: name(name) {
|
||||
}
|
||||
|
||||
IrdaAppRemote& operator=(std::string& new_name) noexcept {
|
||||
name = new_name;
|
||||
buttons.clear();
|
||||
return *this;
|
||||
@@ -61,4 +67,3 @@ public:
|
||||
bool store();
|
||||
bool load(const std::string& name);
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "furi.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include "irda-app.hpp"
|
||||
#include "irda/irda-app-event.hpp"
|
||||
#include "irda-app.h"
|
||||
#include "irda/irda-app-event.h"
|
||||
#include <callback-connector.h>
|
||||
|
||||
IrdaAppViewManager::IrdaAppViewManager() {
|
||||
@@ -112,8 +112,14 @@ void IrdaAppViewManager::receive_event(IrdaAppEvent* event) {
|
||||
}
|
||||
|
||||
void IrdaAppViewManager::send_event(IrdaAppEvent* event) {
|
||||
osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
|
||||
furi_check(result == osOK);
|
||||
uint32_t timeout = 0;
|
||||
/* Rapid button hammering on Remote Scene causes queue overflow - ignore it,
|
||||
* but try to keep button release event - it switches off IRDA DMA sending. */
|
||||
if(event->type == IrdaAppEvent::Type::MenuSelectedRelease) {
|
||||
timeout = 200;
|
||||
}
|
||||
osMessageQueuePut(event_queue, event, 0, timeout);
|
||||
/* furi_check(result == osOK); */
|
||||
}
|
||||
|
||||
uint32_t IrdaAppViewManager::previous_view_callback(void* context) {
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include "irda-app.hpp"
|
||||
#include "irda-app.h"
|
||||
#include "view/irda-app-brut-view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
|
||||
@@ -57,4 +57,3 @@ private:
|
||||
|
||||
void add_view(ViewType view_type, View* view);
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "irda-app.hpp"
|
||||
#include "irda/irda-app-file-parser.hpp"
|
||||
#include "irda-app.h"
|
||||
#include "irda/irda-app-file-parser.h"
|
||||
#include <irda_worker.h>
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
@@ -222,22 +222,33 @@ void IrdaApp::notify_click() {
|
||||
notification_message_block(notification, &sequence);
|
||||
}
|
||||
|
||||
void IrdaApp::notify_click_and_blink() {
|
||||
void IrdaApp::notify_click_and_green_blink() {
|
||||
static const NotificationSequence sequence = {
|
||||
&message_click,
|
||||
&message_delay_1,
|
||||
&message_sound_off,
|
||||
&message_red_0,
|
||||
&message_green_255,
|
||||
&message_blue_0,
|
||||
&message_delay_10,
|
||||
&message_green_0,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
notification_message_block(notification, &sequence);
|
||||
}
|
||||
|
||||
void IrdaApp::notify_blink_green() {
|
||||
static const NotificationSequence sequence = {
|
||||
&message_green_255,
|
||||
&message_delay_10,
|
||||
&message_green_0,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
notification_message(notification, &sequence);
|
||||
}
|
||||
|
||||
void IrdaApp::notify_double_vibro() {
|
||||
notification_message(notification, &sequence_double_vibro);
|
||||
}
|
||||
|
@@ -2,17 +2,16 @@
|
||||
#include <map>
|
||||
#include <irda.h>
|
||||
#include <furi.h>
|
||||
#include "scene/irda-app-scene.hpp"
|
||||
#include "irda-app-event.hpp"
|
||||
#include "scene/irda-app-scene.hpp"
|
||||
#include "irda-app-view-manager.hpp"
|
||||
#include "irda-app-remote-manager.hpp"
|
||||
#include "scene/irda-app-scene.h"
|
||||
#include "irda-app-event.h"
|
||||
#include "scene/irda-app-scene.h"
|
||||
#include "irda-app-view-manager.h"
|
||||
#include "irda-app-remote-manager.h"
|
||||
#include <forward_list>
|
||||
#include <stdint.h>
|
||||
#include <notification/notification-messages.h>
|
||||
#include <irda_worker.h>
|
||||
|
||||
|
||||
class IrdaApp {
|
||||
public:
|
||||
enum class EditElement : uint8_t {
|
||||
@@ -71,7 +70,7 @@ public:
|
||||
void set_learn_new_remote(bool value);
|
||||
|
||||
enum : int {
|
||||
ButtonNA = -1,
|
||||
ButtonNA = -1,
|
||||
};
|
||||
int get_current_button();
|
||||
void set_current_button(int value);
|
||||
@@ -83,7 +82,8 @@ public:
|
||||
void notify_green_on();
|
||||
void notify_green_off();
|
||||
void notify_click();
|
||||
void notify_click_and_blink();
|
||||
void notify_click_and_green_blink();
|
||||
void notify_blink_green();
|
||||
|
||||
static void text_input_callback(void* context);
|
||||
static void popup_callback(void* context);
|
||||
@@ -95,9 +95,9 @@ public:
|
||||
~IrdaApp() {
|
||||
irda_worker_free(irda_worker);
|
||||
furi_record_close("notification");
|
||||
for (auto &it : scenes)
|
||||
delete it.second;
|
||||
for(auto& it : scenes) delete it.second;
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint8_t text_store_size = 128;
|
||||
static const uint8_t text_store_max = 2;
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
{Scene::Start, new IrdaAppSceneStart()},
|
||||
{Scene::Universal, new IrdaAppSceneUniversal()},
|
||||
{Scene::UniversalTV, new IrdaAppSceneUniversalTV()},
|
||||
// {Scene::UniversalAudio, new IrdaAppSceneUniversalAudio()},
|
||||
// {Scene::UniversalAudio, new IrdaAppSceneUniversalAudio()},
|
||||
{Scene::Learn, new IrdaAppSceneLearn()},
|
||||
{Scene::LearnSuccess, new IrdaAppSceneLearnSuccess()},
|
||||
{Scene::LearnEnterName, new IrdaAppSceneLearnEnterName()},
|
@@ -1,4 +1,4 @@
|
||||
#include "irda-app.hpp"
|
||||
#include "irda-app.h"
|
||||
|
||||
extern "C" int32_t irda_app(void* p) {
|
||||
IrdaApp* app = new IrdaApp();
|
||||
|
@@ -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();
|
||||
|
@@ -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) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "../irda-app.hpp"
|
||||
#include "../irda-app.h"
|
||||
#include "gui/modules/submenu.h"
|
||||
|
||||
typedef enum {
|
||||
|
@@ -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();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "../irda-app.hpp"
|
||||
#include "../irda-app.h"
|
||||
#include "gui/modules/text_input.h"
|
||||
|
||||
void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "../irda-app.hpp"
|
||||
#include "../irda-app.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexUniversalLibrary,
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "../irda-app.hpp"
|
||||
#include "../irda-app.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexUniversalTV,
|
||||
|
@@ -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() {
|
||||
}
|
||||
};
|
||||
|
@@ -15,13 +15,15 @@ struct IrdaAppPopupBrut {
|
||||
char percents_string_storage[8];
|
||||
};
|
||||
|
||||
void popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) {
|
||||
bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) {
|
||||
furi_assert(popup_brut);
|
||||
|
||||
if(popup_brut->progress < popup_brut->progress_max)
|
||||
++popup_brut->progress;
|
||||
else
|
||||
furi_assert(0);
|
||||
|
||||
return popup_brut->progress < popup_brut->progress_max;
|
||||
}
|
||||
|
||||
void popup_brut_draw_callback(Canvas* canvas, void* context) {
|
||||
|
@@ -7,7 +7,7 @@ extern "C" {
|
||||
|
||||
typedef struct IrdaAppPopupBrut IrdaAppPopupBrut;
|
||||
|
||||
void popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut);
|
||||
bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut);
|
||||
IrdaAppPopupBrut* popup_brut_alloc();
|
||||
void popup_brut_free(IrdaAppPopupBrut* popup_brut);
|
||||
void popup_brut_draw_callback(Canvas* canvas, void* model);
|
||||
|
@@ -58,7 +58,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
|
||||
IrdaMonitor* irda_monitor = context;
|
||||
|
||||
if(irda_worker_signal_is_decoded(received_signal)) {
|
||||
const IrdaMessage* message = irda_worker_get_decoded_message(received_signal);
|
||||
const IrdaMessage* message = irda_worker_get_decoded_signal(received_signal);
|
||||
snprintf(
|
||||
irda_monitor->display_text,
|
||||
sizeof(irda_monitor->display_text),
|
||||
@@ -112,10 +112,10 @@ int32_t irda_monitor_app(void* p) {
|
||||
gui_add_view_port(gui, irda_monitor->view_port, GuiLayerFullscreen);
|
||||
|
||||
irda_monitor->worker = irda_worker_alloc();
|
||||
irda_worker_set_context(irda_monitor->worker, irda_monitor);
|
||||
irda_worker_start(irda_monitor->worker);
|
||||
irda_worker_set_received_signal_callback(irda_monitor->worker, signal_received_callback);
|
||||
irda_worker_enable_blink_on_receiving(irda_monitor->worker, true);
|
||||
irda_worker_rx_start(irda_monitor->worker);
|
||||
irda_worker_rx_set_received_signal_callback(
|
||||
irda_monitor->worker, signal_received_callback, irda_monitor);
|
||||
irda_worker_rx_enable_blink_on_receiving(irda_monitor->worker, true);
|
||||
|
||||
while(1) {
|
||||
InputEvent event;
|
||||
@@ -126,7 +126,7 @@ int32_t irda_monitor_app(void* p) {
|
||||
}
|
||||
}
|
||||
|
||||
irda_worker_stop(irda_monitor->worker);
|
||||
irda_worker_rx_stop(irda_monitor->worker);
|
||||
irda_worker_free(irda_monitor->worker);
|
||||
osMessageQueueDelete(irda_monitor->event_queue);
|
||||
view_port_enabled_set(irda_monitor->view_port, false);
|
||||
|
Reference in New Issue
Block a user