Closed GoogleCodeExporter closed 9 years ago
Rather than adding functions with different names to the Serial class, I'd
rather do this with a wrapper class for PROGMEM strings / array. For example,
something along the lines of: http://arduiniana.org/libraries/flash/
Original comment by dmel...@gmail.com
on 13 Sep 2010 at 3:47
A wrapper class is not necessary. I have working
void print(prog_char *flashMemStr);
void println(prog_char *flashMemStr);
These are the primary ones needed.
Do you feel that the rest of the data types should be implemented as well?
Mark
Original comment by mark.l.s...@gmail.com
on 13 Sep 2010 at 7:12
That's great. How does it get distinguished from RAM strings? Do you have a
patch?
Other data types probably aren't necessary for now.
Original comment by dmel...@gmail.com
on 13 Sep 2010 at 8:32
At first it was working great, but more testing showed that it did get
confused. I am working on it.
I was expecting to use the _P because that's what strcpy and strcat use.
Mark
Original comment by mark.l.s...@gmail.com
on 13 Sep 2010 at 11:31
We've added the F("string") wrapper to the Arduino 1.0 in development
(new-extension branch on GitHub) that allows for printing of strings from Flash
memory.
Original comment by dmel...@gmail.com
on 24 May 2011 at 5:32
Original comment by dmel...@gmail.com
on 4 Jun 2011 at 2:08
Using android 1.0 I am unable to compile lines using the F() macro. I am using
avr-gcc 4.5.1 on FreeBSD 7.0
/////-- Sample code --
FLASH_STRING(big_string, "The quick brown fox\n"); // Compiles
void setup()
{
Serial.begin(115200); //
Serial << big_string; // Compiles
Serial << F("jumped over \n"); // Does NOT Compile
Serial << "the lazy sleeping dogs"; // Compiles
Serial.print (F("It is so")); // Does NOT Compile
}
////////The pre-processed output is shown below
static const char big_string_flash[] __attribute__((__progmem__)) = "The quick
brown fox\n"; _FLASH_STRING big_string(big_string_flash);;
void setup()
{
Serial.begin(115200);
Serial << big_string;
Serial<< (reinterpret_cast<__FlashStringHelper *>((__extension__({static const char __c[] __attribute__((__progmem__)) = ("jumped over \n"); &__c[0];}))));
Serial << "the sleeping dogs";
Serial.print ((reinterpret_cast<__FlashStringHelper *>((__extension__({static const char __c[] __attribute__((__progmem__)) = ("It is so"); &__c[0];})))));
}
////// Compiler error
avr-gcc tst.cpp -mmcu=atmega328p -DF_CPU=16000000UL -Os -w -Wl,--gc-sections
-ffunction-sections -fdata-sections -felide-constructors -std=c++0x
-DARDUINO=100 -I /home/rr/code/arduino//include/arduino/ -c -o tst.o
tst.cpp: In function 'void setup()':
tst.cpp:9:14: error: reinterpret_cast from type 'const char*' to type
'__FlashStringHelper*' casts away qualifiers
tst.cpp:11:19: error: reinterpret_cast from type 'const char*' to type
'__FlashStringHelper*' casts away qualifiers
Original comment by r.rajam...@gmail.com
on 8 Mar 2012 at 11:02
Sorry I meant to say arduino 1.0 and not android!
Original comment by r.rajam...@gmail.com
on 8 Mar 2012 at 11:03
Original issue reported on code.google.com by
mark.l.s...@gmail.com
on 12 Sep 2010 at 3:13