Driver to control the EM027BS013 board from Embedded Artists
EM027BS013 Simple Driver
This library provides an easy way to write data to the EM027BS013 display, by providing interfaces to common C functions and methods. The library was originally written by Peter Drescher, who created the "EaEpaper" library for the EM027AS012 display (available here, but adapted to use the newer display type and driver (available here), as the existing display is now discontinued.
Big thanks go to the team from Pervasive Displays and Electronic Artists for producing such a nice display, and to Peter for providing the initial interface used in this driver.
EaEpaper.cpp@0:e36f1973a674, 2016-05-09 (annotated)
- Committer:
- Leigh_LbR
- Date:
- Mon May 09 12:29:02 2016 +0000
- Revision:
- 0:e36f1973a674
Created initial display driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Leigh_LbR | 0:e36f1973a674 | 1 | |
Leigh_LbR | 0:e36f1973a674 | 2 | #include "EaEpaper.h" |
Leigh_LbR | 0:e36f1973a674 | 3 | |
Leigh_LbR | 0:e36f1973a674 | 4 | #define EA_IMG_BUF_SZ (5808) // 264 x 176 / 8 = 5808 |
Leigh_LbR | 0:e36f1973a674 | 5 | |
Leigh_LbR | 0:e36f1973a674 | 6 | #define LM75A_ADDRESS (0x92) // 0x49 << 1 |
Leigh_LbR | 0:e36f1973a674 | 7 | #define LM75A_CMD_TEMP 0x00 |
Leigh_LbR | 0:e36f1973a674 | 8 | |
Leigh_LbR | 0:e36f1973a674 | 9 | static uint8_t _image[EA_IMG_BUF_SZ]; |
Leigh_LbR | 0:e36f1973a674 | 10 | |
Leigh_LbR | 0:e36f1973a674 | 11 | EaEpaper::EaEpaper(PinName sec03_SpiSCK, |
Leigh_LbR | 0:e36f1973a674 | 12 | PinName sec04_SpiMOSI, |
Leigh_LbR | 0:e36f1973a674 | 13 | PinName sec05_SpiMISO, |
Leigh_LbR | 0:e36f1973a674 | 14 | PinName sec06_EpdCS, |
Leigh_LbR | 0:e36f1973a674 | 15 | PinName sec07_EpdBusy, |
Leigh_LbR | 0:e36f1973a674 | 16 | PinName sec08_EpdBorder, |
Leigh_LbR | 0:e36f1973a674 | 17 | PinName sec09_I2cSCL, |
Leigh_LbR | 0:e36f1973a674 | 18 | PinName sec10_I2cSDA, |
Leigh_LbR | 0:e36f1973a674 | 19 | PinName sec11_FlashCS, |
Leigh_LbR | 0:e36f1973a674 | 20 | PinName sec12_EpdReset, |
Leigh_LbR | 0:e36f1973a674 | 21 | PinName sec13_EpdPanelOn, |
Leigh_LbR | 0:e36f1973a674 | 22 | PinName sec14_EpdDischarge, |
Leigh_LbR | 0:e36f1973a674 | 23 | const char* name) : |
Leigh_LbR | 0:e36f1973a674 | 24 | _epd(sec03_SpiSCK, |
Leigh_LbR | 0:e36f1973a674 | 25 | sec04_SpiMOSI, |
Leigh_LbR | 0:e36f1973a674 | 26 | sec05_SpiMISO, |
Leigh_LbR | 0:e36f1973a674 | 27 | sec06_EpdCS, |
Leigh_LbR | 0:e36f1973a674 | 28 | sec07_EpdBusy, |
Leigh_LbR | 0:e36f1973a674 | 29 | sec08_EpdBorder, |
Leigh_LbR | 0:e36f1973a674 | 30 | sec09_I2cSCL, |
Leigh_LbR | 0:e36f1973a674 | 31 | sec10_I2cSDA, |
Leigh_LbR | 0:e36f1973a674 | 32 | sec11_FlashCS, |
Leigh_LbR | 0:e36f1973a674 | 33 | sec12_EpdReset, |
Leigh_LbR | 0:e36f1973a674 | 34 | sec13_EpdPanelOn, |
Leigh_LbR | 0:e36f1973a674 | 35 | sec14_EpdDischarge), |
Leigh_LbR | 0:e36f1973a674 | 36 | GraphicsDisplay(name) |
Leigh_LbR | 0:e36f1973a674 | 37 | { |
Leigh_LbR | 0:e36f1973a674 | 38 | draw_mode = NORMAL; |
Leigh_LbR | 0:e36f1973a674 | 39 | memset(_image, 255, EA_IMG_BUF_SZ); |
Leigh_LbR | 0:e36f1973a674 | 40 | } |
Leigh_LbR | 0:e36f1973a674 | 41 | |
Leigh_LbR | 0:e36f1973a674 | 42 | int EaEpaper::width() |
Leigh_LbR | 0:e36f1973a674 | 43 | { |
Leigh_LbR | 0:e36f1973a674 | 44 | return 264; |
Leigh_LbR | 0:e36f1973a674 | 45 | } |
Leigh_LbR | 0:e36f1973a674 | 46 | |
Leigh_LbR | 0:e36f1973a674 | 47 | int EaEpaper::height() |
Leigh_LbR | 0:e36f1973a674 | 48 | { |
Leigh_LbR | 0:e36f1973a674 | 49 | return 176; |
Leigh_LbR | 0:e36f1973a674 | 50 | } |
Leigh_LbR | 0:e36f1973a674 | 51 | |
Leigh_LbR | 0:e36f1973a674 | 52 | // erase pixel after power up |
Leigh_LbR | 0:e36f1973a674 | 53 | void EaEpaper::clear() |
Leigh_LbR | 0:e36f1973a674 | 54 | { |
Leigh_LbR | 0:e36f1973a674 | 55 | memset(_image, 255, EA_IMG_BUF_SZ); |
Leigh_LbR | 0:e36f1973a674 | 56 | |
Leigh_LbR | 0:e36f1973a674 | 57 | _epd.drawImage(_image); |
Leigh_LbR | 0:e36f1973a674 | 58 | } |
Leigh_LbR | 0:e36f1973a674 | 59 | |
Leigh_LbR | 0:e36f1973a674 | 60 | // update screen |
Leigh_LbR | 0:e36f1973a674 | 61 | void EaEpaper::write_disp(void) |
Leigh_LbR | 0:e36f1973a674 | 62 | { |
Leigh_LbR | 0:e36f1973a674 | 63 | _epd.drawImage(_image); |
Leigh_LbR | 0:e36f1973a674 | 64 | } |
Leigh_LbR | 0:e36f1973a674 | 65 | |
Leigh_LbR | 0:e36f1973a674 | 66 | // set one pixel in buffer _image |
Leigh_LbR | 0:e36f1973a674 | 67 | |
Leigh_LbR | 0:e36f1973a674 | 68 | void EaEpaper::pixel(int x, int y, int color) |
Leigh_LbR | 0:e36f1973a674 | 69 | { |
Leigh_LbR | 0:e36f1973a674 | 70 | // first check parameter |
Leigh_LbR | 0:e36f1973a674 | 71 | if(x > 263 || y > 175 || x < 0 || y < 0) return; |
Leigh_LbR | 0:e36f1973a674 | 72 | |
Leigh_LbR | 0:e36f1973a674 | 73 | if(draw_mode == NORMAL) { |
Leigh_LbR | 0:e36f1973a674 | 74 | if(color == 0) |
Leigh_LbR | 0:e36f1973a674 | 75 | _image[(x / 8) + ((y-1) * 33)] &= ~(1 << (x%8)); // erase pixel |
Leigh_LbR | 0:e36f1973a674 | 76 | //_image[(x / 8) + ((y-1) * 33)] = (1 << (x%8)); |
Leigh_LbR | 0:e36f1973a674 | 77 | else |
Leigh_LbR | 0:e36f1973a674 | 78 | _image[(x / 8) + ((y-1) * 33)] |= (1 << (x%8)); // set pixel |
Leigh_LbR | 0:e36f1973a674 | 79 | //_image[(x / 8) + ((y-1) * 33)] = 0; |
Leigh_LbR | 0:e36f1973a674 | 80 | } else { // XOR mode |
Leigh_LbR | 0:e36f1973a674 | 81 | if(color == 1) |
Leigh_LbR | 0:e36f1973a674 | 82 | _image[(x / 8) + ((y-1) * 33)] ^= (1 << (x%8)); // xor pixel |
Leigh_LbR | 0:e36f1973a674 | 83 | //_image[(x / 8) + ((y-1) * 33)] ^= 0; |
Leigh_LbR | 0:e36f1973a674 | 84 | } |
Leigh_LbR | 0:e36f1973a674 | 85 | } |
Leigh_LbR | 0:e36f1973a674 | 86 | |
Leigh_LbR | 0:e36f1973a674 | 87 | // clear screen |
Leigh_LbR | 0:e36f1973a674 | 88 | void EaEpaper::cls(void) |
Leigh_LbR | 0:e36f1973a674 | 89 | { |
Leigh_LbR | 0:e36f1973a674 | 90 | memset(_image, 255, EA_IMG_BUF_SZ); // clear display buffer |
Leigh_LbR | 0:e36f1973a674 | 91 | } |
Leigh_LbR | 0:e36f1973a674 | 92 | |
Leigh_LbR | 0:e36f1973a674 | 93 | // print line |
Leigh_LbR | 0:e36f1973a674 | 94 | void EaEpaper::line(int x0, int y0, int x1, int y1, int color) |
Leigh_LbR | 0:e36f1973a674 | 95 | { |
Leigh_LbR | 0:e36f1973a674 | 96 | int dx = 0, dy = 0; |
Leigh_LbR | 0:e36f1973a674 | 97 | int dx_sym = 0, dy_sym = 0; |
Leigh_LbR | 0:e36f1973a674 | 98 | int dx_x2 = 0, dy_x2 = 0; |
Leigh_LbR | 0:e36f1973a674 | 99 | int di = 0; |
Leigh_LbR | 0:e36f1973a674 | 100 | |
Leigh_LbR | 0:e36f1973a674 | 101 | dx = x1-x0; |
Leigh_LbR | 0:e36f1973a674 | 102 | dy = y1-y0; |
Leigh_LbR | 0:e36f1973a674 | 103 | |
Leigh_LbR | 0:e36f1973a674 | 104 | if (dx > 0) { |
Leigh_LbR | 0:e36f1973a674 | 105 | dx_sym = 1; |
Leigh_LbR | 0:e36f1973a674 | 106 | } else { |
Leigh_LbR | 0:e36f1973a674 | 107 | dx_sym = -1; |
Leigh_LbR | 0:e36f1973a674 | 108 | } |
Leigh_LbR | 0:e36f1973a674 | 109 | |
Leigh_LbR | 0:e36f1973a674 | 110 | if (dy > 0) { |
Leigh_LbR | 0:e36f1973a674 | 111 | dy_sym = 1; |
Leigh_LbR | 0:e36f1973a674 | 112 | } else { |
Leigh_LbR | 0:e36f1973a674 | 113 | dy_sym = -1; |
Leigh_LbR | 0:e36f1973a674 | 114 | } |
Leigh_LbR | 0:e36f1973a674 | 115 | |
Leigh_LbR | 0:e36f1973a674 | 116 | dx = dx_sym*dx; |
Leigh_LbR | 0:e36f1973a674 | 117 | dy = dy_sym*dy; |
Leigh_LbR | 0:e36f1973a674 | 118 | |
Leigh_LbR | 0:e36f1973a674 | 119 | dx_x2 = dx*2; |
Leigh_LbR | 0:e36f1973a674 | 120 | dy_x2 = dy*2; |
Leigh_LbR | 0:e36f1973a674 | 121 | |
Leigh_LbR | 0:e36f1973a674 | 122 | if (dx >= dy) { |
Leigh_LbR | 0:e36f1973a674 | 123 | di = dy_x2 - dx; |
Leigh_LbR | 0:e36f1973a674 | 124 | while (x0 != x1) { |
Leigh_LbR | 0:e36f1973a674 | 125 | |
Leigh_LbR | 0:e36f1973a674 | 126 | pixel(x0, y0, color); |
Leigh_LbR | 0:e36f1973a674 | 127 | x0 += dx_sym; |
Leigh_LbR | 0:e36f1973a674 | 128 | if (di<0) { |
Leigh_LbR | 0:e36f1973a674 | 129 | di += dy_x2; |
Leigh_LbR | 0:e36f1973a674 | 130 | } else { |
Leigh_LbR | 0:e36f1973a674 | 131 | di += dy_x2 - dx_x2; |
Leigh_LbR | 0:e36f1973a674 | 132 | y0 += dy_sym; |
Leigh_LbR | 0:e36f1973a674 | 133 | } |
Leigh_LbR | 0:e36f1973a674 | 134 | } |
Leigh_LbR | 0:e36f1973a674 | 135 | pixel(x0, y0, color); |
Leigh_LbR | 0:e36f1973a674 | 136 | } else { |
Leigh_LbR | 0:e36f1973a674 | 137 | di = dx_x2 - dy; |
Leigh_LbR | 0:e36f1973a674 | 138 | while (y0 != y1) { |
Leigh_LbR | 0:e36f1973a674 | 139 | pixel(x0, y0, color); |
Leigh_LbR | 0:e36f1973a674 | 140 | y0 += dy_sym; |
Leigh_LbR | 0:e36f1973a674 | 141 | if (di < 0) { |
Leigh_LbR | 0:e36f1973a674 | 142 | di += dx_x2; |
Leigh_LbR | 0:e36f1973a674 | 143 | } else { |
Leigh_LbR | 0:e36f1973a674 | 144 | di += dx_x2 - dy_x2; |
Leigh_LbR | 0:e36f1973a674 | 145 | x0 += dx_sym; |
Leigh_LbR | 0:e36f1973a674 | 146 | } |
Leigh_LbR | 0:e36f1973a674 | 147 | } |
Leigh_LbR | 0:e36f1973a674 | 148 | pixel(x0, y0, color); |
Leigh_LbR | 0:e36f1973a674 | 149 | } |
Leigh_LbR | 0:e36f1973a674 | 150 | } |
Leigh_LbR | 0:e36f1973a674 | 151 | |
Leigh_LbR | 0:e36f1973a674 | 152 | |
Leigh_LbR | 0:e36f1973a674 | 153 | // print filled rect |
Leigh_LbR | 0:e36f1973a674 | 154 | void EaEpaper::fillrect(int x0, int y0, int x1, int y1, int color) |
Leigh_LbR | 0:e36f1973a674 | 155 | { |
Leigh_LbR | 0:e36f1973a674 | 156 | int l,c,i; |
Leigh_LbR | 0:e36f1973a674 | 157 | if(x0 > x1) { |
Leigh_LbR | 0:e36f1973a674 | 158 | i = x0; |
Leigh_LbR | 0:e36f1973a674 | 159 | x0 = x1; |
Leigh_LbR | 0:e36f1973a674 | 160 | x1 = i; |
Leigh_LbR | 0:e36f1973a674 | 161 | } |
Leigh_LbR | 0:e36f1973a674 | 162 | |
Leigh_LbR | 0:e36f1973a674 | 163 | if(y0 > y1) { |
Leigh_LbR | 0:e36f1973a674 | 164 | i = y0; |
Leigh_LbR | 0:e36f1973a674 | 165 | y0 = y1; |
Leigh_LbR | 0:e36f1973a674 | 166 | y1 = i; |
Leigh_LbR | 0:e36f1973a674 | 167 | } |
Leigh_LbR | 0:e36f1973a674 | 168 | |
Leigh_LbR | 0:e36f1973a674 | 169 | for(l = x0; l<= x1; l ++) { |
Leigh_LbR | 0:e36f1973a674 | 170 | for(c = y0; c<= y1; c++) { |
Leigh_LbR | 0:e36f1973a674 | 171 | pixel(l,c,color); |
Leigh_LbR | 0:e36f1973a674 | 172 | } |
Leigh_LbR | 0:e36f1973a674 | 173 | } |
Leigh_LbR | 0:e36f1973a674 | 174 | } |
Leigh_LbR | 0:e36f1973a674 | 175 | |
Leigh_LbR | 0:e36f1973a674 | 176 | // print circle |
Leigh_LbR | 0:e36f1973a674 | 177 | void EaEpaper::circle(int x0, int y0, int r, int color) |
Leigh_LbR | 0:e36f1973a674 | 178 | { |
Leigh_LbR | 0:e36f1973a674 | 179 | int x = -r, y = 0, err = 2-2*r, e2; |
Leigh_LbR | 0:e36f1973a674 | 180 | do { |
Leigh_LbR | 0:e36f1973a674 | 181 | pixel(x0-x, y0+y,color); |
Leigh_LbR | 0:e36f1973a674 | 182 | pixel(x0+x, y0+y,color); |
Leigh_LbR | 0:e36f1973a674 | 183 | pixel(x0+x, y0-y,color); |
Leigh_LbR | 0:e36f1973a674 | 184 | pixel(x0-x, y0-y,color); |
Leigh_LbR | 0:e36f1973a674 | 185 | e2 = err; |
Leigh_LbR | 0:e36f1973a674 | 186 | if (e2 <= y) { |
Leigh_LbR | 0:e36f1973a674 | 187 | err += ++y*2+1; |
Leigh_LbR | 0:e36f1973a674 | 188 | if (-x == y && e2 <= x) e2 = 0; |
Leigh_LbR | 0:e36f1973a674 | 189 | } |
Leigh_LbR | 0:e36f1973a674 | 190 | if (e2 > x) err += ++x*2+1; |
Leigh_LbR | 0:e36f1973a674 | 191 | } while (x <= 0); |
Leigh_LbR | 0:e36f1973a674 | 192 | |
Leigh_LbR | 0:e36f1973a674 | 193 | } |
Leigh_LbR | 0:e36f1973a674 | 194 | |
Leigh_LbR | 0:e36f1973a674 | 195 | // print filled circle |
Leigh_LbR | 0:e36f1973a674 | 196 | void EaEpaper::fillcircle(int x0, int y0, int r, int color) |
Leigh_LbR | 0:e36f1973a674 | 197 | { |
Leigh_LbR | 0:e36f1973a674 | 198 | int x = -r, y = 0, err = 2-2*r, e2; |
Leigh_LbR | 0:e36f1973a674 | 199 | do { |
Leigh_LbR | 0:e36f1973a674 | 200 | line(x0-x, y0-y, x0-x, y0+y, color); |
Leigh_LbR | 0:e36f1973a674 | 201 | line(x0+x, y0-y, x0+x, y0+y, color); |
Leigh_LbR | 0:e36f1973a674 | 202 | e2 = err; |
Leigh_LbR | 0:e36f1973a674 | 203 | if (e2 <= y) { |
Leigh_LbR | 0:e36f1973a674 | 204 | err += ++y*2+1; |
Leigh_LbR | 0:e36f1973a674 | 205 | if (-x == y && e2 <= x) e2 = 0; |
Leigh_LbR | 0:e36f1973a674 | 206 | } |
Leigh_LbR | 0:e36f1973a674 | 207 | if (e2 > x) err += ++x*2+1; |
Leigh_LbR | 0:e36f1973a674 | 208 | } while (x <= 0); |
Leigh_LbR | 0:e36f1973a674 | 209 | } |
Leigh_LbR | 0:e36f1973a674 | 210 | |
Leigh_LbR | 0:e36f1973a674 | 211 | // set drawing mode |
Leigh_LbR | 0:e36f1973a674 | 212 | void EaEpaper::setmode(int mode) |
Leigh_LbR | 0:e36f1973a674 | 213 | { |
Leigh_LbR | 0:e36f1973a674 | 214 | draw_mode = mode; |
Leigh_LbR | 0:e36f1973a674 | 215 | } |
Leigh_LbR | 0:e36f1973a674 | 216 | |
Leigh_LbR | 0:e36f1973a674 | 217 | // set cursor position |
Leigh_LbR | 0:e36f1973a674 | 218 | void EaEpaper::locate(int x, int y) |
Leigh_LbR | 0:e36f1973a674 | 219 | { |
Leigh_LbR | 0:e36f1973a674 | 220 | char_x = x; |
Leigh_LbR | 0:e36f1973a674 | 221 | char_y = y; |
Leigh_LbR | 0:e36f1973a674 | 222 | } |
Leigh_LbR | 0:e36f1973a674 | 223 | |
Leigh_LbR | 0:e36f1973a674 | 224 | // calc char columns |
Leigh_LbR | 0:e36f1973a674 | 225 | int EaEpaper::columns() |
Leigh_LbR | 0:e36f1973a674 | 226 | { |
Leigh_LbR | 0:e36f1973a674 | 227 | return width() / font[1]; |
Leigh_LbR | 0:e36f1973a674 | 228 | } |
Leigh_LbR | 0:e36f1973a674 | 229 | |
Leigh_LbR | 0:e36f1973a674 | 230 | // calc char rows |
Leigh_LbR | 0:e36f1973a674 | 231 | int EaEpaper::rows() |
Leigh_LbR | 0:e36f1973a674 | 232 | { |
Leigh_LbR | 0:e36f1973a674 | 233 | return height() / font[2]; |
Leigh_LbR | 0:e36f1973a674 | 234 | } |
Leigh_LbR | 0:e36f1973a674 | 235 | |
Leigh_LbR | 0:e36f1973a674 | 236 | // print char |
Leigh_LbR | 0:e36f1973a674 | 237 | int EaEpaper::_putc(int value) |
Leigh_LbR | 0:e36f1973a674 | 238 | { |
Leigh_LbR | 0:e36f1973a674 | 239 | if (value == '\n') { // new line |
Leigh_LbR | 0:e36f1973a674 | 240 | char_x = 0; |
Leigh_LbR | 0:e36f1973a674 | 241 | char_y = char_y + font[2]; |
Leigh_LbR | 0:e36f1973a674 | 242 | if (char_y >= height() - font[2]) { |
Leigh_LbR | 0:e36f1973a674 | 243 | char_y = 0; |
Leigh_LbR | 0:e36f1973a674 | 244 | } |
Leigh_LbR | 0:e36f1973a674 | 245 | } else { |
Leigh_LbR | 0:e36f1973a674 | 246 | character(char_x, char_y, value); |
Leigh_LbR | 0:e36f1973a674 | 247 | } |
Leigh_LbR | 0:e36f1973a674 | 248 | return value; |
Leigh_LbR | 0:e36f1973a674 | 249 | } |
Leigh_LbR | 0:e36f1973a674 | 250 | |
Leigh_LbR | 0:e36f1973a674 | 251 | // paint char out of font |
Leigh_LbR | 0:e36f1973a674 | 252 | void EaEpaper::character(int x, int y, int c) |
Leigh_LbR | 0:e36f1973a674 | 253 | { |
Leigh_LbR | 0:e36f1973a674 | 254 | unsigned int hor,vert,offset,bpl,j,i,b; |
Leigh_LbR | 0:e36f1973a674 | 255 | unsigned char* zeichen; |
Leigh_LbR | 0:e36f1973a674 | 256 | unsigned char z,w; |
Leigh_LbR | 0:e36f1973a674 | 257 | |
Leigh_LbR | 0:e36f1973a674 | 258 | if ((c < 31) || (c > 127)) return; // test char range |
Leigh_LbR | 0:e36f1973a674 | 259 | |
Leigh_LbR | 0:e36f1973a674 | 260 | // read font parameter from start of array |
Leigh_LbR | 0:e36f1973a674 | 261 | offset = font[0]; // bytes / char |
Leigh_LbR | 0:e36f1973a674 | 262 | hor = font[1]; // get hor size of font |
Leigh_LbR | 0:e36f1973a674 | 263 | vert = font[2]; // get vert size of font |
Leigh_LbR | 0:e36f1973a674 | 264 | bpl = font[3]; // bytes per line |
Leigh_LbR | 0:e36f1973a674 | 265 | |
Leigh_LbR | 0:e36f1973a674 | 266 | if (char_x + hor > width()) { |
Leigh_LbR | 0:e36f1973a674 | 267 | char_x = 0; |
Leigh_LbR | 0:e36f1973a674 | 268 | char_y = char_y + vert; |
Leigh_LbR | 0:e36f1973a674 | 269 | if (char_y >= height() - font[2]) { |
Leigh_LbR | 0:e36f1973a674 | 270 | char_y = 0; |
Leigh_LbR | 0:e36f1973a674 | 271 | } |
Leigh_LbR | 0:e36f1973a674 | 272 | } |
Leigh_LbR | 0:e36f1973a674 | 273 | |
Leigh_LbR | 0:e36f1973a674 | 274 | zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap |
Leigh_LbR | 0:e36f1973a674 | 275 | w = zeichen[0]; // width of actual char |
Leigh_LbR | 0:e36f1973a674 | 276 | // construct the char into the buffer |
Leigh_LbR | 0:e36f1973a674 | 277 | for (j=0; j<vert; j++) { // vert line |
Leigh_LbR | 0:e36f1973a674 | 278 | for (i=0; i<hor; i++) { // horz line |
Leigh_LbR | 0:e36f1973a674 | 279 | z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; |
Leigh_LbR | 0:e36f1973a674 | 280 | b = 1 << (j & 0x07); |
Leigh_LbR | 0:e36f1973a674 | 281 | if (( z & b ) == 0x00) { |
Leigh_LbR | 0:e36f1973a674 | 282 | pixel(x+i,y+j,0); |
Leigh_LbR | 0:e36f1973a674 | 283 | } else { |
Leigh_LbR | 0:e36f1973a674 | 284 | pixel(x+i,y+j,1); |
Leigh_LbR | 0:e36f1973a674 | 285 | } |
Leigh_LbR | 0:e36f1973a674 | 286 | |
Leigh_LbR | 0:e36f1973a674 | 287 | } |
Leigh_LbR | 0:e36f1973a674 | 288 | } |
Leigh_LbR | 0:e36f1973a674 | 289 | |
Leigh_LbR | 0:e36f1973a674 | 290 | char_x += w; |
Leigh_LbR | 0:e36f1973a674 | 291 | } |
Leigh_LbR | 0:e36f1973a674 | 292 | |
Leigh_LbR | 0:e36f1973a674 | 293 | // set actual font |
Leigh_LbR | 0:e36f1973a674 | 294 | void EaEpaper::set_font(unsigned char* f) |
Leigh_LbR | 0:e36f1973a674 | 295 | { |
Leigh_LbR | 0:e36f1973a674 | 296 | font = f; |
Leigh_LbR | 0:e36f1973a674 | 297 | } |
Leigh_LbR | 0:e36f1973a674 | 298 | |
Leigh_LbR | 0:e36f1973a674 | 299 | void EaEpaper::print_bm(Bitmap bm, int x, int y) |
Leigh_LbR | 0:e36f1973a674 | 300 | { |
Leigh_LbR | 0:e36f1973a674 | 301 | int h,v,b; |
Leigh_LbR | 0:e36f1973a674 | 302 | char d; |
Leigh_LbR | 0:e36f1973a674 | 303 | |
Leigh_LbR | 0:e36f1973a674 | 304 | for(v=0; v < bm.ySize; v++) { // lines |
Leigh_LbR | 0:e36f1973a674 | 305 | for(h=0; h < bm.xSize; h++) { // pixel |
Leigh_LbR | 0:e36f1973a674 | 306 | if(h + x > width()) break; |
Leigh_LbR | 0:e36f1973a674 | 307 | if(v + y > height()) break; |
Leigh_LbR | 0:e36f1973a674 | 308 | d = bm.data[bm.Byte_in_Line * v + ((h & 0xF8) >> 3)]; |
Leigh_LbR | 0:e36f1973a674 | 309 | b = 0x80 >> (h & 0x07); |
Leigh_LbR | 0:e36f1973a674 | 310 | if((d & b) == 0) { |
Leigh_LbR | 0:e36f1973a674 | 311 | pixel(x+h,y+v,0); |
Leigh_LbR | 0:e36f1973a674 | 312 | } else { |
Leigh_LbR | 0:e36f1973a674 | 313 | pixel(x+h,y+v,1); |
Leigh_LbR | 0:e36f1973a674 | 314 | } |
Leigh_LbR | 0:e36f1973a674 | 315 | } |
Leigh_LbR | 0:e36f1973a674 | 316 | } |
Leigh_LbR | 0:e36f1973a674 | 317 | |
Leigh_LbR | 0:e36f1973a674 | 318 | } |
Leigh_LbR | 0:e36f1973a674 | 319 | |
Leigh_LbR | 0:e36f1973a674 | 320 | void EaEpaper::drawImage(uint8_t* img) |
Leigh_LbR | 0:e36f1973a674 | 321 | { |
Leigh_LbR | 0:e36f1973a674 | 322 | _epd.drawImage(img); |
Leigh_LbR | 0:e36f1973a674 | 323 | } |