5-Air-合宙820-点墨水屏

点亮墨水屏

我这里用的是大连佳显的GDEY29Z94,资料戳我

瞅瞅官方例程

官方使用的是epd1in54_GDEH0154D27和epd1in54_GDEH0154D67,同样是大连佳显的,所以我可以省去很多驱动,最主要的就是发送命令和发送数据,如下

local function sendCommand(data)
	--log.info("epd1in45.sendCommand",data)
	setDC(0)
	spi.send(spi.SPI_1,string.char(data))
end

local function sendData(data)
	--log.info("epd1in45.sendData",data)
	setDC(1)
	spi.send(spi.SPI_1,string.char(data))
end

其他的硬件驱动也是已经好的

--电压域
pmd.ldoset(15,pmd.LDO_VLCD)

log.info("spi.setup",spi.setup(spi.SPI_1,0,0,8,13000000,0,0))

local function getBusyFnc(msg)
	log.info("Gpio.getBusyFnc",msg)
	if msg==cpu.INT_GPIO_POSEDGE then--上升沿中断
		--不动作
	else--下降沿中断
		sys.publish("BUSY_DOWN")
	end
end

--初始化三个控制引脚
local getBusy         = pins.setup(7,getBusyFnc)
local setRST          = pins.setup(12,1)
local setDC           = pins.setup(18,1)

-- Display resolution
local EPD_WIDTH       = 200
local EPD_HEIGHT      = 200

local function wait()
	while getBusy() == 1 do  -- 0: idle, 1: busy
		sys.waitUntil("BUSY_DOWN",5000)
	end
end

setDC(1)

下载大连佳显官方驱动

主要函数如下

void EPD_HW_Init(void)
{
	EPD_W21_RST_0;  // Module reset   
	driver_delay_xms(100);//At least 10ms delay 
	EPD_W21_RST_1;
	driver_delay_xms(100); //At least 10ms delay 

	Epaper_READBUSY();   
	Epaper_Write_Command(0x12);  //SWRESET
	Epaper_READBUSY();   

	Epaper_Write_Command(0x01); //Driver output control      
	Epaper_Write_Data(0x27);
	Epaper_Write_Data(0x01);
	Epaper_Write_Data(0x00);

	Epaper_Write_Command(0x11); //data entry mode       
	Epaper_Write_Data(0x01);

	Epaper_Write_Command(0x44); //set Ram-X address start/end position   
	Epaper_Write_Data(0x00);
	Epaper_Write_Data(0x0F);    //0x0F-->(15+1)*8=128

	Epaper_Write_Command(0x45); //set Ram-Y address start/end position          
	Epaper_Write_Data(0x27);   //0x0127-->(295+1)=296
	Epaper_Write_Data(0x01);
	Epaper_Write_Data(0x00);
	Epaper_Write_Data(0x00); 

	Epaper_Write_Command(0x3C); //BorderWavefrom
	Epaper_Write_Data(0x05);	

    Epaper_Write_Command(0x18); //Read built-in temperature sensor
	Epaper_Write_Data(0x80);	

	Epaper_Write_Command(0x21); //  Display update control
    Epaper_Write_Data(0x00);	
	Epaper_Write_Data(0x80);	

	Epaper_Write_Command(0x4E);   // set RAM x address count to 0;
	Epaper_Write_Data(0x00);
	Epaper_Write_Command(0x4F);   // set RAM y address count to 0X199;    
	Epaper_Write_Data(0x27);
	Epaper_Write_Data(0x01);
    Epaper_READBUSY();

}
/
void EPD_Update(void)
{   
  Epaper_Write_Command(0x22); //Display Update Control
  Epaper_Write_Data(0xF7);   
  Epaper_Write_Command(0x20);  //Activate Display Update Sequence
  Epaper_READBUSY();   

}
//All screen update
void EPD_WhiteScreen_ALL(const unsigned char *BW_datas,const unsigned char *R_datas)
{
   unsigned int i;	
   Epaper_Write_Command(0x24);   //write RAM for black(0)/white (1)
   for(i=0;i

修改驱动

跟着合宙官方的例程简单修改

function init()
	log.info("epd2in9.init","")
	reset()

	wait()
	sendCommand(0x12) --SWRESET
	wait()

	sendCommand(0x01)  --Driver output control      
	sendData(0x27) 
	sendData(0x01) 
	sendData(0x00) 

	sendCommand(0x11)  --data entry mode       
	sendData(0x01) 

	sendCommand(0x44)  --set Ram-X address start/end position   
	sendData(0x00) 
	sendData(0x0F)     --0x0F-->(15+1)*8=128

	sendCommand(0x45)  --set Ram-Y address start/end position          
	sendData(0x27)    --0x0127-->(295+1)=296
	sendData(0x01) 
	sendData(0x00) 
	sendData(0x00)  

	sendCommand(0x3C)  --BorderWavefrom
	sendData(0x05) 	

	sendCommand(0x18)  --Read built-in temperature sensor
	sendData(0x80) 	

	sendCommand(0x21)  --  Display update control
	sendData(0x00) 	
	sendData(0x80) 	

	sendCommand(0x4E)    -- set RAM x address count to 0 
	sendData(0x00) 
	sendCommand(0x4F)    -- set RAM y address count to 0X199     
	sendData(0x27) 
	sendData(0x01) 
	wait()

	log.info("epd2in9.init","done")
end

function display_frame()
	log.info("epd2in9.display_frame","start")
	sendCommand(0x22)
	sendData(0xF7)
	sendCommand(0x20)
	wait()
	log.info("epd2in9.display_frame","done")
end

function clear()
	sendCommand(0x24)
	for _=1,4736 do
		sendData(0xff)
	end
	sendCommand(0x26)
	for _=1,4736 do
		sendData(0x00)
	end
	display_frame()
	log.info("epd2in9.clear","done")
end

--输入值:数组
function showPictureS(picbw)
	wait()
	log.info("epd2in9.showPicture","")
	sendCommand(0x24)
	for i=1,4736 do
		sendData(picbw[i])
		i=i+1
	end
	sendCommand(0x26)
	for i=1,4736 do
		sendData(0x00)
		i=i+1
	end
	display_frame()
	log.info("epd2in9.clear","done")
end

虽然是三色屏,但我不喜欢红色,所以当黑白屏玩了

5-Air-合宙820-点墨水屏_第1张图片

主要就是这俩寄存器,其他的就不多搞了

硬件连接

注意,如果使用的是820开发板:
需要短接下面的引脚
G-CLK ---- SPI-SCLK
G-RES ---- SPI-MISO
G-CS ---- SPI-CSEL
G-DI ---- SPI-MOSI
G-DC ---- UART1-CTS

侧面的跳线需要 按屏幕型号进行选择
(就是绿色端子边上的3pin排针)
RES ---- 3R
或者
RES ---- 0.47R

这里我们是3R

取模

5-Air-合宙820-点墨水屏_第2张图片

保存到一个lua中

显示

--加载墨水屏功能测试模块
--按需选择
local eink = require"GDEY029Z94"

--加载一下图片数据
local picDatabw = require("gImage_BW")

--显示点东西
sys.taskInit(function ()
	sys.wait(5000)
	log.info("eink.init")
	eink.init()
	log.info("eink.refresh")
	--清屏
	eink.clear()
	sys.wait(5000)
	eink.init()

	--刷图
	eink.showPictureS(picDatabw)
	eink.deepSleep()
end)

上效果

5-Air-合宙820-点墨水屏_第3张图片

你可能感兴趣的:(AIR820,单片机,物联网,嵌入式)