Sketchsize - Problem

Hi,

i'm using a Mega 2560. My Sketch is as big as 101.078 Bytes and the Mega does not run the program, although it is uploaded correctly. There are some pictures in form of extern c. files inside the sketch. When i remove one of them so that my sketch is around 90.000 Bytes everythink works fine. But why? I thought i have 258.048 Bytes of space?

What do you mean by 'does not run program' ? Can you load it to arduino? What compiler says?

Maybe you don't have enough RAM. Try to put this function before and after you load your picture. It shows the remaining number of bytes of RAM.

int free_ram(){                                                      //return byte of free ram, usefull to debug
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

To use it do this :

  Serial.println(free_ram());

Make shure you have started Serial port with

Serial.begin(9600)

or whatever baudrate you want.

If you use a lot of Serial.print("string") or lcd.print("string"), you can use the F() macro to store the strings you want to display in the flash instead of the ram. This macro only work with strings, if you want to store other types of data in the flash, use progmem.

Hope that helps.

There are some pictures in form of extern c. files inside the sketch.

how are these images coded?
are they compressed?
==> By applying e.g. run length compression you could reduce the size of the code

Do you copy the images to some graphical screen?
How big is the buffer in that copy process?