Non-volatile memory data repository pattern (#24356)

* First batch of eeconfig conversions.

* Offset and length for datablocks.

* `via`, `dynamic_keymap`.

* Fix filename.

* Commentary.

* wilba leds

* satisfaction75

* satisfaction75

* more keyboard whack-a-mole

* satisfaction75

* omnikeyish

* more whack-a-mole

* `generic_features.mk` to automatically pick up nvm repositories

* thievery

* deferred variable resolve

* whitespace

* convert api to structs/unions

* convert api to structs/unions

* convert api to structs/unions

* fixups

* code-side docs

* code size fix

* rollback

* nvm_xxxxx_erase

* Updated location of eeconfig magic numbers so non-EEPROM nvm drivers can use them too.

* Fixup build.

* Fixup compilation error with encoders.

* Build fixes.

* Add `via_ci` keymap to onekey to exercise VIA bindings (and thus dynamic keymap et.al.), fixup compilation errors based on preprocessor+sizeof.

* Build failure rectification.
This commit is contained in:
Nick Brassel 2025-03-21 23:38:34 +11:00 committed by GitHub
parent c9d62ddc78
commit 2b00b846dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
87 changed files with 1464 additions and 839 deletions

View file

@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backlight.h"
#include "eeprom.h"
#include "eeconfig.h"
#include "debug.h"
@ -55,7 +54,7 @@ static void backlight_check_config(void) {
* FIXME: needs doc
*/
void backlight_init(void) {
backlight_config.raw = eeconfig_read_backlight();
eeconfig_read_backlight(&backlight_config);
if (!backlight_config.valid) {
dprintf("backlight_init backlight_config.valid = 0. Write default values to EEPROM.\n");
eeconfig_update_backlight_default();
@ -74,7 +73,7 @@ void backlight_increase(void) {
backlight_config.level++;
}
backlight_config.enable = 1;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight increase: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
}
@ -87,7 +86,7 @@ void backlight_decrease(void) {
if (backlight_config.level > 0) {
backlight_config.level--;
backlight_config.enable = !!backlight_config.level;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
}
dprintf("backlight decrease: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
@ -116,7 +115,7 @@ void backlight_enable(void) {
backlight_config.enable = true;
if (backlight_config.raw == 1) // enabled but level == 0
backlight_config.level = 1;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight enable\n");
backlight_set(backlight_config.level);
}
@ -129,7 +128,7 @@ void backlight_disable(void) {
if (!backlight_config.enable) return; // do nothing if backlight is already off
backlight_config.enable = false;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight disable\n");
backlight_set(0);
}
@ -152,7 +151,7 @@ void backlight_step(void) {
backlight_config.level = 0;
}
backlight_config.enable = !!backlight_config.level;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight step: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
}
@ -173,19 +172,11 @@ void backlight_level_noeeprom(uint8_t level) {
*/
void backlight_level(uint8_t level) {
backlight_level_noeeprom(level);
eeconfig_update_backlight(backlight_config.raw);
}
uint8_t eeconfig_read_backlight(void) {
return eeprom_read_byte(EECONFIG_BACKLIGHT);
}
void eeconfig_update_backlight(uint8_t val) {
eeprom_update_byte(EECONFIG_BACKLIGHT, val);
eeconfig_update_backlight(&backlight_config);
}
void eeconfig_update_backlight_current(void) {
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
}
void eeconfig_update_backlight_default(void) {
@ -193,7 +184,7 @@ void eeconfig_update_backlight_default(void) {
backlight_config.enable = BACKLIGHT_DEFAULT_ON;
backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING;
backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
}
/** \brief Get backlight level
@ -226,7 +217,7 @@ void backlight_enable_breathing(void) {
if (backlight_config.breathing) return; // do nothing if breathing is already on
backlight_config.breathing = true;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight breathing enable\n");
breathing_enable();
}
@ -239,7 +230,7 @@ void backlight_disable_breathing(void) {
if (!backlight_config.breathing) return; // do nothing if breathing is already off
backlight_config.breathing = false;
eeconfig_update_backlight(backlight_config.raw);
eeconfig_update_backlight(&backlight_config);
dprintf("backlight breathing disable\n");
breathing_disable();
}