#include <Adafruit_GFX.h> // Core graphics library
#include "LGDP4535.h" // Hardware-specific library
#include <zTouchScreen.h>
#define BOXSIZE 40
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
LGDP4535 tft; // Using the shield, all control and data lines are fixed
#define YP A3 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
// You need to calibrate to fit your LCD
#define TS_MINX 930
#define TS_MINY 903
#define TS_MAXX 142
#define TS_MAXY 117
#define PENRADIUS 3
#define MINPRESSURE 10
#define MAXPRESSURE 1000
int matrix[2][3]; // Initial Declaration
int array[3]
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
// array = start with 1 but the variable read start with 0
String ButtonAction[9]={"a", "b", "c", "d", "e", "f", "g", "h", "i"};
boolean ActiveMenu=true;
void setup(void) {
Serial.begin(9600);
tft.reset();
tft.begin();
ts.InitVariable(3, 240, 320, TS_MINX, TS_MAXX, TS_MINY, TS_MAXY, MINPRESSURE, MAXPRESSURE);
tft.fillScreen(BLACK);
DrawIt(CYAN, "draw");
DrawIt(BLACK, "text");
}
void loop() {//SOME OTHER STUFF}
unsigned long DrawIt(uint16_t color, String CurrentAction) {
int timedcycle=0;
if (CurrentAction == "text") {
int matrix[2][3]={{25,150,265},{45,100,155}};
int array[3]={3,3,3};
tft.setRotation(3);
tft.setTextColor(BLACK);
tft.setTextSize(1);
Serial.println("Text Columns");
}
else if (CurrentAction == "draw") {
int matrix[2][3]={{260,140,20},{40,150,95}};
int array[3]={3,3,3};
}
Serial.println(CurrentAction);
for(int j=0; j<3; j++) {
for(int i=0; i<array[j]; i++) {
if (CurrentAction == "draw") {
if (timedcycle == 7) {
tft.fillCircle(100, 160, 15, WHITE);
}
else {
tft.fillRect(matrix[1][j], matrix[0][i], 20,40, color);
}
}
else if (CurrentAction == "text") {
if (timedcycle == 4) {
true;
//tft.fillCircle(100, 160, 15, WHITE);
}
else {
tft.setCursor(matrix[0][j], matrix[1][i]);
tft.println(ButtonAction[timedcycle]);
}
}
timedcycle++;
}
}
}
So as you can see I'm trying to draw some things in a TFT Touch Screen. Everything seems to be working but no matter what I do I can't change the array value.
If I initialize the array variable with a predetermined value it won't change even if the statement is called correctly. I can see that it runs over serial but the array still doesn't change.
I suppose there's something wrong but I can't pinpoint what it is! Thanks in advance!