📄 lcd5110.c
字号:
#include "stm32f10x_lib.h"
void Display_init(void);
void load(void);
void win(void);
void renew(void);
unsigned char scakey(void);
unsigned char speed=6;
unsigned int score=0;
unsigned int step=0;
unsigned char guan=1;
unsigned char fangkuai[8];//方块值
unsigned char new[3][58];
unsigned char background[3][58];//背景矩阵
unsigned char front[3][8];//涂层矩阵
unsigned char front_x=66;//涂层前端x坐标
unsigned char fknow;//当前方块编号
unsigned char suijishu=0;
unsigned char fknext;//the next one
unsigned char fronttemp[3][8];
unsigned char moved=10;//上下移动记录
unsigned char bianhuan=1;
unsigned char down; //one key is down
unsigned char other; //not only one key down
unsigned char beep2=1;
unsigned char font6x8[][6] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },// sp
{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },// !
{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },// "
{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },// #
{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },// $
{ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },// %
{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },// &
{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },// '
{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },// (
{ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },// )
{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },// *
{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },// +
{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },// ,
{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },// -
{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },// .
{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },// /
{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },// 0
{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },// 1
{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },// 2
{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },// 3
{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },// 4
{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },// 5
{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },// 6
{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },// 7
{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },// 8
{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },// 9
{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },// :
{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },// ;
{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },// <
{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },// =
{ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },// >
{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },// ?
{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },// @
{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },// A
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },// B
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },// C
{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },// D
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },// E
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },// F
{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },// G
{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },// H
{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },// I
{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },// J
{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },// K
{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },// L
{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },// M
{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },// N
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },// O
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },// P
{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },// Q
{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },// R
{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },// S
{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },// T
{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },// U
{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },// V
{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },// W
{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },// X
{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },// Y
{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },// Z
{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },// [
{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },// 55
{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },// ]
{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },// ^
{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },// _
{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },// '
{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },// a
{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },// b
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },// c
{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },// d
{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },// e
{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },// f
{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },// g
{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },// h
{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },// i
{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },// j
{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },// k
{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },// l
{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },// m
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },// n
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },// o
{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },// p
{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },// q
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },// r
{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },// s
{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },// t
{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },// u
{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },// v
{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },// w
{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },// x
{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },// y
{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },// z
{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }// horiz lines
};
unsigned char han[]=
{
/*-- 文字: 俄 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xF8,0x17,0x12,0x14,0xFC,0x12,0x92,0x10,0xFF,0x10,0x12,0xDC,0x90,0x00,
0x00,0x00,0x7F,0x00,0x24,0x62,0x3F,0x01,0x20,0x10,0x0B,0x0C,0x33,0x41,0x30,0x00,
/*-- 文字: 罗 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x7E,0x22,0x22,0x22,0xFE,0xA2,0xA2,0xBE,0xA2,0xA2,0xA2,0xBE,0x00,0x00,
0x80,0x88,0x88,0x84,0x42,0x43,0x25,0x28,0x10,0x10,0x08,0x04,0x03,0x00,0x00,0x00,
/*-- 文字: 斯 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x04,0xFF,0x94,0x94,0x94,0xFF,0x04,0x00,0xFE,0x22,0x22,0xE1,0x21,0x20,0x00,
0x44,0x24,0x37,0x04,0x04,0x14,0x67,0x44,0x30,0x0F,0x00,0x00,0xFF,0x00,0x00,0x00,
/*-- 文字: 方 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x08,0x08,0x08,0x08,0x08,0xF9,0x4A,0x4C,0x48,0x48,0xC8,0x08,0x08,0x08,0x00,
0x40,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x20,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: 块 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0xFF,0x10,0x10,0x00,0x08,0x08,0xFF,0x08,0x08,0x08,0xF8,0x00,0x00,0x00,
0x08,0x18,0x0F,0x04,0x85,0x41,0x31,0x0D,0x03,0x05,0x09,0x11,0x31,0x61,0x21,0x00,
/*-- 文字: 第 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x08,0x04,0xD3,0x56,0x5A,0x52,0x5A,0xF4,0x53,0x56,0x5A,0x72,0x02,0x02,0x00,
0x00,0x20,0x20,0x23,0x12,0x12,0x0A,0x06,0xFF,0x02,0x02,0x12,0x22,0x1E,0x00,0x00,
/*-- 文字: 关 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x10,0x10,0x10,0x11,0x1E,0x14,0xF0,0x10,0x18,0x17,0x12,0x18,0x10,0x00,0x00,
0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x09,0x31,0x61,0xC1,0x41,0x01,0x00,
};
unsigned char shuzi[]={
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 6 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
/*-- 文字: 9 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,
};
/****************************************
fang kuai 8x8
*****************************************/
unsigned char fk[28][8]=
{
/*-- 宽度x高度=8x8 --*/
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xFC,0xFC,0xC0,0xC0,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x30,0x30,0x30,0x30,0x3C,0x3C,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0xFC,0xFC,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x3C,0x3C,0x0C,0x0C,0x0C,0x0C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xC0,0xC0,0xFC,0xFC,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0x0C,0x0C,0x3C,0x3C,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3F,0x3F,0x03,0x03,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x3C,0x3C,0x30,0x30,0x30,0x30,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0xF0,0xF0,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x30,0x30,0x3C,0x3C,0x0C,0x0C,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0xF0,0xF0,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x30,0x30,0x3C,0x3C,0x0C,0x0C,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xF0,0xF0,0x3C,0x3C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0x3C,0x3C,0x30,0x30,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0xF0,0xF0,0x3C,0x3C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0x3C,0x3C,0x30,0x30,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x30,0x30,0x3C,0x3C,0x30,0x30,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3F,0x3F,0x0C,0x0C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0x3C,0x3C,0x0C,0x0C,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x0C,0x0C,0x3F,0x3F,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00,
/*-- 宽度x高度=8x8 --*/
0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00,
};
void sclk(u8 value)
{
GPIO_WriteBit(GPIOA,GPIO_Pin_9,(BitAction)value);
}
void sdin(u8 value)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_9,(BitAction)value);
}
void dc(u8 value)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_7,(BitAction)value);
}
void sce(u8 value)
{
GPIO_WriteBit(GPIOD,GPIO_Pin_15,(BitAction)value);
}
void res(u8 value)
{
GPIO_WriteBit(GPIOD,GPIO_Pin_13,(BitAction)value);
}
void LCD_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_11 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_9 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_15 | GPIO_Pin_13 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_WriteBit(GPIOA,GPIO_Pin_11,(BitAction)1);
GPIO_WriteBit(GPIOD,GPIO_Pin_11,(BitAction)0);
sclk(1);
Display_init();
}
void delay(unsigned char t)//1ms延时函数
{
unsigned int i,j;
for(j=0;j<t;j++)
for(i=0;i<60000;i++);
;
}
void delay_1ms(void)
{
unsigned int i;
for(i=0;i<300;i++);
}
/*--------------------------------------------
LCD_write_byte: 使用SPI接口写数据到LCD
输入参数:dt:写入的数据;
command :写数据/命令选择;
编写日期:20080918
----------------------------------------------*/
void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce(0);
dc(command);
for(i=0;i<8;i++)
{
if(dt&0x80)
sdin(1);
else
sdin(0);
dt=dt<<1;
sclk(0);
sclk(1);
}
dc(1);
sce(1);
sdin(1);
}
/*---------------------------------------
LCD_init: 3310LCD初始化
编写日期:20080918
----------------------------------------- */
void LCD_clear(void);
void Display_init(void)
{
res(0);
delay_1ms();
res(1);
LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令
delay_1ms();
LCD_write_byte(0xC0,0);//设定液晶偏置电压
delay_1ms();
LCD_write_byte(0x06,0);
delay_1ms();
LCD_write_byte(0x13,0);
delay_1ms();
LCD_write_byte(0x20,0);//使用基本指令
delay_1ms();
LCD_write_byte(0x0C,0);//设定显示模式,正常显示
delay_1ms();
LCD_clear();
}
/*-------------------------------------------
LCD_set_XY: 设置LCD坐标函数
输入参数:X:0-83 Y:0-5
编写日期:20080918
---------------------------------------------*/
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
/*------------------------------------------
LCD_clear: LCD清屏函数
编写日期:20080918
--------------------------------------------*/
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
/*---------------------------------------------
LCD_write_shu: 显示8(宽)*16(高)点阵列数字字母符号等半角类
输入参数:c:显示的字符;
编写日期:20080918
-----------------------------------------------*/
#if 0
void LCD_write_shu(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i;
LCD_set_XY(row*8, page);// 列,页
for(i=0; i<8;i++)
{
LCD_write_byte(shuzi[c*16+i],1);
}
LCD_set_XY(row*8, page+1);// 列,页
for(i=8; i<16;i++)
{
LCD_write_byte(shuzi[c*16+i],1);
}
}
#endif
/*********************************************
display shuzi_8x16
**********************************************/
void writeshuzi(unsigned char a,unsigned char b,unsigned char add)
{
unsigned char c;
LCD_set_XY(a*8, b);
for(c=0;c<8;c++)
{
LCD_write_byte(shuzi[add*16+c],1);
}
LCD_set_XY(a*8, b+1);
for(c=8;c<16;c++)
{
LCD_write_byte(shuzi[add*16+c],1);
}
}
/********************************************
汉字显示函数
**********************************************/
void write(unsigned char a,unsigned char b,unsigned char add)//a=01234,b=012345,add=0123456
{
unsigned char c;
LCD_set_XY(a*16, b);
for(c=0;c<16;c++)
{
LCD_write_byte(han[add*32+c],1);
}
LCD_set_XY(a*16, b+1);
for(c=16;c<32;c++)
{
LCD_write_byte(han[add*32+c],1);
}
}
/*********************************************
display a font6*8
*********************************************/
void write_char(unsigned char c)
{
unsigned char temp;
c-=32;
for(temp=0;temp<6;temp++)
LCD_write_byte(font6x8[c][temp],1);
}
/*********************************************
英文字符串显示函数
**********************************************/
void write_string(unsigned char x,unsigned char y,unsigned char *p)
{
LCD_set_XY(x,y);
while(*p)
{
write_char(*p);
p++;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------
/********************************************** 俄罗斯方块主要算法
划分屏幕区域
**********************************************/
void ping(void)
{
write(0,0,5);//第
write(0,4,6);//关
write_string(18,0,"step:");
write_string(19,4,"SCORE:");
write_string(17,5,"pause k1+k2");
LCD_set_XY(74,1);
LCD_write_byte(0xff,1);
LCD_set_XY(74,2);
LCD_write_byte(0xff,1);
LCD_set_XY(74,3);
LCD_write_byte(0xff,1);
}
/////////////////////////////////////////////////
//step++ and display
/////////////////////////////////////////////////
void disstep()
{
unsigned char i,k;
unsigned char shu[5];
step+=1;
shu[0]=step/10000;
shu[1]=(step%10000)/1000;
shu[2]=(step%1000)/100;
shu[3]=(step%100)/10;
shu[4]=step%10;
LCD_set_XY(48,0);
for(i=0;i<5;i++)
{
for(k=0;k<6;k++)
LCD_write_byte(font6x8[shu[i]+16][k],1);;
}
}
/////////////////////////////////////////////////
//display score
/////////////////////////////////////////////////
void disscore()
{
unsigned char i,k;
unsigned char shu[4];
shu[0]=(score%10000)/1000;
shu[1]=(score%1000)/100;
shu[2]=(score%100)/10;
shu[3]=score%10;
LCD_set_XY(55,4);
for(i=0;i<4;i++)
{
for(k=0;k<6;k++)
LCD_write_byte(font6x8[shu[i]+16][k],1);
}
}
/////////////////////////////////////////////////
//display guan
/////////////////////////////////////////////////
void disguan()
{
writeshuzi(0,2,guan/10);
writeshuzi(1,2,guan%10);
}
/////////////////////////////////////////////////
//display GAME OVER
/////////////////////////////////////////////////
void disover()
{
LCD_clear();
write_string(15,2,"GAME OVER");
write_string(0,4,"press k3 to...start new game");
while(scakey()!=3)
{}
}
/////////////////////////////////////////////////
//暂停
/////////////////////////////////////////////////
#if 1
void pause(void)
{
unsigned char i;
// TR0=0;
LCD_clear();
write_string(12,0,"PAUSE...");
write_string(0,2,"K1 LED switch");
write_string(0,3,"k2 BEEP switch");
write_string(0,4,"k3 continue");
while(1)
{
unsigned char keyval;
keyval=scakey();
if(keyval==0)
{
down=0;
other=0;
}
else if(keyval==1&&down==0)
{
down=1;
// beep();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -