• 基于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

  • 相关阅读:
    基于BP神经网络对鸢尾花数据集分类
    Node.js下forever使用
    vue的常用指令
    java毕业设计-篮球资讯网站-源码+lw文档+mybatis+系统+mysql数据库+调试
    一篇文章让你搞懂,Python文件操作
    C语言-简单的程序设计
    Linux服务器常用命令
    uniapp的扩展组件uni-popup 弹出层自动打开
    怎么批量添加事件(事件委托)?
    2024法定节假日|除夕不放假?企业这样做员工更满意
  • 原文地址:https://blog.csdn.net/m0_74295839/article/details/127759594