E_paper, E_ink, Screen size 1.54", resolution 200x200, 4 wire spi, Waveshare, Black and White, Kl25Z, 8 wire print connector, supply 3.3 Volt, IL0373 Controller, font size is 8, 12, 16 and 24.
epd1in54.cpp@8:01db118d1694, 2018-03-29 (annotated)
- Committer:
- GerritPathuis
- Date:
- Thu Mar 29 18:27:28 2018 +0000
- Revision:
- 8:01db118d1694
- Parent:
- 7:25cadf37fd86
- Child:
- 9:9503e1ff98ea
Seems to work
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GerritPathuis | 0:665e04c85d8d | 1 | /** |
GerritPathuis | 0:665e04c85d8d | 2 | * @filename : epd1in54.cpp |
GerritPathuis | 0:665e04c85d8d | 3 | * @brief : Implements for e-paper library |
GerritPathuis | 0:665e04c85d8d | 4 | * @author : Yehui from Waveshare |
GerritPathuis | 0:665e04c85d8d | 5 | * |
GerritPathuis | 0:665e04c85d8d | 6 | * Copyright (C) Waveshare September 5 2017 |
GerritPathuis | 0:665e04c85d8d | 7 | * |
GerritPathuis | 0:665e04c85d8d | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
GerritPathuis | 0:665e04c85d8d | 9 | * of this software and associated documnetation files (the "Software"), to deal |
GerritPathuis | 0:665e04c85d8d | 10 | * in the Software without restriction, including without limitation the rights |
GerritPathuis | 0:665e04c85d8d | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
GerritPathuis | 0:665e04c85d8d | 12 | * copies of the Software, and to permit persons to whom the Software is |
GerritPathuis | 0:665e04c85d8d | 13 | * furished to do so, subject to the following conditions: |
GerritPathuis | 0:665e04c85d8d | 14 | * |
GerritPathuis | 0:665e04c85d8d | 15 | * The above copyright notice and this permission notice shall be included in |
GerritPathuis | 0:665e04c85d8d | 16 | * all copies or substantial portions of the Software. |
GerritPathuis | 0:665e04c85d8d | 17 | * |
GerritPathuis | 0:665e04c85d8d | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
GerritPathuis | 0:665e04c85d8d | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
GerritPathuis | 0:665e04c85d8d | 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
GerritPathuis | 0:665e04c85d8d | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
GerritPathuis | 0:665e04c85d8d | 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
GerritPathuis | 0:665e04c85d8d | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
GerritPathuis | 0:665e04c85d8d | 24 | * THE SOFTWARE. |
GerritPathuis | 0:665e04c85d8d | 25 | */ |
GerritPathuis | 0:665e04c85d8d | 26 | |
GerritPathuis | 0:665e04c85d8d | 27 | #include "epd1in54.h" |
GerritPathuis | 0:665e04c85d8d | 28 | |
GerritPathuis | 7:25cadf37fd86 | 29 | extern Serial pc; |
GerritPathuis | 7:25cadf37fd86 | 30 | |
GerritPathuis | 8:01db118d1694 | 31 | Epd::~Epd() |
GerritPathuis | 8:01db118d1694 | 32 | { |
GerritPathuis | 0:665e04c85d8d | 33 | }; |
GerritPathuis | 0:665e04c85d8d | 34 | |
GerritPathuis | 8:01db118d1694 | 35 | Epd::Epd() |
GerritPathuis | 8:01db118d1694 | 36 | { |
GerritPathuis | 6:469fb6b0d26d | 37 | reset_pin_no= 0; |
GerritPathuis | 6:469fb6b0d26d | 38 | dc_pin_no = 1; |
GerritPathuis | 6:469fb6b0d26d | 39 | cs_pin_no = 2; |
GerritPathuis | 6:469fb6b0d26d | 40 | busy_pin_no = 3; |
GerritPathuis | 0:665e04c85d8d | 41 | width = EPD_WIDTH; |
GerritPathuis | 0:665e04c85d8d | 42 | height = EPD_HEIGHT; |
GerritPathuis | 0:665e04c85d8d | 43 | }; |
GerritPathuis | 0:665e04c85d8d | 44 | |
GerritPathuis | 8:01db118d1694 | 45 | int Epd::Init(const unsigned char* lut) |
GerritPathuis | 8:01db118d1694 | 46 | { |
GerritPathuis | 8:01db118d1694 | 47 | pc.printf("Init... \n\r"); |
GerritPathuis | 0:665e04c85d8d | 48 | /* this calls the peripheral hardware interface, see epdif */ |
GerritPathuis | 0:665e04c85d8d | 49 | if (IfInit() != 0) { |
GerritPathuis | 0:665e04c85d8d | 50 | return -1; |
GerritPathuis | 0:665e04c85d8d | 51 | } |
GerritPathuis | 0:665e04c85d8d | 52 | /* EPD hardware init start */ |
GerritPathuis | 0:665e04c85d8d | 53 | this->lut = lut; |
GerritPathuis | 0:665e04c85d8d | 54 | Reset(); |
GerritPathuis | 0:665e04c85d8d | 55 | SendCommand(DRIVER_OUTPUT_CONTROL); |
GerritPathuis | 0:665e04c85d8d | 56 | SendData((EPD_HEIGHT - 1) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 57 | SendData(((EPD_HEIGHT - 1) >> 8) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 58 | SendData(0x00); // GD = 0; SM = 0; TB = 0; |
GerritPathuis | 0:665e04c85d8d | 59 | SendCommand(BOOSTER_SOFT_START_CONTROL); |
GerritPathuis | 0:665e04c85d8d | 60 | SendData(0xD7); |
GerritPathuis | 0:665e04c85d8d | 61 | SendData(0xD6); |
GerritPathuis | 0:665e04c85d8d | 62 | SendData(0x9D); |
GerritPathuis | 0:665e04c85d8d | 63 | SendCommand(WRITE_VCOM_REGISTER); |
GerritPathuis | 0:665e04c85d8d | 64 | SendData(0xA8); // VCOM 7C |
GerritPathuis | 0:665e04c85d8d | 65 | SendCommand(SET_DUMMY_LINE_PERIOD); |
GerritPathuis | 0:665e04c85d8d | 66 | SendData(0x1A); // 4 dummy lines per gate |
GerritPathuis | 0:665e04c85d8d | 67 | SendCommand(SET_GATE_TIME); |
GerritPathuis | 0:665e04c85d8d | 68 | SendData(0x08); // 2us per line |
GerritPathuis | 0:665e04c85d8d | 69 | SendCommand(DATA_ENTRY_MODE_SETTING); |
GerritPathuis | 0:665e04c85d8d | 70 | SendData(0x03); // X increment; Y increment |
GerritPathuis | 0:665e04c85d8d | 71 | SetLut(this->lut); |
GerritPathuis | 0:665e04c85d8d | 72 | /* EPD hardware init end */ |
GerritPathuis | 8:01db118d1694 | 73 | pc.printf("Init done \n\r"); |
GerritPathuis | 0:665e04c85d8d | 74 | return 0; |
GerritPathuis | 0:665e04c85d8d | 75 | } |
GerritPathuis | 0:665e04c85d8d | 76 | |
GerritPathuis | 0:665e04c85d8d | 77 | /** |
GerritPathuis | 0:665e04c85d8d | 78 | * @brief: basic function for sending commands |
GerritPathuis | 0:665e04c85d8d | 79 | */ |
GerritPathuis | 8:01db118d1694 | 80 | void Epd::SendCommand(unsigned char command) |
GerritPathuis | 8:01db118d1694 | 81 | { |
GerritPathuis | 6:469fb6b0d26d | 82 | DigitalWrite(dc_pin_no, LOW); |
GerritPathuis | 0:665e04c85d8d | 83 | SpiTransfer(command); |
GerritPathuis | 0:665e04c85d8d | 84 | } |
GerritPathuis | 0:665e04c85d8d | 85 | |
GerritPathuis | 0:665e04c85d8d | 86 | /** |
GerritPathuis | 0:665e04c85d8d | 87 | * @brief: basic function for sending data |
GerritPathuis | 0:665e04c85d8d | 88 | */ |
GerritPathuis | 8:01db118d1694 | 89 | void Epd::SendData(unsigned char data) |
GerritPathuis | 8:01db118d1694 | 90 | { |
GerritPathuis | 6:469fb6b0d26d | 91 | DigitalWrite(dc_pin_no, HIGH); |
GerritPathuis | 0:665e04c85d8d | 92 | SpiTransfer(data); |
GerritPathuis | 0:665e04c85d8d | 93 | } |
GerritPathuis | 0:665e04c85d8d | 94 | |
GerritPathuis | 1:d27a7e06c233 | 95 | |
GerritPathuis | 0:665e04c85d8d | 96 | /** |
GerritPathuis | 0:665e04c85d8d | 97 | * @brief: Wait until the busy_pin goes LOW |
GerritPathuis | 0:665e04c85d8d | 98 | */ |
GerritPathuis | 8:01db118d1694 | 99 | void Epd::WaitUntilIdle(void) |
GerritPathuis | 8:01db118d1694 | 100 | { |
GerritPathuis | 8:01db118d1694 | 101 | pc.printf("Wait for idle Busy pin goes low \n\r"); |
GerritPathuis | 6:469fb6b0d26d | 102 | while(DigitalRead(busy_pin_no) == HIGH) { //LOW: idle, HIGH: busy |
GerritPathuis | 8:01db118d1694 | 103 | pc.printf("."); |
GerritPathuis | 0:665e04c85d8d | 104 | DelayMs(100); |
GerritPathuis | 8:01db118d1694 | 105 | } |
GerritPathuis | 0:665e04c85d8d | 106 | } |
GerritPathuis | 0:665e04c85d8d | 107 | |
GerritPathuis | 0:665e04c85d8d | 108 | /** |
GerritPathuis | 0:665e04c85d8d | 109 | * @brief: module reset. |
GerritPathuis | 0:665e04c85d8d | 110 | * often used to awaken the module in deep sleep, |
GerritPathuis | 0:665e04c85d8d | 111 | * see Epd::Sleep(); |
GerritPathuis | 0:665e04c85d8d | 112 | */ |
GerritPathuis | 8:01db118d1694 | 113 | void Epd::Reset(void) |
GerritPathuis | 8:01db118d1694 | 114 | { |
GerritPathuis | 8:01db118d1694 | 115 | pc.printf("Reset... \n\r"); |
GerritPathuis | 8:01db118d1694 | 116 | DigitalWrite(reset_pin_no, LOW); //module reset |
GerritPathuis | 0:665e04c85d8d | 117 | DelayMs(200); |
GerritPathuis | 6:469fb6b0d26d | 118 | DigitalWrite(reset_pin_no, HIGH); |
GerritPathuis | 8:01db118d1694 | 119 | DelayMs(200); |
GerritPathuis | 0:665e04c85d8d | 120 | } |
GerritPathuis | 0:665e04c85d8d | 121 | |
GerritPathuis | 0:665e04c85d8d | 122 | /** |
GerritPathuis | 0:665e04c85d8d | 123 | * @brief: set the look-up table register |
GerritPathuis | 0:665e04c85d8d | 124 | */ |
GerritPathuis | 8:01db118d1694 | 125 | void Epd::SetLut(const unsigned char* lut) |
GerritPathuis | 8:01db118d1694 | 126 | { |
GerritPathuis | 8:01db118d1694 | 127 | pc.printf("Set LUT \n\r"); |
GerritPathuis | 0:665e04c85d8d | 128 | this->lut = lut; |
GerritPathuis | 0:665e04c85d8d | 129 | SendCommand(WRITE_LUT_REGISTER); |
GerritPathuis | 0:665e04c85d8d | 130 | /* the length of look-up table is 30 bytes */ |
GerritPathuis | 0:665e04c85d8d | 131 | for (int i = 0; i < 30; i++) { |
GerritPathuis | 0:665e04c85d8d | 132 | SendData(this->lut[i]); |
GerritPathuis | 0:665e04c85d8d | 133 | } |
GerritPathuis | 0:665e04c85d8d | 134 | } |
GerritPathuis | 0:665e04c85d8d | 135 | |
GerritPathuis | 0:665e04c85d8d | 136 | /** |
GerritPathuis | 0:665e04c85d8d | 137 | * @brief: put an image buffer to the frame memory. |
GerritPathuis | 0:665e04c85d8d | 138 | * this won't update the display. |
GerritPathuis | 0:665e04c85d8d | 139 | */ |
GerritPathuis | 0:665e04c85d8d | 140 | void Epd::SetFrameMemory( |
GerritPathuis | 0:665e04c85d8d | 141 | const unsigned char* image_buffer, |
GerritPathuis | 8:01db118d1694 | 142 | int x,int y, int image_width, int image_height) |
GerritPathuis | 8:01db118d1694 | 143 | { |
GerritPathuis | 0:665e04c85d8d | 144 | int x_end; |
GerritPathuis | 0:665e04c85d8d | 145 | int y_end; |
GerritPathuis | 0:665e04c85d8d | 146 | |
GerritPathuis | 8:01db118d1694 | 147 | pc.printf("SetFrameMemory regel 141\n\r"); |
GerritPathuis | 8:01db118d1694 | 148 | |
GerritPathuis | 0:665e04c85d8d | 149 | if ( |
GerritPathuis | 0:665e04c85d8d | 150 | image_buffer == NULL || |
GerritPathuis | 0:665e04c85d8d | 151 | x < 0 || image_width < 0 || |
GerritPathuis | 0:665e04c85d8d | 152 | y < 0 || image_height < 0 |
GerritPathuis | 0:665e04c85d8d | 153 | ) { |
GerritPathuis | 0:665e04c85d8d | 154 | return; |
GerritPathuis | 0:665e04c85d8d | 155 | } |
GerritPathuis | 0:665e04c85d8d | 156 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ |
GerritPathuis | 0:665e04c85d8d | 157 | x &= 0xF8; |
GerritPathuis | 0:665e04c85d8d | 158 | image_width &= 0xF8; |
GerritPathuis | 0:665e04c85d8d | 159 | if (x + image_width >= this->width) { |
GerritPathuis | 0:665e04c85d8d | 160 | x_end = this->width - 1; |
GerritPathuis | 0:665e04c85d8d | 161 | } else { |
GerritPathuis | 0:665e04c85d8d | 162 | x_end = x + image_width - 1; |
GerritPathuis | 0:665e04c85d8d | 163 | } |
GerritPathuis | 0:665e04c85d8d | 164 | if (y + image_height >= this->height) { |
GerritPathuis | 0:665e04c85d8d | 165 | y_end = this->height - 1; |
GerritPathuis | 0:665e04c85d8d | 166 | } else { |
GerritPathuis | 0:665e04c85d8d | 167 | y_end = y + image_height - 1; |
GerritPathuis | 0:665e04c85d8d | 168 | } |
GerritPathuis | 0:665e04c85d8d | 169 | SetMemoryArea(x, y, x_end, y_end); |
GerritPathuis | 0:665e04c85d8d | 170 | SetMemoryPointer(x, y); |
GerritPathuis | 0:665e04c85d8d | 171 | SendCommand(WRITE_RAM); |
GerritPathuis | 0:665e04c85d8d | 172 | /* send the image data */ |
GerritPathuis | 0:665e04c85d8d | 173 | for (int j = 0; j < y_end - y + 1; j++) { |
GerritPathuis | 0:665e04c85d8d | 174 | for (int i = 0; i < (x_end - x + 1) / 8; i++) { |
GerritPathuis | 0:665e04c85d8d | 175 | SendData(image_buffer[i + j * (image_width / 8)]); |
GerritPathuis | 0:665e04c85d8d | 176 | } |
GerritPathuis | 0:665e04c85d8d | 177 | } |
GerritPathuis | 0:665e04c85d8d | 178 | } |
GerritPathuis | 0:665e04c85d8d | 179 | |
GerritPathuis | 0:665e04c85d8d | 180 | /** |
GerritPathuis | 0:665e04c85d8d | 181 | * @brief: put an image buffer to the frame memory. |
GerritPathuis | 0:665e04c85d8d | 182 | * this won't update the display. |
GerritPathuis | 0:665e04c85d8d | 183 | * |
GerritPathuis | 8:01db118d1694 | 184 | * Question: When do you use this function instead of |
GerritPathuis | 0:665e04c85d8d | 185 | * void SetFrameMemory( |
GerritPathuis | 0:665e04c85d8d | 186 | * const unsigned char* image_buffer, |
GerritPathuis | 0:665e04c85d8d | 187 | * int x, |
GerritPathuis | 0:665e04c85d8d | 188 | * int y, |
GerritPathuis | 0:665e04c85d8d | 189 | * int image_width, |
GerritPathuis | 0:665e04c85d8d | 190 | * int image_height |
GerritPathuis | 0:665e04c85d8d | 191 | * ); |
GerritPathuis | 0:665e04c85d8d | 192 | * Answer: SetFrameMemory with parameters only reads image data |
GerritPathuis | 0:665e04c85d8d | 193 | * from the RAM but not from the flash in AVR chips (for AVR chips, |
GerritPathuis | 8:01db118d1694 | 194 | * you have to use the function pgm_read_byte to read buffers |
GerritPathuis | 0:665e04c85d8d | 195 | * from the flash). |
GerritPathuis | 0:665e04c85d8d | 196 | */ |
GerritPathuis | 8:01db118d1694 | 197 | void Epd::SetFrameMemory(const unsigned char* image_buffer) |
GerritPathuis | 8:01db118d1694 | 198 | { |
GerritPathuis | 8:01db118d1694 | 199 | pc.printf("SetFrameMemory \n\r"); |
GerritPathuis | 8:01db118d1694 | 200 | |
GerritPathuis | 0:665e04c85d8d | 201 | SetMemoryArea(0, 0, this->width - 1, this->height - 1); |
GerritPathuis | 0:665e04c85d8d | 202 | SetMemoryPointer(0, 0); |
GerritPathuis | 0:665e04c85d8d | 203 | SendCommand(WRITE_RAM); |
GerritPathuis | 0:665e04c85d8d | 204 | /* send the image data */ |
GerritPathuis | 0:665e04c85d8d | 205 | for (int i = 0; i < this->width / 8 * this->height; i++) { |
GerritPathuis | 3:e4399b5ceb4b | 206 | //SendData(pgm_read_byte(&image_buffer[i])); |
GerritPathuis | 8:01db118d1694 | 207 | SendData(*(&image_buffer[i])); |
GerritPathuis | 0:665e04c85d8d | 208 | } |
GerritPathuis | 0:665e04c85d8d | 209 | } |
GerritPathuis | 0:665e04c85d8d | 210 | |
GerritPathuis | 0:665e04c85d8d | 211 | /** |
GerritPathuis | 0:665e04c85d8d | 212 | * @brief: clear the frame memory with the specified color. |
GerritPathuis | 0:665e04c85d8d | 213 | * this won't update the display. |
GerritPathuis | 0:665e04c85d8d | 214 | */ |
GerritPathuis | 8:01db118d1694 | 215 | void Epd::ClearFrameMemory(unsigned char color) |
GerritPathuis | 8:01db118d1694 | 216 | { |
GerritPathuis | 8:01db118d1694 | 217 | pc.printf("width= %d, height %d\n\r",this->width ,this->height); |
GerritPathuis | 8:01db118d1694 | 218 | |
GerritPathuis | 0:665e04c85d8d | 219 | SetMemoryArea(0, 0, this->width - 1, this->height - 1); |
GerritPathuis | 8:01db118d1694 | 220 | pc.printf("setpointer \n\r"); |
GerritPathuis | 0:665e04c85d8d | 221 | SetMemoryPointer(0, 0); |
GerritPathuis | 8:01db118d1694 | 222 | pc.printf("send command \n\r"); |
GerritPathuis | 0:665e04c85d8d | 223 | SendCommand(WRITE_RAM); |
GerritPathuis | 8:01db118d1694 | 224 | |
GerritPathuis | 0:665e04c85d8d | 225 | /* send the color data */ |
GerritPathuis | 8:01db118d1694 | 226 | pc.printf("Write to memory\r\n"); |
GerritPathuis | 0:665e04c85d8d | 227 | for (int i = 0; i < this->width / 8 * this->height; i++) { |
GerritPathuis | 0:665e04c85d8d | 228 | SendData(color); |
GerritPathuis | 8:01db118d1694 | 229 | pc.printf("color= %x ,", color); |
GerritPathuis | 0:665e04c85d8d | 230 | } |
GerritPathuis | 0:665e04c85d8d | 231 | } |
GerritPathuis | 0:665e04c85d8d | 232 | |
GerritPathuis | 0:665e04c85d8d | 233 | /** |
GerritPathuis | 0:665e04c85d8d | 234 | * @brief: update the display |
GerritPathuis | 0:665e04c85d8d | 235 | * there are 2 memory areas embedded in the e-paper display |
GerritPathuis | 0:665e04c85d8d | 236 | * but once this function is called, |
GerritPathuis | 8:01db118d1694 | 237 | * the the next action of SetFrameMemory or ClearFrame will |
GerritPathuis | 0:665e04c85d8d | 238 | * set the other memory area. |
GerritPathuis | 0:665e04c85d8d | 239 | */ |
GerritPathuis | 8:01db118d1694 | 240 | void Epd::DisplayFrame(void) |
GerritPathuis | 8:01db118d1694 | 241 | { |
GerritPathuis | 8:01db118d1694 | 242 | pc.printf("DisplayFrame \n\r"); |
GerritPathuis | 0:665e04c85d8d | 243 | SendCommand(DISPLAY_UPDATE_CONTROL_2); |
GerritPathuis | 0:665e04c85d8d | 244 | SendData(0xC4); |
GerritPathuis | 0:665e04c85d8d | 245 | SendCommand(MASTER_ACTIVATION); |
GerritPathuis | 0:665e04c85d8d | 246 | SendCommand(TERMINATE_FRAME_READ_WRITE); |
GerritPathuis | 0:665e04c85d8d | 247 | WaitUntilIdle(); |
GerritPathuis | 0:665e04c85d8d | 248 | } |
GerritPathuis | 0:665e04c85d8d | 249 | |
GerritPathuis | 0:665e04c85d8d | 250 | /** |
GerritPathuis | 0:665e04c85d8d | 251 | * @brief: private function to specify the memory area for data R/W |
GerritPathuis | 0:665e04c85d8d | 252 | */ |
GerritPathuis | 8:01db118d1694 | 253 | void Epd::SetMemoryArea(int x_start, int y_start, int x_end, int y_end) |
GerritPathuis | 8:01db118d1694 | 254 | { |
GerritPathuis | 8:01db118d1694 | 255 | pc.printf("SetMemoryArea \n\r"); |
GerritPathuis | 0:665e04c85d8d | 256 | SendCommand(SET_RAM_X_ADDRESS_START_END_POSITION); |
GerritPathuis | 0:665e04c85d8d | 257 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ |
GerritPathuis | 0:665e04c85d8d | 258 | SendData((x_start >> 3) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 259 | SendData((x_end >> 3) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 260 | SendCommand(SET_RAM_Y_ADDRESS_START_END_POSITION); |
GerritPathuis | 0:665e04c85d8d | 261 | SendData(y_start & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 262 | SendData((y_start >> 8) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 263 | SendData(y_end & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 264 | SendData((y_end >> 8) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 265 | } |
GerritPathuis | 0:665e04c85d8d | 266 | |
GerritPathuis | 0:665e04c85d8d | 267 | /** |
GerritPathuis | 0:665e04c85d8d | 268 | * @brief: private function to specify the start point for data R/W |
GerritPathuis | 0:665e04c85d8d | 269 | */ |
GerritPathuis | 8:01db118d1694 | 270 | void Epd::SetMemoryPointer(int x, int y) |
GerritPathuis | 8:01db118d1694 | 271 | { |
GerritPathuis | 8:01db118d1694 | 272 | pc.printf("SetMemoryPointer \n\r"); |
GerritPathuis | 0:665e04c85d8d | 273 | SendCommand(SET_RAM_X_ADDRESS_COUNTER); |
GerritPathuis | 8:01db118d1694 | 274 | |
GerritPathuis | 0:665e04c85d8d | 275 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ |
GerritPathuis | 0:665e04c85d8d | 276 | SendData((x >> 3) & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 277 | SendCommand(SET_RAM_Y_ADDRESS_COUNTER); |
GerritPathuis | 0:665e04c85d8d | 278 | SendData(y & 0xFF); |
GerritPathuis | 0:665e04c85d8d | 279 | SendData((y >> 8) & 0xFF); |
GerritPathuis | 8:01db118d1694 | 280 | pc.printf("WaitUntilidle \n\r"); |
GerritPathuis | 0:665e04c85d8d | 281 | WaitUntilIdle(); |
GerritPathuis | 8:01db118d1694 | 282 | pc.printf("Done SetMemoryPointer \n\r"); |
GerritPathuis | 0:665e04c85d8d | 283 | } |
GerritPathuis | 0:665e04c85d8d | 284 | |
GerritPathuis | 0:665e04c85d8d | 285 | /** |
GerritPathuis | 8:01db118d1694 | 286 | * @brief: After this command is transmitted, the chip would enter the |
GerritPathuis | 8:01db118d1694 | 287 | * deep-sleep mode to save power. |
GerritPathuis | 8:01db118d1694 | 288 | * The deep sleep mode would return to standby by hardware reset. |
GerritPathuis | 0:665e04c85d8d | 289 | * You can use Epd::Init() to awaken |
GerritPathuis | 0:665e04c85d8d | 290 | */ |
GerritPathuis | 8:01db118d1694 | 291 | void Epd::Sleep() |
GerritPathuis | 8:01db118d1694 | 292 | { |
GerritPathuis | 0:665e04c85d8d | 293 | SendCommand(DEEP_SLEEP_MODE); |
GerritPathuis | 0:665e04c85d8d | 294 | WaitUntilIdle(); |
GerritPathuis | 0:665e04c85d8d | 295 | } |
GerritPathuis | 0:665e04c85d8d | 296 | |
GerritPathuis | 8:01db118d1694 | 297 | const unsigned char lut_full_update[] = { |
GerritPathuis | 8:01db118d1694 | 298 | 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, |
GerritPathuis | 8:01db118d1694 | 299 | 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, |
GerritPathuis | 8:01db118d1694 | 300 | 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, |
GerritPathuis | 0:665e04c85d8d | 301 | 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 |
GerritPathuis | 0:665e04c85d8d | 302 | }; |
GerritPathuis | 0:665e04c85d8d | 303 | |
GerritPathuis | 8:01db118d1694 | 304 | const unsigned char lut_partial_update[] = { |
GerritPathuis | 8:01db118d1694 | 305 | 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, |
GerritPathuis | 8:01db118d1694 | 306 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
GerritPathuis | 8:01db118d1694 | 307 | 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, |
GerritPathuis | 0:665e04c85d8d | 308 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
GerritPathuis | 0:665e04c85d8d | 309 | }; |
GerritPathuis | 0:665e04c85d8d | 310 | |
GerritPathuis | 0:665e04c85d8d | 311 | |
GerritPathuis | 0:665e04c85d8d | 312 | /* END OF FILE */ |
GerritPathuis | 0:665e04c85d8d | 313 | |
GerritPathuis | 0:665e04c85d8d | 314 | |
GerritPathuis | 0:665e04c85d8d | 315 |