Freetronics FTOLED library

Status
Not open for further replies.

aijii

Member
Hi there,

trying to port over some code from an MEGA2560 to Teensy 3.0.

It makes use of the Freetronics FTOLED library.

I come unstuck when I try to include this library:

Code:
C:\Program Files (x86)\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=48000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX128__ -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3 -IC:\Program Files (x86)\Arduino\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\SD -IC:\Users\adrian\Documents\Arduino\libraries\FTOLED C:\Users\adrian\AppData\Local\Temp\build5676235364811397403.tmp\EchoBoth.cpp -o C:\Users\adrian\AppData\Local\Temp\build5676235364811397403.tmp\EchoBoth.cpp.o 
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:10:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:17:0: warning: "memcpy_P" redefined [enabled by default]
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WProgram.h:11:0,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:15,
                 from EchoBoth.pde:8:
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/avr/pgmspace.h:22:0: note: this is the location of the previous definition
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:10:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:21:0: warning: "F" redefined [enabled by default]
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Print.h:37:0,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Stream.h:24,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/HardwareSerial.h:87,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WProgram.h:16,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:15,
                 from EchoBoth.pde:8:
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WString.h:41:0: note: this is the location of the previous definition
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:10:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected unqualified-id before 'const'
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected ')' before 'const'
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected ')' before 'const'

The progmem_compat.h file is as follows:

Code:
/*
 * A header file designed to provide PROGMEM compatible (no-op) macros for
 * Arduino Due or other non-AVR based boards.
 *
 * This allows code written to use PROGMEM on AVRs to transparently run on
 * other platforms
 *
 * This header is necessary on Arduino 1.5.1 & 1.5.2 betas, from 1.5.3
 * the Arduino team added their own wrappers so this header file does
 * nothing.
 */
#ifndef _PROGMEM_COMPAT_H
#define _PROGMEM_COMPAT_H

#if defined(__AVR__) || (defined(ARDUINO) && ARDUINO > 152)
#include <avr/pgmspace.h>
#else // ARM

// Stub out some other common PROGMEM functions
#define PROGMEM
#define memcpy_P memcpy

static inline uint8_t pgm_read_byte(const void *addr) { return *((uint8_t *)addr); }

#define F(X) X


#endif
#endif

I guess this is failing because I need to somehow define the Teensy 3.0 version of "PROGMEM" ? I was reading about this elsewhere in these forums but I don't quite understand what I am to do to get this to work.

From what I can tell Teensy doesn't require us to use the PROGMEM functions, rather we just declare using const and the variables go into flash.... wondering how I could make the above code compile though...
 
Hi there,

Okay so I upgraded, this is what I get when I try to compile:

Code:
Arduino: 1.0.5 (Windows 7), Board: "Teensy 3.0"
C:\Program Files (x86)\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=48000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX128__ -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3 -IC:\Program Files (x86)\Arduino\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\SD -IC:\Users\adrian\Documents\Arduino\libraries\FTOLED C:\Users\adrian\AppData\Local\Temp\build3174194279748787542.tmp\EchoBoth.cpp -o C:\Users\adrian\AppData\Local\Temp\build3174194279748787542.tmp\EchoBoth.cpp.o 
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:14:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:17:0: warning: "memcpy_P" redefined [enabled by default]
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WProgram.h:11:0,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from EchoBoth.pde:10:
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/avr/pgmspace.h:24:0: note: this is the location of the previous definition
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:14:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:21:0: warning: "F" redefined [enabled by default]
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Print.h:38:0,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Stream.h:24,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/HardwareSerial.h:142,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WProgram.h:16,
                 from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from EchoBoth.pde:10:
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WString.h:41:0: note: this is the location of the previous definition
In file included from C:\Users\adrian\Documents\Arduino\libraries\FTOLED/FTOLED.h:42:0,
                 from EchoBoth.pde:14:
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected unqualified-id before 'const'
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected ')' before 'const'
C:\Users\adrian\Documents\Arduino\libraries\FTOLED/progmem_compat.h:19:23: error: expected ')' before 'const'

The library is at https://github.com/freetronics/FTOLED/archive/master.zip. More info at http://www.freetronics.com/pages/oled128-quickstart-guide#.Upnq6GSSAqk...
 
Try using this progmem_compat.h file. It has just one minor change. I was able to compile the library, but I don't have this OLED for testing.
 

Attachments

  • progmem_compat.h
    764 bytes · Views: 209
I wonder if anyone can help. The FTOLED library is marvelous... with a slight mod to mode 0 so it will work with the Ethernet card it is fast. I could not get the textbox to work - but general text works a treat.

BUT... something about the larger fonts.. the SPACE does not seem to do anything... using DROID_SANS_36 if I send a string "20c " - note the space on the end - works lovely... if I then put "11c " - the number 1 is narrower than 2, and so there is some of the original text left there.. you would EXPECT the space to override it - but it doesn't! So you end up with a mess. I don't want to wipe the text area before using it as I'm updating every second..

The small system font works a treat - but the larger ones have this issue. Does anyone know why - and how to fix it other than coming up with a complete set of mono-spaced characters???

Any help would be appreciated.

Peter.

So you you would expect it to
 
Status
Not open for further replies.
Back
Top