Saved name not visible immediately

/*  eeprom_ExtMemory
   Save names to 24LC256 using DUE
   25 May 2019
*/
#include <SPI.h>
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#include <Wire.h>    //use SCL & SDA
extern TwoWire Wire1;// use SCL1 & SDA1
#define disk1 0x50    //Address of 24LC256 eeprom chip

/*removed*/

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 365);
//declare all buttons to be used
Adafruit_GFX_Button on_btn, on_btn1, on_btn2, on_btn3, on_btn4, on_btn5,
                    on_btn6, on_btn7, on_btn8, on_btn9, on_btn10, on_btn11, on_btn12,
                    on_btn13, on_btn14, on_btn15, on_btn16, on_btn17, on_btn18;
const char* post;
const char* post1;
char currentPage;
int pixel_x, pixel_y;
byte Number;//hold Number for a key pressed on p==1
boolean result = false;
unsigned int address;//holds eeprom write location address

bool Touch_getXY(void) {
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
    //Serial.println( pixel_x);
    // Serial.println( pixel_y);
  }
  return pressed;
}

void setup() {
  Serial.begin(9600);
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  Wire.begin();
  Wire1.begin();  // join i2c bus
  HomePage();
}

//declare the button lists as globals
Adafruit_GFX_Button *page0_buttons[] = {&on_btn, &on_btn1, &on_btn2, &on_btn3, &on_btn4,
                                        &on_btn5, &on_btn6, &on_btn7, &on_btn8, NULL
                                       };//HomePage P==0
Adafruit_GFX_Button *page1_buttons[] = {&on_btn9, &on_btn10, &on_btn11, &on_btn12, &on_btn13, &on_btn14,
                                        &on_btn15, &on_btn16, &on_btn17, &on_btn18, NULL
                                       };// p==1


//declare a global for which button list is currently in use
Adafruit_GFX_Button **active_buttons = { NULL };

bool update_button(Adafruit_GFX_Button * b, bool down) {
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  delay(5);//debounce
  return down;
}

bool update_button_list(Adafruit_GFX_Button **pb) {
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop() {
  update_button_list(active_buttons);
  check_buttons();
}

//============== Check menu buttons ===============
void check_buttons() {
  /*select a name change then goto page==1 
  when button is pressed to select a name */
  if (currentPage == '0') {   //============= Home page
    /*load address for eeprom when ghost button
    is pressed. goto page==1 & wait for name input*/
    if (on_btn.justPressed()) {//row1 left button
      address = 1;//load eeprom address
      getName();
    }
    else if (on_btn1.justPressed()) {//row1 middle 
      address = 10;
      getName();
    }
    else if (on_btn2.justPressed())Game();//row1 right not used yet

    else if (on_btn3.justPressed()) {//row2 left button
      address = 20;
      getName();
    }
    else if (on_btn4.justPressed()) {//row2 middle
      address = 30;
      getName();
    }
    else if (on_btn5.justPressed()) Game();//row2 right not used yet
  }
  
  //row1 3 ghost buttons 
  else if (currentPage == '1')  {
    if (on_btn9.justPressed()) {
      if (Number == 0)Number = 1;
      getName();
    }
    else if (on_btn10.justPressed()) {
      if (Number == 0)Number = 2;
      getName();
    }
    else if (on_btn11.justPressed()) {
      if (Number == 0)Number = 3;
      getName();
    }
    //row2 3 ghost buttons
    if (on_btn12.justPressed()) {
      if (Number == 0)Number = 4;
      getName();
    }
    else if (on_btn13.justPressed()) {
      if (Number == 0)Number = 5;
      getName();
    }
    else if (on_btn14.justPressed()) {
      if (Number == 0)Number = 6;
      getName();
    }
    /*...3 Menu buttons at the bottom..*/
    else if (on_btn16.justPressed()) {
      Number = 0;  //delete button
      result = false;
      getName();
    }
    else if (on_btn17.justPressed()) {
      result = true;
      writeEEPROM (disk1, address, Number); //save button
      Number = 0;//reset number
      //HomePage();
    }
    else if (on_btn18.justPressed()) HomePage();
  }//END else if (currentPage=='1'
} //END check_buttons()

// ==================== end Menu =================

void HomePage() {
  currentPage = '0';
  /*this page has 2 Void() menus
  getName() and Game()
  */
  active_buttons = page0_buttons;
  tft.fillScreen(BLACK);
  /*Ghost buttons graphics used to select the name change on page==0
    and Game button(not used yet)*/
  /*row 1 ghost buttons Left Middle & [Right(not used yet)]*/
  on_btn.initButton(&tft, 55, 15, 100, 30, CYAN, BLACK, BLACK, "", 2);
  on_btn.drawButton(false);
  on_btn1.initButton(&tft, 160, 15, 100, 30, CYAN, BLACK, BLACK, "", 2);
  on_btn1.drawButton(false);
  //on_btn2.initButton(&tft,  280, 15, 50, 50, CYAN, DARKGREY, BLACK, "Team1", 1);
  //on_btn2.drawButton(false);
  //row 2
  on_btn3.initButton(&tft, 55, 50, 100, 30, CYAN, BLACK, BLACK, "", 2);
  on_btn3.drawButton(false);
  on_btn4.initButton(&tft,  160, 50, 100, 30, CYAN, BLACK, BLACK, "", 1);
  on_btn4.drawButton(false);
  //on_btn5.initButton(&tft,  280, 50, 50, 50, CYAN, DARKGREY, BLACK, "Team2", 1);
  //on_btn5.drawButton(false);
  //row 3

  /*..get name from EEPROM...*/
  int J = (readEEPROM(disk1, 1));
  int K = (readEEPROM(disk1, 10));
  int L = (readEEPROM(disk1, 20));
  int M = (readEEPROM(disk1, 30));
  /*.print name on page==0 - ghost buttons.*/
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(8, 8);
  post = getName(J);
  tft.print(post);
  
  tft.setCursor(115, 8);
  post = getName(K);
  tft.print(post);

  tft.setCursor(8, 40);
  post = getName(L);
  tft.print(post);
  
  tft.setCursor(115, 40);
  post = getName(M);
  tft.print(post);  
  /*............................................*/
  }

void getName() {  //page==1

  currentPage = '1';
  active_buttons = page1_buttons;
  //Serial.println("getName");
  tft.fillScreen(BLACK);
  /*goto getName and covert number to a name
  print the selected name on the top left of tft*/
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(8, 8);
  post1 = getName(Number);
  tft.print(post1);
  tft.print(" ");
  /*select Name. [ghost buttons page==1]
  row 1*/
  on_btn9.initButton(&tft, 50, 80, 90, 40, CYAN, DARKGREY, BLACK, "Tina", 2);
  on_btn9.drawButton(false);
  on_btn10.initButton(&tft, 145, 80, 90, 40, CYAN, DARKGREY, BLACK, "Ted", 2);
  on_btn10.drawButton(false);
  on_btn11.initButton(&tft, 250, 80, 90, 40, CYAN, DARKGREY, BLACK, "James", 2);
  on_btn11.drawButton(false);
  /*row 2*/
  on_btn12.initButton(&tft, 50, 130, 90, 40, CYAN, DARKGREY, BLACK, "Tanja", 2);
  on_btn12.drawButton(false);
  on_btn13.initButton(&tft, 145, 130, 90, 40, CYAN, DARKGREY, BLACK, "Cliff", 2);
  on_btn13.drawButton(false);
  on_btn14.initButton(&tft, 250, 130, 90, 40, CYAN, DARKGREY, BLACK, "Jeffrey", 2);
  on_btn14.drawButton(false);

  //bottom row Menu buttons
  on_btn16.initButton(&tft, 280, 200, 60, 40, CYAN, DARKGREY, BLACK, "<<<", 2);
  on_btn16.drawButton(false);
  on_btn17.initButton(&tft, 122, 200, 90, 40, CYAN, DARKGREY, BLACK, "Save", 2);
  on_btn17.drawButton(false);
  on_btn18.initButton(&tft, 210, 200, 60, 40, CYAN, DARKGREY, BLACK, "Home", 2);
  on_btn18.drawButton(false);
}// end getName()


void Game() {
}

void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte Number) {
  Wire1.beginTransmission(deviceaddress);
  Wire1.write((int)(eeaddress >> 8));   // MSB
  Wire1.write((int)(eeaddress & 0xFF)); // LSB
  Wire1.write(Number);
  Wire1.endTransmission();
  delay(5);
  Number = 0;
  address = 0;
}

