当前位置:网站首页>Play OLED, u8g2 animation, increasing numbers, random triangles, etc
Play OLED, u8g2 animation, increasing numbers, random triangles, etc
2022-06-27 00:53:00 【arenascat】
1. Dynamic digital display
Logically speaking , Is to draw a solid square , Occlude the last drawn content , Then draw this time .
// Animated digital effects
void dynamicNum(int x, int y, int num)
{
int i;
for (i = 0; i < num; i++)
{
u8g2.setDrawColor(0);
u8g2.drawBox(x, 10, 60, 60);
u8g2.setCursor(x, y);
u8g2.setDrawColor(1);
u8g2.print(i);
u8g2.drawBox(0, 63 - 3, (127 / 100) * i, 3);
u8g2.sendBuffer();
delay(2);
}
}2. The drawing of triangle
This algorithm is to draw an equilateral triangle , It was like this , But I added pseudo-random numbers , So it becomes a flying triangle
random(int i) function , Used to generate from 0 To i A number of
void animateG(int x, int y, int r)
{
int rd1 = random(2);
int rd2 = random(3);
int rd3 = random(3);
int rd4 = random(3);
int rd5 = random(3);
int rd6 = random(2);
u8g2.drawLine(x * rd1, (y - r * 2 / 3) * rd2, (x + r / sqrt(3)) * rd3, (y + r / 3) * rd4);
u8g2.drawLine((x + r / sqrt(3)) * rd3, (y + r / 3) * rd4, (x - r / sqrt(3)) * rd5, (y + r / 3) * rd6);
u8g2.drawLine((x - r / sqrt(3)) * rd5, (y + r / 3) * rd6, x * rd1, (y - r * 2 / 3) * rd2);
}3. Screen closing effect
Similar to the effect of cross closing after power failure of the picture tube of the old TV , I want to imitate this .
void close()
{
u8g2.clear();
u8g2.drawBox(0, 63 / 2 - 3, 127, 6);
u8g2.drawBox(127 / 2 - 3, 0, 6, 63);
u8g2.sendBuffer();
delay(3);
u8g2.clear();
u8g2.drawBox(0, 63 / 2 - 2, 127, 4);
u8g2.drawBox(127 / 2 - 2, 0, 4, 63);
u8g2.sendBuffer();
delay(3);
u8g2.clear();
u8g2.drawBox(0, 63 / 2 - 1, 127, 2);
u8g2.drawBox(127 / 2 - 1, 0, 2, 63);
u8g2.sendBuffer();
delay(3);
u8g2.clear();
}边栏推荐
猜你喜欢

05 | standard design (Part 2): how to standardize the different styles of commit information, which are difficult to read?

MATLAB data type - character type

高清滑环生产过程当中的质量如何把控

直播回顾 | 子芽&CCF TF:云原生场景下软件供应链风险治理技术浅谈

Solve the problem that only one line of text is displayed or not displayed in u8glib

Law of Large Numbers

In depth understanding of UDP in the transport layer and the use of UDP in sockets

Skills needing attention in selection and purchase of slip ring

Simple and fast digital network (network dolls in the network)

Deep learning method for solving mean field game theory problems
随机推荐
Solution of idea hot start failure
Review the old and know the new -- constant renewal at normal temperature
kubernetes可视化界面dashboard
Moher College -x-forwarded-for injection vulnerability practice
Sword finger offer 10- ii Frog jumping on steps
Technical dry goods | what is a big model? Oversized model? Foundation Model?
一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
[vscode] setting sync, a plug-in for synchronizing extensions and settings
Lwip之定时机制
Oracle database basics concepts
Hit the point! The largest model training collection!
Overview of Freescale MCU
Kubeadm create kubernetes cluster
如何通俗易懂的描述机器学习的流程?
JSON解析,ESP32轻松获取时间气温和天气
小白看MySQL--windows环境安装MySQL
网络中的网络(套娃)
Simple and fast digital network (network dolls in the network)
ArcGIS 镶嵌数据集切片丢失问题处理
Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022