自己用到的段式液晶与点阵液晶的资料的一些分享
全部资料51hei下载地址:
Display module.zip
(9.83 MB, 下载次数: 259)
1.给ht1625发送命令控制字 数据必须是9位
2.ht1625初始化时 控制端口初始状态为高电平
ht1625单片机源程序如下:
- #include "lcd.h"
- static void nop(void)//
- {
- u8 i;
- for(i=0;i<90;i++)
- ;
- }
- //给1625发送命令与地址,写入3位ID命令或A6A5A4A3A2A1A0七位地址
- static void SendBit_1625(u8 mdata,u8 cnt) //mdata的高cnt位写入HT1625,高位在前
- {
- u8 i;
- for(i=0;i<cnt;i++)
- {
- LWR_L;
- if((mdata&0x80)==0)
- LDA_L;
- else
- LDA_H;
- nop();
- LWR_H;
- nop();
- mdata<<=1;
- }
- }
- //给1625发送数据,写入D0D1D2D3..cnt位数据到RAM
- static void SendDataBit_1625(u8 mdata,u8 cnt) //mdata的低cnt位写入HT1625,低位在前
- {
- u8 i;
- for(i=0;i<cnt;i++)
- {
- LWR_L;
- if((mdata&0x01)==0x00)
- LDA_L;
- else
- LDA_H;
- nop();
- LWR_H;
- nop();
- mdata>>=1;
- }
- }
- //读一个地址
- u8 Read_1625(u8 addr,u8 cnt)
- {
- u8 rd=0x00,i=0;
- LCS_L;
- SendBit_1625(0xc0,3); //控制命令110,启动读模式
- // SendBit_1625(addr<<1,7);
- // //读入的数据放在RD的低四位
- // for(i=0;i<cnt;i++)
- // {
- // if(LDA)
- // rd|=0x08;
- // else
- // rd&=0xf7;
- // LRD_L;
- // nop();//
- // LRD_H;
- // nop();//
- // rd = rd>>1; //rd>>1;
- // }
- // if(LDA)
- // rd|=0x08;
- // else
- // rd&=0xf7;
- // LCS=1;
- return rd;
- }
- //给1625发送命令控制字
- void SendCmd(u8 command)
- {
- LCS_L;
- SendBit_1625(0x80,3); //控制命令100,启动命令模式
- SendBit_1625(command,9); //jjk命令处 数据数必须是9 将命令command发送给1625
- LCS_H;
- }
- //LCD初始化,向HT1625写入命令
- void LCD_init(void)
- {
- //LCD端口初始化,定义控制引脚数据方向
- LCS_H;LWR_H;LDA_H;LRD_H;nop();
- SendCmd(0x01); //命令2:0x01,打开系统晶振SYS_EN
- SendCmd(0x03); //命令3:0x03,开LCD显示 LCD_ON
- SendCmd(0x18); //命令1:0x18,使用片上RC振荡器RC_32K
- }
- //写一个地址
- void Write_1625(u8 addr,u8 mdata)
- {
- LCS_L;
- SendBit_1625(0xa0,3); //启动写模式
- SendBit_1625(addr,7); //写入A6A5A4A3A2A1A0七位地址
- SendDataBit_1625(mdata,4); //写入D0D1D2D3数据到RAM
- LCS_H;
- }
- //从一地址处连续写入
- void WriteAll_1625(u8 addr,u8 *p,u8 cnt) //起始地址,数组指针,数据字节数
- {
- u8 i;
- LCS_L;
- SendBit_1625(0xa0,3); //启动写模式
- SendBit_1625(addr,7); //写入A6A5A4A3A2A1A0七位地址
- for(i=0;i<cnt;i++,p++) //依次写入cnt个字节数据
- {
- SendDataBit_1625(*p,8);
- }
- LCS_H;
- }
- //清屏&全屏显示
- void full_or_clear (u8 F_C) //1:全显,0:清屏
- {
- u8 i,p;
- if(F_C)
- p=0xff;
- else
- p=0x00;
- LCS_L;
- SendBit_1625(0xa0,3); //启动写模式
- SendBit_1625(0x00,7); //地址0000H
- for(i=0;i<64;i++)
- {
- SendDataBit_1625(p,8); //将全显或清屏数据写入1625
- }
- LCS_H;
- }
复制代码
Segment code LCD菜单程序:
- #include "stm32f10x_it.h"
- #include "lcd.h"
- #include "string.h"
- #include "drv_sys.h"
- #include "delay.h"
- #include "drv_rtc.h"
- #include "math.h"
- u16 SystemPara[18] =
- {0,100,1,246,200,0,0,0,10,1,300,180,100,100,300,0,1,20};
- unsigned char dis_buffer[64]; //液晶显示字符缓存数组
- //1-4行数字 字母 0 1 2 3 4 5 6 7 8 9 . C c o d E F H h n u
- const unsigned char my_7seg_J[21]={0xEE,0x24,0xBA,0xB6,0x74,0xD6,0xDE,0xA4,0xFE,0xF4,0x01,0xCA,0x1A,0x1E,0x3E,0xDA,0xD8,0x7C,0x5C,0x1C,0x0E,};
- //1-4符号 XJ % M K V A M K W Var
- const unsigned char my_unit[10]={0x80,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x01};
- //5符号 M K W h M K V ar
- const unsigned char my_unit5[9]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
- //指示行 数字 字母 0 1 2 3 4 5 6 7 8 9 C U I P Q F
- const unsigned char my_13seg_J[16]={0x9A,0x18,0x92,0x9A,0x18,0x8A,0x8A,0x98,0x9A,0x98,0x82,0x1A,0xC2,0x90,0x9E,0x80};
- const unsigned char my_13seg_K[16]={0x84,0x00,0x24,0x20,0xA0,0xA0,0xA4,0x00,0x84,0xA0,0x84,0x84,0x10,0xA4,0x84,0xA4};
- //*****8位字节翻转
- unsigned char ru8(unsigned char s)
- {
- unsigned char rtn = 0,i=0;
- for(i = 0 ; i < 8 ; i++)
- {
- rtn |= ((s & (1 << i)) >> i) << (7 - i) ;
- }
- return rtn ;
- }
- void Refurbish_Disply(unsigned char *dis_buff,unsigned char dat0,unsigned char dat1,unsigned char dat2,unsigned char dat3,unsigned char dat4,unsigned char line_number)
- {
- switch(line_number)
- {
- case 0:{
- dis_buff[6] = my_7seg_J[dat0];
- dis_buff[7] = my_7seg_J[dat1];
- dis_buff[8] = my_7seg_J[dat2];
- dis_buff[9] = my_7seg_J[dat3];//此处应考虑X9--Var
- //符号
- if(dat4) dis_buff[4] |=0x02;
- else dis_buff[4] &=0xFD;
- //测量内容
- dis_buff[5] |=0x01;//a
- dis_buff[4] |=0x01;//b
- dis_buff[3] |=0x01;//E
-
- } break;
- case 1:{
- dis_buff[12] = my_7seg_J[dat0];
- dis_buff[13] = my_7seg_J[dat1];
- dis_buff[14] = my_7seg_J[dat2];
- dis_buff[15] = my_7seg_J[dat3];//此处应考虑X18--Var
- //符号
- if(dat4)dis_buff[63] |=0x02;
- else dis_buff[63] &=0xFD;
- //测量内容
- dis_buff[0] |=0x01;//b
- dis_buff[63] |=0x01;//c
- dis_buff[63] |=0x04;//E
-
- } break;
- case 2:{
- dis_buff[39] = ru8(my_7seg_J[dat0]);
- dis_buff[38] = ru8(my_7seg_J[dat1]);
- dis_buff[37] = ru8(my_7seg_J[dat2]);
- dis_buff[18] = ru8(my_7seg_J[dat3]);//此处应考虑X27--Var
- //符号
- if(dat4)dis_buff[59] |=0x01;
- else dis_buff[59] &=0xFE;
- //测量内容
- dis_buff[60] |=0x02;//c
- dis_buff[60] |=0x01;//a
- dis_buff[59] |=0x02;//E
-
-
- } break;
- case 3:{
- dis_buff[40] = my_7seg_J[dat0];
- dis_buff[41] = my_7seg_J[dat1];
- dis_buff[42] = my_7seg_J[dat2];
- dis_buff[43] = my_7seg_J[dat3];//此处应考虑X37--Var
- //符号
- if(dat4)dis_buff[55] |=0x04;
- else dis_buff[55] &=0xFB;
- //测量内容
- dis_buff[57] |=0x01;//Avg
- dis_buff[56] |=0x01;//n
- dis_buff[55] |=0x08;//E
- //单位
- dis_buff[44] = my_unit[dat3];
- //Hz
- dis_buff[54] |=0x20;//
- } break;
-
- default :break;
- }
-
- }
- //1,2,3,4行数码管显示数字,缓存数组指针、更新数据、第几行显示
- void dis_number(unsigned char *dis_buf,long data,unsigned char line_number)
- {
- unsigned long mydata;
- unsigned char dat0,dat1,dat2,dat3,dat4;
-
- if(data < 0)
- {
- mydata = fabs(data);
- dat4 = 1;
-
- }else
- {
- mydata = data;
- dat4 = 0;
- }
- dat3 = mydata%10;
- dat2 = mydata%100/10;
- dat1 = mydata%1000/100;
- dat0 = mydata%10000/1000;
- Refurbish_Disply(dis_buf,dat0,dat1,dat2,dat3,dat4,line_number);
- }
- //显示数据高4位值,缓存数组指针、更新数据、第几行显示
- void dis_num_H(unsigned char *dis_buf,long data,unsigned char line_number)
- {
- long mydata;
- if(data / 1000000000)
- mydata = data /1000000;
- else if(data / 100000000)
- mydata = data /100000;
- else if(data / 10000000)
- mydata = data /10000;
- else if(data / 1000000)
- mydata = data /1000;
- else if(data / 100000)
- mydata = data /100;
- else if(data / 10000)
- mydata = data /10;
- else mydata = data;
-
- dis_number(dis_buf,mydata,line_number);
- }
- //5行数码管显示数字,缓存数组指针、更新数据、第几行显示
- void dis_number5(unsigned char *dis_buf,long data)
- {
- unsigned long mydata;
- unsigned char dat0,dat1,dat2,dat3,dat4,dat5,dat6,dat7;
-
- if(data < 0)
- {
- mydata = fabs(data);
- dis_buf[54] |=0x01; //负号
- }else
- {
- mydata = data;
- dis_buf[54] &=0xFE; //负号
- }
-
- dat7 = mydata%10;
- dat6 = mydata%100/10;
- dat5 = mydata%1000/100;
- dat4 = mydata%10000/1000;
- dat3 = mydata%100000/10000;
- dat2 = mydata%1000000/100000;
- dat1 = mydata%10000000/1000000;
- dat0 = mydata%100000000/10000000;
-
- dis_buf[53] = ru8(my_7seg_J[dat0]);
- dis_buf[52] = ru8(my_7seg_J[dat1]);
- dis_buf[51] = ru8(my_7seg_J[dat2]);
- dis_buf[50] = ru8(my_7seg_J[dat3]);
- dis_buf[49] = ru8(my_7seg_J[dat4]);
- dis_buf[48] = ru8(my_7seg_J[dat5]);
- dis_buf[47] = ru8(my_7seg_J[dat6]);
- dis_buf[46] = ru8(my_7seg_J[dat7]);//此处应考虑X37--Var
- //冒号
- dis_buf[54] |=0x04; //P16
- dis_buf[54] |=0x08; //P19
- //测量内容
- dis_buf[55] |=0x40;//a
- dis_buf[55] |=0x20;//b
- dis_buf[55] |=0x10;//c
- dis_buf[55] |=0x80;//E
- //单位
- dis_buf[45] |=my_unit5[my_S_M];//
- dis_buf[46] |=0x80;//h
- }
- //指示行 数码管显示数字,缓存数组指针、更新数据
- void Instruct_line(unsigned char *dis_buff,unsigned char dat0,unsigned char dat1,unsigned char dat2)
- {
- unsigned char Temp[6];
- Temp[0] = dis_buff[0]&0x03;
- Temp[1] = dis_buff[1]&0x01;
- Temp[2] = dis_buff[2]&0x03;
- Temp[3] = dis_buff[3]&0x01;
- Temp[4] = dis_buff[4]&0x03;
- Temp[5] = dis_buff[5]&0x01;
-
- dis_buff[1] = my_13seg_J[dat0] |Temp[1] ;//
- dis_buff[0] = my_13seg_K[dat0] |Temp[0];//
-
- dis_buff[3] = my_13seg_J[dat1] |Temp[3];//
- dis_buff[2] = my_13seg_K[dat1] |Temp[2];//
-
- dis_buff[5] = my_13seg_J[dat2] |Temp[5];//
- dis_buff[4] = my_13seg_K[dat2] |Temp[4];//
- }
- //电压单位转换 小数点
- void Change_U(long data,unsigned char ABC)
- {
- unsigned long Temp_U = 0;
- Temp_U = fabs(data);
- if(Temp_U<10000)//xxx.x V
- {
- switch(ABC){ //V 擦除var 小数点
- case 0:{dis_buffer[10] = my_unit[my_V];dis_buffer[9] &= 0XFE;dis_buffer[8] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_V];dis_buffer[15] &= 0XFE;dis_buffer[14] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_V]);dis_buffer[18] &= 0X7F;dis_buffer[37] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_V];dis_buffer[43] &= 0XFE;dis_buffer[42] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;}break;
- default: break;
- }
- }
- else if(Temp_U<100000)//x.xxx KV
- {
- switch(ABC){
- case 0:{dis_buffer[10] = my_unit[my_V] | my_unit[my_K]; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_V] | my_unit[my_K];dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_V] | my_unit[my_K]);dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_V] | my_unit[my_K];dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default: break;
- }
- }
- else if(Temp_U<1000000)//xx.xx KV
- {
- switch(ABC){
- case 0:{dis_buffer[10] = my_unit[my_V] | my_unit[my_K]; dis_buffer[9] &= 0XFE;dis_buffer[7] |= 0x01; dis_buffer[6] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_V] | my_unit[my_K];dis_buffer[15] &= 0XFE;dis_buffer[13] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_V] | my_unit[my_K]);dis_buffer[18] &= 0X7F;dis_buffer[38] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_V] | my_unit[my_K];dis_buffer[43] &= 0XFE;dis_buffer[41] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default: break;
- }
- }
- else if(Temp_U<10000000)//xxx.x KV
- {
- switch(ABC){
- case 0:{dis_buffer[10] = my_unit[my_V] | my_unit[my_K];dis_buffer[9] &= 0XFE;dis_buffer[8] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_V] | my_unit[my_K];dis_buffer[15] &= 0XFE;dis_buffer[14] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_V] | my_unit[my_K]);dis_buffer[18] &= 0X7F;dis_buffer[37] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_V] | my_unit[my_K];dis_buffer[43] &= 0XFE;dis_buffer[42] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;}break;
-
- default: break;
- }
- }
- else //x.xxx MV
- {
- switch(ABC){
- case 0:{dis_buffer[10] = my_unit[my_V] | my_unit[my_M]; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_V] | my_unit[my_M];dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_V] | my_unit[my_M]);dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_V] | my_unit[my_M];dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
-
- default: break;
- }
- }
- }
- //电流单位转换
- void Change_I(long data,unsigned char ABC)
- {
- unsigned long Temp_A = 0;
- //dis_buffer[6] |= 0x01;dis_buffer[7] |= 0x01;dis_buffer[8] |= 0x01;
- //dis_buffer[12] |= 0x01;dis_buffer[13] |= 0x01;dis_buffer[14] |= 0x01;
- //dis_buffer[39] |= 0x80;dis_buffer[38] |= 0x80;dis_buffer[37] |= 0x80;
- //dis_buffer[40] |= 0x01;dis_buffer[41] |= 0x01;dis_buffer[42] |= 0x01;
- //擦除小数点
- // dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;
- // dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;
- // dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;
- // dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;
- Temp_A = fabs(data);
- if(Temp_A<10000) //x.xxx A
- {
- switch(ABC)
- { //V 擦除var 小数点
- case 0:{dis_buffer[10] = my_unit[my_A]; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_A] ;dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_A] );dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_A] ;dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<100000) //xx.xx A
- {
- switch(ABC)
- {
- case 0:{dis_buffer[10] = my_unit[my_A]; dis_buffer[9] &= 0XFE;dis_buffer[7] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_A];dis_buffer[15] &= 0XFE;dis_buffer[13] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_A] );dis_buffer[18] &= 0X7F;dis_buffer[38] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_A];dis_buffer[43] &= 0XFE;dis_buffer[41] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<1000000) //xxx.x A
- {
- switch(ABC)
- {
- case 0:{dis_buffer[10] = my_unit[my_A] ;dis_buffer[9] &= 0XFE;dis_buffer[8] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_A] ;dis_buffer[15] &= 0XFE;dis_buffer[14] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_A] );dis_buffer[18] &= 0X7F;dis_buffer[37] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_A] ;dis_buffer[43] &= 0XFE;dis_buffer[42] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<10000000) //x.xxx kA
- {
- switch(ABC)
- {
-
- case 0:{dis_buffer[10] = my_unit[my_A] | my_unit[my_K]; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_A] | my_unit[my_K];dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_A] | my_unit[my_K]);dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_A] | my_unit[my_K];dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
- else
- {
- switch(ABC) //xx.xx kA
- {
- case 0:{dis_buffer[10] = my_unit[my_A] | my_unit[my_K]; dis_buffer[9] &= 0XFE;dis_buffer[7] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[my_A] | my_unit[my_K];dis_buffer[15] &= 0XFE;dis_buffer[13] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[my_A] | my_unit[my_K]);dis_buffer[18] &= 0X7F;dis_buffer[38] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[my_A] | my_unit[my_K];dis_buffer[43] &= 0XFE;dis_buffer[41] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
-
- }
- //功率单位转换unsigned char *dis_buf,
- void Change_P(long data,unsigned char ABCD) //电流单位转换,A:0 B:1 C:2
- {
- unsigned long Temp_A = 0;
- Temp_A = fabs(data);
- if(Temp_A<10000) //x.xxx kW
- {
- switch(ABCD)
- { //V 擦除var 小数点
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_K] ; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_K]);dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<100000) //xx.xx kW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_K]; dis_buffer[9] &= 0XFE;dis_buffer[7] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[15] &= 0XFE;dis_buffer[13] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_K]);dis_buffer[18] &= 0X7F;dis_buffer[38] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[43] &= 0XFE;dis_buffer[41] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<1000000) //xxx.x kW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[9] &= 0XFE;dis_buffer[8] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[15] &= 0XFE;dis_buffer[14] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_K]);dis_buffer[18] &= 0X7F;dis_buffer[37] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[43] &= 0XFE;dis_buffer[42] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;}break;
- default :break;
- }
- }
- else if(Temp_A<10000000) //x.xxx MW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_M]; dis_buffer[9] &= 0XFE;dis_buffer[6] |= 0x01;dis_buffer[7] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[15] &= 0XFE;dis_buffer[12] |= 0x01;dis_buffer[13] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_M]);dis_buffer[18] &= 0X7F;dis_buffer[39] |= 0x80;dis_buffer[38] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[43] &= 0XFE;dis_buffer[40] |= 0x01;dis_buffer[41] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default: break;
- }
- }
- else if(Temp_A<100000000) //xx.xx MW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_M]; dis_buffer[9] &= 0XFE;dis_buffer[7] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[8] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[15] &= 0XFE;dis_buffer[13] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[14] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_M]);dis_buffer[18] &= 0X7F;dis_buffer[38] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[37] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[43] &= 0XFE;dis_buffer[41] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[42] &= 0xFE;}break;
- default: break;
- }
- }
- else if(Temp_A<1000000000) //xxx.x MW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[9] &= 0XFE;dis_buffer[8] |= 0x01;dis_buffer[6] &= 0xFE;dis_buffer[7] &= 0xFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[15] &= 0XFE;dis_buffer[14] |= 0x01;dis_buffer[12] &= 0xFE;dis_buffer[13] &= 0xFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_M]);dis_buffer[18] &= 0X7F;dis_buffer[37] |= 0x80;dis_buffer[39] &= 0x7F;dis_buffer[38] &= 0x7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_M];dis_buffer[43] &= 0XFE;dis_buffer[42] |= 0x01;dis_buffer[40] &= 0xFE;dis_buffer[41] &= 0xFE;}break;
- default: break;
- }
- }
- else //xxxx MW
- {
- switch(ABCD)
- {
- case 0:{dis_buffer[10] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[9] &= 0XFE;}break;
- case 1:{dis_buffer[16] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[15] &= 0XFE;}break;
- case 2:{dis_buffer[17] =ru8(my_unit[Power_W] | my_unit[Power_K]);dis_buffer[18] &= 0X7F;}break;
- case 3:{dis_buffer[44] = my_unit[Power_W] | my_unit[Power_K];dis_buffer[43] &= 0XFE;}break;
- default: break;
- }
- }
- }
- void Display_tiaoshi(void)
- {
- LIGHT_H;
- dis_buffer[11] = 0x80;//许继标
-
- dis_buffer[2] |= 0x02;//谐波分量
- dis_buffer[2] |= 0x01;//LINE 3-
- dis_buffer[1] |= 0x01;//3 T7
- dis_buffer[0] |= 0x02;//4 T8
- dis_buffer[63] |= 0x10;//电话谐波因子T9
- dis_buffer[63] |= 0x40;//铃 图案T14
- dis_buffer[63] |= 0x20;//H系数 T15
- dis_buffer[63] |= 0x80;//开入 T16
- dis_buffer[63] |= 0x08;//MAX T17
-
- dis_buffer[62] |= 0x02;//MIN T18
- dis_buffer[62] |= 0x01;//需量 T19
- dis_buffer[62] |= 0x80;//1开入开关座 图标 T20
- dis_buffer[62] |= 0x20;//1开入开 图标 T21
- dis_buffer[62] |= 0x40;//1开入闭 图标 T22
-
- dis_buffer[62] |= 0x10;//2开入开关座 图标 T23
- dis_buffer[62] |= 0x04;//2开入开 图标 T24
- dis_buffer[62] |= 0x08;//2开入闭 图标 T25
-
- dis_buffer[61] |= 0x80;//3开入开关座 图标 T26
- dis_buffer[61] |= 0x20;//3开入开 图标 T27
- dis_buffer[61] |= 0x40;//3开入闭 图标 T28
-
- dis_buffer[61] |= 0x10;//4开入开关座 图标 T29
- dis_buffer[61] |= 0x04;//4开入开 图标 T30
- dis_buffer[61] |= 0x08;//4开入闭 图标 T31
-
- dis_buffer[61] |= 0x02;//开出 T32
- dis_buffer[61] |= 0x01;//电压合格率T33
- dis_buffer[60] |= 0x80;//1开出开关座 图标 T38
- dis_buffer[60] |= 0x20;//1开出开 图标 T39
- dis_buffer[60] |= 0x40;//1开出闭 图标 T40
-
- dis_buffer[60] |= 0x10;//2开出开关座 图标 T41
- dis_buffer[60] |= 0x04;//2开出开 图标 T42
- dis_buffer[60] |= 0x08;//2开出闭 图标 T43
-
- dis_buffer[59] |= 0x80;//3开出开关座 图标 T44
- dis_buffer[59] |= 0x20;//3开出开 图标 T45
- dis_buffer[59] |= 0x40;//3开出闭 图标 T46
-
- dis_buffer[59] |= 0x10;//4开出开关座 图标 T47
- dis_buffer[59] |= 0x04;//4开出开 图标 T48
- dis_buffer[59] |= 0x08;//4开出闭 图标 T49
-
- dis_buffer[58] |= 0x01;//电流K系数 T50
- dis_buffer[58] |= 0x02;//电感图标 T52
- dis_buffer[57] |= 0x02;//电压波峰系数 T53
- dis_buffer[58] |= 0x04;//电容图标 T55
- dis_buffer[56] |= 0x02;//三相不平衡度T56
-
- dis_buffer[58] |= 0x08;//电脑图标 T59
- dis_buffer[57] |= 0x08;//本 T60
- dis_buffer[57] |= 0x04;//上 T61
- dis_buffer[56] |= 0x08;//上 T62
- dis_buffer[56] |= 0x04;//月 T63
- dis_buffer[57] |= 0x20;//尖 T64
- dis_buffer[57] |= 0x10;//峰 T65
- dis_buffer[56] |= 0x20;//平 T66
- dis_buffer[56] |= 0x10;//谷 T67
- dis_buffer[58] |= 0x20;//正 T68
- dis_buffer[58] |= 0x10;//负 T69
- dis_buffer[57] |= 0x40;//有功 T70
- dis_buffer[56] |= 0x40;//电度 T71
- dis_buffer[58] |= 0x40;//正 T75
- dis_buffer[58] |= 0x80;//负 T76
- dis_buffer[57] |= 0x80;//无功 T77
- dis_buffer[56] |= 0x80;//电度 T78
-
- dis_number5(dis_buffer,9876);
- dis_num_H(dis_buffer,9876,0);
- Change_P(9876,0);
- dis_num_H(dis_buffer,-54321,1);
- Change_P(-54321,1);
- WriteAll_1625(0x00,dis_buffer,64);
- dis_num_H(dis_buffer,543212,2);
- Change_P(543211,2);
- WriteAll_1625(0x00,dis_buffer,64);
- dis_num_H(dis_buffer,5432123,3);
- Change_P(5432123,3);
- WriteAll_1625(0x00,dis_buffer,64);
- Instruct_line(dis_buffer,Ins_C,Ins_0,Ins_5);//cos
-
-
- }
复制代码
ht1621b中文.pdf
ht1625v170.pdf
|