您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > stm32的19264程序
#ifndef__LCD_19264_H#define__LCD_19264_H#includestm32f10x_lib.h#definePORTCONTROLGPIOB#definePORTDATAGPIOC#defineGPIO_Pin_BUSYGPIO_Pin_0#defineGPIO_Pin_REQGPIO_Pin_1#defineGPIO_Pin_RESETGPIO_Pin_5#defineWRITE_CHN0xf0//写国标汉字#defineWRITE_CHA0xf1//写8X8ASCII字符#defineWRITE_CHAR0xf9//写8X16ASCII字符#defineWRITE_WEI0xf2//写位点阵#defineWRITE_ZIJIE0xf3//写字节点阵#defineUP0xf5//上移#defineDOWN0xf6//下移#defineLEFT0xf7//左移#defineRIGHT0xf8//右移#defineFANBAI0xfa//反白功能#defineCLR_SCREEN0xf4//清屏/*Privatefunctionprototypes-----------------------------------------------*/voidLCD_Init(void);voidLCD_Write_Data(u8dat);voidLCD_Write_Cmd(u8comm,u8addr_x,u8addr_y);voidDisp_China(u8*chn,u8addr_x,u8addr_y,u8row,u8line);voidDisp_Chr(u8*chr,u8addr_x,u8addr_y,u8row,u8line);voidDisp_wei(u8addr_x,u8addr_y,u8row,u8line);voidCoordinate_axis(void);voidDisp_differevalue(u8*amp,u8*freq);voidDelay(vu32nCount);#endif----------------------------------------------------------------------------------------------------------------------#includeLCD_19264.h#includestm32f10x_lib.hu8Freq[]=频率:;u8Amp[]=幅度:;u8Power[]=总功率:;u8Power_value[]=w;u8Freq_value[]=k;u8Amp_value[]=v;u8zero[]=0;u8X_axis[]=Hz;u8Y_axis[]=v;u8addr_x=14;u8addr_y;u8j;u8number=0;u8number1[]=0123456789;u8unit,decade;externu8i;voidLCD_Init(void){GPIO_WriteBit(PORTCONTROL,GPIO_Pin_REQ,Bit_RESET);GPIO_WriteBit(PORTCONTROL,GPIO_Pin_RESET,Bit_SET);}voidLCD_Write_Data(u8dat){/*---------查忙信号-----------*/while(GPIO_ReadInputDataBit(PORTCONTROL,GPIO_Pin_BUSY)==1);GPIO_Write(PORTDATA,dat);Delay(10);GPIO_WriteBit(PORTCONTROL,GPIO_Pin_REQ,Bit_SET);while(GPIO_ReadInputDataBit(PORTCONTROL,GPIO_Pin_BUSY)==0)Delay(40);GPIO_WriteBit(PORTCONTROL,GPIO_Pin_REQ,Bit_RESET);}/*------------写命令或数据到LCD--------------*/voidLCD_Write_Cmd(u8comm,u8addr_x,u8addr_y){LCD_Write_Data(comm);//写命令LCD_Write_Data(addr_x);//写入X起始坐标LCD_Write_Data(addr_y);//写入Y起始坐标}/*--------------显示中文------------------*/voidDisp_China(u8*chn,u8addr_x,u8addr_y,u8row,u8line){u8i=0,j=0;for(j=addr_y;jline+addr_y;j++){for(i=addr_x;irow+addr_x;i++){LCD_Write_Cmd(WRITE_CHN,i,j);LCD_Write_Data(chn[(j-addr_y)*row*2+(i-addr_x)*2]-0xa0);LCD_Write_Data(chn[(j-addr_y)*row*2+(i-addr_x)*2+1]-0xa0);}}}/*--------------显示8*8ASCII字符------------------*/voidDisp_Chr(u8*chr,u8addr_x,u8addr_y,u8row,u8line)//*chr:指向数组的首地址,xy:起始坐标,row:行坐标,line:列坐标{u8i,j,k;k=0x00;for(i=addr_x;irow+addr_x;i++){for(j=addr_y;jline+addr_y;j++){LCD_Write_Cmd(WRITE_CHA,i,k+j/2);LCD_Write_Data(chr[(i-addr_x)+(j-addr_y)]);k=k+0x08;if(k==0x08*line)k=0x00;}}}/*--------------------------显示位点--------------------*/voidDisp_wei(u8addr_x,u8addr_y,u8row,u8line)//xy:起始坐标,row:行坐标,line:列坐标{u8i,j;for(i=addr_x;irow+addr_x;i++){for(j=addr_y;jline+addr_y;j++){LCD_Write_Cmd(WRITE_WEI,i,j);}}}/*--------------------------建立坐标轴--------------------------*/voidCoordinate_axis(void){/*建立y轴------------------*/Disp_wei(50,5,1,48);/*建立y轴箭头-------------*/Disp_wei(49,6,3,1);Disp_wei(48,7,5,1);/*建立x轴------------------*/Disp_wei(50,53,136,1);/*建立x轴箭头----------------*/Disp_wei(184,52,1,3);Disp_wei(183,51,1,5);/*确定零点坐标----------------*/Disp_Chr(zero,6,110,1,1);/*x轴单位---------------------*/Disp_Chr(X_axis,22,112,2,1);/*y轴单位---------------------*/Disp_Chr(Y_axis,7,0,1,1);/*建立频率值输入框-------------------------*/Disp_China(Freq,0,2,3,1);/*建立幅度值输入框-------------------------*/Disp_China(Amp,0,0,3,1);/*建立总功率值输入框-----------------------*/Disp_China(Power,20,0,4,1);/*显示幅度值和频率值----------------------*/Disp_Chr(Amp_value,5,42,1,1);Disp_Chr(Freq_value,5,100,1,1);Disp_Chr(Power_value,20,10,1,1);}/*----------------------对不同幅度值和频率进行显示------------------*/voidDisp_differevalue(u8*amp,u8*freq){Disp_Chr(amp,0,42,3,1);Disp_Chr(freq,0,100,2,1);}/********************************************************************************FunctionName:Delay*Description:Insertsadelaytime.*Input:nCount:specifiesthedelaytimelength.*Output:None*Return:None*******************************************************************************/voidDelay(vu32nCount){for(;nCount0;nCount--);}
本文标题:stm32的19264程序
链接地址:https://www.777doc.com/doc-7107457 .html