Hi Guys, love arduino, gave me a new lease on life. building a project using a tft screen. Got the screen working now but I have written some code that does not seem to work. I have researched for hours but I cannot see what I am doing wrong. (new to C programming). Please find the two functions I have written below. The idea was to use the function to draw leds (circles) multiple times on different screens where required using the char array and passing it into the drawLEDCircle function. I keep getting garbage printed out on the tft and serial monitor.
void showControlLEDS() {
int arraySize = 14;
int ledLabelLength = 20;
int xPosTxt = 40;
int yPosTxt = 50;
int xPosCircle = 20;
int yPosCircle = 53;
tft.setTextSize(2);
tft.setCursor(50, 20);
tft.setTextColor(ForestGreen);
tft.print("LED");
tft.drawLine(10, 40, 140, 40, ForestGreen);
tft.drawLine(140, 40, 140, 300, ForestGreen);
tft.setTextSize(1);
char ledArray[arraySize];
char ledLabels[arraySize][ledLabelLength] = {"Auto Mode", "Manual Mode", "Bypass Mode", "Radio Rx", "VAC Active", "Servo's Running", "Pump Running", "Tank Empty", "Tank Level OK", "Tank Filling", "Tank 100% Full", "Tank => 75% Full", "Tank <= 25% Full"};
tft.setTextColor(Yellow);
drawLEDCircle(ledArray, arraySize, ledSpacing,xPosTxt, yPosTxt , xPosCircle, yPosCircle); //ledSpacing is a global const int
}
//---------------------------------------------------------------------------------
void drawLEDCircle(char arrayName[], int Size, int spacing,int xPosT, int yPosT, int xPosCirc, int yPosCirc) {
for (uint8_t idx = 0; idx < Size; idx++) {
tft.setCursor(xPosT, yPosT);
tft.drawCircle(xPosCirc, yPosCirc, ledRadius, White);
yPosT = yPosT + spacing;
yPosCirc = yPosCirc + spacing;
tft.print(arrayName[idx]);
Serial.println(arrayName[idx]);
}
}
//---------------------------------------------------------------------------------
Serial monitor printout:
⸮
⸮
{
⸮
Any assistance would be grateful. thankyou