完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
共同进步O(∩_∩)O
|
|
|
|
|
|
楼主帮我看一下,这段程序可以用12864显示不
#include "main.h" #include "lcd.h" #include #include "HX711.h" unsigned char buf[20]; unsigned long HX711_Buffer = 0; unsigned int Weight_Maopi = 0,Weight_Shiwu = 0;// Weight_Shiwu???? float Weight,Price,FMoney; char rice_Count = 0; //×??? unsigned char KEY_NUM = 0; unsigned char rice_Buffer[3] = {0x00,0x00,0x00}; unsigned long Money = 0; bit Flag_OK = 0; //**************************************************** //?÷???? //**************************************************** void main() { init_lcd();//??????LCD WriteString( 2, 0 ,"Welcome to use!") ; /* write_com(0x80);//?????è?? WriteStr("Welcome to use! ");//???ú?????????? */ delayms(2000); //???±2s delayms(2000); delayms(2000); ClrSreen(); looprice_Count = 0; Price_Buffer[0] = 0; Price_Buffer[1] = 0; Price_Buffer[2] = 0; Flag_OK = 0; WriteString( 1 ,0,"??????0.000KG ") ; WriteString( 2,0 ,"????: . ??") ; WriteString( 3 ,0,"×????? . ??") ; WriteString( 4,0, "??????????"); /* write_com(0x80);//?????è?? WriteStr("+WEI |PRI | MON "); write_com(0x80+0x40);//?????è?? WriteStr("0.000| . | . "); */ Get_Maopi();//?????¤???? while(1) { if( Flag_OK == 0) { Get_Weight();//???? write_com(0x80+3); write_data(Weight_Shiwu/1000 + 0x30); write_data('.'); write_data(Weight_Shiwu%1000/100 + 0x30); write_data(Weight_Shiwu%100/10 + 0x30); write_data(Weight_Shiwu%10 + 0x30); //?????±?°???? /* write_com(0x80+0x40); write_data(Weight_Shiwu/1000 + 0x30); write_data('.'); write_data(Weight_Shiwu%1000/100 + 0x30); write_data(Weight_Shiwu%100/10 + 0x30); write_data(Weight_Shiwu%10 + 0x30); */ } KEY_NUM = KEY_Scan(); if( KEY_NUM != 0x55)//?±·??????????????±?ò???·??°??ü°????? { if(KEY_NUM == 16)//??×?A?ü?????¤???? { Get_Maopi();//???¤ } if(KEY_NUM == 15)//??×?B?ü?????ü?????????? { goto loop; } if(KEY_NUM == 12)//??×?C?????????í?ó?±·????????? { Price_Count--; if( rice_Count < 0) { Price_Count = 0; } Price_Buffer[Price_Count] = 0; //???????????????????? switch(Price_Count) { case 0: write_com(0x90+3); write_data(' '); break; case 1: write_com(0x80+3); write_data(0x20);// write_data(' '); break; case 2: write_com(0x80+4); write_data('.'); write_data(' '); break; default: break; } } if(KEY_NUM == 13)//??×?D?ü??????×??? { Money = rice_Buffer[0] * 100 + rice_Buffer[1] * 10 + rice_Buffer[2]; Money = Money * Weight_Shiwu / 1000; write_com(0x88+3); write_data(Money/1000 + 0x30); write_data(Money%1000/100 + 0x30); write_data(Money%100/10 + 0x30); write_data('.'); write_data(Money%10 + 0x30); /* write_com(0x80+0x40+11); write_data(Money/1000 + 0x30); write_data(Money%1000/100 + 0x30); write_data(Money%100/10 + 0x30); write_data('.'); write_data(Money%10 + 0x30); */ Flag_OK = 1; } if(KEY_NUM >= 0 && KEY_NUM <= 9) //???????????????? { Price_Buffer[Price_Count] = KEY_NUM; switch(Price_Count) { case 0: write_com(0x90+3); write_data(Price_Buffer[0] + 0x30); /* write_com(0x80+0x40+6); write_data(Price_Buffer[0] + 0x30); */ break; case 1: write_com(0x90+3); write_data(0x20);// write_data(Price_Buffer[1] + 0x30); /* write_com(0x80+0x40+7); write_data(Price_Buffer[1] + 0x30); */ break; case 2: write_com(0x90+4); write_data('.');// write_data(Price_Buffer[2] + 0x30); /* write_com(0x80+0x40+9); write_data(Price_Buffer[2] + 0x30); */ break; default: break; } Price_Count++; if( rice_Count >= 3) { Price_Count = 3; } } } } } //**************************************************** //???ó?ü???¨?è //**************************************************** unsigned char KEY_Scan() { unsigned char temp = 0; unsigned char com = 0x55 , com1 = 0 , com2 = 0; P3=0xf0; if(P3!=0xf0) { com1=P3; P3=0x0f; com2=P3; } P3=0xf0; while(P3!=0xf0); temp=com1|com2; if(temp==0xee)com=1;//??×?1 if(temp==0xed)com=4;//??×?4 if(temp==0xeb)com=7;//??×?7 if(temp==0xe7)com=11;//±????ü*???ü if(temp==0xd7)com=0;//??×?0 if(temp==0xb7)com=14;//±????ü*???ü if(temp==0xde)com=2; //??×?2 if(temp==0xdd)com=5; //??×?5 if(temp==0xdb)com=8;//??×?8 if(temp==0xbe)com=3;//??×?3 if(temp==0xbd)com=6; //??×?6 if(temp==0xbb)com=9;//??×?9 if(temp==0x7e)com=16;//??×?A?ü?????¤???? if(temp==0x7d)com=15;//??×?B?ü?????ü?????????? if(temp==0x7b)com=12;//??×?C?????????í?ó?±·????????? if(temp==0x77)com=13;//??×?D?ü??????×??? return(com); } //**************************************************** //???? //**************************************************** void Get_Weight() { HX711_Buffer = HX711_Read(); HX711_Buffer = HX711_Buffer/100; if(HX711_Buffer > Weight_Maopi) { Weight_Shiwu = HX711_Buffer; Weight_Shiwu = Weight_Shiwu - Weight_Maopi;//??????????AD???ù?????? Weight_Shiwu = (unsigned int)((float)Weight_Shiwu/4.22+0.05); //?????????????????? //?ò?????????????÷?????ú???????ù???ò???????????????÷?è????????????4.30?????????? //?±·????????????????????ó?±?????????????? //???????????????????????±?????????????? //????????°???4.0-5.0???????ò?????÷???????¨?? //+0.05?????????á????°?·??? Buzzer = 1;//??±???±¨ } else if(HX711_Buffer < Weight_Maopi - 30) { Buzzer = 0;//??????±¨?? } else if(HX711_Buffer > Weight_Maopi + 24970)//?ó??5Kg??×??ó??????±¨?? { Buzzer = 0; } } //**************************************************** //???????¤???? //**************************************************** void Get_Maopi() { HX711_Buffer = HX711_Read(); Weight_Maopi = HX711_Buffer/100; } //**************************************************** //MS???±????(12M?§????????) //**************************************************** void Delay_ms(unsigned int n) { unsigned int i,j; for(i=0;i |
|
|
|
以下附上LCD.c
void delayms(uint z)//???± z ms { uint i; uchar j; for(i=z;i>0;i--) for(j=110;j>0;j--); } void delays(unsigned char j) { unsigned char k; unsigned int i; for(;j>0;j--) { for(i=1250;i>0;i--) { for(k=180;k>0;k--); } } } void write_com(uchar a)//???ü?? { E=0;RS=0;RW=0; E=1; P0=a; delayms(10); //???± 5ms E=0; delayms(10); //???± 5ms } void write_data(uchar b)//?????? { E=0;RS=1;RW=0; E=1; P0=b; delayms(10); //???± 5ms E=0; delayms(10); //???± 5ms } void init_lcd() //?????? { write_com(0x01); //???? write_com(0x30); //?????è?? write_com(0x0c); //??/???????è?? write_com(0x06); //????·????è?? write_com(0x14); //??±ê???? } void ClrSreen() { write_com(0x01); //???? } void LCD_set_xy( unsigned char x,unsigned char y) { unsigned char address; switch(x) { case 0: address = 0x80 + y; break; case 1: address = 0x80 + y; break; case 2: address = 0x90 + y; break; case 3: address = 0x88 + y; break; case 4: address = 0x98 + y; break; default:address = 0x80 + y; break; } write_com(address); } void WriteString( unsigned char x,unsigned char y ,unsigned char *s) //????×?·??????????? { unsigned char ByteNum=0; LCD_set_xy(x,y ); while (*s) { if(*s<0xa0) { ByteNum++; write_data(*s++); } if(*s>=0xa0) { if(ByteNum%2==0) { write_data(*s++); write_data(*s++); } else { write_data(0x20); write_data(*s++); write_data(*s++); ByteNum=0; } } } ByteNum=0; } void WriteStr(unsigned char *s) { while(*s>0) { write_data(*s); s++; } } |
|
|
|
你 粘贴上去的程序语句的注释都乱码了!!!你看一下我分享的程序,然后再搜索一下12864的中文资料对着看一下吧~~楼主正在练级,,,在我没有成为大神之前,不敢误人子弟,呵呵呵。我也是搜索大神的程序,然后改成适合自己用的程序而已~~
|
|
|
|
你 粘贴上去的程序语句的注释都乱码了!!!你看一下我分享的程序,然后再搜索一下12864的中文资料对着看一下吧~~楼主正在练级,,,在我没有成为大神之前,不敢误人子弟,呵呵呵。我也是搜索大神的程序,然后改成适合自己用的程序而已~~
|
|
|
|
谢谢分享...
|
|
|
|
无图无真相。
|
|
|
|
我完全没有理由去忽悠你啊,忽悠你,我会有什么好处吗?
|
|
|
|
O(∩_∩)O
|
|
|
|
没有那意思了,我喜欢LCD的显示,好看,如果有图片就好了。
|
|
|
|
不好意思,误会你了,下次改进(给图给真相)O(∩_∩)O
|
|
|
|
只有小组成员才能发言,加入小组>>
imx6ull 和 lan8742 工作起来不正常, ping 老是丢包
3415 浏览 0 评论
3384 浏览 9 评论
3073 浏览 16 评论
3561 浏览 1 评论
9212 浏览 16 评论
1325浏览 3评论
684浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
682浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2430浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1995浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-3-9 07:44 , Processed in 1.615913 second(s), Total 99, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191