2.7 inch ePaper on Teensy - does not compile - Adafruit_GFX

ahkub

Member
Solved - 2.7 inch ePaper (Embedded Artists) on Teensy - Adafruit_GFX

Dear all,
I am working on porting Brody Kenrick's great ePaper routines to run on Teensy.
On Arduino Pro Mini, his libraries (EPD.h, EPD.cpp, EPD_GFX.h, EPD_GFX.cpp) work well with the latest Adafruit_GFX library (5.July 2013).
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/brodykenrick/gratis

a) Compiling his example sketch "thermo_epd_gfx_ea_partial_screen" works for Arduino Pro Mini on Arduino IDE 1.0.5.

b) Trying to compile the example sketch "thermo_epd_gfx_ea_partial_screen" for Teensy3.1 returns errors (on Arduino IDE 1.0.5 with Teensyduino1.18, https://www.pjrc.com/teensy/td_download.html):
Code:
thermo_epd_gfx_ea_partial_screen:157: error: cannot declare variable 'G_EPD' to be of abstract type 'EPD_GFX'
In file included from thermo_epd_gfx_ea_partial_screen.ino:80:0:
C:\Users\akuchenb\Alf\Arduino_105\libraries\EPD_GFX/EPD_GFX.h:56:7: note:   because the following virtual functions are pure within 'EPD_GFX':
In file included from thermo_epd_gfx_ea_partial_screen.ino:49:0:
C:\Users\akuchenb\Alf\Arduino_105\libraries\Adafruit_GFX/Adafruit_GFX.h:20:16: note: 	virtual void Adafruit_GFX::drawPixel(int16_t, int16_t, uint16_t)

I was thinking about a similar post in this forum, which CMason was able to solve:
http://forum.pjrc.com/threads/10-Adafruit-PCD8544-LCD-library?p=87&viewfull=1#post87

So I added CMason's line, but it did not improve anything:
Code:
virtual ~Adafruit_GFX() {} // force inclusion of vtable.

Would anyone have a good idea what I'm doing wrong here?
Any help appreciated.

Best regards,
Alf
 
Last edited:
Update: In epd_GFX.h, there was a wrong variable

I replaced
Code:
void drawPixel(int16_t x, int16_t y, unsigned int colour)
with
Code:
void drawPixel(int16_t x, int16_t y, uint16_t colour)

It's better, but now I get
c:/users/akuchenb/alf/arduino_105/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text+0x14): undefined reference to `_kill'
c:/users/akuchenb/alf/arduino_105/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text+0x28): undefined reference to `_getpid'
collect2.exe: error: ld returned 1 exit status

confused,
Alf

Oh, this post looks promising:
http://forum.pjrc.com/threads/23739-Assertions-don-t-work-on-Teensy-3-0


OK, SOLVED.
I had to take out "assert.h" and all assert statements in EPD_GFX.h and EPD_GFX.cpp.
When I'm all done, I will set this up on GITHUB and post a link here.

relieved,
Alf
 
Last edited:
Hi Alf, did you need the partial screen refresh with the Teensy? Shouldn't it have enough SRAM to refresh the whole screen at once?
Also if you got the mods on your last post online I'd appreciate if you could post a link - I'm just starting a project with the 2,7'' and the Teensy and probably will run into the same issues.

Thanks!
 
Hello Ishback,
You are probably right with the SRAM statement.
I was working with what I had and did not want to reinvent the wheel. But I'd be interested in code which keeps everything in SRAM at the same time. Should be faster, too.
Today, I asked Brody to implement the necessary changes into his library. For now, you can download the fixed code here: https://github.com/ahkub/gratis

Best regards,
Alf
 
Last edited:
Hi Alf,

Just tried the demo sketches (e.g. demo_epd_ea) and it uploads without errors but the screen doesn't do anything. I've wired it using the same pins as the Arduino UNO. Is there anything you need to change on the examples to work on the Teensy 3.1? Thanks in advance
 
