large array compiler error - Trying to load image into Flash

All,

I am trying to load Flash of Mega 2560 (with 3.2 inch LCD) with a roughly 320x213 image. I try the following segments, and get

sketch_dec16a:11: error: size of array 'myInts' is too large
sketch_dec16a:13: error: size of array 'myInts2' is too large

Board is set correctly in Arduino Sketch. if I move the array size to apps 16000, it compiles and works. Looking for a way to have a few images sent in the executable. (no flash card right now). If I move the size down, everything compiles and downloads just fine. However, it doesn't work if I break it up into 16k chunks to get to the 68k (for the image size)

Suggestions?

#include <UTFT.h>
#include <avr/pgmspace.h>
#include "Arduino.h"

#define arraysize 17000

prog_uint16_t myInts[320][213] PROGMEM;

prog_uint16_t myInts2[arraysize] PROGMEM;

I suspect the Mega uses 16 bit pointer types which cannot address more than 64KB,
BTW your arrays are of 16bit ints, not chars, you are asking for 136kB, not 68kB

16 bits per pixel is quite extravagant . Is it a colour display, and if so what colour depth does your image need to have?

I just used the image converter on http://www.henningkarlsen.com/

If 64k, I should be able to go to 320 x 100, right ? (16 bit) It is bombing after roughly 155x103.
I don't need 16 bit depth. Just trying to put a few images on the display using memory.
Better converter?

#define arraysize 32000
prog_uint8_t myInts2[arraysize] PROGMEM;
is the max that will compile at 8 bit.

Thank you,

Peter

Array indices limited to int16 isn't unlikely on an 8 bit processor with 8K of SRAM. Suspect
it needs to be broken up to be stored.

Apparently there are two separate limits:

  1. The index of arrays is defined to be a signed int, so no array can have more than 32768 things in it.
  2. The total size of the array cannot exceed 64k bytes.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=58517

drewesp:
All,

I am trying to load Flash of Mega 2560 (with 3.2 inch LCD) with a roughly 320x213 image. I try the following segments, and get

Storing a bitmap should require 8 bit variables, like this:

static const uint8_t bitmap[] PROGMEM = {
        0x00, 0xff, 0x00, 0xff, etc........ // bitmap data
};

Using 16 bits is a waste of space.

A 320 by 213 array is 68160 bytes (a bit larger than 64K). The Mega uses a 16 bit pointer for PROGMEM, so it won't be able to address the entire array.

Break it into two bitmaps, then access each one for 1/2 of the image bitmap.

If all your data takes up more than 64K of flash, you may need to use pgm_read_byte_far() to get at them.

Good luck.

westfw:
Apparently there are two separate limits:
1) The index of arrays is defined to be a signed int, so no array can have more than 32768 things in it.
2) The total size of the array cannot exceed 64k bytes.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=58517

I've placed around 50K chunks of data in flash and was able to sequentially access all of them (which it seems I should not be able to if the pointer is SIGNED).

I used static const uint8_t bitmap[] PROGMEM = { ....~50 k of data .... };

and then pgm_read_byte (bitmap + x); where "x" was a uint16_t and it worked fine.

Strange......

Salve a tutti,
non sono riuscito a capire come caricare un'immagine sul display TFT touchscreen,
Devo utilizzare la seguente libreria:
prog_uint16_?

Fatemi sapere grazie

F.N.

Krupski:
I've placed around 50K chunks of data in flash and was able to sequentially access all of them (which it seems I should not be able to if the pointer is SIGNED).

I used static const uint8_t bitmap[] PROGMEM = { ....~50 k of data .... };

Not using Arduino and GCC you didn't. It has a maximum of 32768 bytes, not elements per addressable object regardless of what those AVRFreaks think, try and declare these arrays bigger:

char a[ 32767 ];
short b[ 16383 ];
int c[ 16383 ];
long d[ 8191 ];
long long e[ 4095 ];
float f[ 8191 ];
double g[ 8191 ];

http://arduino.land/FAQ/content/6/7/en/what-is-the-maximum-number-of-elements-an-array-can-have.html