[ ST NUCLEO-U575ZI-Q 测评] 时钟——U8g2
<p>昨天U8G2成功移植,今天写个日历。</p><p>一、工程配置:</p>
<p> </p>
<p>配置好后生成代码。</p>
<p>二、显示函数,在main.c里加入:</p>
<pre>
<code> HAL_RTC_GetTime(&hrtc, &RtcTime,RTC_FORMAT_BIN);//读出时间值
HAL_RTC_GetDate(&hrtc, &RtcDate,RTC_FORMAT_BIN);//一定要先读时间后读日期
sprintf(date_buff,"%d年%d月%d日",2000+RtcDate.Year,RtcDate.Month, RtcDate.Date);
sprintf(time_buff,"%d时%d分%d秒",RtcTime.Hours,RtcTime.Minutes, RtcTime.Seconds);
u8g2_FirstPage(&u8g2);
do
{
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2,u8g2_font_wqy14_t_gb2312);
u8g2_DrawUTF8(&u8g2,0,15,date_buff);
//u8g2_SetFont(&u8g2,u8g2_font_wqy14_t_gb2312);
u8g2_DrawUTF8(&u8g2,0,30,time_buff);
//u8g2_DrawStr(&u8g2,10,60,time_buff);
} while (u8g2_NextPage(&u8g2));
HAL_Delay(500);</code></pre>
<p>然后下载到开发板就可以显示时间日期了</p>
<p>d8a46c639316ed7d57e27ebd1c028652<br />
</p>
<p>测评汇总:免费申请|ST NUCLEO-U575ZI-Q https://bbs.eeworld.com.cn/thread-1228653-1-1.html</p>
页:
[1]