byte readEEPROM(int deviceaddress, unsigned int eeaddress ) {
  byte rdata = 0xFF;
  Wire1.beginTransmission(deviceaddress);
  Wire1.write((int)(eeaddress >> 8));   // MSB
  Wire1.write((int)(eeaddress & 0xFF)); // LSB
  Wire1.endTransmission();
  Wire1.requestFrom(deviceaddress, 1);
  if (Wire1.available()) rdata = Wire1.read();
  return rdata;
}

const char* getName(int i) {
  switch (i) {
    case 1: return "Tina"; break;
    case 2: return "Ted"; break;
    case 3: return "James"; break;
    case 4: return "Tanja"; break;
    case 5: return "Cliff"; break;
    case 6: return "Jeffrey"; break;
    case 7: return "Casey"; break;
    case 8: return "Marge"; break;
    default: return "choose"; break;
  }
}

Members
The video link above might explain this better. When I touch a button on the 1st screen (HomePage) the 2nd page (getName) pops up. I then select a name from a list and press the 'Save' button. The question I have is, why do I have to reset the Arduino to see the saved name appear on the HomePage? I can see the new selected name for a split second on the screen.

fnb111:
https://youtu.be/XpZ0NsKrWxk

Members
The video link above might explain this better. When I touch a button on the 1st screen (HomePage) the 2nd page (getName) pops up. I then select a name from a list and press the ‘Save’ button. The question I have is, why do I have to reset the Arduino to see the saved name appear on the HomePage? I can see the new selected name for a split second on the screen.

After save, when do you redraw the screen?

The screen is redrawn when the ‘Save’ button is pressed.

fnb111:
The screen is redrawn when the 'Save' button is pressed.

You are saving to Eprom, then reading from Eprom to redraw the screen?

Perehama:
You are saving to Eprom, then reading from Eprom to redraw the screen?

Yes. (The full code is at the top of this thread ) I save the name as a single digit number to EEPROM.

Adafruit_GFX_Button on_btn, on_btn1, on_btn2, on_btn3, on_btn4, on_btn5,
                    on_btn6, on_btn7, on_btn8, on_btn9, on_btn10, on_btn11, on_btn12,
                    on_btn13, on_btn14, on_btn15, on_btn16, on_btn17, on_btn18;

I skipped past this initially, but then I couldn't figure out what the buttons were supposed to being doing.

The on_ prefix seems useless. Does it mean something to you?

Just numbering the objects seems silly. If you have a baby, do you name the kid? Do you name the second one kid2?

Give the objects meaningful names. Seeing SavePos1.justPressed() returning true would cause one to suspect that the user wanted to save something, probably in position 1. Seeing on_btn12.JustPressed() returning true causes one to go "So? Am I supposed to care?"

PaulS:

Adafruit_GFX_Button on_btn, on_btn1, on_btn2, on_btn3, on_btn4, on_btn5,

on_btn6, on_btn7, on_btn8, on_btn9, on_btn10, on_btn11, on_btn12,
                    on_btn13, on_btn14, on_btn15, on_btn16, on_btn17, on_btn18;



I skipped past this initially, but then I couldn't figure out what the buttons were supposed to being doing.

The on_ prefix seems useless. Does it mean something to you?

Just numbering the objects seems silly. If you have a baby, do you name the kid? Do you name the second one kid2?

Give the objects meaningful names. Seeing SavePos1.justPressed() returning true would cause one to suspect that the user wanted to save something, probably in position 1. Seeing on_btn12.JustPressed() returning true causes one to go "So? Am I supposed to care?"

