uc1623 段码点阵驱动

void uc1623_IC_Init(void)
{	
	
//#define UC1623_TEMO	

		UC1623_RST(1);
		_mDelay(10);
		UC1623_RST(0);
		_mDelay(15);
		UC1623_RST(1);
		
		_mDelay(3);
	//F_Set_address();
	_uc1623_send(0,0x60|0x0);  // pa  0
	_uc1623_send(0,0x4);
	_uc1623_send(1,0);       // ca ==>0
	_mDelay(1);

	
	_uc1623_send(0,0x10|0x01);  		//Temo Vop off
	_uc1623_send(0,0x12|0x00);  		//Temo FR off    on |0x01 
	_uc1623_send(0,0x14|0x00);  		//Temo Sensor off  on |0x01
	
		_mDelay(1);
	_uc1623_send(0,0x84|0x0);  		//Partial off(default0b)
	_uc1623_send(0,0x86|0x0);  		//COM Scan:Interlace (Default [0]b)
	
	_uc1623_send(0,0x88|0x1);  		//RAM Control ( -> default [001]b)
	
	_uc1623_send(0,0xC0|0x01);  		//LCD Mapping Control(default[01]b)
	
	_uc1623_send(0,0x24);			//Temp:-0.05%(Default)
	_uc1623_send(0,0x2D);      	//PUMP INT/icon on 
	_uc1623_send(0,0x87);			//Progressive()
	_mDelay(1);
	_uc1623_send(0,0xC8);  		//N_Line
	_uc1623_send(1,1);  		//     
	
	_mDelay(1);
	_uc1623_send(0,0xF1);  		//COM END
	_uc1623_send(1,7);  			//0~31
	_mDelay(1);
	
	_uc1623_send(0,0xE8);  		//Bias:1/4=0XE8  ,Bias:1/8(Default)=0XEB ,1/5 = 0xe9 ,{6,8,10,12}
	
//		_mDelay(1);
//	_uc1623_send(0,0x17);  		// Set Temperature Poin
//	_uc1623_send(1,0);  		//no Select Temp Point
//	_uc1623_send(1,55);//238);  	//84(default)

//	_uc1623_send(0,0X30);  		//APC0
//	_uc1623_send(1,0X0D);   //
	
	_mDelay(1);
	_uc1623_send(0,0x81);  		//Set PM
	_uc1623_send(1,0);  		//no Select Temp Point
	_uc1623_send(1,238);//238);  	//84(default)
	
	_mDelay(1);
	_uc1623_send(0,0x16);  		//Set LR
	_uc1623_send(1,0x00);  		//
	_uc1623_send(1,0x1F);  		// D(default:0XD,3.3K)
	_mDelay(1);
	_uc1623_send(0,0xc9);  		//Set display mode
	_uc1623_send(1,0xAC|0x01);  		//display on [1b on]
	_mDelay(1);
}

/*

start, 0~18
set , 0~4   5 的字节
data ,数据

*/
void _Seg_WriteFontByte(u8 start,u8 set, uint8_t data)
{

	int  x = 0,y;
	uint8_t mask=0x01; 

  if(start >= SEG_C_VUNIT_ADDR  && start < SEG_S_VOLT_VAL_ADDR)
	{
      x = 1;
		start +=(4-set);// 
		//start +=set;//  1,2,3,4

	}else  if(start >= SEG_C_MODITEM_ADDR && start < SEG_C_5x7x19_ADDR){

       x = 2;
		
		if( start - SEG_C_MODITEM_ADDR < 5) //11 12 13 14 15 16
			start +=5;
		else
			start -=5;
			start +=(4-set);// 4,3,2,1,0
			

	}else  if(start >= SEG_C_5x7x19_ADDR &&  start < SEG_C_AUNIT_ADDR){

     x = 19; //21 22 2 4 25 26
		start += set;
		if(set >= 2)
		start +=1;
	//段码是倒着来的 BIT0 要写在高位
		for(y = 7; y >= 0;y--)//  0 bit 未接,
		{
			if(data& mask)
			{
				DISPADDR(start) |= (1 << y);
				
			 }else{

				DISPADDR(start) &= ~(1<< y);

				}
				mask <<= 1;
		}
		//---------------clear dot-------------------/
    if(set == 0x04)
		{
				DISPADDR(start+1) = 0;
		}

	}else  if(start >= SEG_C_AUNIT_ADDR &&  start < SEG_S_CURR_VAL_ADDR){

			x = 2;
		
		if( start - SEG_C_AUNIT_ADDR < 5) 
			start +=5;
		else
			start -=5;
			start +=(4-set);//
		
	}

 if(x ==1 || x==2)
	{
		for(y = 0; y < 7;y++)//  0 bit 未接,
		{
			if(data& mask)
			{
				DISPADDR(start) |= (1 << y);
				
			 }else{

				DISPADDR(start) &= ~(1<< y);

				}
				mask <<= 1;
		}
	}

}

 void _SegLcdPutChar(u8 s, u8 c)
{
  int i=0;

  for(i =0;i < 5;i++)
	{
    if(c == 0)
      c = 0x20;
		_Seg_WriteFontByte(s,i,(u8)Char57Ascii[(c - 0x20)][i]); 
	}
}

void SegPutUnits(u8 addr,char *s,int slen) //010.000
{
  int j = 0;
  for(j =0;j < slen;j++)
	{
		_SegLcdPutChar(addr+5*j,*s++);//154 155 156 157 158  159
	}
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值