Bit stumped here. I'm trying to build a menu and display it. For some reason the application will not work when Oled and array. If I remove all Oled related initialization, the Array works, if I add Oled I can't get past Setup(). Following code works (serial shows hello and logo draws:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "MenuHandler.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO: A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define NUMFLAKES 10 // Number of snowflakes in the animation example
#define LOGO_HEIGHT 16
#define LOGO_WIDTH 16
static const unsigned char PROGMEM logo_bmp[] =
{ 0b00000000, 0b11000000,
0b00000001, 0b11000000,
0b00000001, 0b11000000,
0b00000011, 0b11100000,
0b11110011, 0b11100000,
0b11111110, 0b11111000,
0b01111110, 0b11111111,
0b00110011, 0b10011111,
0b00011111, 0b11111100,
0b00001101, 0b01110000,
0b00011011, 0b10100000,
0b00111111, 0b11100000,
0b00111111, 0b11110000,
0b01111100, 0b11110000,
0b01110000, 0b01110000,
0b00000000, 0b00110000 };
void setup() {
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
}
void loop() {
Serial.println("hello");
/* for (int j=0; j<2; j++) {
Serial.println("getting current Menu");
currentMenu = menus[j];
for (int i=0; i<currentMenu.getNumItems(); i++) {
Serial.print("4.item Name: "); Serial.print(currentMenu.getItem(i).getName()); Serial.println(currentMenu.getItem(i).getId());
}
}
*/
delay(500);
}
Now if I add the following statement to the code
#include "Menu.h"
const String _ActionHome = "Home Z";
const String _SubMoveZ = "Move Menu";
const String _ActionMove = "Move Z";
const String _ActionEdge = "Edge find";
const String _ActionBurn = "Burn";
const String _ActionStatus = "Status";
const String _ActionMoveSegment = "MoveSeg";
const String _ActionBack = "Back";
Menu currentMenu;
Menu mainMenu = Menu(0, "main");
Menu moveMenu = Menu(1, "move Z");
Menu menus[2];
Specifically the statement Menu menus[2]; breaks it all.
If I remove all Oled specific code the array works just fine.