天天看點

12864圖檔顯示stc89c52RC顯示史努比源代碼

#include<reg52.h>

#include<intrins.h>

#include<stdlib.h>

#define uchar unsigned char

#define uint unsigned int

#define DATE P2

sbit RS = P0^7;

sbit RW = P0^6;

sbit EN = P0^5;

sbit PSB = P0^4;

uchar code Picture[]=

{

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x07,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x1F,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x38,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x70,0x01,0xC0,0x00,0x00,0x3F,0xFF,0xE0,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0xE0,0x00,0x01,0xFF,0xFF,0xC0,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x60,0x00,0x07,0xC7,0xFE,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x30,0x00,0x0F,0x01,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x38,0x00,0x1C,0x00,0x70,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xFE,0x00,0x00,0x18,0x00,0x3C,0x00,0x38,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x0C,0x00,0x3C,0x00,0x1C,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x3E,0x03,0x00,0x00,0x0C,0x00,0x3C,0x00,0x1F,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0xF8,0x03,0x80,0x00,0x7E,0x00,0x7D,0x80,0x0F,0xC0,0x00,0x00,0x00,

0x00,0x00,0x01,0xC0,0x01,0xC0,0x03,0xFF,0x00,0x7D,0x80,0x0E,0xE0,0x00,0x00,0x00,

0x00,0x00,0x03,0x80,0x00,0xC0,0x03,0xFF,0x00,0x79,0x80,0x06,0x60,0x00,0x00,0x00,

0x00,0x00,0x06,0x00,0x00,0x40,0x07,0xFF,0x00,0xF9,0xC0,0x06,0x30,0x00,0x00,0x00,

0x00,0x00,0x06,0x00,0x00,0x00,0x07,0xFF,0x80,0xFF,0xE0,0x06,0x30,0x00,0x00,0x00,

0x00,0x00,0x0C,0x00,0x00,0x00,0x1F,0xFF,0x81,0xFF,0xF0,0x06,0x30,0x00,0x00,0x00,

0x00,0x00,0x0C,0x00,0x00,0x00,0x1F,0xFF,0x83,0xFF,0x38,0x00,0x30,0x00,0x00,0x00,

0x00,0x00,0x0C,0x00,0x00,0x00,0x1F,0xFF,0x83,0xFB,0x18,0x00,0x3C,0x00,0x00,0x00,

0x00,0x00,0x0C,0x00,0x00,0x00,0x3F,0xFF,0xCE,0x3C,0x18,0x00,0x0E,0x00,0x00,0x00,

0x00,0x00,0x0C,0x00,0x00,0x00,0x3F,0xFF,0xFC,0x3C,0x0C,0x00,0x0F,0x00,0x00,0x00,

0x00,0x00,0x04,0x00,0x00,0x00,0x3F,0xFF,0xF9,0xFC,0x0C,0x0C,0x0F,0x00,0x00,0x00,

0x00,0x00,0x0E,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xF8,0x0E,0x0E,0x03,0x00,0x00,0x00,

0x00,0x00,0x1E,0x00,0x00,0x00,0x7F,0xFF,0xBF,0xF8,0x0E,0x0F,0x07,0x00,0x00,0x00,

0x00,0x00,0x3E,0x00,0x00,0x00,0x7F,0xFF,0x80,0x00,0x0C,0x0F,0x8F,0x00,0x00,0x00,

0x00,0x00,0x3F,0x00,0x00,0x00,0x7F,0xFF,0x80,0x00,0x1C,0x1F,0xC7,0x00,0x00,0x00,

0x00,0x00,0x3F,0x80,0x00,0x00,0x7F,0xFF,0x00,0x00,0x3E,0x3D,0xFF,0x00,0x00,0x00,

0x00,0x00,0x3F,0xE0,0x00,0x00,0x7F,0xFF,0x00,0x00,0x7F,0xF9,0xFF,0xC0,0x00,0x00,

0x00,0x00,0x3E,0xF0,0x00,0x00,0x7F,0xFF,0x00,0x0F,0xE7,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

void Delayms(uint z) //????

{

    uint x;

  for(x=0;x<z;x++);

}

void W_CMD(uchar cmd)  //???

{

    EN=0;

    RS=0;

    RW=0;

    DATE=cmd;

    Delayms(5);

    EN=1;

    Delayms(5);

    EN=0;

}

void W_DAT(uchar dat)  //???

{

    EN=0;

    RS=1;

    RW=0;

    DATE=dat;

    Delayms(5);

    EN=1;

    Delayms(5);

    EN=0;

}

uchar R_DAT(uchar dat)  //???????

{

    EN=0;

    RS=1;

    RW=1;

    DATE=dat;

    Delayms(5);

    EN=1;

    Delayms(5);

    EN=0;

    return dat;

}

uchar R_CMD(uchar cmd)    //???????

{

    EN=0;

    RS=0;

    RW=1;

    DATE=cmd;

    Delayms(5);

    EN=1;

    Delayms(5);

    EN=0;

    return cmd;

}

void Init()            //????????

{

    PSB = 1;

    W_CMD(0x30);

    Delayms(5);

    W_CMD(0x0c);

    Delayms(5);

    W_CMD(0x01);

    Delayms(5);

}

void Picture_Init()

{

    W_CMD(0x34);

    W_CMD(0x36);

    W_CMD(0x3E);

    W_CMD(0x01);

}

void C_ADDR(uchar x,uchar y)       //?????????;

{

    uchar addr;

    switch(x)

    {

        case 0: x=0x80;break;

        case 1: x=0x90;break;

        case 2: x=0x88;break;

        case 3: x=0x98;break;

    }

    addr=x+y;

    W_CMD(addr);

}

void Picture_Addr(uint x,uint y)   //????????

{

    W_CMD(y);

    W_CMD(x);

}

void Display(uchar *Pic)

{

    uchar i,j;

    for(i=0;i<32;i++)

    {

        W_CMD(0x80+i);

        W_CMD(0x80);

        for(j=0;j<16;j++)

        {

            W_DAT(*Pic);

            Pic++;

        }

    }

    for(i=0;i<32;i++)

    {

        W_CMD(0x80+i);

        W_CMD(0x88);

        for(j=0;j<16;j++)

        {

            W_DAT(*Pic);

            Pic++;

        }

    }

}

void main()

{

    W_CMD(0x34);

    Display(Picture);

    W_CMD(0x36);    //??????

  W_CMD(0x30);    //??????

    while(1);

}

51