#include <oledDirect.h>
#include <SD.h>
#include <Array.h>
#ifndef __AVR__
#include <SPI.h>
#endif
// The Arduino Shield from ILSoft uses pins 8, 9 and 7 for CS, DC and Reset.
#define CS 8
#define DC 9
#define RESET 7
// Create a variable to hold our OLED class.
SSD1351 *oled;
// Array to store QR pixels as bits Version 3 29x29
boolean qrData[29][29] = {
{1,1,1,1,1,1,1,0,0,0,1,0,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1},
{1,0,0,0,0,0,1,0,1,0,1,0,0,1,1,1,0,1,0,0,0,0,1,0,0,0,0,0,1},
{1,0,1,1,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0,1},
{1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,0,1},
{1,0,1,1,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,0,1,0,1,0,1,1,1,0,1},
{1,0,0,0,0,0,1,0,1,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1},
{1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,1,1,1,0,1,0,1,0,1,0},
{0,1,0,1,0,0,0,1,1,0,1,0,1,1,1,0,0,0,0,0,1,1,0,1,1,0,0,1,1},
{0,0,1,1,1,1,0,1,0,0,0,0,1,0,1,1,1,0,0,1,0,1,1,1,0,1,0,1,0},
{1,0,0,0,0,1,1,1,0,1,1,0,1,1,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0},
{1,0,0,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1},
{1,0,1,1,0,0,1,0,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,0,0},
{0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,1,0,0,0},
{0,1,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1},
{1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,1,1,1,0,1,1,1},
{1,0,1,0,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,0,0,1,0,1,1,1,0,0,0},
{1,0,1,0,1,1,0,1,0,1,0,0,1,0,1,0,0,0,0,1,1,0,1,1,1,1,0,1,1},
{1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,1,1,1,1,1,1,0,1,1,0},
{0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,1,1,1,1},
{1,1,1,1,1,1,1,0,1,0,1,1,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0},
{1,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,1},
{1,0,1,1,1,0,1,0,1,1,1,1,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1},
{1,0,1,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,1,1},
{1,0,1,1,1,0,1,0,1,0,0,0,0,1,1,1,0,1,1,1,0,1,1,0,1,0,1,1,0},
{1,0,0,0,0,0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1,0,0,1,1,0,0,1,0},
{1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,0,0,0,1,0,0,0,0,1,1,1,0,0}
};
//OLED pixels per QR pixel
int scale=4;
void setup()
{
// Instantiate the class with the pins.
oled = new SSD1351(CS, DC, RESET);
Serial.begin(9600);
Serial.println("Running...");
// Clear the screen.
oled->clearScreen(Colour::White);
drawCode(scale);
}
void drawCode(int s)
{
for (int x=0;x<29;x++){
for (int y=0;y<29;y++){
//if(qrData[x][y]){ //<<-----If uncommented screen is randome pixels, ALL serial output fails
if(x==y){ //<<-----If uncommented screen shows proper test pattern and serial output
Serial.println(x);
oled->fillRect(Rectangle(x*s+6, y*s+6, s, s), Colour::Black);
}
}
}
}
void loop()
{
}
Strange issues when running this code...I have not worked with my Arduino in a while (since before v1.0 of the IDE) so I am not sure what all has changed...As it states in the comments of the code, any time I try to read from this array, serial output does not happen (which was put in to try and debug things) and I get nothing but static on my OLED screen...
Any ideas? I am hoping my eyes are just too tired from manually entering this QR pixel by pixel to see the obvious...
Troubleshooting so far:
Note 1: This also happens when I try to read data from the array outside the for-loop even using fixed values, such as trying something simple like "if(qrData[5][5]==0)" or "Serial.println(int(qrData[5][5]));" As well as if I try to manually set an element, such as " qrData[5][5]=true;"
Note 2: And to clarify, when the other IF-THEN is used, I do mean ALL serial output fails, including the line that should be printed during setup well before attempting to access the array...This kind of makes me wonder if the error is in the compiler rather than the code, since it supposedly compiles properly.
Note 3: If I try to manually set an element the same thing happens as in Note 1...IE: