Infrared: Add option to "Load from Library File" for Universal Remotes (#255)

* init

* comments

* remove trash

* remove code that mistakenly added from merging conflicts

* remove code that mistakenly added from merging conflicts

* format

* remove header that added during debugging

* ecit name

* Revert some whitespace changes to avoid future conflicts

* get_button_count()

* Use same index values

* Use common functions where possible

* Unroll long if into guard check

* Fix furi check failed due to inflated button index

* Show "assets" folders

* Load DB file only once and show loading animation

* Add bool for auto_detect_buttons

* Show error when tryingto load remote file as universal library

* Remove unnecessary includes

* Fix inputs

* more_devices -> from_file

* Consistency

* Remember last selected library file

* Update changelog

---------

Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
sommermorgentraum
2024-10-12 09:08:20 +08:00
committed by GitHub
parent 925481ffd0
commit 2f22fad58b
9 changed files with 233 additions and 5 deletions

View File

@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "infrared_error_code.h"
/**
@@ -46,9 +47,12 @@ void infrared_brute_force_set_db_filename(InfraredBruteForce* brute_force, const
* a infrared_brute_force_set_db_filename() call.
*
* @param[in,out] brute_force pointer to the instance to be updated.
* @param[in] auto_detect_buttons bool whether to automatically register newly discovered buttons.
* @returns InfraredErrorCodeNone on success, otherwise error code.
*/
InfraredErrorCode infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force);
InfraredErrorCode infrared_brute_force_calculate_messages(
InfraredBruteForce* brute_force,
bool auto_detect_buttons);
/**
* @brief Start transmitting signals from a category stored in an InfraredBruteForce's instance dictionary.
@@ -109,3 +113,23 @@ void infrared_brute_force_add_record(
* @param[in,out] brute_force pointer to the instance to be reset.
*/
void infrared_brute_force_reset(InfraredBruteForce* brute_force);
/**
* @brief Get the total number of unique button names in the database, for example,
* if a button name is "Power" and it appears 3 times in the db, then the
* db_size is 1, instead of 3.
*
* @param[in] brute_force pointer to the InfraredBruteForce instance.
* @return size_t number of unique button names.
*/
size_t infrared_brute_force_get_button_count(const InfraredBruteForce* brute_force);
/**
* @brief Get the button name at the specified index.
*
* @param[in] brute_force pointer to the InfraredBruteForce instance.
* @param[in] index index of the button name to retrieve.
* @return const char* button name, or NULL if index is out of range.
*/
const char*
infrared_brute_force_get_button_name(const InfraredBruteForce* brute_force, size_t index);