Pages: [1]   Go Down
Author Topic: progmem P macro question  (Read 583 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8915
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
   /* 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);
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6372
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8915
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6372
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: