Oled menu strange things on page 3

Hello developers.
I am busy for a wail to create a Oled travel clock that sync his time from a GPS device this, is working fine but now I will create a Menu so that I can switch on/off the GPS to reduce battery energy
and that a DS3231 take over the time and date .
This is and challenge to create this.
But my question is when you look to my code “DrawMenu” there is an block that is select as commented
out “page 3” now is the code working but when I set it active my code is not working at all

can someone help my with this…

skylab_clock.ino (6.33 KB)

buttonstate.ino (761 Bytes)

drawMenu.ino (6.04 KB)

MenuActions.ino (512 Bytes)

Just had a quick look at the code and wondering if you ever go from page 1 to page 3, because if you do try, it wouldn't because it's "else" is for the page 2. Probably not anything like that, but just saw it and wondered why that "else" is even there rather than just an "if" by itself.

Can you help my with this I does know how to get this to work
I have tried with an IF or else if but notting work

It's still kinda confusing to me, the placement of the "else(s)" in your code. There should be a definitive reason for having an "else" and if "trying" with and without, and not knowing why, that could be a problem. Can you have a hard look at the code and remove any "else" where is definitely not applicable, retry, and if still not working repost the code with the changes?

I have tried that but my code is not working. when I comment out the “page 3”
then it’s working.

drawMenu.ino (5.98 KB)

I have repost the new code

Code like what is at the bottom of this post looks "kinda suspect" to me, just because of how the "else" (shown on the last line of that code block) is applied against a second block of code when it appears as though both of the "if" statements above it should be combined in a single "if" and then the "else" after those combined. Or, as with the "else" statements you removed, should just be an "if" of it's own rather than an "else if." BUT without seeing an actual flow-chart, or having the hardware in front of me, it's difficult to know the real meaning of it all.

I have some suggestions. Perhaps the easiest, is if you're using a chip that has serial output, simply insert some serial output at certain places in the block related to the "page 3" which is hanging you up and you may find exactly how far it's getting. If no serial output, then perhaps blink an LED a certain number of times at various places to see where you're at - how far you get before it snags - to determine if it's doing exactly what you think it should do. That's something I used to do years ago when writing assembly code (when writing in assembly was pretty common for MCUs), which could be more error-prone, before C for such things (still have my old Microchip books with all examples in assembly) became so popular and I began using it. Anyhow, another suggestion is to just resort to the rather arduous task of writing a complete "flow-chart" of exactly what it's supposed to do, and make sure that you're doing exactly that. Finally know that code for displays can be pretty intense in the way of using up memory due mostly to huge font tables, so make sure you aren't having a memory crash. That last thing can be one of the most difficult things to discover, and can be triggered, when "pushing the limits," by just a single additional variable use, or even a single line of code that needs to push something onto the stack.

		if (up && page == 3) {								// Pagina 3 UP
			up = false;
			if (menuitem == 0)
				menuitem = 3;
		if (down && page == 3) {							// Pagina 3 DOWN
			down = false;
			if (menuitem == 4)
				menuitem = 1;
		else if (page == 3 && menuitem == 3) { page = 2; }