基于stm32单片机俄罗斯方块小游戏Proteus仿真

资料编号:150   下面是相关功能视频演示:

150-基于stm32单片机俄罗斯方块小游戏Proteus仿真(源码+仿真+全套资料)

功能介绍:

通过stm32单片机作为主控,在LCD点阵屏上做出俄罗斯方块的小游戏,通过独立按键来对游戏进行相关设置,全套资料齐全:

下面是该程序的部分展示:

void LCD_Write_Data(uint8_t Data)  //写8位数据
{
    SPI_LCD_CS_LOW; //片选
    SPI_LCD_DATA_W;//写数据
    HAL_SPI_Transmit(&hspi1,(uint8_t *)&Data,1,1);
    SPI_LCD_CS_HIGH; 
}

void LCD_Write_Data_16(uint16_t data) //写16位数据
{
    SPI_LCD_CS_LOW;
    SPI_LCD_DATA_W;//写数据
    uint8_t colorHighBit = data >> 8;
    uint8_t colorLowBit = (uint8_t)data;
    HAL_SPI_Transmit(&hspi1,(uint8_t *)&colorHighBit,1,16);
    HAL_SPI_Transmit(&hspi1,(uint8_t *)&colorLowBit,1,16);
    SPI_LCD_CS_HIGH;
}     

void LCD_Set_Window(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2)  //设定位置
{  
   LCD_Write_Command(0x2a);
   LCD_Write_Data(x1>>8);
   LCD_Write_Data(x1);
   LCD_Write_Data(x2>>8);
   LCD_Write_Data(x2);
    
   LCD_Write_Command(0x2b);
   LCD_Write_Data(y1>>8);
   LCD_Write_Data(y1);
   LCD_Write_Data(y2>>8);
   LCD_Write_Data(y2);
    
   LCD_Write_Command(0x2C);
}


void LCD_DrawWindowAsColor(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color)
{
    LCD_Set_Window(x1,y1,x2,y2);
    SPI_LCD_CS_LOW;
    SPI_LCD_DATA_W;//写数据
    uint8_t colorHighBit = color >> 8;
    uint8_t colorLowBit = (uint8_t)color;
    for(int i = 0; i < (x2 - x1 + 1)*(y2 - y1 + 1) ; i++)
    {    
        HAL_SPI_Transmit(&hspi1,(uint8_t *)&colorHighBit,1,16);
        HAL_SPI_Transmit(&hspi1,(uint8_t *)&colorLowBit,1,16);
    }
    SPI_LCD_CS_HIGH;
}

 下面是该资料的分享下载链接:

https://pan.baidu.com/s/1xCu7uTVo9kZ16cvwypZfdQ?pwd=u650

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值