打印
[STM32F7]

手摇棒源代码

[复制链接]
524|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小傻蛋|  楼主 | 2019-4-28 15:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define KEY=P3^0;
uchar KY;
uchar disp;
uchar pic=0,num=0;
uchar code love[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,
0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00,
0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,
0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20,
0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*LOVE*/
};
uchar code loveyou[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,
0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,
0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*????*/
};
uchar code hehe[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
0xF0,0x0F,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10,
0xF0,0x0F,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*??o(n_n)o??*/
};
unsigned char code hanzi[] = {
//-- ? --
0x04,0x10,0x34,0x08,0xC4,0x06,0x04,0x01,
0xC4,0x82,0x3C,0x8C,0x20,0x40,0x10,0x30,
0x0F,0x0C,0xE8,0x03,0x08,0x0C,0x08,0x10,
0x28,0x60,0x18,0xC0,0x00,0x40,0x00,0x00,
//-- ? --
0x40,0x00,0x42,0x40,0x44,0x20,0xC8,0x1F,
0x00,0x20,0xFC,0x47,0x04,0x42,0x02,0x41,
0x82,0x40,0xFC,0x7F,0x04,0x40,0x04,0x42,
0x04,0x44,0xFE,0x63,0x04,0x20,0x00,0x00,
//-- ? --
0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x00,
0x04,0x80,0xF4,0x43,0x14,0x45,0x14,0x29,
0x14,0x19,0xFF,0x17,0x14,0x21,0x14,0x21,
0x14,0x41,0xF6,0xC3,0x04,0x40,0x00,0x00,
//-- ? --
0x00,0x80,0x00,0x60,0xFE,0x1F,0x22,0x02,
0x22,0x02,0x22,0x02,0x22,0x02,0xFE,0x7F,
0x22,0x02,0x22,0x02,0x22,0x42,0x22,0x82,
0xFF,0x7F,0x02,0x00,0x00,0x00,0x00,0x00,
//-- ? --
0x08,0x01,0x88,0x00,0x49,0x00,0xEE,0xFF,
0x58,0x00,0x88,0x00,0x00,0x00,0xF8,0x1F,
0x88,0x08,0x88,0x08,0xFF,0xFF,0x88,0x08,
0x88,0x08,0xFC,0x1F,0x08,0x00,0x00,0x00,
//-- ? --
0x40,0x00,0x40,0x00,0x44,0x00,0x44,0x3E,
0x64,0x12,0x54,0x12,0x4C,0x12,0x47,0x12,
0x4C,0x3F,0x54,0x42,0x74,0x80,0xC6,0x7F,
0x44,0x00,0x60,0x00,0x40,0x00,0x00,0x00,
//-- ? --
0x00,0x40,0x00,0x30,0xFE,0x8F,0x4A,0x80,
0xAA,0x5F,0x9A,0x4A,0xFE,0x2A,0xAA,0x1A,
0xCB,0x0F,0xAA,0x7A,0xFE,0x8A,0x9A,0xAA,
0xAA,0x8F,0x6B,0x80,0x22,0xE0,0x00,0x00,
//-- ? --
0x80,0x20,0xC0,0x30,0xA0,0x28,0x98,0x24,
0x87,0x22,0x80,0x21,0xC4,0x30,0x04,0x60,
0x04,0x00,0x04,0x20,0x04,0x40,0x04,0x80,
0x04,0x40,0xFE,0x3F,0x04,0x00,0x00,0x00,
//-- ? --
0x10,0x02,0x10,0x42,0x10,0x81,0xFF,0x7F,
0x90,0x04,0x54,0x05,0xCC,0xF4,0xB4,0x44,
0x84,0x44,0xBC,0x7F,0x82,0x44,0xA2,0x44,
0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,
//-- ? --
0x10,0x02,0x10,0x42,0x10,0x81,0xFF,0x7F,
0x90,0x04,0x54,0x05,0xCC,0xF4,0xB4,0x44,
0x84,0x44,0xBC,0x7F,0x82,0x44,0xA2,0x44,
0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,
//-- ? --
0x10,0x04,0x10,0x03,0xD0,0x00,0xFF,0xFF,
0x90,0x00,0x54,0x05,0x44,0x12,0xD4,0x15,
0x14,0x5F,0xFF,0xD4,0x14,0x54,0x15,
0x56,0x12,0x44,0x06,0x40,0x02,0x00,0x00,
//-- ! --
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,
0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/*****????*****/
void display1();
void display2();
void display3();
void display4(    );
/*****n(us)?????*****/
void DelayUs(uint N)
{
int x;
for(x=0; x<=N;x++);
}
/*****??????*****/
void intersvr0(void) interrupt 0 using 1
{
KY=~KY;
if(KY==0)
{
num++;
switch(pic)
{
case 0:{display1();}break;
case 1:{display2();}break;
case 2:{display3();}break;
case 3:{display4();}break;
default:{display1();}
}
}
}
/*****?????1(??)*****/
void display1()
{
char i;
if(num>10){disp++;num=0;}
if(disp>2)disp=0;
DelayUs(5200);
for(i=0;i<64;i++)
{
P0=~hanzi[disp*128+i*2];
P2=~hanzi[disp*128+i*2+1];
DelayUs(80);
}
}
/*****?????2(LOVE)*****/
void display2()
{
uchar i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~love[i*2];
P2=~love[i*2+1];
DelayUs(100);
}
}
/*****?????3(????)*****/
void display3()
{
char i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~loveyou[i*2];
P2=~loveyou[i*2+1];
DelayUs(100);
}
}
/*****?????4(??o(n_n)o??)*****/
void display4()
{
uchar i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~hehe[i*2];
P2=~hehe[i*2+1];
DelayUs(100);
}
}
/*****???*****/
void main(void)
{
IT0=1;
EX0=1;
EA=1;
KY=0;
while(1)
{
  display1();
}
}

使用特权

评论回复
沙发
mmuuss586| | 2019-5-7 21:20 | 只看该作者
不错,感谢分享

使用特权

评论回复
板凳
dongnanxibei| | 2019-5-7 22:16 | 只看该作者
呵呵哒。

使用特权

评论回复
地板
dongnanxibei| | 2019-5-7 22:16 | 只看该作者
这个摇动的频率是固定的还是可以自动计算的

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

4

帖子

0

粉丝