A lib to handle a E-Paper display from Pervasive Displays. There is a interface board from Embedded Artists. The lib can handle graphic and text drawing and is using external fonts.

Dependents:   epaper_mbed_130411_KL25Z epaper_mbed_test epaper_KL25Z_2 test_he10 ... more

/media/uploads/dreschpe/epaper.jpg

The E-Paper display from Pervasive Displays with a interface board is available from Embedded Artists : http://www.embeddedartists.com/products/displays/lcd_27_epaper.php The 2.7 inch display have 264*176 pixel, monochrome.

Technology

You can look at the webside from Pervasive to see how the display works. http://www.pervasivedisplays.com/technology/home

This type of display have ultra low power consumption - due to its bi-stable nature. It requires only very little power to update the display and needs no power to maintain an image. You can disconnect the display - the image is still there. The viewing angle is like real paper - near 180°.

There are also some disadvantages of this technology. To change the image, we have to rewrite the full display in 4 steps. Invert, clear, invert new, new image. This process is visible and take a while -2s at room temperature. If it gets colder the display reacts slower and the interface timing has to be slow down. To compensate this, there is a LM75 temp sensor on the interface board. We also need ram to double buffer the display. 264 * 176 / 8 = 5808 Byte. To double buffer we need 11616 byte of ram. This is no problem for most mbed devices, but it will not run on the LPC11U24 or LPC800-MAX.

Interface

The graphic data is transferred to the display via spi. The maximum speed is 12Mhz. There are also some control signal and the I2C for the temperature sensor. Together we need 12 signals.

Displaymbed LPC1768mbed KL25Zsignal type
1 GNDGNDGNDGND
2 3V3VOUTP3V33.3 V power
3 SCKp7PTD1SCK
4 MOSIp5PTD2MOSI
5 MISOp6PTD3MISO
6 SSELp8PTC17GPIO
7 Busyp13PTA16GPIO
8 Borderp10PTD6GPIO
9 SCLp27PTE1SCL
10 SDAp28PTE0SDA
11 PWMp26PTD4PWM
12 Resetp12PTA17GPIO
13 Power controlp9PTD7GPIO
14 Dischargep11PTE31GPIO

Software

Fonts

How to get nice looking fonts ?

To print characters to a graphic screen we need a font. To code a font by paper is ok for a small lcd, but for a 264*176 pixel display we need bigger fonts. A 12*12 pixel font is readable, but it a lot of work to construct it by hand.

Fonts can be made with the GLCD Font Creator also from http://www.mikroe.com .

With this program you can load a window font and convert it into a c-array. To use this Font with my lib you have to add 4 parameter at the beginning of the font array. - the number of byte / char - the vertial size in pixel - the horizontal size in pixel - the number of byte per vertical line (it is vertical size / 8 ) You also have to change the type of array to char[]. After that you can switch between different fonts with set_font(unsigned char* font); The horizontal size of each character is also stored in the font. It look better if you use bigger fonts or italic. The letter M is wider than a l.

Here are some Fonts from me : http://mbed.org/users/dreschpe/code/TFT_fonts/

The small made for the mbed lab board can also be used : http://mbed.org/users/dreschpe/code/LCD_fonts/

And from Peter Holzleitner : http://mbed.org/users/pholzleitner/code/SourceCodePro31-SB/

Text commands :

You can use the claim() function to redirect the output to stdout or stderr to the display. After claim(stdout) you can simply use the printf function without the classname to print to the display. All other printf from other libs are also redirected to the display if you use this.

  • printf(...); print text and variables to the buffer with format options.
  • locate(x,y); function is used to setup the cursor position. x,y are the pixel position.

Graphics

Graphic commands :

  • cls(); Fill the screen with background color
  • pixel(x,y,color); set a single pixel at x,y with 1 : black or 0 : white
  • line(x0,y0,x1,y1,color); draw a line from x0,y0 to x1,y1 with color
  • rect(x0,y0,x1,y1,color); draw a rectangle x0,y0 to x1,y1 with color
  • fillrect(x0,y0,x1,y1,color); draw a filled rectangle
  • circle( x0,y0,radius ,color); draw a circle around x0,y0 with radius
  • fillcircle(x0,y0,radius ,color); draw a filled circle around x0,y0 with radius
  • setmode(mode); Set the drawing mode for all functions. mode can be NORMAL -> 0 is white and 1 is black or XOR -> the new pixel is a xor between the old display and the new. This mode will invert if a black pixel is draw over a black pixel.
  • print_bm(Bitmap ,x0,x0); Print a monochrome bitmap array. This graphic is defined by a Bitmap struct :

