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:
Sat Nov 09 23:37:43 2013 +0000
Revision:
0:fedcef5319f5
Lib for using a E-Paper display from Pervasive Displays.; There is a interface board from Embedded Artists.; It can handle graphic and text drawing and is using external fonts.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:fedcef5319f5 1 /* mbed GraphicsDisplay Display 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
dreschpe 0:fedcef5319f5 6 #include "GraphicsDisplay.h"
dreschpe 0:fedcef5319f5 7
dreschpe 0:fedcef5319f5 8 const unsigned char FONT8x8[97][8] = {
dreschpe 0:fedcef5319f5 9 0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char
dreschpe 0:fedcef5319f5 10 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20
dreschpe 0:fedcef5319f5 11 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // !
dreschpe 0:fedcef5319f5 12 0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // "
dreschpe 0:fedcef5319f5 13 0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // #
dreschpe 0:fedcef5319f5 14 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $
dreschpe 0:fedcef5319f5 15 0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // %
dreschpe 0:fedcef5319f5 16 0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // &
dreschpe 0:fedcef5319f5 17 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // '
dreschpe 0:fedcef5319f5 18 0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // (
dreschpe 0:fedcef5319f5 19 0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // )
dreschpe 0:fedcef5319f5 20 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // *
dreschpe 0:fedcef5319f5 21 0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // +
dreschpe 0:fedcef5319f5 22 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // ,
dreschpe 0:fedcef5319f5 23 0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // -
dreschpe 0:fedcef5319f5 24 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // .
dreschpe 0:fedcef5319f5 25 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash)
dreschpe 0:fedcef5319f5 26 0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30
dreschpe 0:fedcef5319f5 27 0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1
dreschpe 0:fedcef5319f5 28 0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2
dreschpe 0:fedcef5319f5 29 0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3
dreschpe 0:fedcef5319f5 30 0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4
dreschpe 0:fedcef5319f5 31 0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5
dreschpe 0:fedcef5319f5 32 0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6
dreschpe 0:fedcef5319f5 33 0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7
dreschpe 0:fedcef5319f5 34 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8
dreschpe 0:fedcef5319f5 35 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9
dreschpe 0:fedcef5319f5 36 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // :
dreschpe 0:fedcef5319f5 37 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ;
dreschpe 0:fedcef5319f5 38 0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // <
dreschpe 0:fedcef5319f5 39 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // =
dreschpe 0:fedcef5319f5 40 0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // >
dreschpe 0:fedcef5319f5 41 0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ?
dreschpe 0:fedcef5319f5 42 0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40
dreschpe 0:fedcef5319f5 43 0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A
dreschpe 0:fedcef5319f5 44 0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B
dreschpe 0:fedcef5319f5 45 0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C
dreschpe 0:fedcef5319f5 46 0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D
dreschpe 0:fedcef5319f5 47 0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E
dreschpe 0:fedcef5319f5 48 0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F
dreschpe 0:fedcef5319f5 49 0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G
dreschpe 0:fedcef5319f5 50 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H
dreschpe 0:fedcef5319f5 51 0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I
dreschpe 0:fedcef5319f5 52 0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J
dreschpe 0:fedcef5319f5 53 0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K
dreschpe 0:fedcef5319f5 54 0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L
dreschpe 0:fedcef5319f5 55 0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M
dreschpe 0:fedcef5319f5 56 0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N
dreschpe 0:fedcef5319f5 57 0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O
dreschpe 0:fedcef5319f5 58 0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50
dreschpe 0:fedcef5319f5 59 0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q
dreschpe 0:fedcef5319f5 60 0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R
dreschpe 0:fedcef5319f5 61 0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S
dreschpe 0:fedcef5319f5 62 0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T
dreschpe 0:fedcef5319f5 63 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U
dreschpe 0:fedcef5319f5 64 0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V
dreschpe 0:fedcef5319f5 65 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W
dreschpe 0:fedcef5319f5 66 0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X
dreschpe 0:fedcef5319f5 67 0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y
dreschpe 0:fedcef5319f5 68 0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z
dreschpe 0:fedcef5319f5 69 0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [
dreschpe 0:fedcef5319f5 70 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash)
dreschpe 0:fedcef5319f5 71 0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ]
dreschpe 0:fedcef5319f5 72 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^
dreschpe 0:fedcef5319f5 73 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _
dreschpe 0:fedcef5319f5 74 0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60
dreschpe 0:fedcef5319f5 75 0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a
dreschpe 0:fedcef5319f5 76 0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b
dreschpe 0:fedcef5319f5 77 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c
dreschpe 0:fedcef5319f5 78 0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d
dreschpe 0:fedcef5319f5 79 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e
dreschpe 0:fedcef5319f5 80 0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f
dreschpe 0:fedcef5319f5 81 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g
dreschpe 0:fedcef5319f5 82 0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h
dreschpe 0:fedcef5319f5 83 0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i
dreschpe 0:fedcef5319f5 84 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j
dreschpe 0:fedcef5319f5 85 0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k
dreschpe 0:fedcef5319f5 86 0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l
dreschpe 0:fedcef5319f5 87 0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m
dreschpe 0:fedcef5319f5 88 0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n
dreschpe 0:fedcef5319f5 89 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o
dreschpe 0:fedcef5319f5 90 0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p
dreschpe 0:fedcef5319f5 91 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q
dreschpe 0:fedcef5319f5 92 0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r
dreschpe 0:fedcef5319f5 93 0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s
dreschpe 0:fedcef5319f5 94 0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t
dreschpe 0:fedcef5319f5 95 0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u
dreschpe 0:fedcef5319f5 96 0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v
dreschpe 0:fedcef5319f5 97 0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w
dreschpe 0:fedcef5319f5 98 0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x
dreschpe 0:fedcef5319f5 99 0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y
dreschpe 0:fedcef5319f5 100 0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z
dreschpe 0:fedcef5319f5 101 0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // {
dreschpe 0:fedcef5319f5 102 0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // |
dreschpe 0:fedcef5319f5 103 0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // }
dreschpe 0:fedcef5319f5 104 0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~
dreschpe 0:fedcef5319f5 105 0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL
dreschpe 0:fedcef5319f5 106
dreschpe 0:fedcef5319f5 107 GraphicsDisplay::GraphicsDisplay(const char *name):TextDisplay(name) {
dreschpe 0:fedcef5319f5 108 foreground(0xFFFF);
dreschpe 0:fedcef5319f5 109 background(0x0000);
dreschpe 0:fedcef5319f5 110 }
dreschpe 0:fedcef5319f5 111
dreschpe 0:fedcef5319f5 112 void GraphicsDisplay::character(int column, int row, int value) {
dreschpe 0:fedcef5319f5 113 blitbit(column * 8, row * 8, 8, 8, (char*)&(FONT8x8[value - 0x1F][0]));
dreschpe 0:fedcef5319f5 114 }
dreschpe 0:fedcef5319f5 115
dreschpe 0:fedcef5319f5 116 void GraphicsDisplay::window(int x, int y, int w, int h) {
dreschpe 0:fedcef5319f5 117 // current pixel location
dreschpe 0:fedcef5319f5 118 _x = x;
dreschpe 0:fedcef5319f5 119 _y = y;
dreschpe 0:fedcef5319f5 120 // window settings
dreschpe 0:fedcef5319f5 121 _x1 = x;
dreschpe 0:fedcef5319f5 122 _x2 = x + w - 1;
dreschpe 0:fedcef5319f5 123 _y1 = y;
dreschpe 0:fedcef5319f5 124 _y2 = y + h - 1;
dreschpe 0:fedcef5319f5 125 }
dreschpe 0:fedcef5319f5 126
dreschpe 0:fedcef5319f5 127 void GraphicsDisplay::putp(int colour) {
dreschpe 0:fedcef5319f5 128 // put pixel at current pixel location
dreschpe 0:fedcef5319f5 129 pixel(_x, _y, colour);
dreschpe 0:fedcef5319f5 130 // update pixel location based on window settings
dreschpe 0:fedcef5319f5 131 _x++;
dreschpe 0:fedcef5319f5 132 if(_x > _x2) {
dreschpe 0:fedcef5319f5 133 _x = _x1;
dreschpe 0:fedcef5319f5 134 _y++;
dreschpe 0:fedcef5319f5 135 if(_y > _y2) {
dreschpe 0:fedcef5319f5 136 _y = _y1;
dreschpe 0:fedcef5319f5 137 }
dreschpe 0:fedcef5319f5 138 }
dreschpe 0:fedcef5319f5 139 }
dreschpe 0:fedcef5319f5 140
dreschpe 0:fedcef5319f5 141 void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) {
dreschpe 0:fedcef5319f5 142 window(x, y, w, h);
dreschpe 0:fedcef5319f5 143 for(int i=0; i<w*h; i++) {
dreschpe 0:fedcef5319f5 144 putp(colour);
dreschpe 0:fedcef5319f5 145 }
dreschpe 0:fedcef5319f5 146 }
dreschpe 0:fedcef5319f5 147
dreschpe 0:fedcef5319f5 148 void GraphicsDisplay::cls() {
dreschpe 0:fedcef5319f5 149 fill(0, 0, width(), height(), _background);
dreschpe 0:fedcef5319f5 150 }
dreschpe 0:fedcef5319f5 151
dreschpe 0:fedcef5319f5 152 void GraphicsDisplay::blit(int x, int y, int w, int h, const int *colour) {
dreschpe 0:fedcef5319f5 153 window(x, y, w, h);
dreschpe 0:fedcef5319f5 154 for(int i=0; i<w*h; i++) {
dreschpe 0:fedcef5319f5 155 putp(colour[i]);
dreschpe 0:fedcef5319f5 156 }
dreschpe 0:fedcef5319f5 157 }
dreschpe 0:fedcef5319f5 158
dreschpe 0:fedcef5319f5 159 void GraphicsDisplay::blitbit(int x, int y, int w, int h, const char* colour) {
dreschpe 0:fedcef5319f5 160 window(x, y, w, h);
dreschpe 0:fedcef5319f5 161 for(int i = 0; i < w*h; i++) {
dreschpe 0:fedcef5319f5 162 char byte = colour[i >> 3];
dreschpe 0:fedcef5319f5 163 int offset = i & 0x7;
dreschpe 0:fedcef5319f5 164 int c = ((byte << offset) & 0x80) ? _foreground : _background;
dreschpe 0:fedcef5319f5 165 putp(c);
dreschpe 0:fedcef5319f5 166 }
dreschpe 0:fedcef5319f5 167 }
dreschpe 0:fedcef5319f5 168
dreschpe 0:fedcef5319f5 169 int GraphicsDisplay::columns() {
dreschpe 0:fedcef5319f5 170 return width() / 8;
dreschpe 0:fedcef5319f5 171 }
dreschpe 0:fedcef5319f5 172
dreschpe 0:fedcef5319f5 173 int GraphicsDisplay::rows() {
dreschpe 0:fedcef5319f5 174 return height() / 8;
dreschpe 0:fedcef5319f5 175 }
dreschpe 0:fedcef5319f5 176