Pages: [1]   Go Down
Author Topic: Read big array from header file  (Read 1164 times)
0 Members and 1 Guest are viewing this topic.
Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49258
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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,
       ........................................................................
« Last Edit: February 28, 2011, 02:51:44 pm by gvi70000 » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49258
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

10k !

What kind of an Arduino monstrosity are you using?
Logged

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 28, 2011, 03:41:50 pm by gvi70000 » Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: March 01, 2011, 10:11:57 am by gvi70000 » Logged

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49258
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What size is name? What type?
Logged

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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,
Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Brebu
Offline Offline
Sr. Member
****
Karma: 1
Posts: 262
New to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2590
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: