Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
epdif.cpp
00001 /** 00002 * @filename : epdif.cpp 00003 * @brief : Implements EPD interface functions 00004 * Users have to implement all the functions in epdif.cpp 00005 * @author : Yehui from Waveshare 00006 * 00007 * Copyright (C) Waveshare August 10 2017 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a copy 00010 * of this software and associated documnetation files (the "Software"), to deal 00011 * in the Software without restriction, including without limitation the rights 00012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 * copies of the Software, and to permit persons to whom the Software is 00014 * furished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in 00017 * all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 * THE SOFTWARE. 00026 */ 00027 00028 #include "epdif.h" 00029 #include "epd1in54.h" 00030 00031 extern DigitalOut reset_pin; 00032 extern DigitalOut dc_pin; 00033 extern DigitalOut cs_pin; 00034 extern DigitalIn busy_pin; 00035 extern SPI epaper; 00036 extern DigitalOut myled; 00037 00038 EpdIf::EpdIf() 00039 { 00040 }; 00041 00042 EpdIf::~EpdIf() 00043 { 00044 }; 00045 00046 00047 void EpdIf::DigitalWrite(int pin, int value) 00048 { 00049 using namespace std; 00050 switch(pin) { 00051 case 0: 00052 reset_pin.write(value); 00053 break; 00054 case 1: 00055 dc_pin.write(value); 00056 break; 00057 case 2: 00058 cs_pin.write(value); 00059 break; 00060 } 00061 } 00062 00063 int EpdIf::DigitalRead(int pin) 00064 { 00065 return busy_pin.read(); 00066 } 00067 00068 void EpdIf::DelayMs(unsigned int delaytime) 00069 { 00070 wait_ms(delaytime); 00071 } 00072 00073 void EpdIf::SpiTransfer(unsigned char data) 00074 { 00075 cs_pin.write(LOW); 00076 epaper.write(data); 00077 cs_pin.write(HIGH); 00078 } 00079 00080 int EpdIf::IfInit(void) 00081 { 00082 epaper.frequency(2000000); 00083 //epaper.format(8,0); 00084 //SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); 00085 return 0; 00086 } 00087 00088
Generated on Thu Jul 14 2022 13:24:40 by
1.7.2