使用stm32F103r6实现数独游戏+PROTUES8.11(标准库)

使用spi接口完成按钮的控制,使用显示屏ili9341完成数独表盘的显示和相关数字的绑定和填空,利用中断等函数的意义来实现数独棋盘,以下是实现部分以下是相关代码

void run(void)
{
	int i = 0;
	int j = 0;
	int k = 0;
	for(j = 0; j < 4; j++)
	{
		for(i = 0; i < 4; i++)
		{
			if(subject[levels][j][i] != -1)
			{
				if(refreshComplet == 0)
				{
					BACK_COLOR = WHITE;
					POINT_COLOR = RED;
					LCD_ShowChar(128 / 8 * (2 * i + 1) - 4, 128 / 8 * (2 * j + 1) - 8,RED,WHITE, subject[levels][j][i] + '0',16, 0);
				}
			}
			else
			{
				if(refreshComplet_2 == 0)
				{
					if(input[k])
					{
						BACK_COLOR = WHITE;
						POINT_COLOR = GREEN;	
						LCD_ShowChar(128 / 8 * (2 * i + 1) - 4, 128 / 8 * (2 * j + 1) - 8,RED,WHITE, input[k] + '0',16, 0);
					}
					else
					{
						BACK_COLOR = WHITE;
						POINT_COLOR = RED;	
						LCD_ShowChar(128 / 8 * (2 * i + 1) - 4, 128 / 8 * (2 * j + 1) - 8,RED,WHITE, ' ',16, 0);
					}
					k++;
				}
			}
		}
	}
	if(refreshComplet == 0)
	{
		LCD_ShowChar(20, 138,RED,WHITE, fraction + '0',16, 0);
	}
	refreshComplet = 1;
	refreshComplet_2 = 1;
}
void keyScann(void)
{
	if(PAin(0) == 0)
	{
		PAout(15) = 1;
		while(PAin(0) == 0);
		PAout(15) = 0;
		input[in_position] = 1;
		if(++in_position >= 3) in_position = 0;
		refreshComplet_2 = 0;
	}
	if(PAin(1) == 0)
	{
		PAout(15) = 1;
		while(PAin(1) == 0);
		PAout(15) = 0;
		input[in_position] = 2;
		if(++in_position >= 3) in_position = 0;
		refreshComplet_2 = 0;
	}
	if(PAin(2) == 0)
	{
		PAout(15) = 1;
		while(PAin(2) == 0);
		PAout(15) = 0;
		input[in_position] = 3;
		if(++in_position >= 3) in_position = 0;
		refreshComplet_2 = 0;
	}
	if(PAin(3) == 0)
	{
		PAout(15) = 1;
		while(PAin(3) == 0);
		PAout(15) = 0;
		input[in_position] = 4;
		if(++in_position >= 3) in_position = 0;
		refreshComplet_2 = 0;
	}
	if(PAin(4) == 0)
	{
		PAout(15) = 1;
		while(PAin(4) == 0);
		PAout(15) = 0;
		if(answer[levels][0] == input[0] && answer[levels][1] == input[1] && answer[levels][2] == input[2])
		{
			fraction++;
			if(++levels >= 5)
			{
				levels = 4;
			}
		}
		input[0] = input[1] = input[2] = 0;
		in_position = 0;
		refreshComplet = 0;
		refreshComplet_2 = 0;
	}
}

相关实现表盘自由设置

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值