原野之狼

    1. 废物利用--易拉罐台灯 7/9619 单片机 2008-01-16
      难道uA级的电流你也要省么?
    2. 废物利用--易拉罐台灯 7/9619 单片机 2008-01-16
      偶在想做一个带MP3功能的浇花的东西送给MM。。。
    3. 我的单片机为什么老掉程序呢? 6/14940 单片机 2007-12-07
      初始化程序的哪些操作可能造成如此影响呢,还请大叔进一步点拨啊~~~
    4. 经一朋友指点,现在问题解决了,呵呵~~~其中一文件修改如下,那么在取消调试状态的时候,所有调试语句都被编译器忽略。 /***************************** file:my_debug.h ******************************/ #ifndef _MY_DEBUG_H_ #define _MY_DEBUG_H_ #include <string.h> #include <stdarg.h> #include <stdio.h> //#define MY_DEBUG #ifdef MY_DEBUG void my_printf(char *,...); #define WriteLog my_printf #else void nop_(char *p,...); #define WriteLog 1?(void)0:nop_ #endif #endif
    5. 这样写能实现变长参数么?
    6. 但是我希望能一句话搞定啊~~~~ 就是: WriteLog("Just have a test.....\n%d    %c    %f\n",(int)10,'M',3.1415926); 如果每次输出调试信息都要来那么一段: #ifdef MY_DEBUG WriteLog("Just have a test.....\n%d    %c    %f\n",(int)10,'M',3.1415926); #endif 我觉得麻烦。
    7. /*********************************************************************     Description:整屏幕输出一副位图X_PIXEL*Y_PIXEL         Input:         p_BMP:位图字模指针         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_DispBMP(UINT8 code *p_BMP) {     UINT16 i;     for(i=0;i<488;i++)         DisBuffer=*p_BMP++; } /*********************************************************************     Description:显示整数,坐标基点在左下角         Input:         dat:需要显示的整数         x:x 坐标         y:y坐标         formate:格式化方式     Output:     Return:     Gloable:            struct GUI_RECT 矩形结构体         Number_X_Pixel:字符的X方向上的像素         Number_Y_Pixel:字符在Y方向上的像素         Addr_Base:数字字模段起始地址         Addr_Deviate:数字字模偏移量,即字模字节数     Calls:         GUI_ClearRect();清除一片区域         ZK_To_Bitmap();字模转成位图         RegionInsertInDisBuffer();往缓冲插入一片区域         pow_10();求幂     Called By:              Others:         注意数值范围,目前定义的是16 bit     Modify Record:     *********************************************************************/ void GUI_DisIntData(INT16 dat,UINT8 x,UINT8 y,UINT8 *formate) {     UINT8 xdata buf[10],BufLen,i;     UINT8 xdata mid[72];     struct GUI_RECT rect;     rect.x0=x;     rect.y0=y-Number_Y_Pixel+1;     rect.y1=y;         sprintf(buf,formate,dat);     BufLen = strlen(buf);     GUI_ClearRect(x, x+Number_X_Pixel*BufLen-1, y-Number_Y_Pixel + 1, y);     for (i = 0; i < BufLen; i++)     {         if (buf == '-')         {         GUI_DrawHLine(rect.x0, rect.x0+Number_X_Pixel-1, rect.y0-Number_Y_Pixel/2);                 rect.x0+=Number_X_Pixel;         }         else         {             ZK_To_Bitmap(Addr_Base + Addr_Deviate * (buf-'0'), Number_Y_Pixel, Number_X_Pixel, mid);             rect.x1=rect.x0+Number_X_Pixel-1;             RegionInsertInDisBuffer(&rect, mid);             rect.x0=rect.x0+Number_X_Pixel;         }     } } /*********************************************************************     Description:显示整数,坐标基点在左下角         Input:         dat:需要显示的整数         x:x 坐标         y:y坐标         formate:格式化方式     Output:     Return:     Gloable:            Number_X_Pixel:字符的X方向上的像素         Number_Y_Pixel:字符在Y方向上的像素         special:特殊处理,这是一个设计的局限性,需要在下一个版本中改进     Calls:         pow_10();求幂         GUI_DisIntData();显示整数         GUI_DrawPixel();画点     Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_DisFloatData(FLP32 dat,UINT8 x,UINT8 y,UINT8 *formate) {     UINT8 xdata buf[10],BufLen,i;     UINT8 xdata mid[72];     struct GUI_RECT rect;     rect.x0=x;     rect.y0=y-Number_Y_Pixel+1;     rect.y1=y;         sprintf(buf,formate,dat);     BufLen = strlen(buf);     GUI_ClearRect(x, x+Number_X_Pixel*BufLen-1-(Number_X_Pixel - Number_Dot_Pixel), y-Number_Y_Pixel + 1, y);     for (i = 0; i < BufLen; i++)     {         if (buf == '.')//only one pixel         {             GUI_DrawPixel(rect.x0,rect.y1-Number_Dot_Pixel_Y);             rect.x0+=2;         }         else         {             if (buf == '-')             {                 GUI_DrawHLine(rect.x0, rect.x0+Number_X_Pixel-1, rect.y0-Number_Y_Pixel/2);                 rect.x0+=Number_X_Pixel;             }             else             {                 ZK_To_Bitmap(Addr_Base + Addr_Deviate * (buf-'0'), Number_Y_Pixel, Number_X_Pixel, mid);                 rect.x1=rect.x0+Number_X_Pixel-1;                 RegionInsertInDisBuffer(&rect, mid);                 rect.x0=rect.x0+Number_X_Pixel;             }         }     } } /*********************************************************************     Description:显示区域反转         Input:         x0:左上角x坐标         x1:右下角x坐标         y0:左上角y坐标         y1:右下角y坐标     Output:     Return:     Gloable:            Number_X_Pixel:字符的X方向上的像素         Number_Y_Pixel:字符在Y方向上的像素         special:特殊处理,这是一个设计的局限性,需要在下一个版本中改进         DisBuffer[]:图形缓冲     Calls:              Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_InvertRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1) {     UINT8 i,j,Location_Bit;     UINT16 Location_Byte;     //for(i=x0;i<=x1-5;i++)// 不怎么严谨     for(i=x0;i<=x1;i++)         for(j=y0;j<=y1;j++)         {             Location_Byte=(j/8)*X_PIXEL+i;             Location_Bit=j%8;             if((DisBuffer[Location_Byte]>>Location_Bit)&0x01)                 DisBuffer[Location_Byte]&=(~(0x01<<Location_Bit));             else                 DisBuffer[Location_Byte]|=(0x01<<Location_Bit);         } } /*********************************************************************     Description:清除区域         Input:         x0:左上角x坐标         x1:右下角x坐标         y0:左上角y坐标         y1:右下角y坐标     Output:     Return:     Gloable:                 Calls:         GUI_DrawHLine_();画线,反色     Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_ClearRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1) {     UINT8 i;     for(i=y0;i<=y1;i++)     {         GUI_DrawHLine_(x0, x1,i); //        Display();     } }
    8. /*********************************************************************     Description:像素值转成字节表示(0x00,0x01),这样编程简单,不过此方式需要改变。         Input:         row:字模行数         col:字模列数         zk:字模指针     Output:         p_Bitmap:转换结果存放区域指针     Return:     Gloable:                 Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ void ZK_To_Bitmap(UINT8 code* zk,UINT8 row,UINT8 col,UINT8* p_Bitmap) {     UINT8 i,j,Byte_ZK,Bit_Byte;     for(j=0;j<col;j++)         for(i=0;i<row;i++)         {             Byte_ZK=j*(row/8+1)+i/8;//(i*((col-1)/8+1)+j/8);             Bit_Byte=i%8; //            if((zk[(i*((col-1)/8+1)+j/8)]<<(j%8))==0x80)             if(((zk[Byte_ZK]>>Bit_Byte)&0x01))                 *p_Bitmap++=1;             else                 *p_Bitmap++=0;         } } /* //汉字的基准在左下角 void HZInsertInDis(UINT8 *p_HZ,UINT8 Pixel_X,UINT8 Pixel_Y,UINT8 x,UINT8 y) {     UINT8 temp[144],i;     for(i=0;i<144;i++)         if() }*/ /*********************************************************************     Description:显示信息插入显示缓冲。         Input:         rect:区域位置,和内容相对应         p_Content:显示内容,横排,字节标识像素值(0x00,0x01)     Output:         p_Bitmap:转换结果存放区域指针     Return:     Gloable:            DisBuffer[]:显示缓冲     Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ void RegionInsertInDisBuffer(struct GUI_RECT* rect,UINT8* p_Content) {     UINT8 i,j;     UINT16 Byte_Buffer,Bit_Byte;     for(j=rect->x0;j<=rect->x1;j++)     {    for(i =rect->y0;i<=rect->y1;i++)         {             Byte_Buffer=(i/8)*X_PIXEL+j;//(i-1)*16+(j-1)/8;             Bit_Byte=(i%8);//(j-1)%8;             if((*p_Content++)==1)                 DisBuffer[Byte_Buffer]|=(0x01<<Bit_Byte);             else                 DisBuffer[Byte_Buffer]&=(~(0x01<<Bit_Byte));                     }     } } /*********************************************************************     Description:获取汉字内码,汉字有两个字节表示         Input:         p:单个汉字指针              Output:              Return:         两字节的汉字内码     Gloable:            Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ unsigned int get_hz_const(UINT8 *p) {      unsigned int const_;      const_=*p++;      const_<<=8;      const_|=*p++;      return const_; } /*********************************************************************     Description:获取汉字串的字模表示         Input:         p:汉字串              Output:         HZ_Group:指向字模指针的指针,即存放汉字串中所有汉字字模指针的数组     Return:         两字节的汉字内码     Gloable:            Calls:         get_hz_const();获取汉字内码。     Called By:              Others:         考虑到效率的问题,此函数当中的查找判断需要做优化,方法是做成顺序表。     Modify Record:     *********************************************************************/ UINT8 Generate_HZ_Group(UINT8 *p,UINT8 code **HZ_Group) {     UINT8 n_HZ=0;     UINT8 *q;     UINT8 i;     unsigned int const_mid=0;//mid;     q=p;     while((*q++)!=0x00)          n_HZ++;     n_HZ>>=1;     for(i=0;i<n_HZ;i++)     {            const_mid=*p++;         const_mid<<=8;         const_mid|=*p++;                  if(const_mid==get_hz_const("等"))             *HZ_Group++=hz_deng;         else         if(const_mid==get_hz_const("待"))             *HZ_Group++=hz_dai;         else         if(const_mid==get_hz_const("完"))             *HZ_Group++=hz_wan;         else         if(const_mid==get_hz_const("成"))             *HZ_Group++=hz_cheng_gong;         else         if(const_mid==get_hz_const("测"))             *HZ_Group++=hz_ce;         else         if(const_mid==get_hz_const("量"))             *HZ_Group++=hz_liang;         else         if(const_mid==get_hz_const("设"))             *HZ_Group++=hz_she;         else         if(const_mid==get_hz_const("置"))             *HZ_Group++=hz_zhi;         else         if(const_mid==get_hz_const("存"))             *HZ_Group++=hz_cun;         else         if(const_mid==get_hz_const("储"))             *HZ_Group++=hz_chu_cun;         else         if(const_mid==get_hz_const("时"))             *HZ_Group++=hz_shi;         else         if(const_mid==get_hz_const("间"))             *HZ_Group++=hz_jian_xie;         else         if(const_mid==get_hz_const("通"))             *HZ_Group++=hz_tong;         else         if(const_mid==get_hz_const("信"))             *HZ_Group++=hz_xin;         else         if(const_mid==get_hz_const("仪"))             *HZ_Group++=hz_yi;         else         if(const_mid==get_hz_const("表"))             *HZ_Group++=hz_biao;         else         if(const_mid==get_hz_const("校"))             *HZ_Group++=hz_jiao;         else         if(const_mid==get_hz_const("正"))             *HZ_Group++=hz_zheng;         else         if(const_mid==get_hz_const("试"))             *HZ_Group++=hz_shi_juan;         else         if(const_mid==get_hz_const("件"))             *HZ_Group++=hz_jian;         else         if(const_mid==get_hz_const("模"))             *HZ_Group++=hz_mo;         else         if(const_mid==get_hz_const("式"))             *HZ_Group++=hz_shi_yang;         else         if(const_mid==get_hz_const("峰"))             *HZ_Group++=hz_feng;         else         if(const_mid==get_hz_const("值"))             *HZ_Group++=hz_zhi_ri;         else         if(const_mid==get_hz_const("停"))             *HZ_Group++=hz_ting;         else         if(const_mid==get_hz_const("留"))             *HZ_Group++=hz_liu;         else         if(const_mid==get_hz_const("阈"))             *HZ_Group++=hz_yu;         else         if(const_mid==get_hz_const("报"))             *HZ_Group++=hz_bao;         else         if(const_mid==get_hz_const("警"))             *HZ_Group++=hz_jing;         else         if(const_mid==get_hz_const("截"))             *HZ_Group++=hz_jie;         else         if(const_mid==get_hz_const("面"))             *HZ_Group++=hz_mian;         else         if(const_mid==get_hz_const("打"))             *HZ_Group++=hz_da;         else         if(const_mid==get_hz_const("印"))             *HZ_Group++=hz_yin;         else         if(const_mid==get_hz_const("方"))             *HZ_Group++=hz_fang;         else         if(const_mid==get_hz_const("数"))             *HZ_Group++=hz_shu;         else         if(const_mid==get_hz_const("据"))             *HZ_Group++=hz_ju;         else         if(const_mid==get_hz_const("查"))             *HZ_Group++=hz_cha;         else         if(const_mid==get_hz_const("询"))             *HZ_Group++=hz_xun;         else         if(const_mid==get_hz_const("清"))             *HZ_Group++=hz_qing;         else         if(const_mid==get_hz_const("除"))             *HZ_Group++=hz_chu;         else         if(const_mid==get_hz_const("分"))             *HZ_Group++=hz_fen;         else         if(const_mid==get_hz_const("秒"))             *HZ_Group++=hz_miao;         else         if(const_mid==get_hz_const("年"))             *HZ_Group++=hz_nian;         else         if(const_mid==get_hz_const("月"))             *HZ_Group++=hz_yue;         else         if(const_mid==get_hz_const("日"))             *HZ_Group++=hz_ri;         else         if(const_mid==get_hz_const("波"))             *HZ_Group++=hz_bo;         else         if(const_mid==get_hz_const("特"))             *HZ_Group++=hz_te;         else         if(const_mid==get_hz_const("率"))             *HZ_Group++=hz_lv;         else         if(const_mid==get_hz_const("地"))             *HZ_Group++=hz_di;         else         if(const_mid==get_hz_const("址"))             *HZ_Group++=hz_zhi_di;         else         if(const_mid==get_hz_const("/u"))             *HZ_Group++=symbol_u;         else         if(const_mid==get_hz_const("/d"))             *HZ_Group++=symbol_d;         else //new added         if(const_mid==get_hz_const("三"))             *HZ_Group++=hz_san;                 else         if(const_mid==get_hz_const("思"))             *HZ_Group++=hz_si;                 else         if(const_mid==get_hz_const("行"))             *HZ_Group++=hz_xing;                 else         if(const_mid==get_hz_const("控"))             *HZ_Group++=hz_kong;                 else         if(const_mid==get_hz_const("联"))             *HZ_Group++=hz_lian;                 else         if(const_mid==get_hz_const("系"))             *HZ_Group++=hz_xi;                 else         if(const_mid==get_hz_const("电"))             *HZ_Group++=hz_dian;                 else         if(const_mid==get_hz_const("话"))             *HZ_Group++=hz_hua;                 else         if(const_mid==get_hz_const("实"))             *HZ_Group++=hz_shi_ji;                 else         if(const_mid==get_hz_const("速"))             *HZ_Group++=hz_su_lv;                 else         if(const_mid==get_hz_const("压"))             *HZ_Group++=hz_ya;                 else         if(const_mid==get_hz_const("力"))             *HZ_Group++=hz_li;                 else         if(const_mid==get_hz_const("机"))             *HZ_Group++=hz_ji_qi;                 else         if(const_mid==get_hz_const("欢"))             *HZ_Group++=hz_huan;                 else         if(const_mid==get_hz_const("迎"))             *HZ_Group++=hz_ying;                 else         if(const_mid==get_hz_const("使"))             *HZ_Group++=hz_shi_yong;                 else         if(const_mid==get_hz_const("用"))             *HZ_Group++=hz_yong;                 else         if(const_mid==get_hz_const("是"))             *HZ_Group++=hz_shi_fou;                 else         if(const_mid==get_hz_const("否"))             *HZ_Group++=hz_fou;                 else         if(const_mid==get_hz_const("请"))             *HZ_Group++=hz_qing_shi;                 else         if(const_mid==get_hz_const("输"))             *HZ_Group++=hz_shu_ru;                 else         if(const_mid==get_hz_const("入"))             *HZ_Group++=hz_ru;                 else         if(const_mid==get_hz_const("自"))             *HZ_Group++=hz_zi;                 else         if(const_mid==get_hz_const("动"))             *HZ_Group++=hz_dong;         else         if(const_mid==get_hz_const("全"))             *HZ_Group++=hz_quan;         else         if(const_mid==get_hz_const("部"))             *HZ_Group++=hz_bu;         else         if(const_mid==get_hz_const("密"))             *HZ_Group++=hz_mi;         else         if(const_mid==get_hz_const("码"))             *HZ_Group++=hz_ma;         else         if(const_mid==get_hz_const("两"))             *HZ_Group++=hz_liang_dian;         else         if(const_mid==get_hz_const("多"))             *HZ_Group++=hz_duo;         else         if(const_mid==get_hz_const("点"))             *HZ_Group++=hz_dian_di;         else         if(const_mid==get_hz_const("修"))             *HZ_Group++=hz_xiu;         else         if(const_mid==get_hz_const("改"))             *HZ_Group++=hz_gai;         else         if(const_mid==get_hz_const("新"))             *HZ_Group++=hz_xin_niang;         else         if(const_mid==get_hz_const("隔"))             *HZ_Group++=hz_ge;         else         if(const_mid==get_hz_const("统"))             *HZ_Group++=hz_tong_ji;         else         if(const_mid==get_hz_const("复"))             *HZ_Group++=hz_fu;         else         if(const_mid==get_hz_const("位"))             *HZ_Group++=hz_wei;         else         if(const_mid==get_hz_const("重"))             *HZ_Group++=hz_chong;         else         if(const_mid==get_hz_const("上"))             *HZ_Group++=hz_shang;         else         if(const_mid==get_hz_const("电"))             *HZ_Group++=hz_dian_yuan;         else         if(const_mid==get_hz_const("零"))             *HZ_Group++=hz_ling;         else         if(const_mid==get_hz_const("满"))             *HZ_Group++=hz_man;         else         if(const_mid==get_hz_const("程"))             *HZ_Group++=hz_cheng;         else         if(const_mid==get_hz_const("编"))             *HZ_Group++=hz_bian;         else         if(const_mid==get_hz_const("号"))             *HZ_Group++=hz_hao;         else         if(const_mid==get_hz_const("无"))             *HZ_Group++=hz_wu;         else         if(const_mid==get_hz_const("效"))             *HZ_Group++=hz_xiao;         else         if(const_mid==get_hz_const("低"))             *HZ_Group++=hz_di_wa;         else         if(const_mid==get_hz_const("砌"))             *HZ_Group++=hz_qi;         else         if(const_mid==get_hz_const("体"))             *HZ_Group++=hz_ti;         else         if(const_mid==get_hz_const("原"))             *HZ_Group++=hz_yuan;         else         if(const_mid==get_hz_const("小"))             *HZ_Group++=hz_xiao_shu;         else         if(const_mid==get_hz_const("型"))             *HZ_Group++=hz_xing_hao;         else         if(const_mid==get_hz_const("数"))             *HZ_Group++=hz_shu_ju;         else         if(const_mid==get_hz_const("显"))             *HZ_Group++=hz_xian;         else         if(const_mid==get_hz_const("抗"))             *HZ_Group++=hz_kang;         else         if(const_mid==get_hz_const("折"))             *HZ_Group++=hz_zhe;         else         if(const_mid==get_hz_const("管"))             *HZ_Group++=hz_guan;         else         if(const_mid==get_hz_const("理"))             *HZ_Group++=hz_li_lun;         else         if(const_mid==get_hz_const("所"))             *HZ_Group++=hz_suo;         else         if(const_mid==get_hz_const("选"))             *HZ_Group++=hz_xuan;         else         if(const_mid==get_hz_const("项"))             *HZ_Group++=hz_xiang;         else         if(const_mid==get_hz_const("查"))             *HZ_Group++=hz_cha_kan;         else         if(const_mid==get_hz_const("看"))             *HZ_Group++=hz_kan;         else         if(const_mid==get_hz_const("恢"))             *HZ_Group++=hz_hui;         else         if(const_mid==get_hz_const("出"))             *HZ_Group++=hz_chu_chang;         else         if(const_mid==get_hz_const("厂"))             *HZ_Group++=hz_chang;         else         if(const_mid==get_hz_const("索"))             *HZ_Group++=hz_suo_yin;         else         if(const_mid==get_hz_const("引"))             *HZ_Group++=hz_yin_hao;         else         if(const_mid==get_hz_const("确"))             *HZ_Group++=hz_que;         else         if(const_mid==get_hz_const("认"))             *HZ_Group++=hz_ren;         else         if(const_mid==get_hz_const("息"))             *HZ_Group++=hz_xi_nu;         else         if(const_mid==get_hz_const("定"))             *HZ_Group++=hz_ding;         else         if(const_mid==get_hz_const("退"))             *HZ_Group++=hz_tui;         else         if(const_mid==get_hz_const("出"))             *HZ_Group++=hz_chu_ru;         else         if(const_mid==get_hz_const("向"))             *HZ_Group++=hz_xiang_xia;         else         if(const_mid==get_hz_const("下"))             *HZ_Group++=hz_xia;         else         if(const_mid==get_hz_const("左"))             *HZ_Group++=hz_zuo;         else         if(const_mid==get_hz_const("右"))             *HZ_Group++=hz_you;         else         if(const_mid==get_hz_const("增"))             *HZ_Group++=hz_zeng;         else         if(const_mid==get_hz_const("加"))             *HZ_Group++=hz_jia;         else         if(const_mid==get_hz_const("移"))             *HZ_Group++=hz_yi_wei;         else         if(const_mid==get_hz_const("空"))             *HZ_Group++=hz_kong_kong;         else         if(const_mid==get_hz_const("终"))             *HZ_Group++=hz_zhong;         else         if(const_mid==get_hz_const("止"))             *HZ_Group++=hz_zhi_bu;         else         if(const_mid==get_hz_const("功"))             *HZ_Group++=hz_gong;     }     return n_HZ; }
    9. /************************************************************     FileName: Gui.c     Author:胡贵        Version :V1.0           Date: 2007.9.13     Description:         用于GUI的一些底层代码,只是部分功能,         还需要完善     History:       <author>      <time>      <version >      <desc> ************************************************************/ #include "includes.h" #undef GLOBAL #include "GUI_ZIMU.H" #include "global_variable.h" /**************************************************** //coordinate base 0 //byte0 byte1 ... //DB0   DB0  ...       bit0 //DB1   DB1  ...       bit1 //DB2   DB2  ...       bit2 //DB3   DB3  ...        . //DB4   DB4  ...        . //DB5   DB5  ...        . //DB6   DB6  ... //DB7   DB7  ... *****************************************************/ /*********************************************************************     Description:画点         Input:         x:x坐标         y:y坐标         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:     Others:     Modify Record:     *********************************************************************/ void GUI_DrawPixel(UINT8 x,UINT8 y) {     UINT16 Location_Byte;     UINT8 Location_Bit;     Location_Byte=(y/8)*X_PIXEL+x;     Location_Bit=y%8;     DisBuffer[Location_Byte]|=(0x01<<Location_Bit); } /*********************************************************************     Description:画水平线,实线         Input:         x0:起点x坐标         x1:终点x坐标         y:y坐标         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:     Others:     Modify Record:     *********************************************************************/ void GUI_DrawHLine(UINT8 x0,UINT8 x1,UINT8 y) {     //    000000XX    XXXXXXXX      ....        XXXXXXXX         XX000000            Location_Bit     //             |                                                                    |     //            |                                                                          |     //          Location_Byte0                                                Location_Byte1     UINT16 Location_Byte0,Location_Byte1;     UINT8 Location_Bit;     UINT16 i;     //Location_Byte0=(y/8)*X_PIXEL+x0;     //Location_Byte1=(y/8)*X_PIXEL+x1;     Location_Byte0=(y/8)*(X_PIXEL)+x0;     Location_Byte1=(y/8)*(X_PIXEL)+x1;     Location_Bit=(y%8);     for(i=Location_Byte0;i<=Location_Byte1;i++)         DisBuffer|=(0x01<<Location_Bit); } /*********************************************************************     Description:画水平线,实线,反显,用于擦出区域调用         Input:         x0:起点x坐标         x1:终点x坐标         y:y坐标         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:         Gui_Clearall();              Others:     Modify Record:     *********************************************************************/ void GUI_DrawHLine_(UINT8 x0,UINT8 x1,UINT8 y) {     //    000000XX    XXXXXXXX      ....        XXXXXXXX         XX000000            Location_Bit     //             |                                                                    |     //            |                                                                           |     //          Location_Byte0                                                Location_Byte1     UINT16 Location_Byte0,Location_Byte1;     UINT8 Location_Bit;     UINT16 i;     //Location_Byte0=(y/8)*X_PIXEL+x0;     //Location_Byte1=(y/8)*X_PIXEL+x1;     Location_Byte0=(y/8)*(X_PIXEL)+x0;     Location_Byte1=(y/8)*(X_PIXEL)+x1;     Location_Bit=(y%8);     for(i=Location_Byte0;i<=Location_Byte1;i++)     {         DisBuffer&=(~(0x01<<Location_Bit)); //        uart0_send(DisBuffer);     } //    Display();     _nop_(); } /*********************************************************************     Description:画垂直线,实线         Input:         x0:起点x坐标         x1:终点x坐标         y:y坐标         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_DrawVLine(UINT8 y0,UINT8 y1,UINT8 x) {        //                       //                  0     //                  0     //                  0     //                  0     //                  0                                   } ----->Location_Byte0        //                  0     //                  X -->Location_Bit0     //                  X     //     //                  X     //                  X     //                  X     //                  X     //                  X     //                  X     //                  X     //                  X        //                  .        //                  .        //                  .     //                  X     //                  X --->Location_Bit1     //                  0     //                  0     //                  0                                   }------->Location_Byte1     //                  0     //                  0     //                  0     UINT16 Location_Byte0,Location_Byte1;     UINT8 Location_Bit0,Location_Bit1,temp=0;     UINT16 i;     Location_Byte0=(y0/8)*(X_PIXEL)+x;     Location_Byte1=(y1/8)*(X_PIXEL)+x;     Location_Bit0=(y0%8);     Location_Bit1=(y1%8);     if(Location_Byte0==Location_Byte1)     {         for(i=Location_Bit0;i<=Location_Bit1;i++)             temp|=(0x01<<i);         DisBuffer[Location_Byte0]|=temp;     }     else     {         for(i=Location_Byte0+X_PIXEL;i<=Location_Byte1-X_PIXEL;i+=X_PIXEL)             DisBuffer=0xff;         DisBuffer[Location_Byte0]|=(0xff<<Location_Bit0);//(0x80>>(7-Location_Bit0));         DisBuffer[Location_Byte1]|=(0xff>>(7-Location_Bit1));//~(0x80>>(7-Location_Bit1));//(0x01<<Location_Bit1);     } }
    10. /*********************************************************************     Description:画矩形,实线         Input:         x0:左上角x坐标         x1:右下角x坐标         y0:左上角y坐标         y1:右下角y坐标         Output:     Return:     Gloable:            DisBuffer[]:图形缓冲     Calls:     Called By:         Gui_Clearall();              Others:     Modify Record:     *********************************************************************/ void GUI_DrawRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1) {     GUI_DrawHLine(x0, x1,y0);     GUI_DrawHLine(x0, x1,y1);     GUI_DrawVLine(y0, y1, x0);     GUI_DrawVLine(y0, y1, x1); } /*********************************************************************     Description:获得字符字模指针(部分字符)         Input:         character:字符         Output:     Return:         指向字符字模的指针     Gloable:            hz_A:字模数组         .         .         .     Calls:     Called By:              Others:     Modify Record:     *********************************************************************/ UINT8 code* GetCharPointer(UINT8 character) {     UINT8 code *p;     switch(character)     {         case 'A':p=hz_A;             break;         case 'P':p=hz_P;             break;         case 'S':p=hz_S;             break;         case 'I':p=hz_I;             break;         case 'D':p=hz_D;             break;         case 'H':p=hz_H;             break;         case 'O':p=hz_O;             break;         case 'V':p=hz_V;             break;         case 'R':p=hz_Run;         //Write_UART_STRING("OK1");             break;         case 'T':p=hz_Stop;         //Write_UART_STRING("OK2");             break;         case '0':p=hz_0_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '1':p=hz_1_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '2':p=hz_2_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '3':p=hz_3_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '4':p=hz_4_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '5':p=hz_5_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '6':p=hz_6_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '7':p=hz_7_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '8':p=hz_8_;//+CharacterStyle*(hz_0_-hz_0);             break;         case '9':p=hz_9_;//+CharacterStyle*(hz_0_-hz_0);             break;         default:             break;     }     return p; } /*********************************************************************     Description:在确定位置显示一个字符串,字符块基点在左下角         Input:         x:字符块x坐标         y:字符块y坐标         p_Char:字符串指针     Output:     Return:     Gloable:            struct GUI_RECT 矩形结构体         Number_X_Pixel:字符的X方向上的像素         Number_Y_Pixel:字符在Y方向上的像素     Calls:         Gui_CharacterStyle_Set7_4();设置字体7*4         GUI_ClearRect();清除一片区域         ZK_To_Bitmap();字模转成位图         RegionInsertInDisBuffer();往缓冲插入一片区域     Called By:              Others:     Modify Record:     *********************************************************************/ void GUI_DispChars(UINT8 *p_Char,UINT8 x,UINT8 y) {     UINT8 i,count;     UINT8 xdata mid[72];     struct GUI_RECT rect;     count=strlen(p_Char); //    Gui_CharacterStyle_Set7_4();     GUI_ClearRect(x, x+Number_X_Pixel*count-1, y-Number_Y_Pixel+1, y);     for(i=0;i<count;i++)     {         ZK_To_Bitmap(GetCharPointer(*p_Char++), Number_Y_Pixel, Number_X_Pixel, mid);         rect.x0=x+i*Number_X_Pixel;         rect.x1=rect.x0+Number_X_Pixel-1;         rect.y0=y-Number_Y_Pixel+1;         rect.y1=y;         RegionInsertInDisBuffer(&rect, mid);     } //    Gui_CharacterStyle_Set12_6(); } /* void GUI_DispLine(struct Text *p_Text,UINT8 n_Disp,struct GUI_RECT *p_Rect) {     UINT8 i,mid[144];     struct GUI_RECT rect;     GUI_ClearRect(p_Rect->x0, p_Rect->x1, p_Rect->y0, p_Rect->y1);     for(i=0;i<n_Disp;i++)     {         ZK_To_Bitmap(*(p_Text->p_Content+i), 12, 12, mid);         rect.x0=p_Rect->x0+i*12;         rect.x1=rect.x0+11;         rect.y0=p_Rect->y0;         rect.y1=p_Rect->y1;         RegionInsertInDisBuffer(&rect,mid);         PrintDisBuffer_();     } }*/
    11. /************************************************************     FileName: Gui.h     Author:胡贵        Version :V1.0           Date: 2007.9.13     Description:         用于GUI的一些底层代码,只是部分功能,         还需要完善     History:       <author>      <time>      <version >      <desc> ************************************************************/ #ifndef _GUI_H_ #define _GUI_H_ #include "comm.h" #include "ds1302.h" #define X_PIXEL 128 #define Y_PIXEL 64 #define X_PIXEL_NUMBER 3 #define Y_PIXEL_NUMBER 5 struct GUI_RECT {     UINT8 x0;     UINT8 x1;     UINT8 y0;     UINT8 y1; }; struct Text {     UINT8 code* *p_Content; /*#if TextProperty     UINT8 X_Distance;     UINT8 L_Margin;     UINT8 R_Margin;     UINT8 zimu_X_X; #endif*/ }; struct GUI_BUTTON {     UINT8 *p_HZ_STR;     UINT8 x;     UINT8 y;     UINT8 dx;     UINT8 dy; }; struct StpLabelBlk_YMD {     struct Time *p_Time;     struct Time Time_Temp;     UINT8 Location_Cur_Crt;     UINT8 x;     UINT8 y; }; struct StpLabelBlk_Int {     UINT16 *p_Dat;     UINT8 Location_Cur_Crt;     UINT8 n_Bit;     UINT16 Dat_Temp;     UINT8 x;     UINT8 y; }; //逻辑开关量设置页数据结构 struct StpLabelBlk_Logic {     UINT8 *p_Dat;     UINT8 Dat_Temp;     UINT8 x;     UINT8 y;     UINT8 Location_Cur_Crt; }; /*The base GUI function declaration*/ void GUI_DrawPixel(UINT8 x,UINT8 y); void GUI_DrawHLine(UINT8 x0,UINT8 x1,UINT8 y); void GUI_DrawHLine_(UINT8 x0,UINT8 x1,UINT8 y); void GUI_DrawVLine(UINT8 y0,UINT8 y1,UINT8 x); void GUI_DrawRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1); UINT8 code* GetCharPointer(UINT8 character); void GUI_DispChars(UINT8 *p_Char,UINT8 x,UINT8 y); void GUI_DispLine(struct Text *p_Text,UINT8 n_Disp,struct GUI_RECT *p_Rect); void GUI_DisIntData(INT16 dat,UINT8 x,UINT8 y,UINT8 *formate); void GUI_DisFloatData(FLP32 dat,UINT8 x,UINT8 y,UINT8 *formate); void GUI_InvertRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1); void GUI_ClearRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1); void ZK_To_Bitmap(UINT8 code* zk,UINT8 row,UINT8 col,UINT8* p_Bitmap); void RegionInsertInDisBuffer(struct GUI_RECT* rect,UINT8* p_Content); //UINT8 code* GetCharPointer(UINT8 character); UINT16 get_hz_const(UINT8 *p); UINT8 Generate_HZ_Group(UINT8 *p,UINT8 code **HZ_Group); UINT8  GUI_DispLine_(UINT8 *p_HZ_Str,UINT8 x,UINT8 y); void GUI_DrawArrow(UINT8 up_down); void GUI_ClearAll(void); void Gui_CharacterStyle_Set7_4(void); void Gui_CharacterStyle_Set12_6(void); void GUI_DrawButton(struct GUI_BUTTON *p_btn, UINT8 *p_HZ_Str,UINT8 x,UINT8 y,UINT8 dx,UINT8 dy); void GUI_ButtonClick(struct GUI_BUTTON *p_btn); void GUI_ButtonRelease(struct GUI_BUTTON *p_btn); void GUI_ClearPixel(UINT8 x,UINT8 y); void CreateStpLabel_YMD(UINT8 *p_HZ_Str,UINT8 x_HZ,UINT8 y_HZ,struct Time *p_T, UINT8 x_T,UINT8 y_T,UINT8 flag); void OnOK_YMD(UINT8 flag); void OnPre_YMD(UINT8 flag); void OnNxt_YMD(UINT8 flag); void CreateStpLable_Logic(UINT8 *p_HZ_Str,UINT8 *p_Logic,UINT8 x_HZ,UINT8 y_HZ,UINT8 x_dat,UINT8 y_Dat); void OnOK_Logic(void); void OnPre_Logic(void); void OnNxt_Logic(void); void OnCancle_Logic(void); void CreateStpLabel_Int(UINT8 *p_HZ_Str,UINT8 x_HZ,UINT8 y_HZ,UINT16 *p_Int, UINT8 x_Dat,UINT8 y_Dat,UINT8 n_Int); //UINT8 GetBCD_At(UINT16 dat,UINT8 n_Bit,UINT8 Location_Bit); signed char GetBCD_At(UINT16 dat,UINT8 n_Bit,UINT8 Location_Bit); void OnOk_Int(void); void OnPre_Int(void); void OnNxt_Int(void); void OnCancle_Int(void); #endif
    12. 画框图和流程图时很不错的工具
    13. 在规划界面时很实用很简单的工具
    14. 在编辑源码时很棒的工具
    15. 但是我还需要整理一下代码,整理完毕后再上传,现在急忙发代码是不负责任的。
    16. 工作时界面 菜单 设置界面 第一次贴图,可以丢鸡蛋,不可以扔砖头~~~~

最近访客

< 1/1 >

统计信息

已有65人来访过

  • 芯积分:--
  • 好友:--
  • 主题:5
  • 回复:16

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言