Hi Paul and John, thank you both.
As recommended, changing the enum value name solved the first issue- I still don't understand the manner in which the enum value is linked with the function contained in the .h file. I think once I get the sketch working, the mechanics will become clearer to me. Anyway, the main this is that the error messages have disappeared, so thank you.
I also understand now the "too many initializers" error: there were too many lines for the number of PageLinks, it's expecting them to be the same (20, at present) and I had 26 initializers. So I resolved that issue as well.
I have one final remaining issue, which is:
displayImage [see error code attached] is not declared.
I understand that the line displayImage(page); will call up the relevant "page" .h file corresponding to the selection of the button press in a specific initializer line.
The error code suggest I replace displayImage with display (command from the Adafruit Library), unsurprisingly that didn't work when I tried it.
In the global variables I tried declaring displayImage a number of different ways, but (as is obvious) I'm throwing darts blindly at the wall:
//displayImage(PageLinks);// didn't work
//displayImage(PageLinks, page);// didn't work
//displayImage(const int PageLinks); didn't work
//displayImage(enum buttons, const int PageLinks, enum pages);
Here is the almost working code ( "page .h" files not attached)
#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 upButton = 9; //setting up buttons for pocKonso
int upButtonState = HIGH;
int lastupButtonState = LOW;
const int downButton = 10;
int downButtonState = HIGH;
int lastdownButtonState = LOW;
const int leftButton = 7;
int leftButtonState = HIGH;
int lastleftButtonState = LOW;
const int rightButton = 8;
int rightButtonState = HIGH;
int lastrightButtonState = LOW;
unsigned long lastDebounceTime = 0; // didn't end up using this code; can leave it
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
/* // too many initializers... easy to work around.
{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
*/
};
//displayImage(PageLinks);// didn't work
//displayImage(PageLinks, page);// didn't work
//displayImage(const int PageLinks); didn't work
//displayImage(enum buttons, const int PageLinks, enum pages);
//////////////////////////////////////////
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 (upButton, INPUT_PULLUP);
pinMode (downButton, INPUT_PULLUP);
pinMode (leftButton, INPUT_PULLUP);
pinMode (rightButton, 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 rightButtoPreviousnState = 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 pagbe 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 pagbe 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 pagbe and button
page = PageLinks[page][UpButtonIndex];
displayImage(page);
}
}
}
And here are the straggler error codes:
Arduino: 1.8.16 (Windows Store 1.8.51.0) (Windows 10), Board: "Seeeduino XIAO, Arduino, Off"
GFX_SEEN-post-help-Oct17:100:60: error: expected constructor, destructor, or type conversion before ';' token
displayImage(enum buttons, const int PageLinks, enum pages);
^
C:\Users\patte\Documents\Arduino\GFX_SEEN-post-help-Oct17\GFX_SEEN-post-help-Oct17.ino: In function 'void setup()':
GFX_SEEN-post-help-Oct17:129:1: error: 'displayImage' was not declared in this scope
displayImage(page);
^~~~~~~~~~~~
C:\Users\patte\Documents\Arduino\GFX_SEEN-post-help-Oct17\GFX_SEEN-post-help-Oct17.ino:129:1: note: suggested alternative: 'display'
displayImage(page);
^~~~~~~~~~~~
display
C:\Users\patte\Documents\Arduino\GFX_SEEN-post-help-Oct17\GFX_SEEN-post-help-Oct17.ino: At global scope:
GFX_SEEN-post-help-Oct17:132:1: error: expected declaration before '}' token
}
^
exit status 1
expected constructor, destructor, or type conversion before ';' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.