当前位置:网站首页>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();
}边栏推荐
- matlab数据类型 —— 字符型
- 深度学习方法求解平均场博弈论问题
- 如何把老式键盘转换成USB键盘并且自己编程?
- USB协议中HID设备描述符以及键盘按键值对应编码表
- 3 - wire SPI Screen Drive
- Law of Large Numbers
- Redis detailed tutorial
- Using physical information neural network to solve hydrodynamics equations
- C#程序结构预览最基础入门
- 论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
猜你喜欢

Live review | Ziya &ccf TF: Discussion on software supply chain risk management technology under cloud native scenario

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

Central Limit Theorem

气液滑环与其他滑环的工作原理有什么区别

如何通俗易懂的描述机器学习的流程?

Gaussian and Summary Stats

滑环选型选购时需要注意的技巧

How to easily describe the process of machine learning?

redis详细教程

Com. Faster XML. Jackson. DataBind. Exc.mismatchedinputexception: tableau ou chaîne attendu. At [Source: X
随机推荐
Law of Large Numbers
JSON解析,ESP32轻松获取时间气温和天气
What is the difference between the working principle of gas-liquid slip ring and other slip rings
Law of Large Numbers
3-wire SPI screen driving mode
Lambda expression
05 | standard design (Part 2): how to standardize the different styles of commit information, which are difficult to read?
3 - wire SPI Screen Drive
Using physical information neural network to solve hydrodynamics equations
数据库面试题+sql语句解析
Target tracking shooting? Target occlusion shooting? With 1.9 billion installed petal apps, what unique features attract users?
Central Limit Theorem
3線spi屏幕驅動方式
世界很大,有人把二维码纹在脖子上
Technical dry goods | what is a big model? Oversized model? Foundation Model?
07 | workflow design: how to design a reasonable multi person development mode?
Implementation of ARP module in LwIP
Lorsque le transformateur rencontre l'équation différentielle partielle
What are the skills and methods for slip ring installation
网上开通证券账户安全吗 手机炒股靠谱吗