[ ST NUCLEO-U575ZI-Q 测评] 移植U8g2
<div class='showpostmsg'><p>U8g2是嵌入式设备的单色图形库,一句话简单明了。主要应用于嵌入式设备,当然我们强大的 NUCLEO-U575ZI-Q肯定也是支持的喽,今天就移植U8g2库如下:</p><p># 下载安装U8g2库:</p>
<p> 等下载好后,书写主程序如下:</p>
<pre>
<code>#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <U8g2lib.h>
#define U8X8_HAVE_HW_I2C
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
/* U8g2 Project: SSD1306 Test Board */
u8g2.begin();
}
uint8_t m = 24;
void loop(void) {
char m_str;
strcpy(m_str, u8x8_u8toa(m, 2)); /* convert m to a string with two digits */
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_logisoso62_tn);
u8g2.drawStr(0,63,"9");
u8g2.drawStr(33,63,":");
u8g2.drawStr(50,63,m_str);
} while ( u8g2.nextPage() );
delay(1000);
m++;
if ( m == 60 )
m = 0;
}</code></pre>
<p>编译后上传,就成功实现了仿时钟界面: </p>
<p> </p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>这个不错,显示内容十分醒目!</p>
jinglixixi 发表于 2022-12-18 14:41
这个不错,显示内容十分醒目!
<p>多谢支持。</p>
<p>测评汇总:免费申请|ST NUCLEO-U575ZI-Q https://bbs.eeworld.com.cn/thread-1228653-1-1.html</p>
页:
[1]