Need help with sketch structure and if/else if function

Hi John,

I've had a chance to plug away at this. I'm down to two problems.
First, I'm still stuck on the displayImage is not declared problem. As noted in my previous post above, I have tried a number of iterations without success. I would appreciate a(nother) shove in the right direction.

A new issue has popped up (which didn't appear in prior versions of the code):
"invalid conversion from 'int' to 'pages' [-f permissive]". I'm not sure what this issue is and why it's rearing its ugly head now, and not before...

Thanks for any help,

Angus

#include <SPI.h>
#include <Wire.h> //ANGUS
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#include <Fonts/FreeSerif9pt7b.h>

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);//ANGUS

#include "pocKonsoLOGO.h"

///// Switches 

const int upButtonPin = 9;              //setting up buttons for pocKonso
int upButtonState = HIGH;
int lastupButtonState = LOW;

const int downButtonPin = 10;            
int downButtonState = HIGH;
int lastdownButtonState = LOW;

const int leftButtonPin = 7;
int leftButtonState = HIGH;
int lastleftButtonState = LOW;

const int rightButtonPin = 8;
int rightButtonState = HIGH;
int lastrightButtonState = LOW;

unsigned long lastDebounceTime = 0; // didn't end up using this code
unsigned long debounceDelay = 50;   // didn't end up using this code

/////////////////ROOMS//////////////
#include "room2doors.h"
#include "twodoors.h"
#include "sofawall.h"
#include "library.h"
#include "fourthwall.h"
#include "Book.h"
#include "lounger.h"
#include "dagger.h"
#include "HALL.h"
#include "ARROWWALL.h"
#include "BLANKWall.h"
#include "mirror.h"
#include "lipstick.h"
#include "eye1.h"
#include "eye2.h"
#include "eye3.h"
#include "book1.h"
#include "book2.h"
#include "book3.h"
#include "sofadetail.h"
  
///////////////////// ROOM LINKS ////////////////

enum buttons {upButtonIndex, downButtonIndex, leftButtonIndex, rightButtonIndex};

enum pages {room2doors, twodoors, sofawall, library, fourthwall, Book, lounger, dagger, HALL, ARROWWALL, BLANKWall, mirror, lipstick, eye1, eye2, eye3, book1, book2, book3, sofadetail,     NUMBER_OF_IMAGES} page;

const int PageLinks[NUMBER_OF_IMAGES][4] = 
{
  {twodoors, sofawall, library, fourthwall}, // room2doors
  {HALL, room2doors, ARROWWALL, BLANKWall}, // twodoors
  {mirror, room2doors, lipstick, sofadetail}, // sofawall
  {Book, room2doors, lounger, dagger}, // library
  {eye1, room2doors, eye2, eye3}, // fourthwall
  
  {book1, library, book2, book3}, // Book
  {library, library, library, library}, // lounger
  {library, library, library, library}, // dagger
  {room2doors, room2doors, room2doors, room2doors}, // HALL
  {twodoors, room2doors,sofawall, HALL}, // ARROW WALL
  
  {twodoors, room2doors, HALL, sofawall}, //BLANK Wall
  {sofawall, sofawall, lipstick, dagger}, //mirror
  {sofawall, sofawall, dagger, mirror}, //lipstick 
  {sofawall, sofawall, mirror, lipstick}, //dagger
  {fourthwall, fourthwall, fourthwall, fourthwall}, //eye1
/*  
  {fourthwall, fourthwall, fourthwall, fourthwall}, //eye2
  {fourthwall, fourthwall, fourthwall, fourthwall}, //eye3
  {Book, Book, Book, Book}, // book1
  {Book, Book, Book, Book}, // book2
  {Book, Book, Book, Book}, // book3
  {sofawall, sofawall, sofawall, sofawall}, //sofadetail 
  */
  };



//////////////////////////////////////////

void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
 
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }

display.setRotation(2);     // Rotate display 180 for pocKonso

pinMode (upButtonPin, INPUT_PULLUP);
pinMode (downButtonPin, INPUT_PULLUP);
pinMode (leftButtonPin, INPUT_PULLUP);
pinMode (rightButtonPin, INPUT_PULLUP);
   
  display.clearDisplay();
  display.setRotation(2);
  display.drawBitmap(0, 0, gImage_pocKonsoLOGO, 128, 64, 1); //This is the pocKonso splash screen
  display.display();

      delay(2000);
      display.clearDisplay();     // clear the display 