A valid point. But is this going to fix my problem? I have tried now for several days changing the code around and the problem still persist.

I'll look at a possible change. The use of Adafruit btn just makes it easy to create a button. Or I could place more /* tags*/ into the code for easy reading.

Thanks for the help.

But is this going to fix my problem?

It will you to explain the problem in terms of "when I push button X, Y happens, and I do/do not think that is right".

The use of Adafruit btn just makes it easy to create a button.

No. The use of the Adafruit_GFX_Button class makes it easy. There is NO reason to use btn, buttoN, Btn, or ANY variation of button in the name. You could name all your Adafruit_GFX_Button objects slider_N and all of your Adafruit_GFX_Slider objects button_N, and the code would function exactly the same. It would be confusing as hell asking slider_3 if it was pressed or asking button_3 if it had been slid. So, I wouldn't recommend that.

On the other hand, there is nothing wrong with using btn in the name of Adafruit_GFX_Button instances. But, the rest of the name should reflect why the button is there. If the buttons all have labels 1 through N, and you expect the user to guess which f**king button to stab, then keep the names you have.

But, it the buttons are labeled Up, Down, Stop, No, Yes, Maybe, etc. then name the instances btnUp, btnDown, btnStop, btnNo, btnYes, btnMaybe, etc.

Or I could place more /* tags*/ into the code for easy reading.

You could put:

   // See if the Stop button has been pressed
   if(btn7.isPressed())
   {
      StopWhateverNeedsStopping();
   }

Or, you could put:

   if(btnStop.isPressed())
   {
      StopWhateverNeedsStopping();
   }

and not need a comment.

Your choice. You have to maintain the code, not me.

On the other hand, you are expecting me to help you understand why your code is behaving the way it is, and I do NOT like having to read comments to determine what obscure code is doing, when meaningful names make it perfectly clear.

fnb111:
A valid point. But is this going to fix my problem?

Perhaps a slightly less provocative response to that question is that (IMHO) meaningful variable names make it much easier to understand code and thereby make it easier to spot errors of logic.

They also make it very much easier for a stranger to understand your code when trying to help you.

...R

slow motion video: T1234 - YouTube

/*  eeprom_ExtMemory
   Save names to 24LC256 using DUE
   25 May 2019
*/
#include <SPI.h>
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#include <Wire.h>    //use SCL & SDA
extern TwoWire Wire1;// use SCL1 & SDA1
#define disk1 0x50    //Address of 24LC256 eeprom chip

//Removed
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 365);
//declare all buttons to be used
Adafruit_GFX_Button btnghost, btnghost1, btnteam1, btnghost3, btnghost4, btnteam2,
                    on_btn6, on_btn7, on_btn8, btnTina, btnTed, btnJames,
                    btnTanja, btnCliff, btnJeffrey, btnDelete, btnSave, btnHome;
const char* post;
const char* post1;
char currentPage;
int pixel_x, pixel_y;
byte Number;//hold Number for a key pressed on p==1
boolean result = false;
unsigned int address;//holds eeprom write location address

bool Touch_getXY(void) {
  TSPoint p = ts.getPoint();
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_MAXX, TS_MINX, tft.width(), 0);
    pixel_y = map(p.x, TS_MAXY, TS_MINY, 0, tft.height());
    //Serial.println( pixel_x);
    // Serial.println( pixel_y);
  }
  return pressed;
}

void setup() {
  Serial.begin(9600);
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  Wire.begin();
  Wire1.begin();  // join i2c bus
  HomePage();
}

Adafruit_GFX_Button *page0_buttons[] = {&btnghost, &btnghost1, &btnteam1, &btnghost3,
                                        &btnghost4, &btnteam2, NULL
                                       };//HomePage P==0
Adafruit_GFX_Button *page1_buttons[] = {&btnTina, &btnTed, &btnJames, &btnTanja,
                                        &btnCliff, &btnJeffrey, &btnDelete, &btnSave,
                                        &btnHome, NULL
                                       };// p==1



