Last active
December 29, 2016 19:54
-
-
Save stonegray/348e4855a39074daa9a5540edda78984 to your computer and use it in GitHub Desktop.
Arduino F-Macro / PROGMEM Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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