Leigh Brooks / EaEpaper_EM027BS013

Dependencies:   EM027BS013

Committer:
Leigh_LbR
Date:
Thu May 19 14:08:34 2016 +0000
Revision:
1:46dfef41919b
Parent:
0:e36f1973a674
Added API documentation;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Leigh_LbR 0:e36f1973a674 1 /* Driver for the 2.7" EM027BS013 E-Paper display produced by Pervasive Displays.
Leigh_LbR 0:e36f1973a674 2 * Based off of the 2.7" EM027AS182 display driver produced by Peter Drescher, but with key differences to use the newer Pervasive Displays driver.
Leigh_LbR 0:e36f1973a674 3 * Copyright notice is below for original driver; this is distributed under the same license.
Leigh_LbR 0:e36f1973a674 4 *
Leigh_LbR 0:e36f1973a674 5 * mbed library for 264*176 pixel 2.7 INCH E-PAPER DISPLAY from Pervasive Displays
Leigh_LbR 0:e36f1973a674 6 * Copyright (c) 2013 Peter Drescher - DC2PD
Leigh_LbR 0:e36f1973a674 7 *
Leigh_LbR 0:e36f1973a674 8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Leigh_LbR 0:e36f1973a674 9 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Leigh_LbR 0:e36f1973a674 10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Leigh_LbR 0:e36f1973a674 11 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Leigh_LbR 0:e36f1973a674 12 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Leigh_LbR 0:e36f1973a674 13 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Leigh_LbR 0:e36f1973a674 14 * THE SOFTWARE.
Leigh_LbR 0:e36f1973a674 15 */
Leigh_LbR 0:e36f1973a674 16
Leigh_LbR 0:e36f1973a674 17 #ifndef EAEPAPER_H
Leigh_LbR 0:e36f1973a674 18 #define EAEPAPER_H
Leigh_LbR 0:e36f1973a674 19
Leigh_LbR 0:e36f1973a674 20 /**
Leigh_LbR 0:e36f1973a674 21 * Includes
Leigh_LbR 0:e36f1973a674 22 */
Leigh_LbR 0:e36f1973a674 23 #include "GraphicsDisplay.h"
Leigh_LbR 0:e36f1973a674 24 #include "EM027BS013.h"
Leigh_LbR 0:e36f1973a674 25 #include "mbed.h"
Leigh_LbR 0:e36f1973a674 26
Leigh_LbR 0:e36f1973a674 27 // we have to double buffer the display
Leigh_LbR 0:e36f1973a674 28 #define EA_IMG_BUF_SZ (5808) // 264 x 176 / 8 = 5808
Leigh_LbR 0:e36f1973a674 29
Leigh_LbR 0:e36f1973a674 30 /** Draw mode
Leigh_LbR 0:e36f1973a674 31 * NORMAl
Leigh_LbR 0:e36f1973a674 32 * XOR set pixel by xor of the screen
Leigh_LbR 0:e36f1973a674 33 */
Leigh_LbR 0:e36f1973a674 34 enum {NORMAL,XOR};
Leigh_LbR 0:e36f1973a674 35
Leigh_LbR 0:e36f1973a674 36 /** Bitmap
Leigh_LbR 0:e36f1973a674 37 */
Leigh_LbR 0:e36f1973a674 38 struct Bitmap{
Leigh_LbR 0:e36f1973a674 39 int xSize;
Leigh_LbR 0:e36f1973a674 40 int ySize;
Leigh_LbR 0:e36f1973a674 41 int Byte_in_Line;
Leigh_LbR 0:e36f1973a674 42 char* data;
Leigh_LbR 0:e36f1973a674 43 };
Leigh_LbR 0:e36f1973a674 44
Leigh_LbR 0:e36f1973a674 45
Leigh_LbR 0:e36f1973a674 46 /* color definitions */
Leigh_LbR 0:e36f1973a674 47 #define Black 0x0
Leigh_LbR 0:e36f1973a674 48 #define White 0x1
Leigh_LbR 0:e36f1973a674 49
Leigh_LbR 1:46dfef41919b 50 /**
Leigh_LbR 1:46dfef41919b 51 * Main driver class to drive the EA027BS023 E-Paper display.
Leigh_LbR 1:46dfef41919b 52 */
Leigh_LbR 0:e36f1973a674 53 class EaEpaper : public GraphicsDisplay
Leigh_LbR 0:e36f1973a674 54 {
Leigh_LbR 0:e36f1973a674 55 public:
Leigh_LbR 1:46dfef41919b 56 /** EaEpaper constructor.
Leigh_LbR 1:46dfef41919b 57 * @param sec03_SpiSCK the SPI SCK pin
Leigh_LbR 1:46dfef41919b 58 * @param sec04_SpiMOSI the SPI MOSI pin
Leigh_LbR 1:46dfef41919b 59 * @param sec05_SpiMISO the SPI MISO pin
Leigh_LbR 1:46dfef41919b 60 * @param sec06_EpdCS the SPI chip select pin connected to the display
Leigh_LbR 1:46dfef41919b 61 * @param sec07_EpdBusy the pin connected to the busy pin on the display
Leigh_LbR 1:46dfef41919b 62 * @param sec08_EpdBorder the pin connected to the border pin on the display
Leigh_LbR 1:46dfef41919b 63 * @param sec09_I2cSCL the I2C SCL pin
Leigh_LbR 1:46dfef41919b 64 * @param sec10_I2cSDA the I2C SDA pin
Leigh_LbR 1:46dfef41919b 65 * @param sec11_FlashCS the Flash Chip Select pin connected to the display
Leigh_LbR 1:46dfef41919b 66 * @param sec12_EpdReset the reset pin connected to the display
Leigh_LbR 1:46dfef41919b 67 * @param sec13_EpdPanelOn the power pin connected to the display
Leigh_LbR 1:46dfef41919b 68 * @param sec14_EpdDischarge the discharge pin connected to the display
Leigh_LbR 1:46dfef41919b 69 */
Leigh_LbR 0:e36f1973a674 70 EaEpaper(PinName sec03_SpiSCK,
Leigh_LbR 0:e36f1973a674 71 PinName sec04_SpiMOSI,
Leigh_LbR 0:e36f1973a674 72 PinName sec05_SpiMISO,
Leigh_LbR 0:e36f1973a674 73 PinName sec06_EpdCS,
Leigh_LbR 0:e36f1973a674 74 PinName sec07_EpdBusy,
Leigh_LbR 0:e36f1973a674 75 PinName sec08_EpdBorder,
Leigh_LbR 0:e36f1973a674 76 PinName sec09_I2cSCL,
Leigh_LbR 0:e36f1973a674 77 PinName sec10_I2cSDA,
Leigh_LbR 0:e36f1973a674 78 PinName sec11_FlashCS,
Leigh_LbR 0:e36f1973a674 79 PinName sec12_EpdReset,
Leigh_LbR 0:e36f1973a674 80 PinName sec13_EpdPanelOn,
Leigh_LbR 0:e36f1973a674 81 PinName sec14_EpdDischarge,
Leigh_LbR 0:e36f1973a674 82 const char* name = "EPD");
Leigh_LbR 0:e36f1973a674 83
Leigh_LbR 1:46dfef41919b 84 /** Get the width of the screen in pixel
Leigh_LbR 0:e36f1973a674 85 *
Leigh_LbR 0:e36f1973a674 86 * @param
Leigh_LbR 0:e36f1973a674 87 * @returns width of screen in pixel
Leigh_LbR 0:e36f1973a674 88 *
Leigh_LbR 0:e36f1973a674 89 */
Leigh_LbR 0:e36f1973a674 90 virtual int width();
Leigh_LbR 0:e36f1973a674 91
Leigh_LbR 0:e36f1973a674 92 /** Get the height of the screen in pixel
Leigh_LbR 0:e36f1973a674 93 *
Leigh_LbR 0:e36f1973a674 94 * @returns height of screen in pixel
Leigh_LbR 0:e36f1973a674 95 *
Leigh_LbR 0:e36f1973a674 96 */
Leigh_LbR 0:e36f1973a674 97 virtual int height();
Leigh_LbR 0:e36f1973a674 98
Leigh_LbR 0:e36f1973a674 99
Leigh_LbR 0:e36f1973a674 100 /**
Leigh_LbR 0:e36f1973a674 101 * Clear the display
Leigh_LbR 0:e36f1973a674 102 */
Leigh_LbR 0:e36f1973a674 103 void clear();
Leigh_LbR 0:e36f1973a674 104
Leigh_LbR 0:e36f1973a674 105 /**
Leigh_LbR 0:e36f1973a674 106 * Write image buffer to display
Leigh_LbR 0:e36f1973a674 107 */
Leigh_LbR 0:e36f1973a674 108 void write_disp(void);
Leigh_LbR 0:e36f1973a674 109
Leigh_LbR 0:e36f1973a674 110 /**
Leigh_LbR 0:e36f1973a674 111 * set or reset a single pixel
Leigh_LbR 0:e36f1973a674 112 *
Leigh_LbR 0:e36f1973a674 113 * @param x horizontal position
Leigh_LbR 0:e36f1973a674 114 * @param y vertical position
Leigh_LbR 0:e36f1973a674 115 * @param color : 0 white, 1 black
Leigh_LbR 0:e36f1973a674 116 */
Leigh_LbR 0:e36f1973a674 117 virtual void pixel(int x, int y, int color);
Leigh_LbR 0:e36f1973a674 118
Leigh_LbR 0:e36f1973a674 119 /** Fill the screen with white
Leigh_LbR 0:e36f1973a674 120 *
Leigh_LbR 0:e36f1973a674 121 */
Leigh_LbR 0:e36f1973a674 122 virtual void cls(void);
Leigh_LbR 0:e36f1973a674 123
Leigh_LbR 0:e36f1973a674 124 /** draw a 1 pixel line
Leigh_LbR 0:e36f1973a674 125 *
Leigh_LbR 0:e36f1973a674 126 * @param x0,y0 start point
Leigh_LbR 0:e36f1973a674 127 * @param x1,y1 stop point
Leigh_LbR 0:e36f1973a674 128 * @param color : 0 white, 1 black
Leigh_LbR 0:e36f1973a674 129 */
Leigh_LbR 0:e36f1973a674 130 void line(int x0, int y0, int x1, int y1, int color);
Leigh_LbR 0:e36f1973a674 131
Leigh_LbR 0:e36f1973a674 132 /** draw a rect
Leigh_LbR 0:e36f1973a674 133 *
Leigh_LbR 0:e36f1973a674 134 * @param x0,y0 top left corner
Leigh_LbR 0:e36f1973a674 135 * @param x1,y1 down right corner
Leigh_LbR 0:e36f1973a674 136 * @param color : 0 white, 1 black
Leigh_LbR 0:e36f1973a674 137 */
Leigh_LbR 0:e36f1973a674 138 void rect(int x0, int y0, int x1, int y1, int color);
Leigh_LbR 0:e36f1973a674 139
Leigh_LbR 0:e36f1973a674 140 /** draw a filled rect
Leigh_LbR 0:e36f1973a674 141 *
Leigh_LbR 0:e36f1973a674 142 * @param x0,y0 top left corner
Leigh_LbR 0:e36f1973a674 143 * @param x1,y1 down right corner
Leigh_LbR 0:e36f1973a674 144 * @param color : 0 white, 1 black
Leigh_LbR 0:e36f1973a674 145 */
Leigh_LbR 0:e36f1973a674 146 void fillrect(int x0, int y0, int x1, int y1, int color);
Leigh_LbR 0:e36f1973a674 147
Leigh_LbR 0:e36f1973a674 148 /** draw a circle
Leigh_LbR 0:e36f1973a674 149 *
Leigh_LbR 0:e36f1973a674 150 * @param x0,y0 center
Leigh_LbR 0:e36f1973a674 151 * @param r radius
Leigh_LbR 0:e36f1973a674 152 * @param color : 0 white, 1 black *
Leigh_LbR 0:e36f1973a674 153 */
Leigh_LbR 0:e36f1973a674 154 void circle(int x0, int y0, int r, int color);
Leigh_LbR 0:e36f1973a674 155
Leigh_LbR 0:e36f1973a674 156 /** draw a filled circle
Leigh_LbR 0:e36f1973a674 157 *
Leigh_LbR 0:e36f1973a674 158 * @param x0,y0 center
Leigh_LbR 0:e36f1973a674 159 * @param r radius
Leigh_LbR 0:e36f1973a674 160 * @param color : 0 white, 1 black *
Leigh_LbR 0:e36f1973a674 161 */
Leigh_LbR 0:e36f1973a674 162 void fillcircle(int x0, int y0, int r, int color);
Leigh_LbR 0:e36f1973a674 163
Leigh_LbR 0:e36f1973a674 164 /** set drawing mode
Leigh_LbR 0:e36f1973a674 165 * @param NORMAL : paint normal color, XOR : paint XOR of current pixels
Leigh_LbR 0:e36f1973a674 166 */
Leigh_LbR 0:e36f1973a674 167 void setmode(int mode);
Leigh_LbR 0:e36f1973a674 168
Leigh_LbR 0:e36f1973a674 169 /** setup cursor position
Leigh_LbR 0:e36f1973a674 170 *
Leigh_LbR 0:e36f1973a674 171 * @param x x-position (top left)
Leigh_LbR 0:e36f1973a674 172 * @param y y-position
Leigh_LbR 0:e36f1973a674 173 */
Leigh_LbR 0:e36f1973a674 174 virtual void locate(int x, int y);
Leigh_LbR 0:e36f1973a674 175
Leigh_LbR 0:e36f1973a674 176 /** calculate the max number of char in a line
Leigh_LbR 0:e36f1973a674 177 *
Leigh_LbR 0:e36f1973a674 178 * @returns max columns
Leigh_LbR 0:e36f1973a674 179 * depends on actual font size
Leigh_LbR 0:e36f1973a674 180 */
Leigh_LbR 0:e36f1973a674 181 virtual int columns();
Leigh_LbR 0:e36f1973a674 182
Leigh_LbR 0:e36f1973a674 183 /** calculate the max number of columns
Leigh_LbR 0:e36f1973a674 184 *
Leigh_LbR 0:e36f1973a674 185 * @returns max column
Leigh_LbR 0:e36f1973a674 186 * depends on actual font size
Leigh_LbR 0:e36f1973a674 187 */
Leigh_LbR 0:e36f1973a674 188 virtual int rows();
Leigh_LbR 0:e36f1973a674 189
Leigh_LbR 0:e36f1973a674 190 /** put a char on the screen
Leigh_LbR 0:e36f1973a674 191 *
Leigh_LbR 0:e36f1973a674 192 * @param value char to print
Leigh_LbR 0:e36f1973a674 193 * @returns printed char
Leigh_LbR 0:e36f1973a674 194 */
Leigh_LbR 0:e36f1973a674 195 virtual int _putc(int value);
Leigh_LbR 0:e36f1973a674 196
Leigh_LbR 0:e36f1973a674 197 /** paint a character on given position out of the active font to the screen buffer
Leigh_LbR 0:e36f1973a674 198 *
Leigh_LbR 0:e36f1973a674 199 * @param x x-position (top left)
Leigh_LbR 0:e36f1973a674 200 * @param y y-position
Leigh_LbR 0:e36f1973a674 201 * @param c char code
Leigh_LbR 0:e36f1973a674 202 */
Leigh_LbR 0:e36f1973a674 203 virtual void character(int x, int y, int c);
Leigh_LbR 0:e36f1973a674 204
Leigh_LbR 0:e36f1973a674 205 /** select the font to use
Leigh_LbR 0:e36f1973a674 206 *
Leigh_LbR 0:e36f1973a674 207 * @param f pointer to font array
Leigh_LbR 0:e36f1973a674 208 *
Leigh_LbR 0:e36f1973a674 209 * font array can created with GLCD Font Creator from http://www.mikroe.com
Leigh_LbR 0:e36f1973a674 210 * you have to add 4 parameter at the beginning of the font array to use:
Leigh_LbR 0:e36f1973a674 211 * - the number of byte / char
Leigh_LbR 0:e36f1973a674 212 * - the vertial size in pixel
Leigh_LbR 0:e36f1973a674 213 * - the horizontal size in pixel
Leigh_LbR 0:e36f1973a674 214 * - the number of byte per vertical line
Leigh_LbR 0:e36f1973a674 215 * you also have to change the array to char[]
Leigh_LbR 0:e36f1973a674 216 */
Leigh_LbR 0:e36f1973a674 217 void set_font(unsigned char* f);
Leigh_LbR 0:e36f1973a674 218
Leigh_LbR 0:e36f1973a674 219 /** print bitmap to buffer
Leigh_LbR 0:e36f1973a674 220 *
Leigh_LbR 0:e36f1973a674 221 * @param bm struct Bitmap in flash
Leigh_LbR 0:e36f1973a674 222 * @param x x start
Leigh_LbR 0:e36f1973a674 223 * @param y y start
Leigh_LbR 0:e36f1973a674 224 *
Leigh_LbR 0:e36f1973a674 225 */
Leigh_LbR 0:e36f1973a674 226 void print_bm(Bitmap bm, int x, int y);
Leigh_LbR 0:e36f1973a674 227
Leigh_LbR 1:46dfef41919b 228 /** write raw characters to the display
Leigh_LbR 1:46dfef41919b 229 * @param img array of raw image data
Leigh_LbR 1:46dfef41919b 230 */
Leigh_LbR 0:e36f1973a674 231 void drawImage(uint8_t* img);
Leigh_LbR 0:e36f1973a674 232
Leigh_LbR 0:e36f1973a674 233 unsigned char* font;
Leigh_LbR 0:e36f1973a674 234 unsigned int draw_mode;
Leigh_LbR 0:e36f1973a674 235
Leigh_LbR 0:e36f1973a674 236 private:
Leigh_LbR 0:e36f1973a674 237
Leigh_LbR 0:e36f1973a674 238 EM027BS013 _epd;
Leigh_LbR 0:e36f1973a674 239 unsigned int char_x;
Leigh_LbR 0:e36f1973a674 240 unsigned int char_y;
Leigh_LbR 0:e36f1973a674 241
Leigh_LbR 0:e36f1973a674 242 };
Leigh_LbR 0:e36f1973a674 243
Leigh_LbR 0:e36f1973a674 244
Leigh_LbR 0:e36f1973a674 245 #endif