[FL-1369, FL-1397, FL-1420] IRDA + SDcard (#513)
* Add saving to SD-Card (not ready yet) * Add saving to SD-card (done) * Select previous menu item * Fix central button * Fix current_button * Refactoring * Add notifications * [FL-1417] Add IRDA CLI CLI commands: 1) ir_rx Receives all IR-trafic, decodes and prints result to stdout 2) ir_tx <protocol> <address> <command> Transmits IR-signal. Address and command are hex-formatted * Fix BUG with random memory corruption at random time in random place in random universe in random unknown space and time forever amen * Fix submenu set_selected_item * Bring protocol order back * Add TODO sdcard check
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
#pragma once
|
||||
#include "sys/_stdint.h"
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <irda.h>
|
||||
#include <sd-card-api.h>
|
||||
#include <filesystem-api.h>
|
||||
|
||||
class IrdaAppRemoteButton {
|
||||
friend class IrdaAppRemoteManager;
|
||||
@@ -19,35 +24,50 @@ class IrdaAppRemote {
|
||||
friend class IrdaAppRemoteManager;
|
||||
std::vector<IrdaAppRemoteButton> buttons;
|
||||
std::string name;
|
||||
bool add(const IrdaMessage*);
|
||||
void add_button(size_t remote_index, const char* button_name, const IrdaMessage* message);
|
||||
public:
|
||||
IrdaAppRemote(std::string name);
|
||||
IrdaAppRemote(const std::string& name);
|
||||
IrdaAppRemote& operator=(std::string& new_name) noexcept
|
||||
{
|
||||
name = new_name;
|
||||
buttons.clear();
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class IrdaAppRemoteManager {
|
||||
size_t current_remote_index;
|
||||
size_t current_button_index;
|
||||
std::vector<IrdaAppRemote> remotes;
|
||||
public:
|
||||
std::vector<std::string> get_remote_list() const;
|
||||
std::vector<std::string> get_button_list() const;
|
||||
void add_remote_with_button(const char* button_name, const IrdaMessage* message);
|
||||
void add_button(const char* button_name, const IrdaMessage* message);
|
||||
static const char* irda_directory;
|
||||
static const char* irda_extension;
|
||||
std::unique_ptr<IrdaAppRemote> remote;
|
||||
// TODO: make FS_Api and SdCard_Api unique_ptr
|
||||
SdCard_Api* sd_ex_api;
|
||||
FS_Api* fs_api;
|
||||
void show_file_error_message(const char* error_text) const;
|
||||
bool parse_button(std::string& str);
|
||||
std::string make_filename(const std::string& name) const;
|
||||
char file_buf[48];
|
||||
size_t file_buf_cnt = 0;
|
||||
|
||||
size_t get_current_remote(void) const;
|
||||
size_t get_current_button(void) const;
|
||||
public:
|
||||
bool add_remote_with_button(const char* button_name, const IrdaMessage* message);
|
||||
bool add_button(const char* button_name, const IrdaMessage* message);
|
||||
|
||||
int find_remote_name(const std::vector<std::string>& strings);
|
||||
bool rename_button(uint32_t index, const char* str);
|
||||
bool rename_remote(const char* str);
|
||||
|
||||
bool get_remote_list(std::vector<std::string>& remote_names) const;
|
||||
std::vector<std::string> get_button_list() const;
|
||||
std::string get_button_name(uint32_t index);
|
||||
std::string get_remote_name();
|
||||
size_t get_number_of_buttons();
|
||||
const IrdaMessage* get_button_data(size_t button_index) const;
|
||||
void set_current_remote(size_t index);
|
||||
void set_current_button(size_t index);
|
||||
void rename_button(const char* str);
|
||||
void rename_remote(const char* str);
|
||||
std::string get_current_button_name();
|
||||
std::string get_current_remote_name();
|
||||
size_t get_current_remote_buttons_number();
|
||||
void delete_current_button();
|
||||
void delete_current_remote();
|
||||
bool delete_button(uint32_t index);
|
||||
bool delete_remote();
|
||||
IrdaAppRemoteManager();
|
||||
~IrdaAppRemoteManager() {};
|
||||
~IrdaAppRemoteManager();
|
||||
|
||||
bool store();
|
||||
bool load(const std::string& name);
|
||||
bool check_fs() const;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user