The pixel date array :

static char arm_logo[]={
0x00,0x00...
};

and a Bitmap struct:

Bitmap bitmARM = {
  48, // XSize
  48, // YSize 
  6,  // Bytes in Line
  arm_logo // Pointer to picture data 
};

To convert a graphic into a byte array we can use the tool Picture Converter 1bpp from http://www.embedded-tools.de.vu/ With this tool we load a image, press the convert button and save it as C-Header file. We have to save with horizontal orientation, so we have to press "No". Inside this file we find the data array which we can copy into a header file.

All this commands are writing to the frame buffer only ! To change the active display we have to call

  • write_disp(); This will refresh the display.

Sample code

test code for the LPC1768: http://mbed.org/users/dreschpe/code/epaper_mbed_test/

test code for KL25Z: http://mbed.org/users/dreschpe/code/epaper_mbed_130411_KL25Z/

#include "mbed.h"
#include "EaEpaper.h"
#include "Arial28x28.h"
#include "Arial12x12.h"
#include "font_big.h"
#include "graphics.h"

EaEpaper epaper(
                PTD7,            // PWR_CTRL
                PTD6,            // BORDER
                PTE31,           // DISCHARGE
                PTA17,           // RESET_DISP
                PTA16,           // BUSY
                PTC17,           // SSEL
                PTD4,            // PWM
                PTD2,PTD3,PTD1,  // MOSI,MISO,SCLK
                PTE0,PTE1);      // SDA,SDL 
 
int main() {

    epaper.cls();                                      // clear screen
    epaper.set_font((unsigned char*) Arial28x28);  // select the font
    epaper.locate(5,20);                           // set cursor
    epaper.printf("Hello Mbed");                  // print  text
    epaper.rect(3,15,150,50,1);                  // print a frame 
     
    epaper.set_font((unsigned char*) Arial12x12);  // change font
    epaper.locate(5,60);                               // set cursor
    epaper.printf("small Font");                    // print text
    epaper.set_font((unsigned char*) Neu42x35);  // change font
    epaper.locate(5,70);                               //set cursor
    epaper.printf("big Font");                        // change font
    
    epaper.write_disp(); // update screen       // update display
    
    wait(5);                                           // wait 5 s
    epaper.fillcircle(180,30,22,1);              // paint filled circle
    epaper.circle(160,150,20,1);               // paint circle
    epaper.write_disp(); // update screen      // update display
    
}
  
