当前位置:网站首页>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();
}边栏推荐
- Lwip之定时机制
- Implementation of ARP module in LwIP
- matlab数据类型 —— 字符型
- find_ Detailed use guide of CIRC
- Is it safe for CITIC Securities Commission to open an online account and speculate in stocks
- Freescale 单片机概述
- Reading graph augmentations to learn graph representations (lg2ar)
- 【UVM实战 ===> Episode_3 】~ Assertion、Sequence、Property
- 解决STC8G1K08程序不能运行的问题和端口配置
- Deep learning method for solving mean field game theory problems
猜你喜欢
![[vscode] setting sync, a plug-in for synchronizing extensions and settings](/img/e0/4889b59105e9815d11ae31988f58f2.jpg)
[vscode] setting sync, a plug-in for synchronizing extensions and settings

超越锂电池——未来电池的概念

Flink practical problems (VII): no watermark (watermarks are only available eventtime is used)

根据文件名批量生成文件夹

【UVM实战 ===> Episode_3 】~ Assertion、Sequence、Property

Moher College - SQL injection vulnerability test (error reporting and blind note)

07 | 工作流设计:如何设计合理的多人开发模式?

Kubeadm create kubernetes cluster

Concepts de base de données Oracle

Competition Registration | one of the key ai+ scientific computing competitions - China open source scientific software creativity competition, competing for 100000 bonus!
随机推荐
Gaussian and Summary Stats
kubernetes可视化界面dashboard
“message“:“Bad capabilities. Specify either app or appTopLevelWindow to create a session“
Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022
At present, which securities company is the best and safest to open an account for stock speculation?
解决unable to create a folder to save the sketch: mkdir sketch
Encapsulation of unified result set
直播回顾 | 子芽&CCF TF:云原生场景下软件供应链风险治理技术浅谈
[UVM actual battle== > episode_3] ~ assertion, sequence, property
Flink 实战问题(七):No Watermark(Watermarks are only available EventTime is used)
这10款文案神器帮你速码,做自媒体还担心写不出文案吗?
Hit the point! The largest model training collection!
From bitmap to bloom filter, C # implementation
Deep learning method for solving mean field game theory problems
大健康行业年度必参盛会,2022山东国际大健康产业博览会
Central Limit Theorem
USB协议中HID设备描述符以及键盘按键值对应编码表
ESP32-SOLO开发教程,解决CONFIG_FREERTOS_UNICORE问题
Ten thousand words explanation - mindarmour Xiaobai tutorial!
com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x