Last edited:
Hello Ishback,
This is a pinout which works for me:
Code:
// Arduino IO layout
#ifndef EMBEDDED_ARTISTS
const int Pin_TEMPERATURE = A0;
#endif // ! EMBEDDED_ARTISTS
const int Pin_PANEL_ON = 28;
const int Pin_BORDER = 27;
const int Pin_DISCHARGE = 25;
const int Pin_PWM = 24;
const int Pin_RESET = 26;
const int Pin_BUSY = 32;
const int Pin_EPD_CS = 31;
const int Pin_RED_LED = 13;
#ifndef EMBEDDED_ARTISTS
const int Pin_FLASH_CS = 9;
const int Pin_SW2 = 12;
#endif // ! EMBEDDED_ARTISTS
I hope it works for you, too.

Regards,
Alf
 
Last edited:
Hi Alf,

Some pins you use are on the back of the Teensy. Is there any reason for doing so? Since I didn't want to solder those yet, I tried with this configuration, but it didn't work. I'm using the demo_epd_ea example, just modifying the pins configuration corresponding to how I wired the display to the Teensy:

Code:
#ifndef EMBEDDED_ARTISTS
const int Pin_TEMPERATURE = A0;
#endif /* ! EMBEDDED_ARTISTS */
const int Pin_PANEL_ON = 15;
const int Pin_BORDER = 16;
const int Pin_DISCHARGE = 17;
const int Pin_PWM = 18;
const int Pin_RESET = 19;
const int Pin_BUSY = 20;
const int Pin_EPD_CS = 8;
#ifndef EMBEDDED_ARTISTS
const int Pin_FLASH_CS = 9;
const int Pin_SW2 = 12;
#endif /* ! EMBEDDED_ARTISTS */
const int Pin_RED_LED = 13;

Any idea why this configuration doesn't work? Am I using any pin that is not compatible?

Also I realised you're using SW2 connected to D12. In the Adafruit tutorial for wiring the Arduino UNO they connect MISO (purple) to D12 and MOSI (blue) to D11. But when setting up the pins, they say:

Code:
const int Pin_SW2 = 12;

So this SW2 should be probably MISO and MOSI doesn't need to be connected apparently, because with the UNO it works. But it's confusing, so I'm assuming in your configuration where you say SW2 you're using the purple SPI_MISO one?

Thanks again for your help!
 
Hi Alf, tried a few other combinations of pins with no luck. Do you change anything in the code examples for the epaper display? thanks
 
Works also with original pinout

Hello Ishback,
I changed the pinout now to reflect a more common scheme. It works for me as well.

This is the Pinout:
Code:
Pin 1 (of 14 pin Ribbon Cable)  GND to Teensy Pin GND
Pin 2 VCC (+3.3V)  to Teensy Pin 3.3V
Pin 3 SPI-SCK (output of Teensy) to Teensy Pin 13
Pin 4 SPI-MOSI (output) to Teensy Pin 11
Pin 5 SPI-MISO (input) to Teensy Pin 12
Pin 6 SPI-SSEL (output) to Teensy Pin 8
Pin 7 BUSY to Teensy Pin 7
Pin 8 BORDER to Teensy Pin 3
Pin 9 I2C-SCL (output) to Teensy Pin 19=A5=SCL0
Pin 10 I2C-SDA (bidirectional) to Teensy Pin 18=A4=SDA0
Pin 11 PWM to Teensy Pin 5
Pin 12 RESET to Teensy Pin 6
Pin 13 PANEL ON to Teensy Pin 2
Pin 14 DISCHARGE to Teensy Pin 4

Here are the definitions:
// Arduino IO layout
#ifndef EMBEDDED_ARTISTS
const int Pin_TEMPERATURE = A0;
#endif // ! EMBEDDED_ARTISTS
const int Pin_PANEL_ON = 2;//28;
const int Pin_BORDER = 3;//27;
const int Pin_DISCHARGE = 4;//25;
const int Pin_PWM = 5;//24;
const int Pin_RESET = 6;//26;
const int Pin_BUSY = 7;//32;
const int Pin_EPD_CS = 8;//31;
const int Pin_RED_LED = 13;
const int Pin_WHITE_LED = 14;
#ifndef EMBEDDED_ARTISTS
const int Pin_FLASH_CS = 9;
const int Pin_SW2 = 12;
#endif // ! EMBEDDED_ARTISTS

Oh, one thing. After you download the sketch to your Teensy, you need to open the serial window. This starts the display.
Please post if it works for you, otherwise let's keep debugging until we find the bug.

Good luck!
Alf
 
Back
Top