Go Down

Topic: progmem P macro question (Read 838 times) previous topic - next topic

zoomkat

Is there any advantage to storing data in program memory like below as opposed to just leaving it in the sketch code without trying to specifically storing it?

Code: [Select]

   /* store the HTML in program memory using the P macro */   
P(message) = "<html><head><title>Webduino Image Example</title>"
"<body>"
"<h2>LED Image</h2>"
"<img src='led.png' width=256 height=256>"
"</body></html>";

server.printP(message);
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

westfw

Yeah.  There's about 16 times more program memory than there is ram.  if you start putting large strings, like html webpages, in ordinary RAM memory, you run out pretty quick.

zoomkat

This looks to be a handy way of keeping large blocks of reusable html as a variable. The main question is can this P macro be used to store data once the code is running on the arduino. Recently somebody made the statement that program memory is read only apparently when the arduino program is running.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

westfw

Quote
program memory is read only apparently when the sketch is running.

Yes, that's correct.  You have to handle the constant data in program memory and the variable data in RAM separately.

Go Up