page = room2doors;  // Initial page
displayImage(page);
}

void loop() {
  // put your main code here, to run repeatedly:
  static int upButtonPreviousState = HIGH;
  static int downButtonPreviousState = HIGH;
  static int leftButtonPreviousState = HIGH;
  static int rightButtonPreviousState = HIGH;
  
  int upButtonState = digitalRead(upButtonPin);
  int downButtonState = digitalRead(downButtonPin);
  int leftButtonState = digitalRead(leftButtonPin);
  int rightButtonState = digitalRead(rightButtonPin);
                    

  if (upButtonState != upButtonPreviousState)
  {
    upButtonPreviousState = upButtonState;
    if (upButtonState == LOW)
     {      // button just pressed // Follow the link for the current page and button
      page = PageLinks[page][upButtonIndex]; 
      displayImage(page);    
     }         
    }
    if (downButtonState != downButtonPreviousState)
  {
    downButtonPreviousState = downButtonState;
    if (downButtonState == LOW)
     {
      // button just pressed
      // Follow the link for the current page and button
      page = PageLinks[page][downButtonIndex]; 
      displayImage(page);    
     }         
    }
   if (leftButtonState != leftButtonPreviousState)
  {
    leftButtonPreviousState = leftButtonState;
    if (leftButtonState == LOW)
     {
      // button just pressed
      // Follow the link for the current page and button
      page = PageLinks[page][leftButtonIndex]; 
      displayImage(page);    
     }         
    }
     if (rightButtonState != rightButtonPreviousState)
  {
    rightButtonPreviousState = rightButtonState;
    if (rightButtonState == LOW)
     {
      // button just pressed
      // Follow the link for the current page and button
      page = PageLinks[page][rightButtonIndex]; 
      displayImage(page);    
     }         
    }  
}

Two flavours, one old and one new, of error codes here:

Arduino: 1.8.16 (Windows Store 1.8.51.0) (Windows 10), Board: "Seeeduino XIAO, Arduino, Off"

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino: In function 'void setup()':

GFX_SEEN-Almost-There1:124:1: error: 'displayImage' was not declared in this scope

 displayImage(page);

 ^~~~~~~~~~~~

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino:124:1: note: suggested alternative: 'display'

 displayImage(page);

 ^~~~~~~~~~~~

 display

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino: In function 'void loop()':

GFX_SEEN-Almost-There1:145:43: error: invalid conversion from 'int' to 'pages' [-fpermissive]

       page = PageLinks[page][upButtonIndex];

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

GFX_SEEN-Almost-There1:146:7: error: 'displayImage' was not declared in this scope

       displayImage(page);

       ^~~~~~~~~~~~

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino:146:7: note: suggested alternative: 'display'

       displayImage(page);

       ^~~~~~~~~~~~

       display

GFX_SEEN-Almost-There1:156:45: error: invalid conversion from 'int' to 'pages' [-fpermissive]

       page = PageLinks[page][downButtonIndex];

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

GFX_SEEN-Almost-There1:157:7: error: 'displayImage' was not declared in this scope

       displayImage(page);

       ^~~~~~~~~~~~

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino:157:7: note: suggested alternative: 'display'

       displayImage(page);

       ^~~~~~~~~~~~

       display

GFX_SEEN-Almost-There1:167:45: error: invalid conversion from 'int' to 'pages' [-fpermissive]

       page = PageLinks[page][leftButtonIndex];

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

GFX_SEEN-Almost-There1:168:7: error: 'displayImage' was not declared in this scope

       displayImage(page);

       ^~~~~~~~~~~~

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino:168:7: note: suggested alternative: 'display'

       displayImage(page);

       ^~~~~~~~~~~~

       display

GFX_SEEN-Almost-There1:178:46: error: invalid conversion from 'int' to 'pages' [-fpermissive]

       page = PageLinks[page][rightButtonIndex];

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

GFX_SEEN-Almost-There1:179:7: error: 'displayImage' was not declared in this scope

       displayImage(page);

       ^~~~~~~~~~~~

C:\Users\patte\Documents\Arduino\GFX_SEEN-Almost-There1\GFX_SEEN-Almost-There1.ino:179:7: note: suggested alternative: 'display'

       displayImage(page);

       ^~~~~~~~~~~~

       display

exit status 1

'displayImage' was not declared in this scope



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.