blk_box_tc/main/drivers/star_code.h

39 lines
1.2 KiB
C

#ifndef STAR_CODE_H
#define STAR_CODE_H
#include <stdint.h>
/// @brief A handler for a specific star code
struct StarCodeEntry {
/// @brief The star code without the star
///
/// This must be <= 8 characters.
///
/// You may include a * in the code to match on any character
const char* code;
/// @brief The text to display when the star code is entered (or NULL).
///
/// This must be <= 9 characters.
const char* display_text;
/// @brief The number of ticks to delay when the star code is entered before calling the handler.
uint32_t delay_ticks;
/// @brief The function to call when the star code is entered.
void (*callback)(void);
};
/// @brief Adds a star code to be handled.
/// @param code the star code to add (without the *)
/// @return true iff the star code was added
bool add_star_code(StarCodeEntry code);
/// @brief removes a star code to stop handling it.
/// @param code the star code to remove (without the *)
/// @return true iff the star code was removed
bool rm_star_code(char* code);
/// @brief Triggers the given starcode.
/// @param code the star code to trigger (without the *)
/// @return true iff a star code was triggered
bool trigger_star_code(char* code);
#endif /* STAR_CODE_H */