Is the problem in the code or in the OLED screen?

Thanks for the explanation. To be honest I am not fully convinced about this, let explain why. Imagine that instead of a rotary encoder I am using a set of 37 separate switches, each of them assigned to a different value. When I press switch 1-36, the code will go fetch the respective value from the array. When I press switch 37, however, I think we can agree that I can assign whatever value/command to it, because it's just another switch.
Now, if you think that the rotary encoder is simply another way to enter the value, which simply saves me the space and complication of having a dedicated switch for each of the possible option, then logic would want that every value within the 0-36 range can be attached to anything I want.
To make a very simple example, I could have a code that says that for:
value 0 = turn on red led
Value 1 = turn on green led
Value 2 = make a sound with the buzzer
Value 3 = activate a motor
Just because they are all activated by the rotary encoder when it's in a certain position, it doesn't mean that the actions that follow have to be related to each other or be part of a same array. In fact, I could use each value for anything I want.
Happy to hear your thoughts on this though in case I missed something or you think my logic is wrong.