1 Star 0 Fork 0

DFRobot / DFRobot_ePaper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
DFRobot_IL0376F_I2C.cpp 2.29 KB
一键复制 编辑 原始数据 按行查看 历史
lixin7 提交于 2017-12-01 09:43 . Modify the code 2017-12-1
#include"DFRobot_IL0376F_I2C.h"
DFRobot_IL0376F_I2C::DFRobot_IL0376F_I2C (): DFRobot_ePaper(WIDTH, HIGHLY, NULL, A0, ID)
{
Address = A0;
}
DFRobot_IL0376F_I2C::~DFRobot_IL0376F_I2C()
{}
void DFRobot_IL0376F_I2C::begin(const char busy)
{
DFR_W21_BUSY = busy;
Wire.begin();
//Wire.setClock(100000);
pinMode(DFR_W21_BUSY, INPUT);
//digitalWrite(DFR_W21_BUSY, HIGH);
//Serial.println(Address);
}
void DFRobot_IL0376F_I2C::stateScan()
{
while(1){
delay(1);Serial.println(digitalRead(DFR_W21_BUSY));
if(digitalRead(DFR_W21_BUSY) == 0){
break;
}
}
}
void DFRobot_IL0376F_I2C::i2cWrite(unsigned char addr, unsigned char Reg, unsigned char *buf, unsigned char Num)
{
Wire.beginTransmission(addr); // transmit to device #8
Wire.write(byte(Reg)); // sends one byte
for(uint16_t i = 0; i <Num; i++)
{
Wire.write(byte(buf[i]));
}
Wire.endTransmission(); // stop transmitting
}
void DFRobot_IL0376F_I2C::i2cWriteByte(unsigned char addr, unsigned char Cmd)
{
Wire.beginTransmission(addr); // transmit to device #8
Wire.write(byte(Cmd)); // sends one byteS
Wire.endTransmission(); // stop transmitting
}
void DFRobot_IL0376F_I2C::i2cWriteBuffer(unsigned char addr, unsigned char *buf, unsigned char Num)
{
Wire.beginTransmission(addr); // transmit to device #8
for(uint16_t i = 0; i <Num; i++)
{
Wire.write(byte(buf[i]));
}
Wire.endTransmission(); // stop transmitting
}
void DFRobot_IL0376F_I2C::standby()
{
uint8_t buf[1]={0};
stateScan();
i2cWrite(Address, DFR_IL3895_STANDBY, buf, 1);
}
void DFRobot_IL0376F_I2C::wakeUp()
{
pinMode(DFR_W21_BUSY, OUTPUT);
digitalWrite(DFR_W21_BUSY, HIGH);
digitalWrite(DFR_W21_BUSY, LOW);
begin(DFR_W21_BUSY);
}
void DFRobot_IL0376F_I2C::fillRect(int16_t x, int16_t y, int16_t width, int16_t height,
uint16_t color)
{
uint8_t buf[5]={x, y, width, height, color};
stateScan();
i2cWrite(Address, DFR_IL0376F_DRAWFILLRECT, buf, 5);
}
void DFRobot_IL0376F_I2C::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
{
uint8_t buf[5]={x0, y0, r, 1, color};
stateScan();
i2cWrite(Address, DFR_IL0376F_DRAWCIRCLE, buf, 5);
}
C++
1
https://gitee.com/dfrobot/DFRobot_ePaper.git
git@gitee.com:dfrobot/DFRobot_ePaper.git
dfrobot
DFRobot_ePaper
DFRobot_ePaper
master

搜索帮助