使用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;
}
}
相关实现表盘自由设置