搜索
bottom↓
回复: 597

解封ID,向阿莫申请酷贴,本人珍藏的做GUI界面的算法资料

  [复制链接]

出0入0汤圆

发表于 2012-3-27 13:12:10 | 显示全部楼层 |阅读模式
本人珍藏的做GUI界面的算法资料,希望对各位注重界面设计的电子工程师有帮助。












本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

发表于 2012-3-27 14:07:07 | 显示全部楼层
收藏了,谢谢楼主

出0入143汤圆

发表于 2012-3-27 14:08:04 | 显示全部楼层
資料先留記號,謝謝樓主

出0入0汤圆

发表于 2012-3-27 15:59:25 | 显示全部楼层
好东西啊,收藏了,感谢楼主!

出0入0汤圆

发表于 2012-3-27 16:06:20 | 显示全部楼层
不错的 资料 谢谢

出0入0汤圆

发表于 2012-3-27 16:10:37 | 显示全部楼层
Mark,收下先

出0入0汤圆

发表于 2012-3-27 16:10:48 | 显示全部楼层
先收藏

出0入0汤圆

发表于 2012-3-27 16:15:33 | 显示全部楼层
再加点心得就好了

出0入0汤圆

发表于 2012-3-27 16:19:11 | 显示全部楼层
点了好几次怎么总是下载不了

出0入0汤圆

发表于 2012-3-27 16:20:10 | 显示全部楼层
mark                                               

出0入0汤圆

发表于 2012-3-27 16:20:13 | 显示全部楼层
cool                     

出0入0汤圆

发表于 2012-3-27 17:09:44 | 显示全部楼层
好东西,正好有用

出100入143汤圆

发表于 2012-3-27 17:13:15 | 显示全部楼层
研究了有一段时间了,谢了楼主

出0入0汤圆

发表于 2012-3-27 17:14:12 | 显示全部楼层
好,正在找这方面的资料,收下了,多谢。

出0入0汤圆

发表于 2012-3-27 17:43:17 | 显示全部楼层
好东西,要收藏 哈哈

出0入0汤圆

发表于 2012-3-27 17:45:19 | 显示全部楼层
Mark   收藏了

出0入0汤圆

发表于 2012-3-27 17:49:16 | 显示全部楼层
好贴,收藏,谢谢

出0入0汤圆

发表于 2012-3-27 17:49:59 | 显示全部楼层
收藏了!!!

出0入0汤圆

发表于 2012-3-27 17:51:05 | 显示全部楼层
收藏了!!!

出0入0汤圆

发表于 2012-3-27 17:56:25 | 显示全部楼层
资料不错,先收藏了,谢谢!

出0入0汤圆

发表于 2012-3-27 18:00:02 | 显示全部楼层
好资源,收下了哈

出0入0汤圆

发表于 2012-3-27 18:03:18 | 显示全部楼层
MARK

出0入0汤圆

发表于 2012-3-27 18:27:04 | 显示全部楼层
这么好的资料,谢谢楼主

出0入0汤圆

发表于 2012-3-27 18:37:31 | 显示全部楼层
顶一个先。谢谢分享。

出0入0汤圆

发表于 2012-3-27 19:02:10 | 显示全部楼层
先收藏了,谢谢~~

出0入0汤圆

发表于 2012-3-27 19:06:16 | 显示全部楼层
呵呵,这个要收藏呵,以前写液晶程序时,找这些东西都不好找。

出0入8汤圆

发表于 2012-3-27 19:06:27 | 显示全部楼层
不由自主的收藏!

出0入0汤圆

发表于 2012-3-27 19:06:39 | 显示全部楼层
好资料,收藏了

出0入0汤圆

发表于 2012-3-27 19:13:57 | 显示全部楼层
收藏了,谢谢楼主

出0入0汤圆

发表于 2012-3-27 19:16:05 | 显示全部楼层
不错的 资料 谢谢

出0入0汤圆

发表于 2012-3-27 19:16:57 | 显示全部楼层
向大侠学习了

出0入0汤圆

发表于 2012-3-27 19:25:51 | 显示全部楼层
好东西,非常感谢!

出0入0汤圆

发表于 2012-3-27 19:27:05 | 显示全部楼层
收藏了

出0入0汤圆

发表于 2012-3-27 19:31:33 | 显示全部楼层
右键另存为 ,为什么过了一分钟才弹出来,反应太慢了把

出0入0汤圆

发表于 2012-3-27 19:31:51 | 显示全部楼层
收藏了

出0入0汤圆

发表于 2012-3-27 19:36:31 | 显示全部楼层
收藏了!!!

出0入0汤圆

发表于 2012-3-27 19:39:44 | 显示全部楼层
不错的 资料 谢谢

出0入0汤圆

发表于 2012-3-27 19:45:35 | 显示全部楼层
不错不错 留着 以后用的到

出0入0汤圆

发表于 2012-3-27 19:50:20 | 显示全部楼层
好东西,+1

出5入190汤圆

发表于 2012-3-27 19:58:02 | 显示全部楼层
手机留名,电脑下载

出0入0汤圆

