佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 2865|回复: 31

LCD Queuing System

  [复制链接]
发表于 15-12-2010 12:28 PM | 显示全部楼层 |阅读模式
大家好,我现在在做着project,类似queuing system的..
1.用着AT89C51ED2, C Language, 16X2 LCD.

2.有一part是类似按button,然后display在LCD的value会+1或-1.

3.要display message的code是
                                 [size=13.3333px]void LCD_sendstring(unsigned char *var)
                                 {
                                     while(*var)                    //till string ends
                                     LCD_senddata(*var++);  //send characters one by one
                                  }

                                  [size=13.3333px]void LCD_senddata(unsigned char var)
                                 {
                                     LCD_data = var;      //Function set: 2 Line, 8-bit, 5x7 dots
                                     LCD_rs   = 1;        //Selected data register
                                     LCD_rw   = 0;        //We are writing
                                     LCD_en   = 1;        //Enable H->L
                                     LCD_en   = 0;
                                     LCD_busy();          //Wait for LCD to process the command
                                  }

所以要display message的话就command那一行,然后 LCD_sendstring ("message");

4.遇到的问题是如果我要做到value可以+1或-1的话,那么我应该需要多一个类似LCD_sendstring的void,可是我应该用什么data type来取代(unsigned char *var)呢?

5.hardware没有问题了,button可以用在别的用途了,只是我display不到那个value.

6.如果还缺什么资料的话各位可以告诉我,我会一一放上来,谢谢大家.
回复

使用道具 举报


ADVERTISEMENT

发表于 15-12-2010 03:52 PM | 显示全部楼层
如果你的开发环境不支持 “sprintf” 个功能,就用这个code。

  1. #include <string.h>
  2. void BYTE2ASCII(unsigned char *Dest, unsigned char *Source , unsigned int size )
  3. {
  4.      unsigned int  index = 0;
  5.      for( index = 0; index < size; index++)
  6.      {
  7.         Dest[index*2+0] = TOASCII(((Source[index]&0xF0)>> 4));
  8.         Dest[index*2+1] = TOASCII((Source[index]&0x0F));
  9.      }
  10. }



  11. void Conv_BYTE2ASCII(uint8_t  KeyVal)
  12. {
  13.    unsigned char MSG[10];
  14.    memset (MSG,0x00,sizeof(MSG));
  15.    BYTE2ASCII(MSG,KeyVal,1);
  16.     LCD_sendstring(MSG);
  17. }
复制代码



如果你的开发环境支持 “sprintf” 个功能,就用这个code。

  1. #include <string.h>
  2. void Conv_BYTE2ASCII(uint8_t  KeyVal)
  3. {
  4.     unsigned char MSG[10];
  5.     memset (MSG,0x00,sizeof(MSG));
  6.     sprintf ((char*)MSG,"%d",KeyVal);
  7.     LCD_sendstring(MSG);
  8. }
复制代码
回复

使用道具 举报

 楼主| 发表于 17-12-2010 01:49 PM | 显示全部楼层
如果你的开发环境不支持 “sprintf” 个功能,就用这个code。



如果你的开发环境支持 “sprintf” 个 ...
wkloh 发表于 15-12-2010 03:52 PM



谢谢你哦,最近忙考试,考完试就继续了^^
回复

使用道具 举报

发表于 18-12-2010 12:29 AM | 显示全部楼层
回复 1# choon1988


   

看来一些基本的hardware你都做了。
button看起来没问题。
你的lcd可以操作吗?基本的1,2,3,4,5,a,b,c,A,B,C能显示吗?
你用什么compiler?
at89c51ed2,不多人用。你那里学生啊?fyp?
回复

使用道具 举报

 楼主| 发表于 18-12-2010 11:45 PM | 显示全部楼层
回复  choon1988


   

看来一些基本的hardware你都做了。
button看起来没问题。
你的lcd可以操作 ...
fritlizt 发表于 18-12-2010 12:29 AM


LCD可以display字了的,是FYP,现在的part是要差不多类似的功能,所以button只是testing用罢了...
回复

使用道具 举报

发表于 19-12-2010 12:09 AM | 显示全部楼层
回复 5# choon1988


   
嗯。。。。既然lcd和button都可以work了。应该七七八八了。
再问你几个问题。
如果你已经能显示1,那要在lcd接下去显示2,该怎么样?
显示12过后,擦掉12,只显示3,要怎么做?
能的话回答仔细点.要看看你到底能做到哪里了。
回复

使用道具 举报

Follow Us
 楼主| 发表于 19-12-2010 01:05 PM | 显示全部楼层
回复  choon1988


   
嗯。。。。既然lcd和button都可以work了。应该七七八八了。
再问你几个问题。 ...
fritlizt 发表于 19-12-2010 12:09 AM


谢谢你的回复哦..最近忙考试,没有什么时间想..
你意思是说一开始LCD会1,然后12,然后3?
那那些123是increment还是放123就可以了?
回复

使用道具 举报

发表于 19-12-2010 02:55 PM | 显示全部楼层
回复 7# choon1988


   
不管increment.一开始
__________________
1                            |
__________________|

__________________
12                           |
__________________|

__________________
3                            |
__________________|
就这样。
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 20-12-2010 12:12 PM | 显示全部楼层
回复  choon1988


   
不管increment.一开始
__________________
1                            | ...
fritlizt 发表于 19-12-2010 02:55 PM



普通的sendstring + clear LCD的话很简单啊,还是你要别的?
回复

使用道具 举报

