Go Down

Topic: Read big array from header file (Read 1 time) previous topic - next topic

gvi70000

Hello,
How can i read a big array (10k) from a header file?
I have an image stored in the h file and all the posts that i found till now are referring to small array stored in flash

PaulS

Quote
How can i read a big array (10k) from a header file?

Header files get #included into the sketch. Obviously, that header file can not be included, so you have a problem.

What is the data in the array for?

gvi70000

#2
Feb 28, 2011, 08:48 pm Last Edit: Feb 28, 2011, 08:51 pm by gvi70000 Reason: 1
is an 16 bits bmp 80x42 pixels image stored as an array
i need to read each pixel and put it on the screen
data looks like this

const unsigned short name[] =
{
   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
   0x0000,0x0022,0x0066,0x00AA,0x00EF,0x0154,0x0176,0x0177,
   0x0177,0x0177,0x0177,0x0178,0x0176,0x0111,0x00CD,0x0088,
   0x0044,0x0022,0x0000,0x0000,0x0000,0x0000,0x0000,0x0020,
       ........................................................................

PaulS

What kind of 80 x 42, 16 bit screen are you putting this data on? What does this static image represent?

gvi70000

the lcd is LS020 and hardware is similar to s65 shield
the image is a small logo that i want to display on the screen

AlphaBeta

10k !

What kind of an Arduino monstrosity are you using?

gvi70000

#6
Feb 28, 2011, 09:37 pm Last Edit: Feb 28, 2011, 09:41 pm by gvi70000 Reason: 1
well, i'm using an duemilanove transformed in uno
and i have left 11k of free memory...so i decided to put a picture in the free space
some pictures of this can be founded here http://grozeaion.com/electronics/high-speed-photography.html

AlphaBeta

The Uno has 2k of RAM, I think you'll need to use PROGMEM for this array then. :)

gvi70000

#8
Mar 01, 2011, 04:09 pm Last Edit: Mar 01, 2011, 04:11 pm by gvi70000 Reason: 1
But how can i use PROGMEM on an 8-10k array?

It it is helpful i can upload or send by e-mail the h file

gvi70000

This is a new problem that beats me
Serial.println((int)name[2000]);// This work for any any value from the array
unsigned int p=0; //position in name
for(byte i=0; i<79; i++)
{
  for(byte j=0; j<41; j++)
  {
    Serial.println((int)name[p]);// this line doesn't show anything
    p++;
  }
}

What i'm doing wrong here?

PaulS


gvi70000

const uint16_t name[] = //78*40=3120 items in array
{
   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
   0x0000,0x0022,0x0066,0x00AA,0x00EF,0x0154,0x0176,0x0177,
   0x0177,0x0177,0x0177,0x0178,0x0176,0x0111,0x00CD,0x0088,
   0x0044,0x0022,0x0000,0x0000,0x0000,0x0000,0x0000,0x0020,
   0x0105,0x02CD,0x055A,0x061E,0x065F,0x067F,0x067F,0x067F,
   0x065F,0x04B7,0x0146,0x0000,0x0000,0x0000,0x0000,0x0000,
   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
   0x0021,0x0167,0x0371,0x057A,0x05DD,0x063E,0x067F,0x065F,
   0x061E,0x03B2,0x00A3,0x0000,0x2040,0x58A0,0xA940,0xB960,
   0xC980,0xC980,0xC980,0xC980,0xC180,0x8900,0x0000,0x0000,
   0x0000,0x0000,0x0000,0x0000,0x0000,0x0022,0x0089,0x0110,
   0x0155,0x0155,0x0111,0x00CC,0x00AA,0x0088,0x0087,0x0088,

Senso

You have an 2K RAM, putting more than say 1,7Kb of data in the ram will likely kill your arduino programm because the stack will be corrupted by data and it will just have an erratic behaviour, as said, google for avr progmem and learn how to use it, that will move the data from the ram to the flash memory.

gvi70000

Got it working
my stupid assumption was that using PROGMEM the data will be stored in sram
sorry for your time wasted with me

Magician

http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#ga75acaba9e781937468d0911423bc0c35

Go Up