Problem with array...

Hello!

I am trying to use an array as base to build a text which will be displayed on a 8x8 matrix.

byte a[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};    
byte b[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};  
byte c[8]={0x00,0x7c,0x40,0x40,0x40,0x7c,0x00,0x00};  
..
..
..

now.. instead of doing loops for each character I would like to put the displayed text inside another array, like this.

char text[7]={'a','r','d','u','i','n','o'};

how can I do the loop like this:

text[1][1] = 0x7c
text[2][3] = 0x44

I hope you know what I mean...

Thanks for any help!

-andreas

Do you mean like

char text[4][7]={
    {'a','r','d','u','i','n','o'},
    {'b','a','r','d','a','l','i'},
    {'c','a','r','d','a','l','i'},
    {'y','a','d', 'd','a','l','i'},
};

?

nope not really...

array#2 should trigger array#1

text[1] = "a";
and this "a" should be
a[2] = 0x7c;

You mean an array of pointers as a lookup table?

byte a[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};    
byte b[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};  
..
..
byte* chargen[] = {a, b...};
..
..

ehrmm... i should be more precise (my english is not the best since I am a native german speaker) :wink:

more like this:

byte a[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};    
byte b[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};  
byte c[8]={0x00,0x7c,0x40,0x40,0x40,0x7c,0x00,0x00}; 
char text[] = {"a","b","c"};

loop pos[1-3] {
 loop char[1-8] {
  display text[pos][char]
 }
}

I hope it's clear now.. :wink:

-andreas

byte a[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};
byte b[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};
..
..
byte* chargen[] = {a, b...};

char text [] = {'a', 'b', 'c'};

for (int i = 0; i < sizeof (text); i++) {
  byte* charArray = chargen [text [i] - 'a'];
  for (int j = 0; j < 8; j++) {
    byte pattern = charArray [j];
    // send pattern to LCD
  }
}

Groove... you're a genious! You saved my evening!

Big Up from Switzerland!

-andreas

Or you could just have it:

byte chargen [][8] = {
{0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00},
{0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00},
....
};

char text [] = {'a', 'b', 'c'};

for (int i = 0; i < sizeof (text); i++) {
  for (int j = 0; j < 8; j++) {
    byte pattern = chargen [text[i] - 'a'] [j];
    // send pattern to LCD
  }
}

or any number of variations!

have fun, enjoy!