发表于 20-12-2010 08:49 PM | 显示全部楼层
回复 9# choon1988


   

不要别的。就是要你的concept, pseudo code/c code更好。可以直接从那边指点你。
如果这个没问题。你的问题实在如何把1,2,3换去ascii string是吧?
你用什么compiler?问第二次的了。
回复

使用道具 举报

 楼主| 发表于 20-12-2010 10:10 PM | 显示全部楼层
回复  choon1988


   

不要别的。就是要你的concept, pseudo code/c code更好。可以直接从那边指点 ...
fritlizt 发表于 20-12-2010 08:49 PM


对,就是不洞怎样换去ascii string..
不好意思,上次忘了回答你,用的是SDCC
回复

使用道具 举报

 楼主| 发表于 20-12-2010 10:13 PM | 显示全部楼层
回复  choon1988


   

不要别的。就是要你的concept, pseudo code/c code更好。可以直接从那边指点 ...
fritlizt 发表于 20-12-2010 08:49 PM


就是用
void sendstring
void senddata
和别的LCD command来display出message,所以一般的display是没有问题了,问题只是我不懂要怎样把类似
i=0, i++
的号码display出来..

谢谢指导^^
回复

使用道具 举报

发表于 20-12-2010 11:00 PM | 显示全部楼层
回复 12# choon1988


   

你可以参考wkloh的方法。一般上sprintf是c standard library。sdcc应该也有。
试试看sprintf.把variable print成formatted string,然后再把string显示出来。
回复

使用道具 举报

 楼主| 发表于 22-12-2010 10:44 PM | 显示全部楼层
本帖最后由 choon1988 于 22-12-2010 10:49 PM 编辑

如果你的开发环境不支持 “sprintf” 个功能,就用这个code。



如果你的开发环境支持 “sprintf” 个 ...
wkloh 发表于 15-12-2010 03:52 PM



   


#include <string.h>
void Conv_BYTE2ASCII(uint8_t  KeyVal)
{
    unsigned char MSG[10];
    memset (MSG,0x00,sizeof(MSG));
    sprintf ((char*)MSG,"%d",KeyVal);
    LCD_sendstring(MSG);
}

想问下 KeyVal 是什么????
回复

使用道具 举报

 楼主| 发表于 22-12-2010 11:10 PM | 显示全部楼层
#include
void Conv_BYTE2ASCII(uint8_t  KeyVal)
{
    unsigned char MSG[10];
    me ...
choon1988 发表于 22-12-2010 10:44 PM



是不是先要define KeyVal 然后就是KeyVal在increase,再convert去Ascii string再display??
回复

使用道具 举报

发表于 22-12-2010 11:42 PM | 显示全部楼层
#include
void Conv_BYTE2ASCII(uint8_t  KeyVal)
{
    unsigned char MSG[10];
    me ...
choon1988 发表于 22-12-2010 10:44 PM


到目前为止,你的program是你自己写的吗?
比如说

  1. void LCD_sendstring(unsigned char *var)
  2. {
  3.     while(*var)                    //till string ends
  4.         LCD_senddata(*var++);  //send characters one by one
  5. }

  6. void LCD_senddata(unsigned char var)
  7. {
  8.     LCD_data = var;      //Function set: 2 Line, 8-bit, 5x7 dots
  9.     LCD_rs   = 1;        //Selected data register
  10.     LCD_rw   = 0;        //We are writing
  11.     LCD_en   = 1;        //Enable H->L
  12.     LCD_en   = 0;
  13.     LCD_busy();          //Wait for LCD to process the command
  14. }
复制代码
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 22-12-2010 11:49 PM | 显示全部楼层
到目前为止,你的program是你自己写的吗?
比如说
fritlizt 发表于 22-12-2010 11:42 PM

有部分是自己学过的自己写,部分是参考online resource,去明白它再自己写过自己要的东西..之前整个星期在考试,所以现在是在分析你给的source,明白后会写出自己要的东西..
回复

使用道具 举报

发表于 23-12-2010 12:29 AM | 显示全部楼层
本帖最后由 wkloh 于 23-12-2010 12:32 AM 编辑

回复 14# choon1988

void Conv_BYTE2ASCII(uint8_t  KeyVal)

改成 void Conv_BYTE2ASCII(unsigned char  KeyVal),这样看明白了吧!

之前是用我写给STM32用的程序,修改后贴上去的!

不好意思,改得不彻底!

KeyVal 就是你想要LCD显示的数字,它可以是你的button value(+/-)。
只要call在程序里呼叫Conv_BYTE2ASCII(button value);这行就行了。


回复 15# choon1988   

这个函数Conv_BYTE2ASCII();就已经包含了convert string和LCD display ASCII功能。
除非的的LCD代码还没调好!
回复

使用道具 举报

 楼主| 发表于 23-12-2010 12:34 AM | 显示全部楼层
回复  choon1988

void Conv_BYTE2ASCII(uint8_t  KeyVal)

改成 void Conv_BYTE2ASCII(unsigned char ...
wkloh 发表于 23-12-2010 12:29 AM



哦..那我应该明白你的code了..
我再研究下,不明白再问你,真的谢谢你...
回复

使用道具 举报

 楼主| 发表于 23-12-2010 03:06 AM | 显示全部楼层
到目前为止,你的program是你自己写的吗?
比如说
fritlizt 发表于 22-12-2010 11:42 PM



我用SDCC..好像不支持sprintf和TOASCII...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 29-3-2024 03:39 PM , Processed in 0.086101 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表