The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunioArduono IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some Arduono IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread. In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that could can compile, as the Flash.h
is not included.
Oh and btwEDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, most recent avrsince avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the __flashPROGMEM
pragma that doesmacro, simplifying the same thingwhole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as PROGMEMshown is this thread . In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that could can compile, as the Flash.h
is not included.
Oh and btw, most recent avr-gcc introduced the __flash
pragma that does the same thing as PROGMEM
The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:
#define FLASH_ARRAY(type, name, values...) \
static const type name##_flash[] PROGMEM = { values }; \
_FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type));
which is an instance of the _FLASH_ARRAY
class defined in that same file, which is a facility to access PROGMEM/Flash memory.
Basically, it's a lot of boilerplate for what already does the PSTR()
macro amongst other from pgmspace.h
. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.
BTW, except for some ardunio IDE magic, I don't think that can compile, as the Flash.h
is not included.
EDIT:
To make another point against the FLASH_TABLE
/FLASH_ARRAY
boilerplate/overhead, since avc-gcc 4.8 has been introduced the __flash
qualifier which is a replacement for the PROGMEM
macro, simplifying the whole stuff:
// to use string literals without having to cast
#define FSTR(X) ((const __flash char[]) { X })
// create string pstr in the .progmem.data address space
const __flash char* pstr = FSTR ("foo");
and no more use of the pgm_read_*()
functions, you can now access the content of the flash memory using *pstr
, as shown is this thread . In case you want to keep a code compatible with older version of avr-gcc, here's a post that offers macros to deal with both systems.