Skip to content

Commit 2d3fb6c

Browse files
committed
Allow the code to compile and run on MBED (APOLLO3 v2)
1 parent 1775ff1 commit 2d3fb6c

File tree

7 files changed

+42
-21
lines changed

7 files changed

+42
-21
lines changed

src/SFE_MicroOLED.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ You should have received a copy of the GNU General Public License
3434
along with this program. If not, see <http://www.gnu.org/licenses/>.
3535
******************************************************************************/
3636
#include <Arduino.h>
37-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
38-
#include <avr/pgmspace.h>
37+
#if defined(ARDUINO_ARCH_MBED)
38+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
39+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
40+
#include <avr/pgmspace.h>
3941
#else
40-
#include <pgmspace.h>
42+
#include <pgmspace.h>
4143
#endif
4244
#include <SFE_MicroOLED.h>
4345

src/SFE_MicroOLED.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4444
#include <Wire.h> // Needed for TwoWire - even if we are using SPI or Parallel
4545
#include <SPI.h> // Needed for SPIClass - even if we are using I2C or Parallel
4646

47-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
48-
#include <avr/pgmspace.h>
47+
#if defined(ARDUINO_ARCH_MBED)
48+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
49+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
50+
#include <avr/pgmspace.h>
4951
#else
50-
#include <pgmspace.h>
52+
#include <pgmspace.h>
5153
#endif
5254

5355
#define I2C_ADDRESS_SA0_0 0b0111100

src/util/7segment.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ July 27, 2015
2525
#ifndef FONT7SEGMENT_H
2626
#define FONT7SEGMENT_H
2727

28-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
28+
#if defined(ARDUINO_ARCH_MBED)
29+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
30+
static const unsigned char sevensegment [] = {
31+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
2932
#include <avr/pgmspace.h>
33+
static const unsigned char sevensegment [] PROGMEM = {
3034
#else
3135
#include <pgmspace.h>
36+
static const unsigned char sevensegment [] PROGMEM = {
3237
#endif
33-
34-
static const unsigned char sevensegment [] PROGMEM = {
3538
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
3639
10,16,46,13,1,30,
3740
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

src/util/font5x7.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ July 27, 2015
2525
#ifndef FONT5X7_H
2626
#define FONT5X7_H
2727

28-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
28+
// Standard ASCII 5x7 font
29+
#if defined(ARDUINO_ARCH_MBED)
30+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
31+
static const unsigned char font5x7[] = {
32+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
2933
#include <avr/pgmspace.h>
34+
static const unsigned char font5x7[] PROGMEM = {
3035
#else
3136
#include <pgmspace.h>
37+
static const unsigned char font5x7[] PROGMEM = {
3238
#endif
33-
34-
// Standard ASCII 5x7 font
35-
static const unsigned char font5x7[] PROGMEM = {
3639
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
3740
5,8,0,255,12,75,
3841
0x00, 0x00, 0x00, 0x00, 0x00,

src/util/font8x16.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ July 27, 2015
2424
#ifndef FONT8X16_H
2525
#define FONT8X16_H
2626

27-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
27+
#if defined(ARDUINO_ARCH_MBED)
28+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
29+
static const unsigned char font8x16[] = {
30+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
2831
#include <avr/pgmspace.h>
32+
static const unsigned char font8x16[] PROGMEM = {
2933
#else
3034
#include <pgmspace.h>
35+
static const unsigned char font8x16[] PROGMEM = {
3136
#endif
32-
33-
static const unsigned char font8x16[] PROGMEM = {
3437
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
3538
8,16,32,96,2,56,
3639
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,

src/util/fontlargeletter31x48.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ August 13, 2015
1919

2020
#ifndef FONTLARGELETTER31X48_H
2121
#define FONTLARGELETTER31X48_H
22-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
22+
23+
#if defined(ARDUINO_ARCH_MBED)
24+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
25+
static const unsigned char fontlargeletter31x48 [] = {
26+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
2327
#include <avr/pgmspace.h>
28+
static const unsigned char fontlargeletter31x48 [] PROGMEM = {
2429
#else
2530
#include <pgmspace.h>
31+
static const unsigned char fontlargeletter31x48 [] PROGMEM = {
2632
#endif
27-
static const unsigned char fontlargeletter31x48 [] PROGMEM = {
2833
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
2934
31,48,65,58,0,62,
3035
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xF8, 0xF8, 0xF8,

src/util/fontlargenumber.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ July 27, 2015
2525
#ifndef FONTLARGENUMBER_H
2626
#define FONTLARGENUMBER_H
2727

28-
#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
28+
#if defined(ARDUINO_ARCH_MBED)
29+
// ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h
30+
static const unsigned char fontlargenumber[] = {
31+
#elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)
2932
#include <avr/pgmspace.h>
33+
static const unsigned char fontlargenumber[] PROGMEM = {
3034
#else
3135
#include <pgmspace.h>
36+
static const unsigned char fontlargenumber[] PROGMEM = {
3237
#endif
33-
34-
static const unsigned char fontlargenumber[] PROGMEM = {
3538
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
3639
12,48,48,11,1,32,
3740
0x00, 0xC0, 0xF8, 0x7C, 0x3E, 0x3E, 0xFC, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0,

0 commit comments

Comments
 (0)