mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-23 09:35:12 +08:00
Non-volatile memory data repository pattern (#24356)
Update API Data / api_data (push) Has been cancelled
CI Build Major Branch / Determine concurrency (push) Has been cancelled
CLI CI / test (push) Has been cancelled
Update feature branches after develop merge / feature_branch_update (riot) (push) Has been cancelled
Update feature branches after develop merge / feature_branch_update (xap) (push) Has been cancelled
Lint Format / lint (push) Has been cancelled
Regenerate Files / regen (push) Has been cancelled
Unit Tests / test (push) Has been cancelled
CI Build Major Branch / Compile keymap default (push) Has been cancelled
CI Build Major Branch / Consolidation (push) Has been cancelled
Update API Data / api_data (push) Has been cancelled
CI Build Major Branch / Determine concurrency (push) Has been cancelled
CLI CI / test (push) Has been cancelled
Update feature branches after develop merge / feature_branch_update (riot) (push) Has been cancelled
Update feature branches after develop merge / feature_branch_update (xap) (push) Has been cancelled
Lint Format / lint (push) Has been cancelled
Regenerate Files / regen (push) Has been cancelled
Unit Tests / test (push) Has been cancelled
CI Build Major Branch / Compile keymap default (push) Has been cancelled
CI Build Major Branch / Consolidation (push) Has been cancelled
* 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:
@@ -30,6 +30,8 @@ QUANTUM_SRC += \
|
||||
$(QUANTUM_DIR)/logging/sendchar.c \
|
||||
$(QUANTUM_DIR)/process_keycode/process_default_layer.c \
|
||||
|
||||
include $(QUANTUM_DIR)/nvm/rules.mk
|
||||
|
||||
VPATH += $(QUANTUM_DIR)/logging
|
||||
# Fall back to lib/printf if there is no platform provided print
|
||||
ifeq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk)","")
|
||||
|
||||
@@ -61,6 +61,7 @@ define HANDLE_GENERIC_FEATURE
|
||||
SRC += $$(wildcard $$(QUANTUM_DIR)/process_keycode/process_$2.c)
|
||||
SRC += $$(wildcard $$(QUANTUM_DIR)/$2/$2.c)
|
||||
SRC += $$(wildcard $$(QUANTUM_DIR)/$2.c)
|
||||
SRC += $$(wildcard $$(QUANTUM_DIR)/nvm/$$(NVM_DRIVER_LOWER)/nvm_$2.c)
|
||||
VPATH += $$(wildcard $$(QUANTUM_DIR)/$2/)
|
||||
OPT_DEFS += -D$1_ENABLE
|
||||
endef
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
The size of the transient EEPROM buffer size.
|
||||
*/
|
||||
#ifndef TRANSIENT_EEPROM_SIZE
|
||||
# include "eeconfig.h"
|
||||
# include "nvm_eeprom_eeconfig_internal.h"
|
||||
# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
|
||||
#endif
|
||||
|
||||
@@ -164,7 +164,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
|
||||
if (record->event.pressed) {
|
||||
set_single_persistent_default_layer(MAC_B);
|
||||
keymap_config.no_gui = 0;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
case QK_RGB_MATRIX_TOGGLE:
|
||||
|
||||
@@ -53,10 +53,26 @@ void board_init(void) {
|
||||
SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
|
||||
}
|
||||
|
||||
uint32_t read_custom_config(void *data, uint32_t offset, uint32_t length) {
|
||||
#ifdef VIA_ENABLE
|
||||
return via_read_custom_config(data, offset, length);
|
||||
#else
|
||||
return eeconfig_read_kb_datablock(data, offset, length);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t write_custom_config(const void *data, uint32_t offset, uint32_t length) {
|
||||
#ifdef VIA_ENABLE
|
||||
return via_update_custom_config(data, offset, length);
|
||||
#else
|
||||
return eeconfig_update_kb_datablock(data, offset, length);
|
||||
#endif
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
/*
|
||||
This is a workaround to some really weird behavior
|
||||
Without this code, the OLED will turn on, but not when you initially plug the keyboard in.
|
||||
Without this code, the OLED will turn on, but not when you initially plug the keyboard in.
|
||||
You have to manually trigger a user reset to get the OLED to initialize properly
|
||||
I'm not sure what the root cause is at this time, but this workaround fixes it.
|
||||
*/
|
||||
@@ -74,11 +90,11 @@ void keyboard_post_init_kb(void) {
|
||||
void custom_set_value(uint8_t *data) {
|
||||
uint8_t *value_id = &(data[0]);
|
||||
uint8_t *value_data = &(data[1]);
|
||||
|
||||
|
||||
switch ( *value_id ) {
|
||||
case id_oled_default_mode:
|
||||
{
|
||||
eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, value_data[0]);
|
||||
write_custom_config(&value_data[0], EEPROM_DEFAULT_OLED_OFFSET, 1);
|
||||
break;
|
||||
}
|
||||
case id_oled_mode:
|
||||
@@ -92,7 +108,7 @@ void custom_set_value(uint8_t *data) {
|
||||
uint8_t index = value_data[0];
|
||||
uint8_t enable = value_data[1];
|
||||
enabled_encoder_modes = (enabled_encoder_modes & ~(1<<index)) | (enable<<index);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
|
||||
write_custom_config(&enabled_encoder_modes, EEPROM_ENABLED_ENCODER_MODES_OFFSET, 1);
|
||||
break;
|
||||
}
|
||||
case id_encoder_custom:
|
||||
@@ -109,11 +125,12 @@ void custom_set_value(uint8_t *data) {
|
||||
void custom_get_value(uint8_t *data) {
|
||||
uint8_t *value_id = &(data[0]);
|
||||
uint8_t *value_data = &(data[1]);
|
||||
|
||||
|
||||
switch ( *value_id ) {
|
||||
case id_oled_default_mode:
|
||||
{
|
||||
uint8_t default_oled = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
|
||||
uint8_t default_oled;
|
||||
read_custom_config(&default_oled, EEPROM_DEFAULT_OLED_OFFSET, 1);
|
||||
value_data[0] = default_oled;
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +196,6 @@ void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void read_host_led_state(void) {
|
||||
led_t led_state = host_keyboard_led_state();
|
||||
if (led_state.num_lock) {
|
||||
@@ -290,25 +306,25 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
|
||||
}
|
||||
|
||||
void custom_config_reset(void){
|
||||
void *p = (void*)(VIA_EEPROM_CUSTOM_CONFIG_ADDR);
|
||||
void *end = (void*)(VIA_EEPROM_CUSTOM_CONFIG_ADDR+VIA_EEPROM_CUSTOM_CONFIG_SIZE);
|
||||
while ( p != end ) {
|
||||
eeprom_update_byte(p, 0);
|
||||
++p;
|
||||
for(int i = 0; i < VIA_EEPROM_CUSTOM_CONFIG_SIZE; ++i) {
|
||||
uint8_t dummy = 0;
|
||||
write_custom_config(&dummy, i, 1);
|
||||
}
|
||||
eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, 0x1F);
|
||||
|
||||
uint8_t encoder_modes = 0x1F;
|
||||
write_custom_config(&encoder_modes, EEPROM_ENABLED_ENCODER_MODES_OFFSET, 1);
|
||||
}
|
||||
|
||||
void custom_config_load(void){
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
oled_mode = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
|
||||
enabled_encoder_modes = eeprom_read_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES);
|
||||
read_custom_config(&oled_mode, EEPROM_DEFAULT_OLED_OFFSET, 1);
|
||||
read_custom_config(&enabled_encoder_modes, EEPROM_ENABLED_ENCODER_MODES_OFFSET, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called from via_init() if VIA_ENABLE
|
||||
// Called from matrix_init_kb() if not VIA_ENABLE
|
||||
void via_init_kb(void)
|
||||
void satisfaction_core_init(void)
|
||||
{
|
||||
// This checks both an EEPROM reset (from bootmagic lite, keycodes)
|
||||
// and also firmware build date (from via_eeprom_is_valid())
|
||||
@@ -326,8 +342,7 @@ void via_init_kb(void)
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
#ifndef VIA_ENABLE
|
||||
via_init_kb();
|
||||
via_eeprom_set_valid(true);
|
||||
satisfaction_core_init();
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
rtcGetTime(&RTCD1, &last_timespec);
|
||||
@@ -335,6 +350,11 @@ void matrix_init_kb(void)
|
||||
oled_request_wakeup();
|
||||
}
|
||||
|
||||
#ifdef VIA_ENABLE
|
||||
void via_init_kb(void) {
|
||||
satisfaction_core_init();
|
||||
}
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
void housekeeping_task_kb(void) {
|
||||
rtcGetTime(&RTCD1, &last_timespec);
|
||||
@@ -345,52 +365,3 @@ void housekeeping_task_kb(void) {
|
||||
oled_request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// In the case of VIA being disabled, we still need to check if
|
||||
// keyboard level EEPROM memory is valid before loading.
|
||||
// Thus these are copies of the same functions in VIA, since
|
||||
// the backlight settings reuse VIA's EEPROM magic/version,
|
||||
// and the ones in via.c won't be compiled in.
|
||||
//
|
||||
// Yes, this is sub-optimal, and is only here for completeness
|
||||
// (i.e. catering to the 1% of people that want wilba.tech LED bling
|
||||
// AND want persistent settings BUT DON'T want to use dynamic keymaps/VIA).
|
||||
//
|
||||
#ifndef VIA_ENABLE
|
||||
|
||||
bool via_eeprom_is_valid(void)
|
||||
{
|
||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
||||
|
||||
return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
|
||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
|
||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
|
||||
}
|
||||
|
||||
// Sets VIA/keyboard level usage of EEPROM to valid/invalid
|
||||
// Keyboard level code (eg. via_init_kb()) should not call this
|
||||
void via_eeprom_set_valid(bool valid)
|
||||
{
|
||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
||||
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
|
||||
}
|
||||
|
||||
void via_eeprom_reset(void)
|
||||
{
|
||||
// Set the VIA specific EEPROM state as invalid.
|
||||
via_eeprom_set_valid(false);
|
||||
// Set the TMK/QMK EEPROM state as invalid.
|
||||
eeconfig_disable();
|
||||
}
|
||||
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <hal.h>
|
||||
|
||||
#include "via.h" // only for EEPROM address
|
||||
#include "satisfaction_keycodes.h"
|
||||
|
||||
#define EEPROM_ENABLED_ENCODER_MODES (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
|
||||
#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+1)
|
||||
#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
|
||||
#define EEPROM_ENABLED_ENCODER_MODES_OFFSET 0
|
||||
#define EEPROM_DEFAULT_OLED_OFFSET 1
|
||||
#define EEPROM_CUSTOM_ENCODER_OFFSET 2
|
||||
|
||||
enum s75_keyboard_value_id {
|
||||
id_encoder_modes = 1,
|
||||
@@ -94,3 +96,6 @@ void oled_request_repaint(void);
|
||||
bool oled_task_needs_to_repaint(void);
|
||||
|
||||
void custom_config_load(void);
|
||||
|
||||
uint32_t read_custom_config(void *data, uint32_t offset, uint32_t length);
|
||||
uint32_t write_custom_config(const void *data, uint32_t offset, uint32_t length);
|
||||
|
||||
@@ -215,10 +215,13 @@ uint16_t handle_encoder_press(void){
|
||||
|
||||
uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior){
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
|
||||
uint32_t offset = EEPROM_CUSTOM_ENCODER_OFFSET + (encoder_idx * 6) + (behavior * 2);
|
||||
//big endian
|
||||
uint16_t keycode = eeprom_read_byte(addr) << 8;
|
||||
keycode |= eeprom_read_byte(addr + 1);
|
||||
uint8_t hi, lo;
|
||||
read_custom_config(&hi, offset+0, 1);
|
||||
read_custom_config(&lo, offset+1, 1);
|
||||
uint16_t keycode = hi << 8;
|
||||
keycode |= lo;
|
||||
return keycode;
|
||||
#else
|
||||
return 0;
|
||||
@@ -227,8 +230,10 @@ uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior){
|
||||
|
||||
void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code){
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
|
||||
eeprom_update_byte(addr, (uint8_t)(new_code >> 8));
|
||||
eeprom_update_byte(addr + 1, (uint8_t)(new_code & 0xFF));
|
||||
uint32_t offset = EEPROM_CUSTOM_ENCODER_OFFSET + (encoder_idx * 6) + (behavior * 2);
|
||||
uint8_t hi = new_code >> 8;
|
||||
uint8_t lo = new_code & 0xFF;
|
||||
write_custom_config(&hi, offset+0, 1);
|
||||
write_custom_config(&lo, offset+1, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "matrix.h"
|
||||
#include "led.h"
|
||||
#include "host.h"
|
||||
#include "oled_driver.h"
|
||||
#include "progmem.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -16,6 +15,7 @@ void draw_default(void);
|
||||
void draw_clock(void);
|
||||
|
||||
#ifdef OLED_ENABLE
|
||||
#include "oled_driver.h"
|
||||
|
||||
oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_0; }
|
||||
|
||||
|
||||
@@ -42,4 +42,7 @@
|
||||
// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
|
||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 20
|
||||
|
||||
|
||||
// And if VIA isn't enabled, fall back to using standard QMK for configuration
|
||||
#ifndef VIA_ENABLE
|
||||
#define EECONFIG_KB_DATA_SIZE VIA_EEPROM_CUSTOM_CONFIG_SIZE
|
||||
#endif
|
||||
|
||||
@@ -40,5 +40,10 @@
|
||||
// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
|
||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 20
|
||||
|
||||
// And if VIA isn't enabled, fall back to using standard QMK for configuration
|
||||
#ifndef VIA_ENABLE
|
||||
#define EECONFIG_KB_DATA_SIZE VIA_EEPROM_CUSTOM_CONFIG_SIZE
|
||||
#endif
|
||||
|
||||
// VIA lighting is handled by the keyboard-level code
|
||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
||||
|
||||
@@ -36,7 +36,7 @@ void eeconfig_init_kb(void) {
|
||||
}
|
||||
}
|
||||
// Write default value to EEPROM now
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
eeconfig_init_user();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void eeconfig_init_kb(void) {
|
||||
// On Keyboard startup
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Read custom menu variables from memory
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
// Set runtime values to EEPROM values
|
||||
ec_config.actuation_mode = eeprom_ec_config.actuation_mode;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Copyright 2023 Cipulot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "eeprom.h"
|
||||
|
||||
#if (EECONFIG_KB_DATA_SIZE) > 0
|
||||
# define EEPROM_KB_PARTIAL_UPDATE(__struct, __field) eeprom_update_block(&(__struct.__field), (void *)((void *)(EECONFIG_KB_DATABLOCK) + offsetof(typeof(__struct), __field)), sizeof(__struct.__field))
|
||||
#endif
|
||||
|
||||
#if (EECONFIG_USER_DATA_SIZE) > 0
|
||||
# define EEPROM_USER_PARTIAL_UPDATE(__struct, __field) eeprom_update_block(&(__struct.__field), (void *)((void *)(EECONFIG_USER_DATABLOCK) + offsetof(typeof(__struct), __field)), sizeof(__struct.__field))
|
||||
#endif
|
||||
@@ -13,7 +13,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "eeprom_tools.h"
|
||||
#include "ec_switch_matrix.h"
|
||||
#include "action.h"
|
||||
#include "print.h"
|
||||
@@ -73,7 +72,7 @@ void via_config_set_value(uint8_t *data) {
|
||||
uprintf("# Actuation Mode: Rapid Trigger #\n");
|
||||
uprintf("#################################\n");
|
||||
}
|
||||
EEPROM_KB_PARTIAL_UPDATE(eeprom_ec_config, actuation_mode);
|
||||
eeconfig_update_kb_datablock_field(eeprom_ec_config, actuation_mode);
|
||||
break;
|
||||
}
|
||||
case id_mode_0_actuation_threshold: {
|
||||
@@ -293,7 +292,7 @@ void ec_save_threshold_data(uint8_t option) {
|
||||
ec_rescale_values(3);
|
||||
ec_rescale_values(4);
|
||||
}
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
uprintf("####################################\n");
|
||||
uprintf("# New thresholds applied and saved #\n");
|
||||
uprintf("####################################\n");
|
||||
@@ -321,7 +320,7 @@ void ec_save_bottoming_reading(void) {
|
||||
ec_rescale_values(2);
|
||||
ec_rescale_values(3);
|
||||
ec_rescale_values(4);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
}
|
||||
|
||||
// Show the calibration data
|
||||
|
||||
@@ -44,7 +44,7 @@ void eeconfig_init_kb(void) {
|
||||
}
|
||||
}
|
||||
// Write default value to EEPROM now
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
eeconfig_init_user();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void eeconfig_init_kb(void) {
|
||||
// On Keyboard startup
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Read custom menu variables from memory
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
// Set runtime values to EEPROM values
|
||||
ec_config.actuation_mode = eeprom_ec_config.actuation_mode;
|
||||
|
||||
@@ -44,7 +44,7 @@ void eeconfig_init_kb(void) {
|
||||
}
|
||||
}
|
||||
// Write default value to EEPROM now
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_update_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
eeconfig_init_user();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void eeconfig_init_kb(void) {
|
||||
// On Keyboard startup
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Read custom menu variables from memory
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config);
|
||||
eeconfig_read_kb_datablock(&eeprom_ec_config, 0, EECONFIG_KB_DATA_SIZE);
|
||||
|
||||
// Set runtime values to EEPROM values
|
||||
ec_config.actuation_mode = eeprom_ec_config.actuation_mode;
|
||||
|
||||
@@ -222,9 +222,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -311,9 +311,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2025 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
#define TRANSIENT_EEPROM_SIZE 160
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2025 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum custom_keycodes {
|
||||
KC_HELLO = SAFE_RANGE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
LAYOUT_ortho_1x1(KC_HELLO)
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case KC_HELLO:
|
||||
if (record->event.pressed) {
|
||||
send_string_P("Hello world!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
// Customise these values to desired behaviour
|
||||
debug_enable=true;
|
||||
debug_matrix=true;
|
||||
//debug_keyboard=true;
|
||||
//debug_mouse=true;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"config": {
|
||||
"features": {
|
||||
"via": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
EEPROM_DRIVER = transient
|
||||
@@ -1,2 +1,2 @@
|
||||
USE_CHIBIOS_CONTRIB = yes
|
||||
|
||||
EEPROM_DRIVER = transient
|
||||
|
||||
@@ -182,9 +182,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -32,7 +32,7 @@ void set_mac_mode_kb(bool macmode) {
|
||||
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
|
||||
*/
|
||||
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
@@ -27,7 +27,7 @@ void set_mac_mode(bool macmode) {
|
||||
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
|
||||
*/
|
||||
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
|
||||
@@ -27,7 +27,7 @@ void set_mac_mode(bool macmode) {
|
||||
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
|
||||
*/
|
||||
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <lib/lib8tion/lib8tion.h>
|
||||
#include "eeconfig.h"
|
||||
|
||||
#define LED_TRAIL 10
|
||||
|
||||
@@ -105,7 +106,7 @@ static void swirl_set_color(hsv_t hsv) {
|
||||
traverse_matrix();
|
||||
|
||||
if (!(top <= bottom && left <= right)) {
|
||||
eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config));
|
||||
eeconfig_read_rgb_matrix(&rgb_matrix_config);
|
||||
rgb_matrix_mode_noeeprom(rgb_matrix_config.mode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
|
||||
}
|
||||
if(active){
|
||||
keymap_config.no_gui = 0;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -472,9 +472,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
case EXT_PLV:
|
||||
|
||||
@@ -190,7 +190,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
set_single_persistent_default_layer(MAC_B);
|
||||
layer_state_set(1<<MAC_B);
|
||||
keymap_config.no_gui = 0;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
case QK_RGB_MATRIX_TOGGLE:
|
||||
|
||||
@@ -163,7 +163,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
|
||||
if (record->event.pressed) {
|
||||
set_single_persistent_default_layer(MAC_B);
|
||||
keymap_config.no_gui = 0;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
case GU_TOGG:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "omnikeyish.h"
|
||||
#include <string.h>
|
||||
#include "eeprom.h"
|
||||
|
||||
dynamic_macro_t dynamic_macros[DYNAMIC_MACRO_COUNT];
|
||||
|
||||
|
||||
@@ -215,9 +215,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -255,9 +255,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "keycode_lookup.h"
|
||||
#include "quantum_keycodes.h"
|
||||
#include "keymap_us.h"
|
||||
|
||||
@@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&keymap_config);
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "quantum.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
#include "usb_mux.h"
|
||||
|
||||
@@ -73,7 +74,7 @@ led_config_t g_led_config = { {
|
||||
} };
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
bool eeprom_is_valid(void) {
|
||||
bool eeprom_is_valid(void) {
|
||||
return (
|
||||
eeprom_read_word(((void *)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC &&
|
||||
eeprom_read_byte(((void *)EEPROM_VERSION_ADDR)) == EEPROM_VERSION
|
||||
|
||||
@@ -12,7 +12,7 @@ bool is_keyboard_left(void) {
|
||||
gpio_set_pin_input(SPLIT_HAND_PIN);
|
||||
return x;
|
||||
#elif defined(EE_HANDS)
|
||||
return eeprom_read_byte(EECONFIG_HANDEDNESS);
|
||||
return eeconfig_read_handedness();
|
||||
#endif
|
||||
|
||||
return is_keyboard_master();
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
// Called from via_init() if VIA_ENABLE
|
||||
// Called from matrix_init_kb() if not VIA_ENABLE
|
||||
void via_init_kb(void)
|
||||
void wt_main_init(void)
|
||||
{
|
||||
// This checks both an EEPROM reset (from bootmagic lite, keycodes)
|
||||
// and also firmware build date (from via_eeprom_is_valid())
|
||||
@@ -64,11 +64,9 @@ void via_init_kb(void)
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
// If VIA is disabled, we still need to load backlight settings.
|
||||
// Call via_init_kb() the same way as via_init(), with setting
|
||||
// EEPROM valid afterwards.
|
||||
// Call via_init_kb() the same way as via_init_kb() does.
|
||||
#ifndef VIA_ENABLE
|
||||
via_init_kb();
|
||||
via_eeprom_set_valid(true);
|
||||
wt_main_init();
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
matrix_init_user();
|
||||
@@ -109,6 +107,10 @@ void suspend_wakeup_init_kb(void)
|
||||
// Moving this to the bottom of this source file is a workaround
|
||||
// for an intermittent compiler error for Atmel compiler.
|
||||
#ifdef VIA_ENABLE
|
||||
void via_init_kb(void) {
|
||||
wt_main_init();
|
||||
}
|
||||
|
||||
void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
|
||||
uint8_t *command_id = &(data[0]);
|
||||
uint8_t *channel_id = &(data[1]);
|
||||
@@ -159,50 +161,3 @@ void via_set_device_indication(uint8_t value)
|
||||
}
|
||||
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
//
|
||||
// In the case of VIA being disabled, we still need to check if
|
||||
// keyboard level EEPROM memory is valid before loading.
|
||||
// Thus these are copies of the same functions in VIA, since
|
||||
// the backlight settings reuse VIA's EEPROM magic/version,
|
||||
// and the ones in via.c won't be compiled in.
|
||||
//
|
||||
// Yes, this is sub-optimal, and is only here for completeness
|
||||
// (i.e. catering to the 1% of people that want wilba.tech LED bling
|
||||
// AND want persistent settings BUT DON'T want to use dynamic keymaps/VIA).
|
||||
//
|
||||
#ifndef VIA_ENABLE
|
||||
|
||||
bool via_eeprom_is_valid(void)
|
||||
{
|
||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
||||
|
||||
return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
|
||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
|
||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
|
||||
}
|
||||
|
||||
void via_eeprom_set_valid(bool valid)
|
||||
{
|
||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
||||
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
|
||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
|
||||
}
|
||||
|
||||
void via_eeprom_reset(void)
|
||||
{
|
||||
// Set the VIA specific EEPROM state as invalid.
|
||||
via_eeprom_set_valid(false);
|
||||
// Set the TMK/QMK EEPROM state as invalid.
|
||||
eeconfig_disable();
|
||||
}
|
||||
|
||||
#endif // VIA_ENABLE
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "progmem.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
#include "nvm_eeprom_eeconfig_internal.h" // expose EEPROM addresses, no appetite to move legacy/deprecated code to nvm
|
||||
#include "nvm_eeprom_via_internal.h" // expose EEPROM addresses, no appetite to move legacy/deprecated code to nvm
|
||||
#include "via.h" // uses EEPROM address, lighting value IDs
|
||||
#define MONO_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
#include "quantum/color.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
#include "nvm_eeprom_eeconfig_internal.h" // expose EEPROM addresses, no appetite to move legacy/deprecated code to nvm
|
||||
#include "nvm_eeprom_via_internal.h" // expose EEPROM addresses, no appetite to move legacy/deprecated code to nvm
|
||||
#include "via.h" // uses EEPROM address, lighting value IDs
|
||||
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ static void startup_animation_setleds(effect_params_t* params, bool dots) {
|
||||
} else if (num == 0 || num == 1 || num == 2) {
|
||||
return;
|
||||
} else if (num >= 22) {
|
||||
eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config));
|
||||
eeconfig_read_rgb_matrix(&rgb_matrix_config);
|
||||
rgb_matrix_mode_noeeprom(rgb_matrix_config.mode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ bool is_oneshot_layer_active(void) {
|
||||
void oneshot_set(bool active) {
|
||||
if (keymap_config.oneshot_enable != active) {
|
||||
keymap_config.oneshot_enable = active;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(&keymap_config);
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
dprintf("Oneshot: active: %d\n", active);
|
||||
}
|
||||
|
||||
@@ -149,14 +149,14 @@ void audio_driver_start(void) {
|
||||
}
|
||||
|
||||
void eeconfig_update_audio_current(void) {
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
eeconfig_update_audio(&audio_config);
|
||||
}
|
||||
|
||||
void eeconfig_update_audio_default(void) {
|
||||
audio_config.valid = true;
|
||||
audio_config.enable = AUDIO_DEFAULT_ON;
|
||||
audio_config.clicky_enable = AUDIO_DEFAULT_CLICKY_ON;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
eeconfig_update_audio(&audio_config);
|
||||
}
|
||||
|
||||
void audio_init(void) {
|
||||
@@ -164,7 +164,7 @@ void audio_init(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
audio_config.raw = eeconfig_read_audio();
|
||||
eeconfig_read_audio(&audio_config);
|
||||
if (!audio_config.valid) {
|
||||
dprintf("audio_init audio_config.valid = 0. Write default values to EEPROM.\n");
|
||||
eeconfig_update_audio_default();
|
||||
@@ -196,7 +196,7 @@ void audio_toggle(void) {
|
||||
stop_all_notes();
|
||||
}
|
||||
audio_config.enable ^= 1;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
eeconfig_update_audio(&audio_config);
|
||||
if (audio_config.enable) {
|
||||
audio_on_user();
|
||||
} else {
|
||||
@@ -206,7 +206,7 @@ void audio_toggle(void) {
|
||||
|
||||
void audio_on(void) {
|
||||
audio_config.enable = 1;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
eeconfig_update_audio(&audio_config);
|
||||
audio_on_user();
|
||||
PLAY_SONG(audio_on_song);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ void audio_off(void) {
|
||||
wait_ms(100);
|
||||
audio_stop_all();
|
||||
audio_config.enable = 0;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
eeconfig_update_audio(&audio_config);
|
||||
}
|
||||
|
||||
bool audio_is_on(void) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# include "audio_dac.h"
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
typedef union audio_config_t {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
bool enable : 1;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# define BREATHING_PERIOD 6
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
typedef union backlight_config_t {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
bool enable : 1;
|
||||
@@ -58,10 +58,8 @@ void backlight_level_noeeprom(uint8_t level);
|
||||
void backlight_level(uint8_t level);
|
||||
uint8_t get_backlight_level(void);
|
||||
|
||||
uint8_t eeconfig_read_backlight(void);
|
||||
void eeconfig_update_backlight(uint8_t val);
|
||||
void eeconfig_update_backlight_current(void);
|
||||
void eeconfig_update_backlight_default(void);
|
||||
void eeconfig_update_backlight_current(void);
|
||||
void eeconfig_update_backlight_default(void);
|
||||
|
||||
// implementation specific
|
||||
void backlight_init_ports(void);
|
||||
|
||||
+3
-3
@@ -246,7 +246,7 @@ static void print_eeconfig(void) {
|
||||
xprintf("eeconfig:\ndefault_layer: %u\n", eeconfig_read_default_layer());
|
||||
|
||||
debug_config_t dc;
|
||||
dc.raw = eeconfig_read_debug();
|
||||
eeconfig_read_debug(&dc);
|
||||
xprintf(/* clang-format off */
|
||||
|
||||
"debug_config.raw: %02X\n"
|
||||
@@ -263,7 +263,7 @@ static void print_eeconfig(void) {
|
||||
); /* clang-format on */
|
||||
|
||||
keymap_config_t kc;
|
||||
kc.raw = eeconfig_read_keymap();
|
||||
eeconfig_read_keymap(&kc);
|
||||
xprintf(/* clang-format off */
|
||||
|
||||
"keymap_config.raw: %02X\n"
|
||||
@@ -296,7 +296,7 @@ static void print_eeconfig(void) {
|
||||
# ifdef BACKLIGHT_ENABLE
|
||||
|
||||
backlight_config_t bc;
|
||||
bc.raw = eeconfig_read_backlight();
|
||||
eeconfig_read_backlight(&bc);
|
||||
xprintf(/* clang-format off */
|
||||
"backlight_config"
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user