zlg7290.c

来自「我写的针对lpc2141的ucos源码」· C语言 代码 · 共 100 行

C
100
字号
#include <LPC214X.h>
#include "type.h"
#include "irq.h"
#include "i2c.h"
#include "zlg7290.h"
#include "delay.h"




uint8 zlg7290_display(uint8 offset, uint8 content, uint8 dp,uint8 flash)
{
	I2C_WR_UNIT i2c_op[1];
	uint8 command[3];
	
	if(offset>7 && content>0x1f ) return FALSE;
	
	command[0]=ZLG7290_CmdBuf0;
	command[1]=0x60; 
	command[1]|=offset;
	command[2]=content;
	command[2]|=dp<<7;
	command[2]|=flash<<6;

	delay(10*1000);

	i2c_op[0].device_addr=0x70;
	i2c_op[0].length=3;
	i2c_op[0].buffer=command;
	i2c_op[0].counter=0;

		
	return i2c0_operation(i2c_op,1);


}

//display a "minus" at location indicated by offset
uint8 zlg7290_minus(uint8 offset)
{
	I2C_WR_UNIT i2c_op[1];
	uint8 command[2];

	command[0]=0x10+offset;
	command[1]=0x02;

	delay(10*1000);

	i2c_op[0].device_addr=0x70;
	i2c_op[0].length=2;
	i2c_op[0].buffer=command;
	i2c_op[0].counter=0;

	return i2c0_operation(i2c_op,1);
}


uint8 i2c_getkey()
{
	I2C_WR_UNIT op[2];
	uint8 subaddr[1]={0x01};	
	uint8 rd_buffer[1];

	op[0].device_addr=0x70;
	op[0].length=1;
	op[0].buffer=subaddr;
	op[0].counter=0;

	op[1].device_addr=0x71;
	op[1].length=1;
	op[1].buffer=rd_buffer;
	op[1].counter=0;

	i2c0_operation(op,2);

	return op[1].buffer[0];

}

void zlg7290_clean_left()
{

	zlg7290_display(0,0x1f,0,0);
	zlg7290_display(1,0x1f,0,0);
	zlg7290_display(2,0x1f,0,0);
	zlg7290_display(3,0x1f,0,0);

}

void zlg7290_clean_right()
{

	zlg7290_display(4,0x1f,0,0);
	zlg7290_display(5,0x1f,0,0);
	zlg7290_display(6,0x1f,0,0);
	zlg7290_display(7,0x1f,0,0);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?