发表于 2012-3-27 20:00:10 | 显示全部楼层
MARK,用过Bresenham和画圆的那个

出0入0汤圆

发表于 2012-3-27 20:04:14 | 显示全部楼层
楼主的资料很强大。感谢

出0入0汤圆

发表于 2012-3-27 20:04:22 | 显示全部楼层
Mark  加减法神马的嘴讨厌了

出0入0汤圆

发表于 2012-3-27 20:06:14 | 显示全部楼层
莫大的收藏功能很强大啊,非常好用

出0入0汤圆

发表于 2012-3-27 20:07:17 | 显示全部楼层
本帖最后由 Name_006 于 2012-3-27 20:07 编辑

好资料   要顶 要收藏了啊   

出0入0汤圆

发表于 2012-3-27 20:08:22 | 显示全部楼层
好东西,先收藏了

出0入0汤圆

发表于 2012-3-27 20:11:10 | 显示全部楼层
不错的资料 收藏了

出0入0汤圆

发表于 2012-3-27 20:12:37 | 显示全部楼层
已经收藏  谢谢楼主

出0入0汤圆

发表于 2012-3-27 20:13:55 | 显示全部楼层
谢谢楼主的资料

出0入0汤圆

发表于 2012-3-27 20:16:21 | 显示全部楼层
好东西,收下了!

出0入0汤圆

发表于 2012-3-27 20:18:05 | 显示全部楼层
收藏了,多谢多谢

出0入0汤圆

发表于 2012-3-27 20:18:49 | 显示全部楼层
资料很好,不知道有没有自己的原创呀?

出0入0汤圆

发表于 2012-3-27 20:18:57 | 显示全部楼层
收藏了~~~~~~

出0入0汤圆

发表于 2012-3-27 20:20:56 | 显示全部楼层
好东西啊

出0入0汤圆

发表于 2012-3-27 20:59:49 | 显示全部楼层
谢谢楼主分享好资料

出0入0汤圆

发表于 2012-3-27 21:09:06 | 显示全部楼层
好东西啊,收藏了,感谢楼主!

出0入0汤圆

发表于 2012-3-27 21:13:32 | 显示全部楼层
楼主,你太猛了!!!非常感谢!

出0入0汤圆

发表于 2012-3-27 21:19:57 | 显示全部楼层
果断 收了,哈哈

出0入0汤圆

发表于 2012-3-27 21:20:01 | 显示全部楼层
资料很有用,收藏了

出0入0汤圆

发表于 2012-3-27 21:22:05 | 显示全部楼层
非常感谢啊!

出0入0汤圆

发表于 2012-3-27 21:24:26 | 显示全部楼层
谢谢,收藏了。

出0入0汤圆

发表于 2012-3-27 21:25:49 | 显示全部楼层
不错的资料,好东西,要收藏

出0入0汤圆

发表于 2012-3-27 21:27:35 | 显示全部楼层
必须收藏啊

出0入0汤圆

发表于 2012-3-27 21:29:42 | 显示全部楼层
这个给力!

出0入0汤圆

发表于 2012-3-27 21:30:01 | 显示全部楼层
   mark gui

出0入0汤圆

发表于 2012-3-27 21:30:32 | 显示全部楼层
Mark 谢谢分享

出0入0汤圆

发表于 2012-3-27 21:45:38 | 显示全部楼层
好资料,谢谢分享

出0入0汤圆

发表于 2012-3-27 21:50:35 | 显示全部楼层
不错的说~~~好资料~

出0入0汤圆

发表于 2012-3-27 21:51:14 | 显示全部楼层
还是研究下开源的gui实际些!

出0入8汤圆

发表于 2012-3-27 21:59:02 | 显示全部楼层
谢谢,先收藏下。

出0入0汤圆

发表于 2012-3-27 22:41:11 | 显示全部楼层
好资料!收藏了

出0入24汤圆

发表于 2012-3-27 22:43:22 | 显示全部楼层
好东西,Mark!

出0入0汤圆

发表于 2012-3-27 22:50:09 | 显示全部楼层
是个好东西,谢谢楼主

出0入0汤圆

发表于 2012-3-27 22:52:50 | 显示全部楼层
Mark,收下先

出0入0汤圆

发表于 2012-3-27 23:27:14 | 显示全部楼层
有收藏功能就是好啊

出0入0汤圆

发表于 2012-3-27 23:39:49 | 显示全部楼层
感谢楼主的分享,虽然这些东西书里都有.

出0入0汤圆

发表于 2012-3-28 00:00:52 | 显示全部楼层
这资料真不错,正需要。谢谢LZ。

出0入0汤圆

发表于 2012-3-28 00:17:59 | 显示全部楼层
收藏,谢了,有空对照一下

出0入0汤圆

发表于 2012-3-28 01:06:00 | 显示全部楼层
马克            

出0入0汤圆

发表于 2012-3-28 01:19:51 来自手机 | 显示全部楼层
谢谢分享

出0入0汤圆

发表于 2012-3-28 01:21:29 | 显示全部楼层
液晶程序的好算法。

出0入0汤圆

发表于 2012-3-28 09:21:35 | 显示全部楼层
Lz辛苦了,珍藏了

