Skip to content

Commit

Permalink
knob: Fix loading of prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
xingrz committed Oct 18, 2023
1 parent e6f7772 commit 6029018
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion config/boards/arm/hw75_dynamic/app/knob_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,20 @@ static int knob_app_settings_load_cb(const char *name, size_t len, settings_read

if (settings_name_steq(name, "prefs", &next) && !next) {
if (len != sizeof(loader)) {
LOG_ERR("Invalid knob prefs size: %d", len);
return -EINVAL;
}

ret = read_cb(cb_arg, &loader, sizeof(loader));
if (ret >= 0) {
if (ret < 0) {
LOG_ERR("Failed to read knob prefs: %d", ret);
return 0;
}

for (uint8_t i = 0; i < ARRAY_SIZE(loader); i++) {
LOG_DBG("Read knob pref %d: layer=\"%s\", active=%d", i, loader[i].name,
loader[i].active);

if (!loader[i].active) {
continue;
}
Expand All @@ -172,6 +177,11 @@ static int knob_app_settings_load_cb(const char *name, size_t len, settings_read
if (strcmp(loader[i].name, knob_prefs[j].name) == 0) {
memcpy(&knob_prefs[j], &loader[i],
sizeof(struct knob_pref));

LOG_DBG("Loaded knob pref %d for layer %d \"%s\": mode=%d, ppr=%d, torque_limit=%.03f",
i, j, knob_prefs[j].name, knob_prefs[j].mode,
knob_prefs[j].ppr, knob_prefs[j].torque_limit);

break;
}
}
Expand Down

0 comments on commit 6029018

Please sign in to comment.