⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ag12864c.txt

📁 欣瑞达12864例子程序源程序,128×64C语言驱动
💻 TXT
📖 第 1 页 / 共 2 页
字号:
一:
128×64C语言驱动,可实现滚屏、上下卷集、淡入淡出、逐层堆积和百叶窗等

void AC_fill(unsigned char fdata)            //Fill the full LCD with "fdata"
{
    unsigned char data i,j;

    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
            wdata(fdata,1,0);
        set_adr(i,0);
        for(j=0;j<64;j++)
            wdata(fdata,0,1);
    }
}


void AC_load(unsigned char *np)         //Load the LCD with a 128*64 image,*np is the pointer  to the image
{
    unsigned char data i,j;

    set_startline(0);
    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,1,0);
            np++;
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,0,1);
            np++;
        }
    }
}


void AC_pageup(unsigned char *cp,unsigned char *np,unsigned char rows,unsigned char fdata)        //Roll all of the LCD and replace the Current page(*cp) with the Next(*np),"rows" designate how many banks filled with "fdata" will be inserted between the two pages
{
    unsigned char data i,j;
    unsigned char data rbits=0xff;

    for(i=0;i<rows*8;i++)
    {
        set_startline((i+1)%64);
        rbits <<=((i%8)+1);
        set_adr(((i/8)%8),0);
        for(j=0;j<64;j++)
        {
            wdata(((rbits&(*cp))|((~rbits)&fdata)),1,0);
            cp++;
        }
        set_adr((i/8)%8,0);
        for(j=0;j<64;j++)
        {
            wdata(((rbits&(*cp))|((~rbits)&fdata)),0,1);
            cp++;
        }
        rbits =0xff;
        cp -=128;
        if((i+1)%8==0)
            cp +=128;
        delay(0xb00);
    }

    for(i=0;i<64;i++)
    {
        set_startline((i+rows*8+1)%64);
        rbits <<=((i%8)+1);
        set_adr(((i+rows*8)/8)%8,0);
        if((i+rows*8)<64)
        {
            for(j=0;j<64;j++)
            {
                wdata(((rbits&(*cp))|((~rbits)&(*np))),1,0);
                cp++;
                np++;
            }
        }
        else
        {
            for(j=0;j<64;j++)
            {
                wdata(((rbits&fdata)|((~rbits)&(*np))),1,0);
                np++;
            }
        }
        set_adr(((i+rows*8)/8)%8,0);
        if((i+rows*8)<64)
        {
            for(j=0;j<64;j++)
            {
                wdata(((rbits&(*cp))|((~rbits)&(*np))),0,1);
                cp++;
                np++;
            }
        }
        else
        {
            for(j=0;j<64;j++)
            {
                wdata(((rbits&fdata)|((~rbits)&(*np))),0,1);
                np++;
            }
        }
        rbits =0xff;
        cp -=128;
        np -=128;
        if((i+1)%8==0)
        {
            cp +=128;
            np +=128;
        }
        delay(0xb00);
    }
/*    np -=0x400;
    dison_off(0);
    AC_load(np);
    dison_off(1);
*/
}


void AC_wrapdown(unsigned char *np)        //wrap down the full screen the Next page(*np)
{
    unsigned char data i,j;

    set_startline(0);
    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,1,0);
            np++;
            delay(0xa0);
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,0,1);
            np++;
            delay(0xa0);
        }
    }
}


void AC_wrapup(unsigned char *np)        //wrap up the full screen the Next page(*np)
{
    unsigned char data i,j;

    np +=0x380;
    set_startline(0);
    for(i=0;i<8;i++)
    {
        set_adr(7-i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,1,0);
            np++;
            delay(0xa0);
        }
        set_adr(7-i,0);
        for(j=0;j<64;j++)
        {
            wdata(*np,0,1);
            np++;
            delay(0xa0);
        }
        np -=0x100;
    }
}


void AC_pileup(unsigned char *np,unsigned char fdata)    //Pileup the LCD by falling banks of image(*np) from top to bottom and rest of the LCD filled with "fdata"
{
    unsigned char data i,j,k;
    unsigned char rbits =0xff;

    AC_fill(fdata);
    np +=0x380;                //from the last bank of LCM
    for(i=0;i<8;i++)
    {
        for(j=0;j<64-8*i;j++)     //how many rows will been put down
        {
            rbits <<=7-(j%8);
            if(j<8)
            {
                set_adr(0,0);
                for(k=0;k<64;k++)
                {
                    wdata((*np&rbits)|(~rbits)&fdata,1,0);
                    np++;
                }
                set_adr(0,0);
                for(k=0;k<64;k++)
                {
                    wdata((*np&rbits)|(~rbits)&fdata,0,1);
                    np++;
                }
            }
            else
            {
                set_adr(j/8,0);
                for(k=0;k<64;k++)
                {
                    wdata(*np&rbits,1,0);
                    np++;
                }
                set_adr(j/8,0);
                for(k=0;k<64;k++)
                {
                    wdata(*np&rbits,0,1);
                    np++;
                }

                np -=0x80;
                set_adr((j/8)-1,0);
                for(k=0;k<64;k++)
                {
                    wdata((*np)&(~rbits)|(rbits&fdata),1,0);
                    np++;
                }
                set_adr((j/8)-1,0);
                for(k=0;k<64;k++)
                {
                    wdata((*np)&(~rbits)|(rbits&fdata),0,1);
                    np++;
                }
            }
            np -=0x80;
            rbits =0xff;
            delay(0x80);
        }
        np -=0x80;
        delay(0x1000);
    }
}


void AC_fadein(unsigned char *np,unsigned char fdata)        //Fadein an image
{
    unsigned char data i,j;

    AC_fill(fdata);
    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*np&0x05)|(fdata&0xfa),1,0);
            np++;
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*np&0x05)|(fdata&0xfa),0,1);
            np++;
        }
    }
    delay(0x5000);
    np -=0x400;
    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*np&0x55)|(fdata&0xaa),1,0);
            np++;
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*np&0x55)|(fdata&0xaa),0,1);
            np++;
        }
    }
    delay(0x5000);
    np -=0x400;
    AC_load(np);
}


void AC_fadeout(unsigned char *cp,unsigned char fdata)        //Fadeout an image
{
    unsigned char data i,j;

    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*cp&0xaa)|(fdata&0x55),1,0);
            cp++;
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*cp&0xaa)|(fdata&0x55),0,1);
            cp++;
        }
    }
    delay(0x5000);
    cp -=0x400;
    for(i=0;i<8;i++)
    {
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*cp&0x0a)|(fdata&0xf5),1,0);
            cp++;
        }
        set_adr(i,0);
        for(j=0;j<64;j++)
        {
            wdata((*cp&0x0a)|(fdata&0xf5),0,1);
            cp++;
        }
    }
    delay(0x5000);
    AC_fill(fdata);
}


void AC_shutter(unsigned char *np,unsigned char fdata)
{
    unsigned char data i,j,k;
    unsigned char data rbits=0xff;

    AC_fill(fdata);
    for(i=0;i<8;i++)
    {
        rbits >>=7-i;
        for(j=0;j<8;j++)
        {
            set_adr(j,0);
            for(k=0;k<64;k++)
            {
                wdata((*np&rbits)|(~rbits&fdata),1,0);
                np++;
            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -