From 4ece705c296ad7ef5fde7cf26b53aaf1135b2cd0 Mon Sep 17 00:00:00 2001 From: rafa Date: Sat, 24 May 2025 00:42:16 +0100 Subject: [PATCH] fix: not detecting end of array(make it circular) --- code/LCDScreen.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/LCDScreen.cpp b/code/LCDScreen.cpp index df04b9d..fe197c7 100644 --- a/code/LCDScreen.cpp +++ b/code/LCDScreen.cpp @@ -65,10 +65,16 @@ class LCDScreen { } LCDScreenState get_next_state(){ + if (this->current_state == 2){ + return this->ordered_states[0]; + } return this->ordered_states[this->current_state + 1]; } LCDScreenState get_previous_state(){ + if (this->current_state == 0){ + return this->ordered_states[2]; + } return this->ordered_states[this->current_state - 1]; }