Committer:
dreschpe
Date:
Wed Jun 25 17:43:32 2014 +0000
Revision:
3:1371614703cd
Parent:
0:fedcef5319f5
remove the use of the BurstSPI driver to make the lib compatible with all platforms. There is no time difference, because the display itself need so much time.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:fedcef5319f5 1 /* mbed TextDisplay Library Base Class
dreschpe 0:fedcef5319f5 2 * Copyright (c) 2007-2009 sford
dreschpe 0:fedcef5319f5 3 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 0:fedcef5319f5 4 *
dreschpe 0:fedcef5319f5 5 * A common base class for Text displays
dreschpe 0:fedcef5319f5 6 * To port a new display, derive from this class and implement
dreschpe 0:fedcef5319f5 7 * the constructor (setup the display), character (put a character
dreschpe 0:fedcef5319f5 8 * at a location), rows and columns (number of rows/cols) functions.
dreschpe 0:fedcef5319f5 9 * Everything else (locate, printf, putc, cls) will come for free
dreschpe 0:fedcef5319f5 10 *
dreschpe 0:fedcef5319f5 11 * The model is the display will wrap at the right and bottom, so you can
dreschpe 0:fedcef5319f5 12 * keep writing and will always get valid characters. The location is
dreschpe 0:fedcef5319f5 13 * maintained internally to the class to make this easy
dreschpe 0:fedcef5319f5 14 */
dreschpe 0:fedcef5319f5 15
dreschpe 0:fedcef5319f5 16 #ifndef MBED_TEXTDISPLAY_H
dreschpe 0:fedcef5319f5 17 #define MBED_TEXTDISPLAY_H
dreschpe 0:fedcef5319f5 18
dreschpe 0:fedcef5319f5 19 #include "mbed.h"
dreschpe 0:fedcef5319f5 20
dreschpe 0:fedcef5319f5 21 class TextDisplay : public Stream {
dreschpe 0:fedcef5319f5 22 public:
dreschpe 0:fedcef5319f5 23
dreschpe 0:fedcef5319f5 24 // functions needing implementation in derived implementation class
dreschpe 0:fedcef5319f5 25 /** Create a TextDisplay interface
dreschpe 0:fedcef5319f5 26 *
dreschpe 0:fedcef5319f5 27 * @param name The name used in the path to access the strean through the filesystem
dreschpe 0:fedcef5319f5 28 */
dreschpe 0:fedcef5319f5 29 TextDisplay(const char *name = NULL);
dreschpe 0:fedcef5319f5 30
dreschpe 0:fedcef5319f5 31 /** output a character at the given position
dreschpe 0:fedcef5319f5 32 *
dreschpe 0:fedcef5319f5 33 * @param column column where charater must be written
dreschpe 0:fedcef5319f5 34 * @param row where character must be written
dreschpe 0:fedcef5319f5 35 * @param c the character to be written to the TextDisplay
dreschpe 0:fedcef5319f5 36 */
dreschpe 0:fedcef5319f5 37 virtual void character(int column, int row, int c) = 0;
dreschpe 0:fedcef5319f5 38
dreschpe 0:fedcef5319f5 39 /** return number if rows on TextDisplay
dreschpe 0:fedcef5319f5 40 * @result number of rows
dreschpe 0:fedcef5319f5 41 */
dreschpe 0:fedcef5319f5 42 virtual int rows() = 0;
dreschpe 0:fedcef5319f5 43
dreschpe 0:fedcef5319f5 44 /** return number if columns on TextDisplay
dreschpe 0:fedcef5319f5 45 * @result number of rows
dreschpe 0:fedcef5319f5 46 */
dreschpe 0:fedcef5319f5 47 virtual int columns() = 0;
dreschpe 0:fedcef5319f5 48
dreschpe 0:fedcef5319f5 49 // functions that come for free, but can be overwritten
dreschpe 0:fedcef5319f5 50
dreschpe 0:fedcef5319f5 51 /** redirect output from a stream (stoud, sterr) to display
dreschpe 0:fedcef5319f5 52 * @param stream stream that shall be redirected to the TextDisplay
dreschpe 0:fedcef5319f5 53 */
dreschpe 0:fedcef5319f5 54 virtual bool claim (FILE *stream);
dreschpe 0:fedcef5319f5 55
dreschpe 0:fedcef5319f5 56 /** clear screen
dreschpe 0:fedcef5319f5 57 */
dreschpe 0:fedcef5319f5 58 virtual void cls();
dreschpe 0:fedcef5319f5 59 virtual void locate(int column, int row);
dreschpe 0:fedcef5319f5 60 virtual void foreground(uint16_t colour);
dreschpe 0:fedcef5319f5 61 virtual void background(uint16_t colour);
dreschpe 0:fedcef5319f5 62 // putc (from Stream)
dreschpe 0:fedcef5319f5 63 // printf (from Stream)
dreschpe 0:fedcef5319f5 64
dreschpe 0:fedcef5319f5 65 protected:
dreschpe 0:fedcef5319f5 66
dreschpe 0:fedcef5319f5 67 virtual int _putc(int value);
dreschpe 0:fedcef5319f5 68 virtual int _getc();
dreschpe 0:fedcef5319f5 69
dreschpe 0:fedcef5319f5 70 // character location
dreschpe 0:fedcef5319f5 71 uint16_t _column;
dreschpe 0:fedcef5319f5 72 uint16_t _row;
dreschpe 0:fedcef5319f5 73
dreschpe 0:fedcef5319f5 74 // colours
dreschpe 0:fedcef5319f5 75 uint16_t _foreground;
dreschpe 0:fedcef5319f5 76 uint16_t _background;
dreschpe 0:fedcef5319f5 77 char *_path;
dreschpe 0:fedcef5319f5 78 };
dreschpe 0:fedcef5319f5 79
dreschpe 0:fedcef5319f5 80 #endif