出0入0汤圆

发表于 2012-3-28 09:35:16 | 显示全部楼层
好东西哦!!

出0入0汤圆

发表于 2012-3-28 09:36:32 | 显示全部楼层
收藏先,合希望不要删除,以后我会用得上

出0入0汤圆

发表于 2012-3-28 09:39:26 | 显示全部楼层
同样收藏的路过

出0入0汤圆

发表于 2012-3-28 09:40:07 | 显示全部楼层
好东西,研究ing.

出0入0汤圆

发表于 2012-3-28 09:40:55 | 显示全部楼层
很好的资料,谢谢楼主分享

出0入0汤圆

发表于 2012-3-28 09:42:38 | 显示全部楼层
好东西,一定要没收

出0入0汤圆

发表于 2012-3-28 09:45:03 | 显示全部楼层
收藏,谢谢楼主

出0入0汤圆

发表于 2012-3-28 09:47:16 | 显示全部楼层
下载反应好慢啊 过好久才能下载

出0入0汤圆

发表于 2012-3-28 09:48:08 | 显示全部楼层
不错看看

出0入0汤圆

发表于 2012-3-28 09:53:28 | 显示全部楼层
都是好资料。

出0入0汤圆

发表于 2012-3-28 09:54:00 | 显示全部楼层
mark!                     

出0入0汤圆

发表于 2012-3-28 09:55:18 | 显示全部楼层
MARK           

出0入0汤圆

发表于 2012-3-28 10:28:03 | 显示全部楼层
好资料,谢谢

出0入0汤圆

发表于 2012-3-28 10:33:50 | 显示全部楼层
不错。。。以前做过不来神汉姆算法。。。楼主的没有实际的例子。。

出0入0汤圆

发表于 2012-3-28 10:37:37 | 显示全部楼层
http://blog.csdn.net/yangxingbo0311/article/details/7201097这有我的具体的实现。。。也贴上代码。不过是几年前的了。。

    ------------------------------------------------------------------------------------------------  
    程序说明:程序由12864的串行模式修改为并行模式,主要是为了提高12864的速度。在原有的  
              汉字、字符显示功能,绘图功能的基础上,增加了多个功能函数,以完善12864显示各种图象数据的  
              功能  

