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.
epdif.cpp@6:469fb6b0d26d, 2018-03-28 (annotated)
- Committer:
- GerritPathuis
- Date:
- Wed Mar 28 09:21:33 2018 +0000
- Revision:
- 6:469fb6b0d26d
- Parent:
- 2:d7fc318a1528
- Child:
- 7:25cadf37fd86
Compilation succes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GerritPathuis | 0:665e04c85d8d | 1 | /** |
GerritPathuis | 0:665e04c85d8d | 2 | * @filename : epdif.cpp |
GerritPathuis | 0:665e04c85d8d | 3 | * @brief : Implements EPD interface functions |
GerritPathuis | 0:665e04c85d8d | 4 | * Users have to implement all the functions in epdif.cpp |
GerritPathuis | 0:665e04c85d8d | 5 | * @author : Yehui from Waveshare |
GerritPathuis | 0:665e04c85d8d | 6 | * |
GerritPathuis | 0:665e04c85d8d | 7 | * Copyright (C) Waveshare August 10 2017 |
GerritPathuis | 0:665e04c85d8d | 8 | * |
GerritPathuis | 0:665e04c85d8d | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
GerritPathuis | 0:665e04c85d8d | 10 | * of this software and associated documnetation files (the "Software"), to deal |
GerritPathuis | 0:665e04c85d8d | 11 | * in the Software without restriction, including without limitation the rights |
GerritPathuis | 0:665e04c85d8d | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
GerritPathuis | 0:665e04c85d8d | 13 | * copies of the Software, and to permit persons to whom the Software is |
GerritPathuis | 0:665e04c85d8d | 14 | * furished to do so, subject to the following conditions: |
GerritPathuis | 0:665e04c85d8d | 15 | * |
GerritPathuis | 0:665e04c85d8d | 16 | * The above copyright notice and this permission notice shall be included in |
GerritPathuis | 0:665e04c85d8d | 17 | * all copies or substantial portions of the Software. |
GerritPathuis | 0:665e04c85d8d | 18 | * |
GerritPathuis | 0:665e04c85d8d | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
GerritPathuis | 0:665e04c85d8d | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
GerritPathuis | 0:665e04c85d8d | 21 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
GerritPathuis | 0:665e04c85d8d | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
GerritPathuis | 0:665e04c85d8d | 23 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
GerritPathuis | 0:665e04c85d8d | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
GerritPathuis | 0:665e04c85d8d | 25 | * THE SOFTWARE. |
GerritPathuis | 0:665e04c85d8d | 26 | */ |
GerritPathuis | 0:665e04c85d8d | 27 | |
GerritPathuis | 6:469fb6b0d26d | 28 | #include "epdif.h" |
GerritPathuis | 6:469fb6b0d26d | 29 | #include "epd1in54.h" |
GerritPathuis | 1:d27a7e06c233 | 30 | |
GerritPathuis | 6:469fb6b0d26d | 31 | extern DigitalOut reset_pin; |
GerritPathuis | 6:469fb6b0d26d | 32 | extern DigitalOut dc_pin; |
GerritPathuis | 6:469fb6b0d26d | 33 | extern DigitalOut cs_pin; |
GerritPathuis | 6:469fb6b0d26d | 34 | extern DigitalIn busy_pin; |
GerritPathuis | 6:469fb6b0d26d | 35 | extern SPI epaper; |
GerritPathuis | 0:665e04c85d8d | 36 | |
GerritPathuis | 1:d27a7e06c233 | 37 | EpdIf::EpdIf() |
GerritPathuis | 1:d27a7e06c233 | 38 | { |
GerritPathuis | 1:d27a7e06c233 | 39 | }; |
GerritPathuis | 0:665e04c85d8d | 40 | |
GerritPathuis | 1:d27a7e06c233 | 41 | EpdIf::~EpdIf() |
GerritPathuis | 1:d27a7e06c233 | 42 | { |
GerritPathuis | 0:665e04c85d8d | 43 | }; |
GerritPathuis | 0:665e04c85d8d | 44 | |
GerritPathuis | 0:665e04c85d8d | 45 | |
GerritPathuis | 1:d27a7e06c233 | 46 | void EpdIf::DigitalWrite(int pin, int value) |
GerritPathuis | 1:d27a7e06c233 | 47 | { |
GerritPathuis | 1:d27a7e06c233 | 48 | using namespace std; |
GerritPathuis | 1:d27a7e06c233 | 49 | switch(pin) { |
GerritPathuis | 1:d27a7e06c233 | 50 | case 0: |
GerritPathuis | 2:d7fc318a1528 | 51 | reset_pin.write(value); |
GerritPathuis | 1:d27a7e06c233 | 52 | break; |
GerritPathuis | 1:d27a7e06c233 | 53 | case 1: |
GerritPathuis | 1:d27a7e06c233 | 54 | dc_pin.write(value); |
GerritPathuis | 1:d27a7e06c233 | 55 | break; |
GerritPathuis | 1:d27a7e06c233 | 56 | case 2: |
GerritPathuis | 1:d27a7e06c233 | 57 | cs_pin.write(value); |
GerritPathuis | 1:d27a7e06c233 | 58 | break; |
GerritPathuis | 1:d27a7e06c233 | 59 | } |
GerritPathuis | 0:665e04c85d8d | 60 | } |
GerritPathuis | 0:665e04c85d8d | 61 | |
GerritPathuis | 1:d27a7e06c233 | 62 | int EpdIf::DigitalRead(int pin) |
GerritPathuis | 1:d27a7e06c233 | 63 | { |
GerritPathuis | 2:d7fc318a1528 | 64 | return busy_pin.read(); |
GerritPathuis | 1:d27a7e06c233 | 65 | //return pins_in[pin].read; |
GerritPathuis | 1:d27a7e06c233 | 66 | } |
GerritPathuis | 1:d27a7e06c233 | 67 | |
GerritPathuis | 1:d27a7e06c233 | 68 | void EpdIf::DelayMs(unsigned int delaytime) |
GerritPathuis | 1:d27a7e06c233 | 69 | { |
GerritPathuis | 1:d27a7e06c233 | 70 | wait_ms(delaytime); |
GerritPathuis | 0:665e04c85d8d | 71 | } |
GerritPathuis | 0:665e04c85d8d | 72 | |
GerritPathuis | 1:d27a7e06c233 | 73 | void EpdIf::SpiTransfer(unsigned char data) |
GerritPathuis | 1:d27a7e06c233 | 74 | { |
GerritPathuis | 1:d27a7e06c233 | 75 | //digitalWrite(CS_PIN, LOW); |
GerritPathuis | 1:d27a7e06c233 | 76 | cs_pin.write(LOW); |
GerritPathuis | 1:d27a7e06c233 | 77 | //SPI.transfer(data); |
GerritPathuis | 1:d27a7e06c233 | 78 | epaper.write(data); |
GerritPathuis | 1:d27a7e06c233 | 79 | //digitalWrite(CS_PIN, HIGH); |
GerritPathuis | 1:d27a7e06c233 | 80 | cs_pin.write(HIGH); |
GerritPathuis | 0:665e04c85d8d | 81 | } |
GerritPathuis | 0:665e04c85d8d | 82 | |
GerritPathuis | 1:d27a7e06c233 | 83 | int EpdIf::IfInit(void) |
GerritPathuis | 1:d27a7e06c233 | 84 | { |
GerritPathuis | 1:d27a7e06c233 | 85 | //pinMode(CS_PIN, OUTPUT); |
GerritPathuis | 1:d27a7e06c233 | 86 | //pinMode(RST_PIN, OUTPUT); |
GerritPathuis | 1:d27a7e06c233 | 87 | //pinMode(DC_PIN, OUTPUT); |
GerritPathuis | 1:d27a7e06c233 | 88 | //pinMode(BUSY_PIN, INPUT); |
GerritPathuis | 1:d27a7e06c233 | 89 | epaper.frequency(2000000); |
GerritPathuis | 1:d27a7e06c233 | 90 | //SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); |
GerritPathuis | 1:d27a7e06c233 | 91 | //SPI.begin(); |
GerritPathuis | 0:665e04c85d8d | 92 | return 0; |
GerritPathuis | 0:665e04c85d8d | 93 | } |
GerritPathuis | 0:665e04c85d8d | 94 | |
GerritPathuis | 0:665e04c85d8d | 95 |