SOLVED! Help needed for a noobie using an array to control graphics

Hi Guys;

I am trying to use an array to setup the segments of a graphical 7 segment display.
I think I am close but I get an error in the drawing lines.

here is a section of the code that I am using:

#define sclk 15
#define mosi 16
#define cs   10
#define dc   9
#define rst  6

#define BLACK 0x0000
#define WHITE 0xFFFF

#include <Adafruit_GFX_AS.h>
#include <Adafruit_ILI9341_AS.h>
#include <SPI.h>

Adafruit_ILI9341_AS tft = Adafruit_ILI9341_AS(cs, dc, rst);

void setup(void) {


void loop() {
    if (H==0) String Element[]={"WHITE","WHITE","WHITE","WHITE","WHITE","WHITE","BLACK"}; // 0
    if (H==1) String Element[]={"BLACK","WHITE","WHITE","BLACK","BLACK","BLACK","BLACK"}; // 1
    if (H==2) String Element[]={"WHITE","WHITE","BLACK","WHITE","WHITE","BLACK","WHITE"}; // 2
    if (H==3) String Element[]={"WHITE","WHITE","WHITE","WHITE","BLACK","BLACK","WHITE"}; // 3
    if (H==4) String Element[]={"BLACK","WHITE","WHITE","BLACK","BLACK","WHITE","WHITE"}; // 4
    if (H==5) String Element[]={"WHITE","BLACK","WHITE","WHITE","BLACK","WHITE","WHITE"}; // 5
    if (H==6) String Element[]={"WHITE","WHITE","WHITE","WHITE","WHITE","WHITE","WHITE"}; // 6
    if (H==7) String Element[]={"WHITE","WHITE","WHITE","BLACK","BLACK","BLACK","BLACK"}; // 7
    if (H==8) String Element[]={"WHITE","WHITE","WHITE","WHITE","WHITE","WHITE","WHITE"}; // 8
    if (H==9) String Element[]={"WHITE","WHITE","WHITE","WHITE","BLACK","WHITE","WHITE"}; // 9

// "A"

// "B"
// "C"
// "D"
// "E"
// "F"
// "G"


my errors are in the “tft.fillxxxx” lines it appears that it does not like using a array to set the color that way.

Is there a fix for this or do I need to do something different?


What are all those Strings with the same name (hint) doing there?

the value in H sets up the 7 segment array of Element that way i will minimize redundant code


Do you realise that WHITE and “WHITE” are not even remotely related?

I tried removing the quotes and changing it from "String" to "unsigned"

This is the error message I receive:

Display_Test_ILI9341:142:39: error: 'Element' was not declared in this scope



exit status 1
'Segment' was not declared in this scope


if (H==0) String Element[]={"WHITE","WHITE","WHITE","WHITE","WHITE","WHITE","BLACK"}; // 0the variable declaration comes after an 'if' statement, and therefor goes out of scope the moment that conditional bit of code is complete (in this case by the end of the line where there is a ';' )
If you want to do it this way (which i do not recommend but it's up to you) then you should declare a 2 dimensional array of unsigned int (globally, const, and probably within PROGMEM), 1 dimension for the 7 segment representation (per character) and 1 for the elements of them. (WHITE, BLACK etc) so you declaration would be something like

const unsigned int digits[10][7] = { 
etc..                                                                       } };

rather wasteful since the information can be stored within a byte per character as you are using only black and white as colors.

Thanks Deva_Rishi!

I was able to get it working with your help!

Thank you so much