[cpp] view plaincopyprint?

    ------------------------------------------------------------------------------------------------  
    1.汉字字幕的左移动功能,函数名称为:  
        dispstr_12864_move(uchar x,uchar y1,uchar y2,uchar *pstr1,uint word_number,uint speed)  
    使用说明:x为文字在屏幕上地址定位横坐标;y1为第(1~4)行文字定位地址坐标;y2为第(1~4)行文字定位地  
    址坐标;*pstr1为第一行文字组;*pstr2为第二行文字组 ;word_number 移动显示的文字数目;speed 为字幕移  
    动的速度。该函数的功能大家可以根据自己的需要修改和完善,本函数中只提供基本的移动算法。  
    --------------------------------------------------------------------------------------------------  
    2.12864全屏区域单点描点函数,函数名称为:  
        plot_12864(uchar x,uchar y,uchar *buf),给定一个坐标(x,y),即可在屏幕上对应的坐标显示出一个点  
    其中,x取值范围为:1~128   y的取值范围为:1~64    !!!注意!!!不可超出规定的取值范围,否则屏幕  
    有可能不能正常显示,原因是数据溢出缓冲区。  
    --------------------------------------------------------------------------------------------------  
    3.12864全屏区域多点镜像描点函数,函数名称为:  
        mirror_point_12864(uchar center,uchar x,uchar h,uchar *buf)center为对称轴的坐标,即屏幕上对应  
    的y坐标x为要镜像描点的横坐标,h为镜像描点的高度,buf为数据存放的目标缓存区。此函数主要是用在音乐频  
    谱的显示上。  
    ----------------------------------------------------------------------------------------------------  
    4.任意两点间画直线的函数,函数名为:  
        draw_Line(uchar x0,uchar y0,uchar x1,uchar y1),采用布兰森汉姆(Bresenham)算法画线,给定两个点的  
    坐标(x0,y0),(x1,y1)就能实现在这两点间画出直线。辅助实现该函数功能的附属函数有:  
    ①求两个数的绝对值|a-b|的函数abs(uchar a,uchar b)  
    ②画垂直线的函数subsection_point_12864(uchar x,uchar center,uchar h,uchar *buf)  
    ③画横线的函数line_piont(uchar x0,uchar y0,uchar x1,uchar *buf)  
    ----------------------------------------------------------------------------------------------------  
    5.画圆函数,函数名为:  
       draw_circle(uchar x0,uchar y0,uchar r),采用布兰森汉姆(Bresenham)算法画圆,先画1/8个圆,然后用对称  
    方法画出剩下的部分。(x0,y0)为圆心的坐标,x0:1~128  y0:1~64  r为圆的半径:1~31。   
    -----------------------------------------------------------------------------------------------------  
    **************************************************************************************************  
    *************************************************************************************************/  
      
      
      
    //*******头文件部分********//  
    #include "avr/io.h"  
    #include <util/delay.h>   
    #include "math.h"   
      
    #define data_port    PORTB   
    #define RS_1()     {DDRC |= (1<<7);nop();PORTC |= (1<<7);}  
    #define RW_1()     {DDRC |= (1<<6);nop();PORTC |= (1<<6);}  
    #define EN_1()     {DDRC |= (1<<5);nop();PORTC |= (1<<5);}  
      
    #define RS_0()   {DDRC |= (1<<7);nop();PORTC &= ~(1<<7);}  
    #define RW_0()   {DDRC |= (1<<6);nop();PORTC &= ~(1<<6);}  
    #define EN_0()   {DDRC |= (1<<5);nop();PORTC &= ~(1<<5);}  
      
    #define set_output()  DDRB = 0XFF  
    #define set_input()   DDRB = 0X00  
    #define port_lcd   PINB  
    #define nop() asm("nop")  
    #define uchar unsigned char  
    #define uint  unsigned int  
      
      
      
      
      
    uchar   music[1024]={};   
    uchar   magic[16]={};  
      
    //**********************************************************************  
    void delay_100ms(uint i)  
    {  
        uint k;  
        for (k=0;k<i;k++)  
        {  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
            _delay_ms(10);  
        }  
         
    }  
         
    //**********************************************************************   
      
      
    //*************函数部分***************/  
    /* 名字:busywait_12864()            */  
    /* 功能:检测RT12864M是否忙          */  
    /* 局部变量:无                      */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/  
    void busywait_12864(void)  
    {  
        uchar bf=0;  
         
    loop:RS_0();  
        RW_1();  
        EN_1();  
        set_input();  
        _delay_us(6);  
        bf = port_lcd;  
        EN_0();  
        if(bf&0x80)goto loop;  
        set_output();  
    }  
    //*************函数部分***************/  
    /* 名字:writecomm_12864()           */  
    /* 功能:写命令进RT12864M            */  
    /* 局部变量:command                 */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/   
    void writecomm_12864(uchar command)  
    {  
        busywait_12864();  
        set_output();  
        RS_0();  
        RW_0();  
        data_port = command;  
        EN_1();  
        EN_0();  
      
    }  
    //*************函数部分***************/  
    /* 名字:writedata_12864()           */  
    /* 功能:写数据写进RT12864M          */  
    /* 局部变量:wrdata                  */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/   
    void writedata_12864(uchar wrdata)  
    {  
        busywait_12864();  
        set_output();  
        RS_1();  
        RW_0();  
        data_port = wrdata;  
        EN_1();  
        EN_0();  
    }  
    //*************函数部分***************/  
    /* 名字:Init_12864()                */  
    /* 功能:初始化RT12864M              */  
    /* 局部变量:无                      */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/  
    void Init_12864(void)  
    {  
         
         
        writecomm_12864(0x30);//功能设置 8位数据,基本指令  
        _delay_ms(1);  
        writecomm_12864(0x0c);//显示状态 ON,游标OFF,反白OFF  
        _delay_ms(1);  
        writecomm_12864(0x01);//清除显示  
        _delay_ms(1);  
        writecomm_12864(0x02);//地址归位  
    }  
    //*************函数部分***************/  
    /* 名字:locatexy_12864()            */  
    /* 功能:定位显示地址                */  
    /* 局部变量:x,y                     */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/  
    void locatexy_12864(uchar x,uchar y)  
    {  
        uchar addr=0;  
        switch(y)  
            {  
               case 0:addr=0x80+x;break;  
               case 1:addr=0x90+x;break;  
               case 2:addr=0x88+x;break;  
               case 3:addr=0x98+x;break;  
               default:break;  
            }     
        writecomm_12864(addr);  
    }  
    //*************函数部分***************/  
    /* 名字:distwochar_12864()          */  
    /* 功能:显示两个字符即一个汉字      */  
    /* 局部变量:x,y,char1,char2        */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/  
    void distwochar_12864(uchar x,uchar y,uchar char1,uchar char2)  
    {  
        locatexy_12864(x,y);   
        writedata_12864(char1);  
        writedata_12864(char2);  
    }  
    //*************函数部分***************/  
    /* 名字:dispstr_12864()             */  
    /* 功能:显示汉字字组                */  
    /* 局部变量:x,y,*pstr              */  
    /* 全局变量:无                      */  
    /* 返回值:  无                      */  
    //************************************/  
    void dispstr_12864(uchar x,uchar y,uchar *pstr)  
    {  
        uint i,t=0;  
        while(pstr[t]!='\0')t++;  
        for(i=0;i<t;i++)  
            {  
              distwochar_12864(x,y,pstr,pstr[i+1]);  
              i+=1;  
              x+=1;  
              if(x==8)  
                {  
                  x=0;  
                  y++;  
                  if(y==4)y=0;  
                }   
            }   
    }  
      
    /*=========================================*/  
    /* 函数:drawpic(uchar *pdraw);            */  
    /* 功能描述:画图形                        */  
    /* 参数接口:pdraw,是存放图形数据的表     */  
    /*=========================================*/  
    void drawpic_12864(uchar *pdraw)  
    {     
        uint x,y;  
        long uint k=0;  
        uchar yaddr=0x80;  
        //writecomm_12864(0x30);//功能设置---8BIT控制界面,绘图显示OFF  
        writecomm_12864(0x34);//功能设置---8BIT控制界面,扩充指令集  
        for(y=0;y<32;y++)  
            {  
                writecomm_12864(yaddr++);//设置绘图区的Y地址坐标  
                writecomm_12864(0x80);  //设置绘图区的X地址坐标  
                for(x=0;x<8;x++)  
                    {  
                      writedata_12864(pdraw[k++]);  
                      writedata_12864(pdraw[k++]);  
                    }  
            }  
        yaddr=0x80;  
        for(y=0;y<32;y++)  
            {     
                writecomm_12864(yaddr++);//设置绘图区的Y地址坐标  
                writecomm_12864(0x88);   //设置绘图区的X地址坐标  
                for(x=0;x<8;x++)  
                    {  
                        writedata_12864(pdraw[k++]);  
                        writedata_12864(pdraw[k++]);  
                    }  
            }  
       // writecomm_12864(0x32);//功能设置---8BIT控制界面,绘图显示ON  
        writecomm_12864(0x36);//功能设置---8BIT控制界面,绘图显示OFF  
        //返回基本设置  
         
        writecomm_12864(0x30);//功能设置 8位数据,基本指令  
        writecomm_12864(0x0c);//显示状态 ON,游标OFF,反白OFF  
        writecomm_12864(0x02);//地址归位  
    }  
      
      
      
    //*************函数部分***************************************************  
    // 名字:dispstr_12864()               
    // 功能:移动显示汉字字组                  
    // 局部变量:x,y12,*pstr1,*pstr2,word_number,speed   
    // 使用说明:x为文字定位地址横坐标?  
    //           y1为第(1~4)行文字定位地址坐标  
    //           y2为第(1~4)行文字定位地址坐标  
    //           *pstr1为第一行文字组  
    //           *pstr2为第二行文字组   
    //           word_number 移动显示的文字数目  
    //           speed 移动的速度           
    // 全局变量:无                        
    // 返回值:  无                        
    //***********************************************************************  
    void dispstr_12864_move(uchar x,uchar y1,uchar y2,  
                             uchar *pstr1,  
                             uint word_number,uint speed)  
    {  
        uchar i,t;  
        uint move;  
         
         
        for (move=0;move<word_number;move++)  
        {  
            for (t=0;t<16;t++)  
            {     
               
                for(i=0;i<t;i++)  
                {  
                    distwochar_12864(x,y1,pstr1[i+move*2],pstr1[i+move*2+1]);  
                    //distwochar_12864(x,y2,pstr2[i+move*2],pstr2[i+move*2+1]);  
                    i+=1;  
                    x+=1;  
                    if(x==8)  
                    {  
                        x=0;  
                    }   
                }  
            }   
            delay_100ms(speed);  
              
        }  
      
    }  
      
      
    //******************************************************  
    //*************函数部分********************************/  
    /* 名字:abs(x1-x0)                                  */  
    /* 功能:计算两个数相减的绝对值                       */  
    /* 局部变量:取值范围                                 */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意                                               */  
    //*****************************************************/  
    int abs(int a,int b)  
    {  
        uint fabs = 0;  
        if ((a-b)>0)   fabs = a-b;  
        else           fabs = b-a;  
        return (fabs);  
    }  
    //****************************************************  
    //*************函数部分****************************/  
    /* 名字:plot1_12864()                            */  
    /* 功能:图象单点描点函数                         */  
    /* 局部变量:取值范围  x:[-64,64]  y:[-32,31]   */  
    /* 全局变量:无                                   */  
    /* 返回值:  无                                   */  
    //*************************************************/  
    void plot1_12864(int x,int y,uchar *buf)  
    {  
        uchar a=0;  
        if ((x>0)|(x==0))  
        {  
            if (!((x+64)%8))     
            {  
                a|=(1<<0);   
                buf[(31-y)*16+((x+64)/8)-1]|=a;  
            }  
            else            
            {  
                a|=(1<<(8-(x+63)%8));  
                buf[(31-y)*16+((x+64)/8)]|=a;  
            }  
        }  
        else   
        {  
              
            if (!((64+x)%8))     
            {                                                
                a|=(1<<0);   
                buf[(31-y)*16+((64+x)/8)-1]|=a;  
            }  
            else            
            {  
                a|=(1<<(8-(x+64)%8));  
                buf[(31-y)*16+(64+x)/8]|=a;  
            }  
        }  
      
    }   
      
      
    //*************函数部分****************************/  
    /* 名字:plot1_12864()                            */  
    /* 功能:图象单点描点函数                         */  
    /* 局部变量:取值范围  x:[-64,64]  y:[-32,31]   */  
    /* 全局变量:无                                   */  
    /* 返回值:  无                                   */  
    //*************************************************/  
    void plot_12864(int x,int y,uchar *buf)  
    {  
        uchar a=0;  
         
        if (!(x%8))     
        {  
            a|=(1<<0);   
            buf[(64-y)*16+(x/8)-1]|=a;  
        }  
        else            
        {  
            a|=(1<<(8-x%8));  
            buf[(64-y)*16+(x/8)]|=a;  
        }  
      
    }  
      
    //******************************************************  
    //*************函数部分********************************/  
    /* 名字:mirror_point_12864()                         */  
    /* 功能:图象多点镜像描点函数                         */  
    /* 局部变量:取值范围 :y:[1,128]                      */  
    /*           像距为:h:[1,63]  中心线:center:[1,64]  */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意!!:两点之间的距离不得超过64(12864只有64行)*/  
    //*****************************************************/  
    void mirror_point_12864(uchar center,uchar x,uchar h,uchar *buf)  
    {  
        uchar a=0,i,high=0;  
        if (h>31)  high = 31;  
        else       high = h;  
         
        if (!(x%8))     
        {  
            a|=(1<<0);  
            for (i=0;i<high;i++)   
            {  
                buf[(64-center+i)*16+(x/8)-1]|=a;  
                buf[(64-center-i)*16+(x/8)-1]|=a;  
            }  
        }  
         
        else            
        {  
            a|=(1<<(8-x%8));  
            for (i=0;i<high;i++)   
            {  
                buf[(64-center+i)*16+(x/8)]|=a;  
                buf[(64-center-i)*16+(x/8)]|=a;  
            }  
        }  
      
      
    }  
      
      
      
    //******************************************************  
    //*************函数部分********************************/  
    /* 名字:clear_print_12864()                          */  
    /* 功能:清除图象数据存储区                           */  
    /* 局部变量:取值范围 :y:[1,128]                      */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意                                               */  
    //*****************************************************/  
    void clear_print_12864(uchar *buffer)  
    {  
        int i;  
        for (i=0;i<1024;i++)  
        {  
            buffer = 0x00;  
        }  
        drawpic_12864(buffer);  
    }  
      
      
      
    //******************************************************  
    //*************函数部分********************************/  
    /* 名字:subsection_point_12864()                     */  
    /* 功能:分段描点函数                                 */  
    /* 局部变量:                                         */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意!!:两点之间的距离不得超过64(12864只有64行)*/  
    //*****************************************************/  
    void  subsection_point_12864(uchar x,uchar center,uchar h,uchar *buf)  
    {  
            uchar a=0,i,high=0;  
        if (h>63)  high = 63;  
        else       high = h;  
         
        if (!(x%8))     
        {  
            a|=(1<<0);  
            for (i=0;i<high;i++)   
            {  
                buf[(64-center-i)*16+(x/8)-1]|=a;  
            }  
        }  
         
        else            
        {  
            a|=(1<<(8-x%8));  
            for (i=0;i<high;i++)   
            {  
                buf[(64-center-i)*16+(x/8)]|=a;  
            }  
              
        }  
         
      
    }  
      
      
    //*************函数部分********************************/  
    /* 名字:line_piont()                                 */  
    /* 功能:画横线函数                                   */  
    /* 局部变量:                                         */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意!!:两点之间的距离不得超过128(12864只有128宽*/  
    //*****************************************************/  
    void line_piont(int x0,int y0,int x1,uchar *buf)  
    {  
        uchar i;  
        for (i=x0;i<x1;i++)  
        {  
            plot_12864(i,y0,buf);  
        }  
         
    }  
      
    //*************函数部分********************************/  
    /* 名字:load_magic_12864()                          */  
    /* 功能:加载频谱魔幻花样                             */  
    /* 局部变量:取值范围 :y:[1,128]                      */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意                                               */  
    //*****************************************************/  
    void load_magic_12864(uchar *buffer)   
    {  
        uchar i,h;  
         
        for (i=0;i<16;i++)  
        {  
            h= buffer;  
            line_piont(i*8+1,h+1,i*8+8,music);  
            line_piont(i*8+1,h+2,i*8+8,music);  
        }  
    }  
      
      
    /********************************************************  
    * 名称:draw_Line()  
        采用布兰森汉姆(Bresenham)算法画线  
    * 功能:任意两点间的直线。根据硬件特点,实现加速。  
    * 入口参数:x0     直线起点所在行的位置  
    *       y0     直线起点所在列的位置  
    *       x1     直线终点所在行的位置  
    ‘       y1     直线终点所在列的位置  
    * 出口参数:   无  
    * 说明:操作失败原因是指定地址超出缓冲区范围。  
    *********************************************************/   
    void draw_line(int x0,int y0,int x1,int y1)   
    {   
        int temp;   
        int dx,dy;               //定义起点到终点的横、纵坐标增加值   
        int s1,s2,status,i;   
        int Dx,Dy,sub;   
      
        dx=x1-x0;   
         
        if(dx>=0)                 //X的方向是增加的   
        s1=1;   
        else                   //X的方向是降低的   
        s1=-1;      
        dy=y1-y0;                 //判断Y的方向是增加还是降到的   
        if(dy>=0)   s2=1;  
           
        else        s2=-1;  
           
        Dx=abs(x1,x0);           //计算横、纵标志增加值的绝对值   
        Dy=abs(y1,y0);   
       if(Dy>Dx)               //                  
       {                     //以45度角为分界线,靠进Y轴是status=1,靠近X轴是status=0   
            temp=Dx;   
            Dx=Dy;   
            Dy=temp;   
            status=1;   
        }   
       else  status=0;   
        
      
    //********判断垂直线和水平线*******************************************   
        //if(dx==0)                 //横向上没有增量,画一条水平线   
        //line_piont(x0,y0,x1,music);   
        //if(dy==0)                 //纵向上没有增量,画一条垂直线   
       // subsection_point_12864(x0,y0,y1,music);   
      
      
    //*********Bresenham算法画任意两点间的直线*****************************   
        sub=2*Dy-Dx;               //第1次判断下个点的位置   
        for(i=0;i<Dx+1;i++)   
        {   
            plot_12864(x0,y0,music);           //画点   
            if(sub>=0)                                
            {   
                if(status==1)             //在靠近Y轴区,x值加1   
                x0+=s1;   
                else                   //在靠近X轴区,y值加1               
                y0+=s2;   
                sub-=2*Dx;               //判断下下个点的位置   
            }   
            if(status==1)   
            y0+=s2;   
            else        
            x0+=s1;   
            sub+=2*Dy;   
        }   
      
      
    }   
      
      
      
      
    /***************************************************************   
    名称:Draw_circle (在任意位置画圆)   
    说明:使用Bresenham法画1/8个圆,在用对称性画出其他的7/8个圆   
         
        按下图把圆分为8份   
            0   
          7   1   
        6       2   
          5   3   
            4   
    *****************************************************************/   
    void draw_circle(uchar x0,uchar y0,uchar r)   
    {   
        int a,b;   
        int di;   
        a=0;   
        b=r;   
        di=3-2*r;             //判断下个点位置的标志   
        while(a<=b)   
       {    //plot_12864(uchar x,uchar y,uchar *buf)  
            plot_12864(x0-b,y0-a,music);           //3              
            plot_12864(x0+b,y0-a,music);           //0              
            plot_12864(x0-a,y0+b,music);           //1        
            plot_12864(x0-b,y0-a,music);           //7              
            plot_12864(x0-a,y0-b,music);           //2              
            plot_12864(x0+b,y0+a,music);           //4                  
            plot_12864(x0+a,y0-b,music);           //5   
            plot_12864(x0+a,y0+b,music);           //6   
            plot_12864(x0-b,y0+a,music);              
            a++;   
            /***使用Bresenham算法画圆**/      
            if(di<0)   
            di +=4*a+6;   
            else   
            {   
                di +=10+4*(a-b);      
                b--;   
            }   
            plot_12864(x0+a,y0+b,music);   
           
        }   
    }   
      
      
    //*************函数部分********************************/  
    /* 名字:cube_3D()                                    */  
    /* 功能:3D图象变换算法变换立方体                     */  
    /* 局部变量:                                         */  
    /*                                                    */   
    /* 全局变量:无                                       */  
    /* 返回值:  无                                       */  
    /* 注意!!:两点之间的距离不得超过64(12864只有64行)*/  
    //*****************************************************/  
    /* 定义显示位置 */  
    //#define OFFSETX 30   
    uchar OFFSETX = 64;         
    #define OFFSETY 38           
    #define OFFSETZ 60  
      
    /////////////////////////////////立方体加文字/////////////////////////////////////////////////////////  
    /*const signed int aa[23]={8,-8,-8,8,8,-8,-8,8,8,8,8,8,8,0,4,-4,-8,-8,-8,-8,-8,-8,-8}; // x  
    const signed int bb[23]={8,8,-8,-8,8,8,-8,-8,0,-4,4,-2,2,8,8,8,4,4,4,-4,-4,-4,0};   // y  
    const signed int cc[23]={-8,-8,-8,-8,8,8,8,8,6,-6,-6,0,0,-6,6,6,-6,0,6,6,0,-6,0};   // z
     
    const int ff[22]={1,2,3,4,5,6,7,8,1,2,3,4,9,9,12,14,14,17,19,20,21,22};         // start
    const int gg[22]={2,3,4,1,6,7,8,5,5,6,7,8,10,11,13,15,16,19,20,21,18,23};       // end*/  
    /////////////////////////////////////////////////////////////////////////////////////////////////////  
      
    const signed int aa[14]={-16,-14,-18,-12,-20,8,-8,0,20,12,20,12,20,12}; // x   
    const signed int bb[14]={16,10,10,0,0,16,16,0,16,16,10,10,0,0};   // y   
    const signed int cc[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};   // z  
      
    const int ff[13]={1,3,1,2,3,6,7,10,12,10,9,12,12};         // start  
    const int gg[13]={3,5,2,4,2,8,8,12,14,9,11,11,13};       // end  
      
    /////////////////////////////////////////////////////////////////////////////////////////////////////////  
      
    /*const signed int aa[16]={-11,-3,-7,11,-3,-13,-1,-7,-13,-1,0,8,4,8,0,0}; // x  
    const signed int bb[16]={20,20,12,16,16,12,12,12,0,0,20,20,16,12,12,0};   // y  
    const signed int cc[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};   // z
     
    const int ff[12]={1,2,4,3,6,8,8,11,11,12,13,14};         // start
    const int gg[12]={3,3,5,8,7,9,10,16,12,13,14,15};       // end*/  
      
    /////////////////////////////////////////////////////////////////////////////////////////////////////////  
    /*const signed int aa[16]={-26,-26,-16,-12,-12,-3,-3,2,10,18,22,30,22,30,22,30}; // x  
    const signed int bb[16]={16,0,0,16,0,16,0,16,0,16,16,16,8,8,0,0};   // y  
    const signed int cc[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};   // z
     
    const int ff[13]={1,2,4,4,6,5,8,9,11,13,11,13,15};         // start
    const int gg[13]={2,3,5,6,7,7,9,10,13,15,12,14,16};       // end*/  
      
    /////////////////////////////////////////////////////////////////////////////////////////////////////////  
      
      
    int sx,sy,ex,ey;                   // define global vars for calling graphics subroutines  
    float rotx=0.00;                     // starting amount of x rotation  
    float roty=0.00;                     // starting amount of y rotation  
    float rotz=0.00;                     // starting amount of z rotation  
      
      
    /**************************************************************************
    *                 3D显示主程序
    ***************************************************************************/  
    void Disply3D(float xpos,float ypos,float zpos)     
    {  
        int newx[23];                     // translated screen x co-ordinates for vertex  
        int newy[23];                     // translated screen y co-ordinates for vertex  
        int i,loop;                         // temp variable for loops  
        int vertex;  
        float xt,yt,zt,x,y,z,sinax,cosax,sinay,cosay,sinaz,cosaz;   // lots of work variables  
        for (loop=0;loop<1;loop++)  
        {  
            xpos=xpos+0.00;               // move the object  
            ypos=ypos+0.00;               // it would wander off screen  
            zpos=zpos+0.00;               // really quick, so leave it centered  
            rotx=rotx+0.00;                 // rotate the cube on X axis  
            roty=roty+0.15;                 // and on its y axis  
            rotz=rotz+0.00;                 // dont bother with z or it gets confusing  
              
            sinax=sin(rotx);               // precalculate the sin and cos values  
            cosax=cos(rotx);             // for the rotation as this saves a   
              
            sinay=sin(roty);             // little time when running as we  
            cosay=cos(roty);             // call sin and cos less often  
              
            sinaz=sin(rotz);             // they are slow routines  
            cosaz=cos(rotz);           // and we dont want slow!  
              
            for (i=0; i<14; i++)         // translate 3d vertex position to 2d screen position  
            {  
                x=aa;                   // get x for vertex i  
                y=bb;                   // get y for vertex i  
                z=cc;                   // get z for vertex i  
                  
                yt = y * cosax - z * sinax;         // rotate around the x axis  
                zt = y * sinax + z * cosax;       // using the Y and Z for the rotation  
                y = yt;  
                z = zt;  
                  
                yt = y * cosax - z * sinax;         // rotate around the x axis  
                zt = y * sinax + z * cosax;       // using the Y and Z for the rotation  
                y = yt;  
                z = zt;  
                  
                xt = x * cosay - z * sinay;       // rotate around the Y axis  
                zt = x * sinay + z * cosay;       // using X and Z  
                x = xt;  
                z = zt;  
                  
                xt = x * cosaz - y * sinaz;         // finaly rotate around the Z axis  
                yt = x * sinaz + y * cosaz;       // using X and Y  
                x = xt;  
                y = yt;  
                  
                x=x+xpos;                         // add the object position offset  
                y=y+ypos;                         // for both x and y  
                z=z+OFFSETZ-zpos;           // as well as Z  
                  
                newx=(x*64/z)+OFFSETX;       // translate 3d to 2d coordinates for screen  
                newy=(y*64/z)+OFFSETY;       // drawing so we can see the cube  
            }  
              
            for (i=0; i<13; i++)           // draw the lines that make up the object  
            {  
                vertex=ff-1;               // temp = start vertex for this line  
                sx=newx[vertex];           // set line start x to vertex x position  
                sy=newy[vertex];           // set line start y to vertex y position  
                vertex=gg-1;             // temp = end vertex for this line  
                ex=newx[vertex];           // set line end x to vertex[i+1] x position  
                ey=newy[vertex];           // set line end y to vertex[i+1] y position  
                if((sx>255) | (sy>255) | (ex>255) |( ey>255))  
                {  
                    sx=255;  
                    sy=255;  
                    ex=255;  
                    ey=255;  
                }  
                draw_line(sx,sy,ex,ey);  
            }  
        }  
      
    }  

出75入4汤圆

发表于 2012-3-28 10:37:40 | 显示全部楼层
不错。参考下。

出0入0汤圆

发表于 2012-3-28 10:42:29 | 显示全部楼层
咦。。。。刚刚的回帖咋不见了。。。晕

出0入0汤圆

发表于 2012-3-28 10:46:47 | 显示全部楼层
什么意思?不登陆还下载不了资料,改个版连性质都变了,无语
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-29 08:27

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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