diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-26 16:21:07 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-26 16:21:07 +0200 |
commit | 6b7b02596522b0db476dd64bb69e0e3825ce790d (patch) | |
tree | d2a648d45abc1db0138ff35edbbc05ec352c520d /robot/modes.c | |
parent | 6c3d73d260a4254013e48b7f992c8c4fd87f5689 (diff) |
added error beeps and fix mode history IOB error
Diffstat (limited to 'robot/modes.c')
-rw-r--r-- | robot/modes.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/robot/modes.c b/robot/modes.c index a54bc43..d706c2f 100644 --- a/robot/modes.c +++ b/robot/modes.c @@ -30,8 +30,7 @@ void w2_modes_init() { void w2_modes_main() { (*g_w2_modes[g_w2_mode_history[g_w2_mode_history_index]])(); } void w2_modes_switch(w2_e_mode new_mode, bool replace) { - int16_t next_history_index = - g_w2_mode_history_index + (new_mode == W2_M_PREV ? -1 : 1) * (replace - 1); + int16_t next_history_index = g_w2_mode_history_index + (new_mode == W2_M_PREV ? -1 : 1) * !replace; if (next_history_index == -1 || next_history_index == W2_MODE_HISTORY_BUFFER_SIZE - 1) { next_history_index = W2_RANGE(0, next_history_index, W2_MODE_HISTORY_BUFFER_SIZE); w2_errcatch_throw(W2_E_WARN_MODE_HISTORY_BUFFER_IOB); |