Skip to content

Instantly share code, notes, and snippets.

@stonegray
Last active December 29, 2016 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonegray/348e4855a39074daa9a5540edda78984 to your computer and use it in GitHub Desktop.
Save stonegray/348e4855a39074daa9a5540edda78984 to your computer and use it in GitHub Desktop.
Arduino F-Macro / PROGMEM Fix
// Arduino compatibility snippet to use with other platforms.
// Doesn't work (or not optimized) on your platform? Email me!
// https://gist.github.com/stonegray/348e4855a39074daa9a5540edda78984
#if defined( __AVR__ )
#include <avr/pgmspace.h>
#elif defined( ESP8266 )
#include <pgmspace.h>
#define F(x) (x)
#elif defined( __arm__ )
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define F(x) (x)
#define PROGMEM const
#else
#pragma message("Unknown Architecture. Using fallback for pgmspace")
#define F(x) (x)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define PROGMEM const
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment