From 6aa8cbe7aed3aea647ac9f7b892c5d40088b83d3 Mon Sep 17 00:00:00 2001 From: stonegray Date: Thu, 27 Oct 2016 18:52:00 -0400 Subject: [PATCH 1/2] Add support for more devices (ESP8266, ARM, etc) Precompiler check for devices with pgmspace support, fallback to plain old C on unknown or unsupported devices. --- Base64.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Base64.cpp b/Base64.cpp index 8f59178..a878500 100644 --- a/Base64.cpp +++ b/Base64.cpp @@ -1,5 +1,18 @@ #include "Base64.h" -#include + +#if defined( __AVR__ ) + #include +#elif defined( ESP8266 ) // ESP32 should work here too + #include +#elif defined( __arm__ ) + #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) + #define PROGMEM const +#else + #pragma message("Unknown Architecture. Using compatibility fallback for pgmspace") + #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) + #define PROGMEM const +#endif + const char PROGMEM b64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; From 1501d1b246981898f35852ff2c9198266fb2e30d Mon Sep 17 00:00:00 2001 From: stonegray Date: Thu, 27 Oct 2016 18:55:45 -0400 Subject: [PATCH 2/2] Fix formatting --- Base64.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Base64.cpp b/Base64.cpp index a878500..0f6be97 100644 --- a/Base64.cpp +++ b/Base64.cpp @@ -1,14 +1,14 @@ #include "Base64.h" #if defined( __AVR__ ) - #include + #include #elif defined( ESP8266 ) // ESP32 should work here too - #include + #include #elif defined( __arm__ ) #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) #define PROGMEM const #else - #pragma message("Unknown Architecture. Using compatibility fallback for pgmspace") + #pragma message("Unknown Architecture. Using compatibility fallback for pgmspace") #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) #define PROGMEM const #endif