I have a lot of const PROGMEM char* variablename = “ABC”;
and like to put that in a separte file.
so I created a static.h and a static.cpp
I did #include <pgmspace.h>in the cpp file.
But different versions produces errors.
can anybody give me an example
for the .h and the .ccp file
I suspect that in your static.h file you have defined the variables as PROGMEM but you didn’t #include <avr/pgmspace.h> in the header file? Note, it’s avr/pgmspace.h by the way.
#include "Arduino.h"
#include "static.h"
void setup() {
Serial.begin(9600);
// Read one unsigned 16 bit int from PROGMEM
// into a local uint16_t and print it to Serial.
// Because PROGMEM expects pointers, we need the
// address of myInt, not myInt itself. beware!
uint16_t showMyInt;
showMyInt = pgm_read_word_near(&myInt);
Serial.println(showMyInt);
Serial.println();
// Read 'n' uint16_t variables from an int array. The array is
// already a pointer, so no need for the address of the array.
for (uint8_t x = 0; x < (sizeof(intArray)/sizeof(uint16_t)); x++) {
showMyInt = pgm_read_word_near(intArray + x);
Serial.println(showMyInt);
}
Serial.println();
// Read 'n' bytes from PROGMEM and send to Serial.
char myAbc;
for (uint8_t x = 0; x < strlen(abc); x++) {
myAbc = pgm_read_byte_near(abc + x);
Serial.print(myAbc);
}
Serial.println();
}
void loop() {
}