<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flash</title>
	<atom:link href="http://arduiniana.org/libraries/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://arduiniana.org</link>
	<description>Arduino software jewellery and wisdom by Mikal Hart</description>
	<lastBuildDate>Fri, 03 Sep 2010 07:40:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Antonio</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-4457</link>
		<dc:creator>Antonio</dc:creator>
		<pubDate>Fri, 03 Sep 2010 07:40:09 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-4457</guid>
		<description>Hi Mikal,
thanks for your reply.
Indeed wrapping the Flash library&#039;s header into the preprocessor &#039;#ifndef&#039; was one of my first moves but not the solution.
I think I&#039;ve found a workaround for the _FLASH_STRING. This is what I did:

//////////////    MyLibrary.h:

#ifndef _MyLibrary_H_
#define _MyLibrary_H_

#include &quot;Wprogram.h&quot;
#include &quot;Flash.h&quot;

//--Flash strings declaration
extern _FLASH_STRING CMD1;
extern _FLASH_STRING CMD2;
....
....
#endif

//////////////    MyLibrary.cpp

#include &quot;WProgram.h&quot;
#include &quot;Flash.h&quot;
#include &quot;MyLibrary.h&quot;



//--Flash strings definition
FLASH_STRING(CMD1,&quot;Command1_string\r&quot;);
FLASH_STRING(CMD2,&quot;Command1_string\r&quot;);
...
...

///////////////////////////////

So I realized that
-the compiler is accepting _FLASH_STRING as a type.
-the Flash strings are only declared in the .h and then defined in the .cpp (the compiler is now happier)
-the Flash strings are both visible in the scope of MyLibrary.cpp and in my sketch, after including MyLibrary.h.

I still have the feeling this is not the best solution....but, for the time being, is working.

The problems started again when I try to use _FLASH_STRING_ARRAY or _FLASH_ARRAY as types: no way I could get them work.
For the _FLASH_STRING_ARRAY I&#039;m now trying to use the PROGMEM type &#039;extern const prog_char** myStrArray&#039; in MyLibrary.h and then define it in MyLibrary.cpp with:  FLASH_STRING_ARRAY(myStrArray, PSTR(&quot;subStr1&quot;), PSTR(&quot;subStr2&quot;),...);

I still don&#039;t know if it&#039;s properly working, but at least the compiler does not complain.

Looking forward to your comments and/or suggestions.

Thanks in advance.

Antonio</description>
		<content:encoded><![CDATA[<p>Hi Mikal,<br />
thanks for your reply.<br />
Indeed wrapping the Flash library&#8217;s header into the preprocessor &#8216;#ifndef&#8217; was one of my first moves but not the solution.<br />
I think I&#8217;ve found a workaround for the _FLASH_STRING. This is what I did:</p>
<p>//////////////    MyLibrary.h:</p>
<p>#ifndef _MyLibrary_H_<br />
#define _MyLibrary_H_</p>
<p>#include &#8220;Wprogram.h&#8221;<br />
#include &#8220;Flash.h&#8221;</p>
<p>//&#8211;Flash strings declaration<br />
extern _FLASH_STRING CMD1;<br />
extern _FLASH_STRING CMD2;<br />
&#8230;.<br />
&#8230;.<br />
#endif</p>
<p>//////////////    MyLibrary.cpp</p>
<p>#include &#8220;WProgram.h&#8221;<br />
#include &#8220;Flash.h&#8221;<br />
#include &#8220;MyLibrary.h&#8221;</p>
<p>//&#8211;Flash strings definition<br />
FLASH_STRING(CMD1,&#8221;Command1_string\r&#8221;);<br />
FLASH_STRING(CMD2,&#8221;Command1_string\r&#8221;);<br />
&#8230;<br />
&#8230;</p>
<p>///////////////////////////////</p>
<p>So I realized that<br />
-the compiler is accepting _FLASH_STRING as a type.<br />
-the Flash strings are only declared in the .h and then defined in the .cpp (the compiler is now happier)<br />
-the Flash strings are both visible in the scope of MyLibrary.cpp and in my sketch, after including MyLibrary.h.</p>
<p>I still have the feeling this is not the best solution&#8230;.but, for the time being, is working.</p>
<p>The problems started again when I try to use _FLASH_STRING_ARRAY or _FLASH_ARRAY as types: no way I could get them work.<br />
For the _FLASH_STRING_ARRAY I&#8217;m now trying to use the PROGMEM type &#8216;extern const prog_char** myStrArray&#8217; in MyLibrary.h and then define it in MyLibrary.cpp with:  FLASH_STRING_ARRAY(myStrArray, PSTR(&#8220;subStr1&#8243;), PSTR(&#8220;subStr2&#8243;),&#8230;);</p>
<p>I still don&#8217;t know if it&#8217;s properly working, but at least the compiler does not complain.</p>
<p>Looking forward to your comments and/or suggestions.</p>
<p>Thanks in advance.</p>
<p>Antonio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikal</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-4437</link>
		<dc:creator>Mikal</dc:creator>
		<pubDate>Thu, 02 Sep 2010 15:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-4437</guid>
		<description>This is a superb question, Antonio, and one that I am interested to find the answer to as well.  The question basically is &quot;how can I include a library header from another library?&quot;.

If you modify the flash.h header so that it is safe for multiple inclusions, does that make it work?  Something like:

#ifndef __FLASH_H_INCLUDED__
#define __FLASH_H_INCLUDED__
[original flash.h text here]

#endif

Mikal</description>
		<content:encoded><![CDATA[<p>This is a superb question, Antonio, and one that I am interested to find the answer to as well.  The question basically is &#8220;how can I include a library header from another library?&#8221;.</p>
<p>If you modify the flash.h header so that it is safe for multiple inclusions, does that make it work?  Something like:</p>
<p>#ifndef __FLASH_H_INCLUDED__<br />
#define __FLASH_H_INCLUDED__<br />
[original flash.h text here]</p>
<p>#endif</p>
<p>Mikal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-4371</link>
		<dc:creator>Antonio</dc:creator>
		<pubDate>Tue, 31 Aug 2010 22:05:34 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-4371</guid>
		<description>Dear Mikal,
First of all: I subscribe to the list of the ones grateful for your libraries and for sharing them with us.

I used all of them with success in all my project.
Now, however, I would like to use them in a slight different scope: I would like to replace all my constant strings defined in the header file of my library, with strings stored in the flash memory of my Arduino (IDE ver. 18 + Arduino 2009 328, FYI).
I know I cannot include something like:

FLASH_STRING(CMD_ACTIVE_ON,&quot;HH P1 S1\r&quot;);

in the header file of my library, or I would get a multiple definition error from compiler (since I must include the header file both in the .pde sketch and in the .cpp of my library).
I could use the FLASH functions in the .pde sketch. But in this case I have the problem that the flash strings would not be accessible by the .cpp of my library (not in scope).  
If I&#039;m correct I think I should declare my flash strings in the header of my library and define them (calling the FLASH_STRING function) in the .cpp file of my library.
But I couldn&#039;t find a correct way to solve this despite all my attempts. 
Supposing that I could properly explain my problem, do you have any suggestion to solve it?
Thanks in advance for your attention.

Antonio</description>
		<content:encoded><![CDATA[<p>Dear Mikal,<br />
First of all: I subscribe to the list of the ones grateful for your libraries and for sharing them with us.</p>
<p>I used all of them with success in all my project.<br />
Now, however, I would like to use them in a slight different scope: I would like to replace all my constant strings defined in the header file of my library, with strings stored in the flash memory of my Arduino (IDE ver. 18 + Arduino 2009 328, FYI).<br />
I know I cannot include something like:</p>
<p>FLASH_STRING(CMD_ACTIVE_ON,&#8221;HH P1 S1\r&#8221;);</p>
<p>in the header file of my library, or I would get a multiple definition error from compiler (since I must include the header file both in the .pde sketch and in the .cpp of my library).<br />
I could use the FLASH functions in the .pde sketch. But in this case I have the problem that the flash strings would not be accessible by the .cpp of my library (not in scope).<br />
If I&#8217;m correct I think I should declare my flash strings in the header of my library and define them (calling the FLASH_STRING function) in the .cpp file of my library.<br />
But I couldn&#8217;t find a correct way to solve this despite all my attempts.<br />
Supposing that I could properly explain my problem, do you have any suggestion to solve it?<br />
Thanks in advance for your attention.</p>
<p>Antonio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mircha Emanuel D'Angelo</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-4046</link>
		<dc:creator>Mircha Emanuel D'Angelo</dc:creator>
		<pubDate>Fri, 20 Aug 2010 21:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-4046</guid>
		<description>AWESOME!!! You saved me! :)

Just a note: if I use the library Streaming.h and I declare Flash.h before Streaming.h there is an exception in compile time due to some conflicts. The conflicts are resolved if I declare Streaming.h before Flash.h.

THANKS for your work!!!
Mircha</description>
		<content:encoded><![CDATA[<p>AWESOME!!! You saved me! <img src='http://arduiniana.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Just a note: if I use the library Streaming.h and I declare Flash.h before Streaming.h there is an exception in compile time due to some conflicts. The conflicts are resolved if I declare Streaming.h before Flash.h.</p>
<p>THANKS for your work!!!<br />
Mircha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3964</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 16 Aug 2010 02:05:38 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3964</guid>
		<description>Mikal,

I am using Arduino 18 on a Duemilanove (ATMEGA328P).  

I found the same thing you did after I posted the last code segment.  Funny, I still don&#039;t get the right results.  Can you send me (email) the output you got?  I really appreciate the time you&#039;ve given this.  Thanks,

Mark</description>
		<content:encoded><![CDATA[<p>Mikal,</p>
<p>I am using Arduino 18 on a Duemilanove (ATMEGA328P).  </p>
<p>I found the same thing you did after I posted the last code segment.  Funny, I still don&#8217;t get the right results.  Can you send me (email) the output you got?  I really appreciate the time you&#8217;ve given this.  Thanks,</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikal</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3961</link>
		<dc:creator>Mikal</dc:creator>
		<pubDate>Sun, 15 Aug 2010 22:14:15 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3961</guid>
		<description>Mark, I ran this code in Arduino 0018, and it generated the correct results.  Or, to be perfectly accurate, I cleaned up one puzzling bit of your code:

&lt;pre&gt;// find the pressure element to start from
while ( altitudeTable[ index ][0] &gt; Pascals )
index–;

altitudeTable[ index ][1];

&lt;/pre&gt;

I&#039;m frankly surprised (and puzzled) that that compiles.  [Note: I checked in 0018 and it doesn&#039;t].  I changed it to:

&lt;pre&gt;// find the pressure element to start from
while ( altitudeTable[ index ][0] &gt; Pascals )
   index–-;
&lt;/pre&gt;

I don&#039;t see how that change fixed the problem though.  What version of the Arduino software are you using anyway?

Mikal</description>
		<content:encoded><![CDATA[<p>Mark, I ran this code in Arduino 0018, and it generated the correct results.  Or, to be perfectly accurate, I cleaned up one puzzling bit of your code:</p>
<pre>// find the pressure element to start from
while ( altitudeTable[ index ][0] &gt; Pascals )
index–;

altitudeTable[ index ][1];
</pre>
<p>I&#8217;m frankly surprised (and puzzled) that that compiles.  [Note: I checked in 0018 and it doesn't].  I changed it to:</p>
<pre>// find the pressure element to start from
while ( altitudeTable[ index ][0] &gt; Pascals )
   index–-;
</pre>
<p>I don&#8217;t see how that change fixed the problem though.  What version of the Arduino software are you using anyway?</p>
<p>Mikal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3955</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sun, 15 Aug 2010 14:19:44 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3955</guid>
		<description>Mikal,

I forgot to include the code I changed to get the results above.

float AltitudeFromPressure( float Pascals )
{
  
  int index = altitudeTable.rows() - 1;

  float slope = 0;
  float delta = 0;
  float pressure = 0; 
  float base = 0;
  
 // find the pressure element to start from
 while (  altitudeTable[ index ][0] &gt; Pascals )
   index--;
   
  altitudeTable[ index ][1];
  // get the values
 pressure = altitudeTable[ index ][0];
 base = altitudeTable[ index ][1];
 slope = altitudeTable[ index ][2];
 delta = Pascals - pressure;


 // return the altitude
 Serial.print(&quot;Pressure : &quot; );
 Serial.println(Pascals, 4);
 Serial.print(&quot;Table Pressure : &quot; );
 Serial.println(altitudeTable[ index ][0], 4);
 Serial.print(&quot;Base Altitude : &quot; );
 Serial.println(altitudeTable[ index ][1], 4);
 Serial.print(&quot;Slope : &quot; );
 Serial.println(altitudeTable[ index ][2], 4);
 Serial.print(&quot;Var Pressure : &quot; );
 Serial.println(pressure, 4);
 Serial.print(&quot;Var Altitude : &quot; );
 Serial.println(base, 4);
 Serial.print(&quot;Var Slope : &quot; );
 Serial.println(slope, 4);
 Serial.print(&quot;Static Math (This is the correct value) : &quot; );
 Serial.println( ((float) -83.8107 * ((float) 100.8096 - (float) 100.1389)) + (float) 105.66);
 Serial.print(&quot;Calc (This is the bad value) : &quot; );
 return (slope * delta ) + base;
 //return ( altitudeTable[ index + 1 ] + (( Pascals - altitudeTable[ index ]) * altitudeTable[ index + 2 ]));

}
  Thanks,

Mark</description>
		<content:encoded><![CDATA[<p>Mikal,</p>
<p>I forgot to include the code I changed to get the results above.</p>
<p>float AltitudeFromPressure( float Pascals )<br />
{</p>
<p>  int index = altitudeTable.rows() &#8211; 1;</p>
<p>  float slope = 0;<br />
  float delta = 0;<br />
  float pressure = 0;<br />
  float base = 0;</p>
<p> // find the pressure element to start from<br />
 while (  altitudeTable[ index ][0] &gt; Pascals )<br />
   index&#8211;;</p>
<p>  altitudeTable[ index ][1];<br />
  // get the values<br />
 pressure = altitudeTable[ index ][0];<br />
 base = altitudeTable[ index ][1];<br />
 slope = altitudeTable[ index ][2];<br />
 delta = Pascals &#8211; pressure;</p>
<p> // return the altitude<br />
 Serial.print(&#8220;Pressure : &#8221; );<br />
 Serial.println(Pascals, 4);<br />
 Serial.print(&#8220;Table Pressure : &#8221; );<br />
 Serial.println(altitudeTable[ index ][0], 4);<br />
 Serial.print(&#8220;Base Altitude : &#8221; );<br />
 Serial.println(altitudeTable[ index ][1], 4);<br />
 Serial.print(&#8220;Slope : &#8221; );<br />
 Serial.println(altitudeTable[ index ][2], 4);<br />
 Serial.print(&#8220;Var Pressure : &#8221; );<br />
 Serial.println(pressure, 4);<br />
 Serial.print(&#8220;Var Altitude : &#8221; );<br />
 Serial.println(base, 4);<br />
 Serial.print(&#8220;Var Slope : &#8221; );<br />
 Serial.println(slope, 4);<br />
 Serial.print(&#8220;Static Math (This is the correct value) : &#8221; );<br />
 Serial.println( ((float) -83.8107 * ((float) 100.8096 &#8211; (float) 100.1389)) + (float) 105.66);<br />
 Serial.print(&#8220;Calc (This is the bad value) : &#8221; );<br />
 return (slope * delta ) + base;<br />
 //return ( altitudeTable[ index + 1 ] + (( Pascals &#8211; altitudeTable[ index ]) * altitudeTable[ index + 2 ]));</p>
<p>}<br />
  Thanks,</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3954</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sun, 15 Aug 2010 14:17:43 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3954</guid>
		<description>Mikal,

Here is the output I get when i run it:

Pressure : 100.8096
Table Pressure : 100.1389
Base Altitude : 105.6600
Slope : -83.8107
Var Pressure : 100.1389
Var Altitude : 100.1389
Var Slope : 100.1389
Static Math (This is the correct value) : 49.45
Calc (This is the bad value) : 167.30

It looks like the values read from the table are returned correctly (Table Pressure, Base Altitude and slope) but the variables all contain the same value (Var Pressure, Var Altitude and Var Slope.)

Thanks,

Mark</description>
		<content:encoded><![CDATA[<p>Mikal,</p>
<p>Here is the output I get when i run it:</p>
<p>Pressure : 100.8096<br />
Table Pressure : 100.1389<br />
Base Altitude : 105.6600<br />
Slope : -83.8107<br />
Var Pressure : 100.1389<br />
Var Altitude : 100.1389<br />
Var Slope : 100.1389<br />
Static Math (This is the correct value) : 49.45<br />
Calc (This is the bad value) : 167.30</p>
<p>It looks like the values read from the table are returned correctly (Table Pressure, Base Altitude and slope) but the variables all contain the same value (Var Pressure, Var Altitude and Var Slope.)</p>
<p>Thanks,</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikal</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3946</link>
		<dc:creator>Mikal</dc:creator>
		<pubDate>Sat, 14 Aug 2010 23:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3946</guid>
		<description>Mark, sorry I can&#039;t see anything wrong here.  What happens when you print the values of slope, delta, and base?

Mikal</description>
		<content:encoded><![CDATA[<p>Mark, sorry I can&#8217;t see anything wrong here.  What happens when you print the values of slope, delta, and base?</p>
<p>Mikal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikal</title>
		<link>http://arduiniana.org/libraries/flash/comment-page-1/#comment-3941</link>
		<dc:creator>Mikal</dc:creator>
		<pubDate>Sat, 14 Aug 2010 23:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://sundial.org/arduino/?page_id=221#comment-3941</guid>
		<description>Terry, I agree with your suggestion that short strings are not worth storing in flash.  In my own projects I usually keep strings of 2 or fewer characters as &quot;normal&quot; strings.  A &quot;_FLASH_STRING&quot; object only takes up 2 bytes of RAM, but then there is the overhead of loading the string from flash every time you use it.

Thanks,

Mikal</description>
		<content:encoded><![CDATA[<p>Terry, I agree with your suggestion that short strings are not worth storing in flash.  In my own projects I usually keep strings of 2 or fewer characters as &#8220;normal&#8221; strings.  A &#8220;_FLASH_STRING&#8221; object only takes up 2 bytes of RAM, but then there is the overhead of loading the string from flash every time you use it.</p>
<p>Thanks,</p>
<p>Mikal</p>
]]></content:encoded>
	</item>
</channel>
</rss>
