8 Step macro and profile switching fully working

This commit is contained in:
Julian Appel 2026-04-13 22:34:54 +02:00
parent 098a166a9f
commit 433d61c29f
10 changed files with 204 additions and 193 deletions

View file

@ -255,13 +255,16 @@ void CMainController::poll_vendor()
cfg.version == NVM_CONFIG_VERSION &&
cfg.crc == nvm_config_crc(cfg))
{
nvm_config_save(cfg);
init_buttons();
usb_serial_send(USB_EVT_CONFIG_ACK, 0); // Erfolg melden
if (nvm_config_save(cfg)) {
init_buttons();
usb_serial_send(USB_EVT_CONFIG_ACK, 0); // Erfolg melden
} else {
usb_serial_send(USB_EVT_CONFIG_NACK, 0); // NVM-Timeout
}
}
else
{
usb_serial_send(USB_EVT_CONFIG_NACK, 0); // Fehler melden
usb_serial_send(USB_EVT_CONFIG_NACK, 0); // CRC/Magic-Fehler
}
}
break;
@ -288,8 +291,11 @@ void CMainController::poll_vendor()
if (m_macro_receiving) {
m_macro_receiving = false;
memcpy(&m_macros, m_macro_buf, sizeof(m_macros));
macro_config_save(m_macros);
usb_serial_send(USB_EVT_MACRO_ACK, 0);
if (macro_config_save(m_macros)) {
usb_serial_send(USB_EVT_MACRO_ACK, 0);
} else {
usb_serial_send(USB_EVT_MACRO_NACK, 0); // NVM-Timeout
}
}
break;
@ -439,8 +445,10 @@ void CMainController::execute_action_down(SAction action, uint8_t key_id)
target = (cfg.active_profile + 1) % 3; // Zyklus: 0→1→2→0
if (target > 2) break;
cfg.active_profile = target;
nvm_config_save(cfg);
init_buttons();
cfg.crc = nvm_config_crc(cfg); // CRC nach Änderung aktualisieren
if (nvm_config_save(cfg))
init_buttons();
// Bei NVM-Timeout: kein Profil-Wechsel (Config unverändert in NVM)
break;
}