资料编号:151 下面是相关功能视频演示:
151-基于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;
}
下面是该资料的分享下载链接: