Mobsya / aseba-target-thymio2

Thymio 2 firmware
8 stars 8 forks source link

Enforcing setting limits before saving #55

Closed ypiguet-epfl closed 2 years ago

ypiguet-epfl commented 2 years ago

In behavior.c at line 487, set_save_settings() is called before constraining the new volume value between 0 and 8 inclusive. This causes a call to AsebaNative__system_settings_flash() at shutdown (main.c line 295) even if the volume hasn't been changed.

I suggest to move the tests as follows:

when(buttons_state[BUTTON_BACKWARD]) {
    if (volume < 8) {
        volume++;
        set_save_settings();
    }
}
when(buttons_state[BUTTON_FORWARD]) {
    if (volume > 0) {
        volume--;
        set_save_settings();
    }
}

There is the same problem with SET_MOTOR (correction between -50 and 50).

mbonani commented 2 years ago

implement in eb408bddabbfcca163cfc838a979c8c4d35e7d82