Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用哪个函数显示啊,没有汉字显示啊 #10

Open
2021zhangyixu opened this issue Aug 22, 2023 · 1 comment
Open

调用哪个函数显示啊,没有汉字显示啊 #10

2021zhangyixu opened this issue Aug 22, 2023 · 1 comment

Comments

@2021zhangyixu
Copy link

No description provided.

@longware
Copy link

U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=/ 13,
/
data=/ 11, / cs=/ 10, / dc=/ 9, / reset=*/ 8);

void setup(void) {
u8g2.begin();
u8g2.enableUTF8Print();
}

void loop(void) {
// 清除内部缓冲区
u8g2.clearBuffer();

// 设置字体类型为我们刚才自定义的字库类型
u8g2.setFont(u8g2_font_hapiwan);

//汉字字体的大小为 1616像素 屏幕像素宽128,设置x=40,可以起到居中效果,计算公式:(128-163) / 2
u8g2.setCursor(/x/40, /y/15);
//直接用print方法将String类型输出到屏幕
u8g2.print("哈皮玩");

//利用U8g2自带的字体类型画天气符号
u8g2.setFont(u8g2_font_open_iconic_weather_2x_t);
u8g2.drawGlyph(3, 16, 67);//代表雨

//画一条横线
u8g2.drawLine(/x-start/0, /y-start/17, /x-end/128, /y-end/17);

//将字体设置回来
u8g2.setFont(u8g2_font_hapiwan);
//测试这种字体下屏幕可以显示的ASCII字符有几个,测试结果ASCII字符大小约为8*12
u8g2.drawStr(/x/0,/y/30,/字符串/"ABCDEF0123456789");

u8g2.setCursor(0, 46);
u8g2.print("温度:28.9");

//利用U8g2自带的字体类型绘制温度符号
u8g2.setFont(u8g2_font_logisoso16_tf);
u8g2.setCursor(80, 48);
u8g2.print("°C");

//将字体设置回来
u8g2.setFont(u8g2_font_hapiwan);
u8g2.setCursor(0, 62);
u8g2.print("湿甲醛有机挥发物");

//画边框线示例。先执行此代码,后面在画字体时,可能会将“线条”冲掉
u8g2.drawFrame(/x/0,/y/0,/width/128,/height/64);

// transfer internal memory to the display
u8g2.sendBuffer();

delay(200);
}
————————————————
版权声明:本文为CSDN博主「哈皮玩」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yulusilian1/article/details/117388091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants