GxEPD & Teensy

Hello Everyone, I am hoping i can get some assistance with this.

I am using Zingg’s GxEPD library to control my WaveShare 4.2" E Paper display (GxGDEW042T2)

My project is going wonderfully and working without any problems until i reached the limits of my arduino pro mini. Because of that, i went ahead and started working with a Teensy LC. I installed the drivers and libraries for the arduino IDE and it is working great. i tested it with the basic LED blink sketch. Then i tried a sample RFID reader sketch. No Problems. i am now trying to get my epaper display to work and i am running into some issues. I am fairly new to coding and im not sure if this is a simple mistake or something else.

My project consists of the Teensy LC, the RC522 RFID reader, Micro SD reader, and the E Paper display.

Basically when a specific RFID card is scanned, it logs it to the sd card and updates the display with some information. Using the same sketch i had for my pro mini i am getting errors in my compiling:

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\JOSEPH~1.FAR\AppData\Local\Temp\arduino_build_616413/lga-test2.ino.elf section `.bss' will not fit in region `RAM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 10120 bytes

collect2.exe: error: ld returned 1 exit status

I only get this error when the line:GxEPD_Class display(io /*RST=9*/ /*BUSY=7*/); // default selection of (9), 7 is enabled. if i comment it out, it compiles and uploads perfectly.

Is there some modification i need to do for this?

Here is the beginning of my code so you have an idea:

#include <SD.h>
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include "RTClib.h"
#include <GxEPD.h>
#include <GxGDEW042T2/GxGDEW042T2.cpp>      // 4.2" b/w
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <Fonts/FreeMonoBold12pt7b.h>

GxIO_Class io(SPI, /*CS=*/ SS, /*DC=*/ 8, /*RST=*/ 9); // arbitrary selection of 8, 9 selected for default of GxEPD_Class
GxEPD_Class display(io /*RST=9*/ /*BUSY=7*/); // default selection of (9), 7

RTC_DS1307 rtc;
File fd;
#define RST_PIN         6           // RFID RESET Pin
#define SS_PIN          5           // RFID SS Pin
// BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
const uint8_t chipSelect = 14; //SD CS PIN
const uint8_t cardDetect = 15; //SD CD PIN
char fileName[] = "test.txt"; // SD library only supports up to 8.3 names
//uint8_t index = 0;
enum states: uint8_t { NORMAL, E, EO };
uint8_t state = NORMAL;
bool alreadyBegan = false;  // SD.begin() misbehaves if not first call

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
String read_rfid;
String ok_rfid_1="502a94a3";
//String ok_rfid_2="ffffffff"; //add as many as you need.
const int greenLED = 4;
const int redLED = 3;
const int buzzer = 2;
/*
 * Initialize.
 */
void setup() {
    Serial.begin(4800);         // Initialize serial communications with the PC
    SPI.begin();                // Init SPI bus
    mfrc522.PCD_Init();         // Init MFRC522 card
    pinMode(redLED, OUTPUT);
    pinMode(greenLED, OUTPUT);
    pinMode(cardDetect, INPUT);
    initializeCard();
  
if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
DateTime now = rtc.now();
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print('/');
    Serial.print(now.year(), DEC);
    Serial.print(" (");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println(')');
  Serial.println();
  Serial.println("Initializing Display");
  //display.init(115200); // enable diagnostic output on Serial
  Serial.println("Display Initialized");
}

Thanks in advance guys, sorry if its something stupid i missed. :slight_smile:

PS: forgot to mention this sketch should not be over ram for the LC. it was using 140% of the arduino pro mini which has much less ram than the teensy LC

Hi capeman121,

the Arduino Pro Mini is an AVR arduino. It has not enough RAM for a full buffer for graphics rendering.
The display class uses a reduced buffer if the precompiler symbol __AVR is defined, and the application needs to use paged drawing for graphics rendering in this case.

GxEPD knows nothing about teensys, I don't have any and don't claim it is supported by GxEPD.
You can modify the display class for your display to use a reduced buffer space for your teensy, but I do not recommend this.

You could use GxEPD2 instead. In GxEPD2 you can specify the height of the page buffer as a parameter (template instance parameter), and then used one of the two options for paged drawing, one uses callbacks like in GxEPD.

Jean-Marc

Hey Jean,

Thanks for the reply. i will have a look at the GxEPD2 library and give it a shot.

I know the arduino pro mini was limited with the e-paper display having only 2KB of SRAM and 30KB Memory which is why i switched to the Teensy LC that has 8KB RAM and 62KB Memory.

So far i can get the SD card reader, RFID and RTC working with no problems right out of the box using same pins etc. Its only a problem when i activate that one line of code that refers to the GxEPD that causes the issue.

I will take your recommendations.

I know you dont support this microcontroller but because of its popularity i though maybe you would have ran into someone else with this problem, no worries, Thanks!

Use the F() macro to move string literals to program memory.
For example, instead of this:

Serial.println("Couldn't find RTC");

do this:

Serial.println(F("Couldn't find RTC"));

Don't use String. That takes a lot of memory.

If you post your full code, people might be able to recommend further optimizations. Please do a Tools > Auto Format on your code before posting to the forum so it will be easier for us to read.