[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:
@@ -33,16 +33,15 @@ static std::string
|
||||
}
|
||||
}
|
||||
|
||||
bool IrdaAppRemoteManager::add_button(const char* button_name, const IrdaMessage* message) {
|
||||
remote->buttons.emplace_back(button_name, message);
|
||||
bool IrdaAppRemoteManager::add_button(const char* button_name, const IrdaAppSignal& signal) {
|
||||
remote->buttons.emplace_back(button_name, signal);
|
||||
return store();
|
||||
}
|
||||
|
||||
bool IrdaAppRemoteManager::add_remote_with_button(
|
||||
const char* button_name,
|
||||
const IrdaMessage* message) {
|
||||
const IrdaAppSignal& signal) {
|
||||
furi_check(button_name != nullptr);
|
||||
furi_check(message != nullptr);
|
||||
|
||||
std::vector<std::string> remote_list;
|
||||
bool result = get_remote_list(remote_list);
|
||||
@@ -51,7 +50,7 @@ bool IrdaAppRemoteManager::add_remote_with_button(
|
||||
auto new_name = find_vacant_name(remote_list, default_remote_name);
|
||||
|
||||
remote = std::make_unique<IrdaAppRemote>(new_name);
|
||||
return add_button(button_name, message);
|
||||
return add_button(button_name, signal);
|
||||
}
|
||||
|
||||
IrdaAppRemote::IrdaAppRemote(const std::string& name)
|
||||
@@ -70,12 +69,12 @@ std::vector<std::string> IrdaAppRemoteManager::get_button_list(void) const {
|
||||
return name_vector;
|
||||
}
|
||||
|
||||
const IrdaMessage* IrdaAppRemoteManager::get_button_data(size_t index) const {
|
||||
const IrdaAppSignal& IrdaAppRemoteManager::get_button_data(size_t index) const {
|
||||
furi_check(remote.get() != nullptr);
|
||||
auto& buttons = remote->buttons;
|
||||
furi_check(index < buttons.size());
|
||||
|
||||
return &buttons.at(index).message;
|
||||
return buttons.at(index).signal;
|
||||
}
|
||||
|
||||
std::string IrdaAppRemoteManager::make_filename(const std::string& name) const {
|
||||
@@ -166,7 +165,6 @@ size_t IrdaAppRemoteManager::get_number_of_buttons() {
|
||||
|
||||
bool IrdaAppRemoteManager::store(void) {
|
||||
File file;
|
||||
uint16_t write_count;
|
||||
std::string dirname(std::string("/") + irda_directory);
|
||||
|
||||
IrdaAppFileParser file_parser;
|
||||
@@ -186,25 +184,9 @@ bool IrdaAppRemoteManager::store(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char content[128];
|
||||
|
||||
for(const auto& button : remote->buttons) {
|
||||
auto protocol = button.message.protocol;
|
||||
|
||||
sniprintf(
|
||||
content,
|
||||
sizeof(content),
|
||||
"%.31s %.31s A:%0*lX C:%0*lX\n",
|
||||
button.name.c_str(),
|
||||
irda_get_protocol_name(protocol),
|
||||
irda_get_protocol_address_length(protocol),
|
||||
button.message.address,
|
||||
irda_get_protocol_command_length(protocol),
|
||||
button.message.command);
|
||||
|
||||
auto content_len = strlen(content);
|
||||
write_count = file_parser.get_fs_api().file.write(&file, content, content_len);
|
||||
if(file.error_id != FSE_OK || write_count != content_len) {
|
||||
bool result = file_parser.store_signal(&file, button.signal, button.name.c_str());
|
||||
if(!result) {
|
||||
file_parser.get_sd_api().show_error(
|
||||
file_parser.get_sd_api().context, "Cannot write\nto key file");
|
||||
file_parser.get_fs_api().file.close(&file);
|
||||
@@ -267,9 +249,9 @@ bool IrdaAppRemoteManager::load(const std::string& name) {
|
||||
remote = std::make_unique<IrdaAppRemote>(name);
|
||||
|
||||
while(1) {
|
||||
auto message = file_parser.read_message(&file);
|
||||
if(!message) break;
|
||||
remote->buttons.emplace_back(message->name, &message->message);
|
||||
auto file_signal = file_parser.read_signal(&file);
|
||||
if(!file_signal.get()) break;
|
||||
remote->buttons.emplace_back(file_signal->name, file_signal->signal);
|
||||
}
|
||||
file_parser.get_fs_api().file.close(&file);
|
||||
|
||||
|
Reference in New Issue
Block a user