Driver to control the EM027BS013 board from Embedded Artists
Embed:
(wiki syntax)
Show/hide line numbers
EaEpaper.h
00001 /* Driver for the 2.7" EM027BS013 E-Paper display produced by Pervasive Displays. 00002 * Based off of the 2.7" EM027AS182 display driver produced by Peter Drescher, but with key differences to use the newer Pervasive Displays driver. 00003 * Copyright notice is below for original driver; this is distributed under the same license. 00004 * 00005 * mbed library for 264*176 pixel 2.7 INCH E-PAPER DISPLAY from Pervasive Displays 00006 * Copyright (c) 2013 Peter Drescher - DC2PD 00007 * 00008 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00009 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00010 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00011 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00012 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00013 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00014 * THE SOFTWARE. 00015 */ 00016 00017 #ifndef EAEPAPER_H 00018 #define EAEPAPER_H 00019 00020 /** 00021 * Includes 00022 */ 00023 #include "GraphicsDisplay.h" 00024 #include "EM027BS013.h" 00025 #include "mbed.h" 00026 00027 // we have to double buffer the display 00028 #define EA_IMG_BUF_SZ (5808) // 264 x 176 / 8 = 5808 00029 00030 /** Draw mode 00031 * NORMAl 00032 * XOR set pixel by xor of the screen 00033 */ 00034 enum {NORMAL,XOR}; 00035 00036 /** Bitmap 00037 */ 00038 struct Bitmap{ 00039 int xSize; 00040 int ySize; 00041 int Byte_in_Line; 00042 char* data; 00043 }; 00044 00045 00046 /* color definitions */ 00047 #define Black 0x0 00048 #define White 0x1 00049 00050 /** 00051 * Main driver class to drive the EA027BS023 E-Paper display. 00052 */ 00053 class EaEpaper : public GraphicsDisplay 00054 { 00055 public: 00056 /** EaEpaper constructor. 00057 * @param sec03_SpiSCK the SPI SCK pin 00058 * @param sec04_SpiMOSI the SPI MOSI pin 00059 * @param sec05_SpiMISO the SPI MISO pin 00060 * @param sec06_EpdCS the SPI chip select pin connected to the display 00061 * @param sec07_EpdBusy the pin connected to the busy pin on the display 00062 * @param sec08_EpdBorder the pin connected to the border pin on the display 00063 * @param sec09_I2cSCL the I2C SCL pin 00064 * @param sec10_I2cSDA the I2C SDA pin 00065 * @param sec11_FlashCS the Flash Chip Select pin connected to the display 00066 * @param sec12_EpdReset the reset pin connected to the display 00067 * @param sec13_EpdPanelOn the power pin connected to the display 00068 * @param sec14_EpdDischarge the discharge pin connected to the display 00069 */ 00070 EaEpaper(PinName sec03_SpiSCK, 00071 PinName sec04_SpiMOSI, 00072 PinName sec05_SpiMISO, 00073 PinName sec06_EpdCS, 00074 PinName sec07_EpdBusy, 00075 PinName sec08_EpdBorder, 00076 PinName sec09_I2cSCL, 00077 PinName sec10_I2cSDA, 00078 PinName sec11_FlashCS, 00079 PinName sec12_EpdReset, 00080 PinName sec13_EpdPanelOn, 00081 PinName sec14_EpdDischarge, 00082 const char* name = "EPD"); 00083 00084 /** Get the width of the screen in pixel 00085 * 00086 * @param 00087 * @returns width of screen in pixel 00088 * 00089 */ 00090 virtual int width(); 00091 00092 /** Get the height of the screen in pixel 00093 * 00094 * @returns height of screen in pixel 00095 * 00096 */ 00097 virtual int height(); 00098 00099 00100 /** 00101 * Clear the display 00102 */ 00103 void clear(); 00104 00105 /** 00106 * Write image buffer to display 00107 */ 00108 void write_disp(void); 00109 00110 /** 00111 * set or reset a single pixel 00112 * 00113 * @param x horizontal position 00114 * @param y vertical position 00115 * @param color : 0 white, 1 black 00116 */ 00117 virtual void pixel(int x, int y, int color); 00118 00119 /** Fill the screen with white 00120 * 00121 */ 00122 virtual void cls(void); 00123 00124 /** draw a 1 pixel line 00125 * 00126 * @param x0,y0 start point 00127 * @param x1,y1 stop point 00128 * @param color : 0 white, 1 black 00129 */ 00130 void line(int x0, int y0, int x1, int y1, int color); 00131 00132 /** draw a rect 00133 * 00134 * @param x0,y0 top left corner 00135 * @param x1,y1 down right corner 00136 * @param color : 0 white, 1 black 00137 */ 00138 void rect(int x0, int y0, int x1, int y1, int color); 00139 00140 /** draw a filled rect 00141 * 00142 * @param x0,y0 top left corner 00143 * @param x1,y1 down right corner 00144 * @param color : 0 white, 1 black 00145 */ 00146 void fillrect(int x0, int y0, int x1, int y1, int color); 00147 00148 /** draw a circle 00149 * 00150 * @param x0,y0 center 00151 * @param r radius 00152 * @param color : 0 white, 1 black * 00153 */ 00154 void circle(int x0, int y0, int r, int color); 00155 00156 /** draw a filled circle 00157 * 00158 * @param x0,y0 center 00159 * @param r radius 00160 * @param color : 0 white, 1 black * 00161 */ 00162 void fillcircle(int x0, int y0, int r, int color); 00163 00164 /** set drawing mode 00165 * @param NORMAL : paint normal color, XOR : paint XOR of current pixels 00166 */ 00167 void setmode(int mode); 00168 00169 /** setup cursor position 00170 * 00171 * @param x x-position (top left) 00172 * @param y y-position 00173 */ 00174 virtual void locate(int x, int y); 00175 00176 /** calculate the max number of char in a line 00177 * 00178 * @returns max columns 00179 * depends on actual font size 00180 */ 00181 virtual int columns(); 00182 00183 /** calculate the max number of columns 00184 * 00185 * @returns max column 00186 * depends on actual font size 00187 */ 00188 virtual int rows(); 00189 00190 /** put a char on the screen 00191 * 00192 * @param value char to print 00193 * @returns printed char 00194 */ 00195 virtual int _putc(int value); 00196 00197 /** paint a character on given position out of the active font to the screen buffer 00198 * 00199 * @param x x-position (top left) 00200 * @param y y-position 00201 * @param c char code 00202 */ 00203 virtual void character(int x, int y, int c); 00204 00205 /** select the font to use 00206 * 00207 * @param f pointer to font array 00208 * 00209 * font array can created with GLCD Font Creator from http://www.mikroe.com 00210 * you have to add 4 parameter at the beginning of the font array to use: 00211 * - the number of byte / char 00212 * - the vertial size in pixel 00213 * - the horizontal size in pixel 00214 * - the number of byte per vertical line 00215 * you also have to change the array to char[] 00216 */ 00217 void set_font(unsigned char* f); 00218 00219 /** print bitmap to buffer 00220 * 00221 * @param bm struct Bitmap in flash 00222 * @param x x start 00223 * @param y y start 00224 * 00225 */ 00226 void print_bm(Bitmap bm, int x, int y); 00227 00228 /** write raw characters to the display 00229 * @param img array of raw image data 00230 */ 00231 void drawImage(uint8_t* img); 00232 00233 unsigned char* font; 00234 unsigned int draw_mode; 00235 00236 private: 00237 00238 EM027BS013 _epd; 00239 unsigned int char_x; 00240 unsigned int char_y; 00241 00242 }; 00243 00244 00245 #endif
Generated on Wed Jul 13 2022 18:48:29 by 1.7.2