当前位置:网站首页>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();
}边栏推荐
- com.fasterxml.jackson.databind.exc.MismatchedInputException: Expected array or string. at [Source:x
- These 10 copywriting artifacts help you speed up the code. Are you still worried that you can't write a copywriting for US media?
- Kubernetes visual interface dashboard
- Review the old and know the new -- constant renewal at normal temperature
- 光谱共焦如何测量玻璃基板厚度
- Oracle database basics concepts
- Other service registration and discovery
- Flink practical problems (VII): no watermark (watermarks are only available eventtime is used)
- Oracle 數據庫基本知識概念
- Reading graph augmentations to learn graph representations (lg2ar)
猜你喜欢

世界很大,有人把二维码纹在脖子上

About Random Numbers

When transformer encounters partial differential equation solution

ArcGIS 镶嵌数据集切片丢失问题处理

BootstrapBlazor + FreeSql实战 Chart 图表使用(2)

buuctf-pwn write-ups (6)

MATLAB data type - character type

墨者学院-SQL注入漏洞测试(报错盲注)

ESP32-SOLO开发教程,解决CONFIG_FREERTOS_UNICORE问题

Target tracking shooting? Target occlusion shooting? With 1.9 billion installed petal apps, what unique features attract users?
随机推荐
kubernetes可视化界面dashboard
ESP32-SOLO开发教程,解决CONFIG_FREERTOS_UNICORE问题
Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022
Flink 实战问题(七):No Watermark(Watermarks are only available EventTime is used)
These 10 copywriting artifacts help you speed up the code. Are you still worried that you can't write a copywriting for US media?
“message“:“Bad capabilities. Specify either app or appTopLevelWindow to create a session“
【Vscode】预览md文件
Central Limit Theorem
Amway! How to provide high-quality issue? That's what Xueba wrote!
3-wire SPI screen driving mode
自定义JSP[if,foreach,数据,select]标签
Pet hospital management system based on SSMP
墨者学院-X-Forwarded-For注入漏洞实战
From bitmap to bloom filter, C # implementation
Statistical Hypothesis Testing
When transformer encounters partial differential equation solution
这3个并发编程的核心,竟然还有人不知道?
如何把老式键盘转换成USB键盘并且自己编程?
滑环选型选购时需要注意的技巧
其他服务注册与发现