1
0
forked from me/IronOS

Use settings desc by indexing instead of direct pointer

This commit is contained in:
Alvin Wong
2021-04-06 17:24:57 +08:00
parent 4810a67e2e
commit 09a58f6f48
3 changed files with 17 additions and 15 deletions

View File

@@ -110,6 +110,6 @@ enum class SettingsItemIndex : uint8_t {
constexpr uint8_t settings_item_index(const SettingsItemIndex i) { return static_cast<uint8_t>(i); }
// Use a constexpr function for type-checking.
#define SETTINGS_DESC(i) (SettingsDescriptions[settings_item_index(i)])
#define SETTINGS_DESC(i) (settings_item_index(i) + 1)
#endif /* TRANSLATION_H_ */

View File

@@ -21,7 +21,9 @@
// Struct for holding the function pointers and descriptions
typedef struct {
const char *description;
// The settings description index, please use the `SETTINGS_DESC` macro with
// the `SettingsItemIndex` enum. Use 0 for no description.
uint8_t description;
// return true if increment reached the maximum value
bool (*const incrementHandler)(void);
bool (*const draw)(void);