Adafruit_GFX_Button **active_buttons = { NULL };

bool update_button(Adafruit_GFX_Button * b, bool down) {
  b->press(down && b->contains(pixel_x, pixel_y));
  if (b->justReleased())
    b->drawButton(false);
  if (b->justPressed())
    b->drawButton(true);
  delay(5);//debounce
  return down;
}

bool update_button_list(Adafruit_GFX_Button **pb) {
  bool down = Touch_getXY();
  for (int i = 0 ; pb[i] != NULL; i++) {
    update_button(pb[i], down);
  }
  return down;
}

void loop() {
  update_button_list(active_buttons);
  check_buttons();
}

//===== Check menu buttons ==
void check_buttons() {
  /*select a name change then goto page==1
    when button is pressed to select a name */
  if (currentPage == '0') {   // Home page
    /*load address for eeprom when ghost button
      is pressed. goto page==1 & wait for name input*/
    if (btnghost.justPressed()) {//row1 left button
      address = 1;//load eeprom address
      GetName();
    }
    else if (btnghost1.justPressed()) {//row1 middle
      address = 10;
      GetName();
    }
    else if (btnteam1.justPressed())Game();//row1 right not used yet

    else if (btnghost3.justPressed()) {//row2 left button
      address = 20;
      GetName();
    }
    else if (btnghost4.justPressed()) {//row2 middle
      address = 30;
      GetName();
    }
    else if (btnteam2.justPressed()) Game();//row2 right not used yet
  }//end page==0

  /*....................row1 3 buttons ..................*/
  else if (currentPage == '1')  {
    if (btnTina.justPressed()) {
      if (Number == 0)Number = 1;
      GetName();
    }
    else if (btnTed.justPressed()) {
      if (Number == 0)Number = 2;
      GetName();
    }
    else if (btnJames.justPressed()) {
      if (Number == 0)Number = 3;
      GetName();
    }
    //................row2 3 buttons
    if (btnTanja.justPressed()) {
      if (Number == 0)Number = 4;
      GetName();
    }
    else if (btnCliff.justPressed()) {
      if (Number == 0)Number = 5;
      GetName();
    }
    else if (btnJeffrey.justPressed()) {
      if (Number == 0)Number = 6;
      GetName();
    }
    /*.............3 Menu buttons at the bottom..*/
    else if (btnDelete.justPressed()) {
      Number = 0;  //delete button
      result = false;
      GetName();
    }
    else if (btnSave.justPressed()) {
      result = true;
      writeEEPROM (disk1, address, Number); //save button
      Number = 0;//reset number
      HomePage();
    }
    else if (btnHome.justPressed()) HomePage();
  }//END else if (currentPage=='1'
} //END check_buttons()

// ==== end Menu ===

void HomePage() {
  currentPage = '0';
  /*this page has 2 Void() menus
    const char* getName(int i) and Game()
  */
  active_buttons = page0_buttons;
  tft.fillScreen(BLACK);
  /*Ghost buttons graphics used to select the name change on page==0
    and Game button(not used yet)*/
  /*row 1 ghost buttons Left Middle & [Right(not used yet)]*/
  btnghost.initButton(&tft, 55, 15, 100, 30, CYAN, BLACK, BLACK, "", 2);
  btnghost.drawButton(false);
  btnghost1.initButton(&tft, 160, 15, 100, 30, CYAN, BLACK, BLACK, "", 2);
  btnghost1.drawButton(false);
  //btnteam1.initButton(&tft,  280, 15, 50, 50, CYAN, DARKGREY, BLACK, "Team1", 1);
  //btnteam1.drawButton(false);
  //row 2
  btnghost3.initButton(&tft, 55, 50, 100, 30, CYAN, BLACK, BLACK, "", 2);
  btnghost3.drawButton(false);
  btnghost4.initButton(&tft,  160, 50, 100, 30, CYAN, BLACK, BLACK, "", 1);
  btnghost4.drawButton(false);
  //btnteam2.initButton(&tft,  280, 50, 50, 50, CYAN, DARKGREY, BLACK, "Team2", 1);
  //btnteam2.drawButton(false);
  //row 3
 
  /*.print name on page==0 - ghost buttons.*/
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(8, 8);
  int J = (readEEPROM(disk1, 1));
  post = getName(J);
  tft.print(post);

  tft.setCursor(115, 8);
  int K = (readEEPROM(disk1, 10));
  post = getName(K);
  tft.print(post);

  tft.setCursor(8, 40);
  int L = (readEEPROM(disk1, 20));
  post = getName(L);
  tft.print(post);

  tft.setCursor(115, 40);
  int M = (readEEPROM(disk1, 30));
  post = getName(M);
  tft.print(post);
  /*............................................*/
}//end HpomePage

