当前位置:网站首页>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();
}边栏推荐
- 新型冠状病毒变异Delta毒株的模拟(MindSPONGE应用)
- 基于SSMP的宠物医院管理系统
- Is it safe to open a securities account online? Is it reliable to speculate in stocks by mobile phone
- Lambda expression
- 【Vscode】预览md文件
- “message“:“Bad capabilities. Specify either app or appTopLevelWindow to create a session“
- 从位图到布隆过滤器,C#实现
- Other service registration and discovery
- 剑指 Offer 10- II. 青蛙跳台阶问题
- How to write test cases and a brief introduction to go unit test tool testify
猜你喜欢

Ten thousand words explanation - mindarmour Xiaobai tutorial!

简单快速的数网络(网络中的网络套娃)

What is the difference between the working principle of gas-liquid slip ring and other slip rings

Review the old and know the new -- constant renewal at normal temperature

MATLAB data type - character type

Special topic II on mathematical physics of the sprint strong foundation program

LeetCode 142. Circular linked list II

3 - wire SPI Screen Drive

Pet hospital management system based on SSMP

Oracle 数据库基本知识概念
随机推荐
2022健康博览会,山东养生保健展会,产后健康、睡眠健康展
Special topic II on mathematical physics of the sprint strong foundation program
指南针开户安全的吗?
find_ Detailed use guide of CIRC
C#程序结构预览最基础入门
Processing of slice loss in ArcGIS mosaic dataset
[UVM actual battle== > episode_3] ~ assertion, sequence, property
CPU exception handling
USB协议中HID设备描述符以及键盘按键值对应编码表
05 | 規範設計(下):commit 信息風格迥异、難以閱讀,如何規範?
com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x
From bitmap to bloom filter, C # implementation
接口测试框架实战(一) | Requests 与接口请求构造
3線spi屏幕驅動方式
深度学习方法求解平均场博弈论问题
Target tracking shooting? Target occlusion shooting? With 1.9 billion installed petal apps, what unique features attract users?
CPU的异常处理
“message“:“Bad capabilities. Specify either app or appTopLevelWindow to create a session“
These 10 copywriting artifacts help you speed up the code. Are you still worried that you can't write a copywriting for US media?
Interface test framework practice (I) | requests and interface request construction