Hi,
I am working with an Arduino Mega 2560 with an extension board and the E-ink 2.0 and 2.7
I am using the libraries EPD, EPD_GFX and Adafruit_GFX and I have an issue with the 2.7 screen:
There is no problem when I only use the EPD library for displaying pictures but when I want to write some characters with the EPD_GFX and Adafruit_GFX libraries, the definition of the arrays old_image and new_image is not working.
I think there is an overflow in the stack because, when I decrease the size of the screen, it works, but when I try to put the width 264 and the height 176, it does nothing.
First, it wasn't compiling because of the calculation of the size of the array which I modified like this:
(HEIGHT_SCREEN/ 8 ) * WIDTH_SCREEN to make it compiling (no overflow anymore in the calculation).
Now it is compiling but nothing is happening on the screen.
I tried to declare old_image and new_image as PROGMEM (to put this in the flash memory) and used the function
this->EPD.image(this->old_image, this->new_image);
instead of
this->EPD.image_sram(this->old_image, this->new_image);
in the display function of GFX but still nothing.
Does somebody have already that issue? Any idea?
Thanks
EPD_GFX and Adafruit_GFX libraries
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
I haven't experimented much with the new larger displays. But 264x176 is 46464 pixels or 5808 bytes. Since the Mega has only 8K of SRAM, there is not enough room to hold two such arrays. You should be able to pull in static displays from progmem, but you won't be able to write them back out from your sketch.
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Thanks for the answer.
I am not sure to really understand. Does that mean that I can't read what is in the flash memory?
If yes, the best idea would be to only use it with xbm files, isn't it?
I am not sure to really understand. Does that mean that I can't read what is in the flash memory?
If yes, the best idea would be to only use it with xbm files, isn't it?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
You can read from flash memory, you just can't have more than one screen buffer in SRAM.
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Ok thanks, got you!
Another thing, I am also trying to alternate a screen with an image and a screen with characters written by the function drawchar but I have an error that I really don't get:
c:/users/sonevilayvanh/documents/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':
(.vectors+0xc0): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_48' defined in .text section in c:/users/sonevilayvanh/documents/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o
If i comment the drawchar function, everything works or if I only use the drawchar function, it works too. But the association of the drawchar function with the EPD.image function is not working.
By the way, I am using the Arduino 1.0.3.
Any idea?
Another thing, I am also trying to alternate a screen with an image and a screen with characters written by the function drawchar but I have an error that I really don't get:
c:/users/sonevilayvanh/documents/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':
(.vectors+0xc0): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_48' defined in .text section in c:/users/sonevilayvanh/documents/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o
If i comment the drawchar function, everything works or if I only use the drawchar function, it works too. But the association of the drawchar function with the EPD.image function is not working.
By the way, I am using the Arduino 1.0.3.
Any idea?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
Can you post the code that causes that error?
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Uncomment or comment EPD.image
Code: Select all
#include <inttypes.h>
#include <ctype.h>
#include <avr/pgmspace.h>
#include <SPI.h>
#include <FLASH.h>
#include <EPD.h>
#include <S5813A.h>
#include <Adafruit_GFX.h>
#include <EPD_GFX.h>
#define EPD_SIZE EPD_2_0
#define PICTURE "SPlogo.xbm"
#define PICTURE_BITS SPlogo_bits
#include <Images.h>
PROGMEM const
#define unsigned
#define char uint8_t
#include PICTURE
#undef char
#undef unsigned
// Arduino IO layout
const int Pin_TEMPERATURE = A0;
const int Pin_PANEL_ON = 2;
const int Pin_BORDER = 3;
const int Pin_DISCHARGE = 4;
const int Pin_PWM = 5;
const int Pin_RESET = 6;
const int Pin_BUSY = 7;
const int Pin_EPD_CS = 8;
const int Pin_FLASH_CS = 9;
const int Pin_SW2 = 12;
const int Pin_RED_LED = 13;
// LED anode through resistor to I/O pin
// LED cathode to Ground
#define LED_ON HIGH
#define LED_OFF LOW
// pre-processor convert to string
#define MAKE_STRING1(X) #X
#define MAKE_STRING(X) MAKE_STRING1(X)
// define the E-Ink display
EPD_Class EPD(EPD_SIZE, Pin_PANEL_ON, Pin_BORDER, Pin_DISCHARGE, Pin_PWM, Pin_RESET, Pin_BUSY, Pin_EPD_CS, SPI);
EPD_GFX G_EPD(EPD, S5813A);
// I/O setup
void setup() {
pinMode(Pin_RED_LED, OUTPUT);
pinMode(Pin_SW2, INPUT);
pinMode(Pin_TEMPERATURE, INPUT);
pinMode(Pin_PWM, OUTPUT);
pinMode(Pin_BUSY, INPUT);
pinMode(Pin_RESET, OUTPUT);
pinMode(Pin_PANEL_ON, OUTPUT);
pinMode(Pin_DISCHARGE, OUTPUT);
pinMode(Pin_BORDER, OUTPUT);
pinMode(Pin_EPD_CS, OUTPUT);
pinMode(Pin_FLASH_CS, OUTPUT);
digitalWrite(Pin_RED_LED, LOW);
digitalWrite(Pin_PWM, LOW);
digitalWrite(Pin_RESET, LOW);
digitalWrite(Pin_PANEL_ON, LOW);
digitalWrite(Pin_DISCHARGE, LOW);
digitalWrite(Pin_BORDER, LOW);
digitalWrite(Pin_EPD_CS, LOW);
digitalWrite(Pin_FLASH_CS, HIGH);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV4);
Serial.begin(9600);
FLASH.begin(Pin_FLASH_CS, SPI);
if (FLASH.available()) {
Serial.println("FLASH chip detected OK");
}
else {
Serial.println("unsupported FLASH chip");
}
// configure temperature sensor
S5813A.begin(Pin_TEMPERATURE);
}
int state = 0;
// main loop
void loop() {
EPD.begin();
G_EPD.begin();
EPD.clear();
switch (state){
case 0:
//EPD.image(PICTURE_BITS);
++state;
break;
case 1:
G_EPD.drawChar(10, 1, 'P', EPD_GFX::BLACK, EPD_GFX::WHITE, 1);
state = 0;
G_EPD.display();
break;
}
delay (6000);
EPD.end();
}
Last edited by adafruit_support_bill on Thu Jun 06, 2013 11:15 am, edited 3 times in total.
Reason: Please use the 'code' button when submitting code
Reason: Please use the 'code' button when submitting code
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
Possibly an error in your logo file. I renamed one of the other 2.7" xbm files to SPlogo and it compiled fine here.
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Still even when i am using the images from the examples
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
I tried it with several versions of the IDE and have no errors from any of them. Maybe something corrupt in your Arduino install?
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Ok thanks, i will try to re-install it from a new package.
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
I tried with the 1.0.5 IDE but still not working.
Would that be possible that at the compilation, it tries to get enough memory from the ram to put old_image, new_image and enough space for the picture file?
Because the error is about "relocation truncated" and each image is 2.4kb (for the E-ink 2.0) and the ram has only 5118 bytes left so maybe it is trying to put that anywhere else in the memory...?
Would that be possible that at the compilation, it tries to get enough memory from the ram to put old_image, new_image and enough space for the picture file?
Because the error is about "relocation truncated" and each image is 2.4kb (for the E-ink 2.0) and the ram has only 5118 bytes left so maybe it is trying to put that anywhere else in the memory...?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
Not sure why it would compile differently on your machine than on mine. What operating system are you using? (I'm on Win-7/64)
-
- Posts: 10
- Joined: Wed Jun 05, 2013 7:06 am
Re: EPD_GFX and Adafruit_GFX libraries
Windows 7 Pro - 64 Bit
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: EPD_GFX and Adafruit_GFX libraries
Same OS even. I'm stumped. You might try posting this over at Arduino.cc. There are people over there with a better understanding of the low level operation of the GCC/AVR compiler.
Please be positive and constructive with your questions and comments.