void GetName() {  //page==1
  currentPage = '1';
  active_buttons = page1_buttons;
  //Serial.println("getName");
  tft.fillScreen(BLACK);
 
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(8, 8);
  post1 = getName(Number);
  tft.print(post1);
  tft.print(" ");
  /*select Name. [page==1]
    row 1*/
  btnTina.initButton(&tft, 50, 80, 90, 40, CYAN, DARKGREY, BLACK, "Tina", 2);
  btnTina.drawButton(false);
  btnTed.initButton(&tft, 145, 80, 90, 40, CYAN, DARKGREY, BLACK, "Ted", 2);
  btnTed.drawButton(false);
  btnJames.initButton(&tft, 250, 80, 90, 40, CYAN, DARKGREY, BLACK, "James", 2);
  btnJames.drawButton(false);
  /*row 2*/
  btnTanja.initButton(&tft, 50, 130, 90, 40, CYAN, DARKGREY, BLACK, "Tanja", 2);
  btnTanja.drawButton(false);
  btnCliff.initButton(&tft, 145, 130, 90, 40, CYAN, DARKGREY, BLACK, "Cliff", 2);
  btnCliff.drawButton(false);
  btnJeffrey.initButton(&tft, 250, 130, 90, 40, CYAN, DARKGREY, BLACK, "Jeffrey", 2);
  btnJeffrey.drawButton(false);

  //bottom row Menu buttons
  btnDelete.initButton(&tft, 280, 200, 60, 40, CYAN, DARKGREY, BLACK, "<<<", 2);
  btnDelete.drawButton(false);
  btnSave.initButton(&tft, 122, 200, 90, 40, CYAN, DARKGREY, BLACK, "Save", 2);
  btnSave.drawButton(false);
  btnHome.initButton(&tft, 210, 200, 60, 40, CYAN, DARKGREY, BLACK, "Home", 2);
  btnHome.drawButton(false);
}// end getName()


void Game() {
}

void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte Number) {
  Wire1.beginTransmission(deviceaddress);
  Wire1.write((int)(eeaddress >> 8));   // MSB
  Wire1.write((int)(eeaddress & 0xFF)); // LSB
  Wire1.write(Number);
  Wire1.endTransmission();
  delay(6);
  Number = 0;
  address = 0;
}

byte readEEPROM(int deviceaddress, unsigned int eeaddress ) {
  byte rdata = 0xFF;
  Wire1.beginTransmission(deviceaddress);
  Wire1.write((int)(eeaddress >> 8));   // MSB
  Wire1.write((int)(eeaddress & 0xFF)); // LSB
  Wire1.endTransmission();
  Wire1.requestFrom(deviceaddress, 1);
  if (Wire1.available()) rdata = Wire1.read();
  return rdata;
}

const char* getName(int i) {
  switch (i) {
    case 1: return "Tina"; break;
    case 2: return "Ted"; break;
    case 3: return "James"; break;
    case 4: return "Tanja"; break;
    case 5: return "Cliff"; break;
    case 6: return "Jeffrey"; break;
    case 7: return "Casey"; break;
    case 8: return "Marge"; break;
    default: return "choose"; break;
  }
}

I found this in one of the threads (software reset). Instead of going to page==0 the board gets a reset.

else if (btnHome.justPressed()) { //software reset
      __DSB;
      SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk);
    }

not the correct way but it does work.