2840 views|5 replies

171

Posts

0

Resources
The OP
 

Fun Oscilloscope + Running Polygons [Copy link]

This post was last edited by sylar^z on 2020-4-11 18:17

I made a running polygon using the stm32f407 core board. The polygons include triangles, squares, pentagons and hexagons, which are randomly generated by pressing buttons. The size, moving direction, moving speed, and rotation angular velocity of the polygon are all randomly generated.

//------------------------------------------------ -------------------------------------------------- --------------------------

I saw the suggestion from @ led2015 below . I sorted it out and shared my production ideas, hoping it will be of some use to you.

This fun oscilloscope is realized by using the dual-channel XY mode of the oscilloscope and the visual aftereffect to achieve image/graphic output. As for how to set the XY mode of the oscilloscope, the methods vary for different models of oscilloscopes, so you can search it yourself.

The running polygon is drawn by determining the vertices of the polygon and drawing the points into lines. How to determine the vertices? It's very simple. A regular polygon has a circumscribed circle, and the coordinates of each vertex can be easily determined through the circumscribed circle. As shown below:

Among the polygons I have implemented, the five-pointed star is the most complex, so I will use the five-pointed star as an example here. Through the diameter R of the circumscribed circle, the angle between each vertex and the center of the circle and the horizontal line, the sine and cosine functions are used to calculate the [X, Y] coordinates of the vertex relative to the center of the circle. Vertex 1:

X = R * COS ( A );

Y = R * SIN ( A );

Vertex 2:

X = R * COS ( A + 72 );

Y = R * SIN ( A + 72 );

Among them, A = 18 degrees. The same applies to other vertices.

When drawing a line, start from vertex 1 à vertex 3 à vertex 5 à vertex 2 à vertex 4 à vertex 1;

At the same time, you can change the size of the five-pointed star by controlling R.

The next step is to make the five-pointed star move by setting a set of parameters, namely the speed (pixels) of the center of the circle, the direction of the center of the circle (the slope of the running line), and the angle of rotation.

When moving, you need to consider the boundary. When the pentagram reaches the boundary, you need to go back. The boundary coordinates and diameter R can be used to calculate when the pentagram and the boundary meet. After reaching the boundary, you can reverse the slope of the running track to switch the direction when returning. When you encounter the left and right boundaries, you also need to reverse the moving speed to switch the direction.

The rotation angle can be achieved by adding an angle to the starting angle A of vertex 1 in time.

Finally, a new polygon is created by key interruption. Each parameter gets a random number through RNG.

The software configuration is relatively simple, just enable the DAC and two timers. I set the timer to 100us for drawing points and 100ms for moving polygons. The logic implementation is not complicated.

This post is from Test/Measurement

Latest reply

It's awesome, it would be nice if there were detailed steps so everyone can gain some experience   Details Published on 2020-4-9 22:41

赞赏

1

查看全部赞赏

 
 

661

Posts

18

Resources
2
 

Awesome! Any code?

This post is from Test/Measurement

Comments

The code is a bit messy, so I won't upload it. I'll share the principle and my ideas. See if it's useful to you.  Details Published on 2020-4-11 18:16
 
 
 

1w

Posts

25

Resources
3
 

This is interesting

This post is from Test/Measurement
 
 
 

4817

Posts

4

Resources
4
 

It's awesome, it would be nice if there were detailed steps so everyone can gain some experience

This post is from Test/Measurement

Comments

Already added to the post  Details Published on 2020-4-11 18:18
 
 
 

171

Posts

0

Resources
5
 
Lambo posted on 2020-4-9 09:18 Very cool! Do you have the code?

The code is a bit messy, so I won't upload it. I'll share the principle and my ideas. See if it's useful to you.

This post is from Test/Measurement
 
 
 

171

Posts

0

Resources
6
 
led2015 posted on 2020-4-9 22:41 Very cool, it would be great if there were detailed steps, so that everyone can gain some experience

Already added in the post

This post is from Test/Measurement
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list