Using "avr/pgmspace.h" with mbed boards

I am trying to use my e-paper display with my arduino nano 33 ble sense and all of the library's I can find online use "avr/pgmspace.h" somewhere within them. I was wondering if there was a library which accomplished the same thing but that worked with mbed boards.

FYI the specific keyword which seems to be shared across all of the examples is PROGEM.

I think you will have to pick a library and edit it to remove the use of PROGMEM. That should not be hard. You could use the preprocessor to include replacement macros for any pgmspace functions used.

#ifdef ARDUINO_ARCH_AVR
#include <avr/pgmspace.h>
#else
#define PROGMEM
#define pgm_read_byte_near(x) (*(uint8_t *)(x))  // Treat the argument as a byte pointer
#define pgm_read_word_near(x) (*(uint16_t *)(x))  // Treat the argument as a word pointer
#endif

johnwasser:
You could use the preprocessor to include replacement macros for any pgmspace functions used.

You don't have to write these replacements, they are already included in the ArduinoCore-mbed and ArduinoCore-API: ArduinoCore-API/pgmspace.h at fdccb197a72c7168bf7308700dbf310b929c1735 · arduino/ArduinoCore-API · GitHub

You can fix the compilation errors about the missing header by replacing it by something like this: ArduinoCore-API/String.h at fdccb197a72c7168bf7308700dbf310b929c1735 · arduino/ArduinoCore-API · GitHub

#if defined(__AVR__)
#include "avr/pgmspace.h"
#else
#include "deprecated-avr-comp/avr/pgmspace.h"
#endif

Pieter

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.