【HuaDiao hands-on】Interesting and fun music visualization series projects (32)--P10 matrix LED unit board

On a whim, I wanted to do a series of topics on music visualization. The difficulty of this topic is a bit high, and it involves a wide range of areas. The related algorithms such as FFT and FHT are also quite complicated. However, I still plan to start with the simplest ones, do practical experiments, try various solutions patiently, and gradually accumulate some useful ones. We will try to form some practical and fun music visualizer projects.

insert image description here
insert image description here

Popular science knowledge points: LED and LED display
1. LED (Light Emitting Diode)
1. LED is the abbreviation of light emitting diode. It is a semiconductor light source that emits light when current passes through it; that is, an electroluminescent semiconductor electronic component in which electrons recombine with electron holes and release energy in the form of photons. The core part of the light-emitting diode structure is the pn junction, and the peripheral part has epoxy resin to seal the lead wire and the frame to protect the inner core wire. When the pn junction is connected with a forward current, it can emit visible or invisible radiation, which is a composite light source composed of trivalent and pentavalent elements. Light-emitting diodes can only be turned on (energized) in one direction, which is called forward bias; when the current flows, electrons and holes (electron holes) recombine in it to emit monochromatic light, which is called "electroluminescence". effect”; while the wavelength and color of the light are related to the type of semiconductor material used and the elemental impurities intentionally added. Light-emitting diodes have the advantages of high efficiency, long life, unbreakable, fast response, and high reliability, which are not as good as traditional light sources.
When light-emitting diodes appeared in 1962, they could only emit low-level red light, which was used as an indicator light after being patented by Hewlett-Packard. Later, other versions of monochromatic light were developed. Today, the light that can be emitted has covered visible light, infrared rays and ultraviolet rays, and the luminosity has also increased to a very high level. With the emergence of white light-emitting diodes, the use has gradually developed from the initial use of indicator lights and display panels to lighting use in recent years. The luminous efficiency of white light LED has also improved recently, and its cost per thousand lumens has been reduced due to a large amount of capital investment. In recent years, it has become more and more popular in lighting applications.
2. The structure of LED
LED is a special diode, which is composed of semiconductor chips like ordinary diodes. The semiconductor chip is the core of the LED. It is attached to the substrate and directly connected to the negative pole. The positive pole is connected to the anode post by a wire. The lighting effect of the chip is enhanced by the reflective bowl. The entire chip is encapsulated by epoxy resin. In-line LED is mainly composed of the following parts:
chip: (function - light source to emit light)
bracket: including substrate, heat dissipation base, pins, etc. (function - heat dissipation, conduction)
gold wire: (function - conduction)
Transparent resin: (function - protect the crystal grain, transmit light)

insert image description here
insert image description here

3. Main characteristics of LED
As the fourth-generation new light source, LED has many characteristics that the previous three-generation light sources did not have: high efficiency, long life, strong safety and reliability, no heat radiation, and belongs to cold light source, which can accurately control light type and light emission Angle, good for environmental protection, small size of light source, can be combined at will are notable features, and gradually become the mainstream light source in this era.
(1) Energy saving is the most prominent feature of LED lamps - in terms of energy consumption, the energy consumption of LED lamps is one-tenth of that of incandescent lamps and one-fourth of that of energy-saving lamps. This is one of the biggest features of LED lights. Nowadays, people advocate energy saving and environmental protection. It is precisely because of this feature of energy saving that the application range of LED lights is very wide, making LED lights very popular.
(2) It can work in high-speed switching state - when we usually walk on the road, we will find that the screen or picture composed of each LED is unpredictable. This shows that LED lights can perform high-speed switching. However, for the incandescent lamps we usually use, such a working state cannot be achieved. In normal life, if the number of switches is too many, it will directly cause the filament of the incandescent lamp to break. This is also an important reason for the popularity of LED lights.
(3) Environmental protection - LED lamps do not contain any heavy metal materials such as mercury, but incandescent lamps contain them, which reflects the environmental protection characteristics of LED lamps. People nowadays attach great importance to environmental protection, so more people are willing to choose environmentally friendly LED lights.
(4) Fast response speed - LED lights also have a prominent feature, that is, the response speed is relatively fast. As long as the power is turned on, the LED light will light up immediately. Compared with the energy-saving lamps we usually use, their response speed is faster. When the traditional light bulb is turned on, it often takes a long time to illuminate the room, and it can only be turned on after the light bulb is completely heated.
(5) Conducive to environmental protection - LED is an all-solid illuminant, impact-resistant and not easy to break, waste can be recycled, no pollution, reduce a large amount of harmful gases such as sulfur dioxide and nitrides, and greenhouse gases such as carbon dioxide. Improve people's living environment, can be It is called "green lighting source."
insert image description here

4. Related parameters of LED
(1) Forward voltage VF
refers to the voltage generated between anode A and cathode K when a forward current flows. The unit is V (volts). When the forward voltage is less than a certain value (called threshold), the current is extremely small and no light is emitted. When the voltage exceeds a certain value, the forward current increases rapidly with the voltage and emits light. And beyond the normal operating voltage, the LED may be broken down. Generally, the normal forward voltage of LEDs with different luminous colors is also different. For example, the red light is usually between 1.8~2.0V, while the blue light and white light are between 2.8~3.3V.
(2) The forward current IF
refers to the current generated between the anode A and the cathode K when a forward current flows. The unit is A (ampere). Generally, the forward current of the LED should be controlled within 20mA. Excessive current may easily cause the junction temperature Tj between the P and N of the LED to be too high, resulting in damage to the LED or reducing the service life. In addition, LEDs are like ordinary diodes. When the voltage increases, the current will increase to a large extent, so generally LED light-emitting diodes are connected in series with protective resistors.
(3) The luminous intensity IV
represents the brightness observed from a specific direction. The unit is cd (candela, the corresponding smaller unit is millicandela, or mcd), and one lumen of light emitted within a unit solid angle is called one candela. Pay special attention to pointing angles when comparing light intensities. Luminous intensity refers to the luminous flux emitted within a unit solid angle. As a component of the LED package, the lens can concentrate the light output in a specific direction (light collection by the lens), and it can collect light even if the light output is small, so the light intensity becomes larger. It should be pointed out that the IV value usually needs to specify how much forward current IF the LED is measured under.
(4) Luminous flux Φv [lm]
refers to the total amount of light emitted from the light source. The unit is lm (lumen). Luminous flux refers to the radiant power that the human eye can perceive, which is equal to the product of the radiant energy of a certain band per unit time and the relative visibility of the band. Since the relative viewing rate of the human eye to different wavelengths of light is different, when the radiant power of different wavelengths of light is equal, the luminous flux is not equal.
(5) Dominant wavelength λD [nm]
LEDs generally use wavelengths to represent colors. The dominant wavelength is equivalent to the wavelength corresponding to the color seen by the eyes, which is different from the peak wavelength of the luminous wavelength, and the unit is nm (nanometer).
The following are the wavelength parameters of LEDs with various luminous colors:
Purple: 400-435nm
Blue: 435-480nm
Blue-green: 480-500nm
Green: 500-560nm Yellow -
green: 560-580nm
Yellow: 580-595nm
Orange: 595-610nm
■Red: 610-760nm
■White is usually represented by the following color coordinates. Or simply use warm white, true white, and cool white to express.
※Remarks:
The above wavelength ranges and color marks are slightly different according to different documents, and are for reference only.

2. LED display (LED panel)
1. LED display is a flat-panel display, which is composed of small LED module panels and is used to display various information such as text, images, and videos. LED electronic display integrates microelectronics technology, computer technology, and information processing, and has the advantages of bright colors, wide dynamic range, high brightness, long life, stable and reliable work, etc. LED displays are widely used in commercial media, cultural performance markets, stadiums, information dissemination, press releases, securities transactions, etc., and can meet the needs of different environments.
insert image description here

2. The LED display screen is an electronic display screen composed of LED dot matrix. By turning on and off the traffic light beads to replace the screen display content forms such as text, animation, pictures, and video in a timely manner, the component display control is performed through a modular structure. It is mainly divided into display module, control system and power supply system. The display module is a dot matrix of LED lights to form a screen to emit light; the control system is to control the on and off conditions in the area to convert the content displayed on the screen; the power system is to convert the input voltage and current to meet the needs of the display screen.

The LED screen can realize the transformation between different forms of various information presentation modes, and can be used indoors and outdoors, and has incomparable advantages over other display screens. With the characteristics of high luminous intensity, low working power consumption, low voltage demand, small and convenient equipment, long service life, stable impact resistance and strong resistance to external interference, it has developed rapidly and is widely used in various fields.

insert image description here
3. The luminous color and luminous efficiency of LED are related to the material and process of making LED. The light bulb is full of blue light at first, and phosphor powder is added later. According to the different needs of users, different light colors can be adjusted. Widely used There are four kinds of red, green, blue and yellow. Due to the low working voltage of the LED (only 1.2~4.0V), it can actively emit light and have a certain brightness, and the brightness can be adjusted by voltage (or current), and it is shock-resistant, vibration-resistant, and has a long life (100,000 hours). Among the large display devices, there is no other display method comparable to the LED display method.
The display screen made by putting red and green LED chips or light tubes together as a pixel is called a three-color or dual-primary color screen. Putting red, green, and blue LED chips or light tubes together as a pixel display The screen is called a three-color screen or a full-color screen. If there is only one color, it is called monochrome or single-primary color screen. The pixel size of indoor LED screen is generally 1.5-12 mm. The size is mostly 6-41.5 mm. Each pixel is composed of several single-color LEDs. The common finished product is called a pixel tube. The two-color pixel tube is generally composed of 2 red and 1 green, and the three-color pixel tube uses 1 red and 1 green. Green 1 blue composition.
Regardless of using LEDs to make single-color, two-color or three-color screens, the luminance of each LED that constitutes a pixel must be adjustable to display an image, and the fineness of its adjustment is the gray level of the display screen. The higher the gray level, the more delicate the image displayed, the richer the color, and the more complex the corresponding display control system. Generally, for images with 256-level grayscale, the color transition is very soft, while for color images with 16-level grayscale, the boundary line of color transition is very obvious. Therefore, color LED screens are currently required to be made of 256 to 4096 gray levels.

insert image description here
4. Basic principles of LED display
LED display is a new type of information display media, which is a flat display screen composed of light-emitting diode dot matrix modules or pixel units. The figure shows the structure diagram of 8×8 dot matrix LED display screen. From the figure, 8×8 dot matrix needs 64 light-emitting diodes in total, and each light-emitting diode is placed at the intersection of row lines and column lines. When When a corresponding row is set to a high level and a certain column is set to a low level, the corresponding diode is lit. For example, when you want to display text, you can light up the corresponding diodes according to the strokes that make up the text, so as to achieve the purpose of displaying text, as shown in the figure. The complete dot matrix can be composed of 16×16, 32×32 and other display modules. Each pixel of a single-color LED display is composed of 1 single-color LED light-emitting diode, that is, each pixel contains 1 LED light-emitting diode; each pixel of a dual-color LED display is composed of 2 LED light-emitting diodes of 2 single colors Composition, that is, each dual-primary color pixel contains 2 LED light-emitting diodes; and for a three-primary color full-color LED display, the diodes that make up the pixel point include 3 or more, such as red light and green light respectively. It is composed of 3 diodes with blue light, so that the purpose of color display can be achieved according to the color matching principle of the three primary colors; and some display screens may be composed of 4 diodes in order to improve the display effect: 2 red LEDs, 1 green LED LED and 1 blue LED.

insert image description here
insert image description here
5. Classification of LED display
(1) According to the base color of the display color:
a. Monochrome LED display: single color: red LED display, white LED display, green LED display, yellow LED display Display, blue LED electronic display, purple LED electronic display (rose LED electronic display).
b. Double (primary) color LED electronic display screen: red and green two primary colors, can display red, green and mixed color yellow.
c. Full-color LED electronic display screen: red, green and blue three primary colors, and a full-color display screen with 256 gray levels can display more than 16 million colors.
(2) According to the installation indoor and outdoor environment or waterproof can be divided into:
a, indoor LED electronic display (not waterproof);
b, semi-outdoor (sub-outdoor) LED electronic display (not waterproof, one is only on the door or eaves The single-color LED electronic display screen used only in the next year is limited to text and text information bar screens, and such classifications are generally not mentioned);
c. Outdoor LED electronic display screens (waterproof).
(3) According to the luminous pixel pitch (P or PH) or diameter (Φ), it can be divided into:
a. Single and double colors: P10, P8, P7.62 (the old model is called Φ5 according to the diameter), P4.75 (the old model It is called Φ3.75 according to the diameter), the old model is called Φ3 according to the diameter (no new one)
b, regular indoor full-color: P7.62, P6, P5, P4, P3, P2.5
c, small-pitch indoor full-color P2 , P1.923, P1.875, P1.667, P1.523, P1.4, P1.25, P1.0, P0.87...
d. Outdoor full color: P20, P16, P12, P13.3, P10, P8, P6, P5, P4, P3
e, commonly used on rental screens: P5.68, P4.81, P3.91, P2.97, P2.60....
(4) Classified by lamp beads:
Plug-in type (old style); mounted type (new style).

insert image description here
6. LED display development history
LED display is a new type of information display media that developed rapidly in the world in the late 1980s. It uses dot matrix modules or pixel units composed of light-emitting diodes (LEDs) to form a large display screen. It has the characteristics of reliability, long service life, strong environmental adaptability, high price-performance ratio, and low cost of use. In the past ten years, it has rapidly grown into a mainstream product of flat panel display and has been widely used in the field of information display. After several years of development, my country's LED display industry has basically formed a number of backbone enterprises with a certain scale. There are many social and economic fields for LED display screens, and its development has probably gone through the following three stages:
(1) The growth and formation period of LED display screens before 1990. On the one hand, due to the limitation of LED materials and devices, the application field of LED display has not been widely developed. On the other hand, LED display technology is basically a communication control method, which objectively affects the display effect. During this period, LED display screens were widely used abroad, but few in China. The products were mainly red and green dual primary colors, and the LED display control card was used for communication control. The gray scale was single-point 4-level gray adjustment. The cost of the product is relatively high.
(2) In the 1990s, this stage was a period of rapid development of LED displays. In the 1990s, the global information industry has grown rapidly, and various fields of information technology have continued to make breakthroughs. LED displays have also continuously emerged new achievements in LED materials and LED display technologies. The blue LED chip was successfully developed, and the full-color LED display entered the market; the technological development in the field of electronic computers and microelectronics, video control technology appeared in the field of display control technology, and the gray scale of the display screen achieved 16 gray levels and 64 levels. The gray scale is adjusted to gray, and the dynamic display effect of the display screen is greatly improved. At this stage, LED display screens are developing very rapidly in my country. From the initial few enterprises with an annual output value of tens of millions of yuan to dozens of enterprises with an annual output value of hundreds of millions of yuan, the product application fields involve financial securities, sports, and airports. , railways, stations, highway transportation, commercial advertising, post and telecommunications and many other fields, especially the development of the securities and stock industry in 1993 led to a substantial growth in the LED display market. LED display has basically taken shape as a mainstream product in the field of flat panel display, and the LED display industry has become an emerging high-tech industry.
(3) Since the 21st century, the development of LED display screens has entered a period of overall steady improvement and adjustment of the industrial structure. Since 2000, the internal competition in the LED large screen industry has intensified, and many small and medium-sized enterprises have been formed. The price of LED display screens has dropped sharply, and the application fields have become wider. A series of new problems have emerged in terms of product quality and standardization. The development of display screens has been paid attention to and properly regulated and guided. At present, the work in this area is gradually deepening.

7. The scanning mode of the LED display screen
is within a certain display area of ​​the LED display screen. The ratio of the number of lines lit at the same time to the number of lines in the entire area is called the scanning mode; The full-color LED display is generally 1/8 scan, the outdoor single and double-color LED display is generally 1/4 scan, and the outdoor full-color LED display is generally static scan. At present, there are two driving methods of LED display on the market: static scanning and dynamic scanning. Static scanning is divided into static real pixel and static virtual, and dynamic scanning is also divided into dynamic real image and dynamic virtual. The driving device generally uses domestic HC595 and Taiwan MBI5026 , Japan Toshiba TB62726, generally have 1/2 sweep, 1/4 sweep, 1/8 sweep, 1/16 sweep.

Example: A commonly used full-color module has a pixel size of 16 8 (2R1G1B). If MBI5026 is used to drive the module, the total used in the module is: 16 8*(2+1+1)=512. MBI5026 is a 16-bit chip. 512/16=32
(1) If 32 MBI5026 chips are used, it is static virtual
(2) If 16 MBI5026 chips are used, it is dynamic 1/2 scan virtual
(3) If 8 MBI5026 chips are used, it is dynamic 1/4 Scan virtual
If two red lights are connected in series on the board
(4) use 24 MBI5026 chips, use 12 MBI5026 chips for static real pixels
(5) use 12 MBI5026 chips for dynamic 1/2 scan real pixels
(6) use 6 MBI5026 chips, It is a dynamic 1/4 scanning pixel.
On the LED display, the scanning methods are 1/16, 1/8, 1/4, 1/2, and static. How to distinguish? One of the easiest ways is to count the number of LEDs on the LED display unit board and the number of 74HC595.
Calculation method: Divide the number of LEDs by the number of 74HC595 and then divide by 8 = a fraction of scanning
real pixels correspond to virtual ones: in simple terms, real pixel screens refer to the red, green and blue light-emitting tubes that make up the display screen Each light-emitting tube in the LED display only participates in the imaging of one pixel in order to obtain sufficient brightness.
Virtual pixels use software algorithms to control the light-emitting tubes of each color to finally participate in the imaging of multiple adjacent pixels, so that fewer lamps can be used to achieve greater resolution and improve display resolution.

8. Precautions for the use of LED display
(1) Switching sequence: when the screen is turned on - turn on the screen first, then turn on the screen. When turning off the screen - turn off the screen first, then turn off the phone.
(Turn off the computer first without turning off the display screen, which will cause bright spots on the screen body, and the LED will burn out the lamp tube, and the consequences will be serious.) (
2) The interval between switching the screen on and off should be greater than 5 minutes.
(3) After the computer enters the engineering control software, the screen can be turned on and powered on.
(4) Avoid turning on the screen when the screen is all white, because the inrush current of the system is the largest at this time.
(5) Avoid turning on the screen when it is out of control, because the inrush current of the system is the largest at this time.
(6) When one line of the electronic display is very bright, you should pay attention to turn off the screen in time, and it is not advisable to turn on the screen for a long time in this state.
(7) If the power switch of the display screen trips frequently, check the screen body or replace the power switch in time.
(8) Regularly check the firmness of the joint. If there is looseness, pay attention to timely adjustment, re-strengthen or update the hanging parts.
(9) When the ambient temperature is too high or the heat dissipation conditions are not good, the LED lighting should be careful not to open the screen for a long time.

insert image description here

For this experiment, two P10LED unit boards were collected, one is a P10(1R)V706 module, and the other is a P10(1R)V701AG module, both are 32X16 LED displays.

insert image description here

Find the reference electrical schematics of several module unit boards

insert image description here
insert image description here

P10 (1R) V706 module technical parameters

insert image description here
insert image description here
insert image description here
Signal pin definition

insert image description here
insert image description here

EN: This pin is used to control the brightness of the LED panel by supplying PWM pulses to it.
A, B: These are called multiplex select pins. They take digital inputs to select any multiplexed row
Shift Clock (CLK), Store Clock (SCLK): These are regular shift registers Control Pin
DATA: This pin is used for data input in PWM form.

insert image description here
Features of P10 display module:
¼ duty scan type [a quarter of the LEDs on the module are driven by IC at one time]
Brightness: 3500nits to 4500nits
Maximum power consumption: 20W
DC 5V voltage input
IP65 waterproof
High contrast and viewing angle
1W pixel configuration

P10 Display Module Specifications:
Input Voltage: 5V
Maximum Current Input: 4A
Average Power Consumption: 8W-10W
Color: Red
Pixel Pitch: 10mm
LED Pixel Size: 32X16 = 512

Self-made HUB12 interface UNO expansion board,
mainly based on the Proto Shield prototype expansion board, with two P16 sockets added for easy experimentation

insert image description here

This is how it is done (the P5 socket is the interface of the DS1307 clock module)

insert image description here

Experimental wiring diagram

insert image description here

insert image description here

insert image description here

insert image description here

Use Arduino to program P10 LED module, the common driver library is
DMD.h download link: https://github.com/freetronics/DMD
TimerOne.h download link: https://github.com/PaulStoffregen/TimerOne

insert image description here

【HuaDiao hands-on】Interesting and fun music visualization series projects (31) - LCD1602 liquid crystal screen
Project one: Light up the screen and scroll to display "Hello World 1234567890"

/*
  【花雕动手做】有趣好玩的音乐可视化系列项目(31)--LCD1602液晶屏
  项目程序之一:点亮屏幕滚动显示“Hello World 1234567890”
*/

#include <SPI.h>//导入驱动库
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define ROW 1
#define COLUMN 1
#define FONT Arial_Black_16//字体16
DMD led_module(ROW, COLUMN);//行、列

void scan_module() {
    
    
  led_module.scanDisplayBySPI();//模块扫描显示 By SPI
}

void setup() {
    
    
  Timer1.initialize(2000);
  Timer1.attachInterrupt(scan_module);
  led_module.clearScreen( true );
}

void loop() {
    
    
  led_module.selectFont(FONT);//设置字体
  led_module.drawMarquee("Hello World 1234567890", 25, (32 * ROW), 0);
  long start = millis();
  long timming = start;
  boolean flag = false;
  while (!flag)
  {
    
    
    if ((timming + 20) < millis())
    {
    
    
      flag = led_module.stepMarquee(-1, 0);
      timming = millis();
      delay(50);//通过延时时间来调整字幕滚动快慢
    }
  }
}

Experimental scene graph

insert image description here
insert image description here

Video recording of the experiment Youku
: https://v.youku.com/v_show/id_XNTg3MjI2MjE0MA==.html?spm=a2hcb.playlsit.page.1

The program description
includes all the necessary font libraries, in our case we use the "Arial Black font" for display.

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include “SystemFont5x7.h”
#include “Arial_black_16.h”

In the next step, define the number of rows and columns for the LED display board. In our example, we are only using one module, so the ROW value and COLUMN value will be 1. Then define a font name for the scrolling text on the display panel - Arial_Black_16 .

#define ROW 1
#define COLUMN 1
#define FONT Arial_Black_16 DMD led_module(ROW, COLUMN);

The function scan_module() checks for any incoming data from the Arduino side via the SPI terminal. If yes, then it will trigger an interrupt pin to execute some event.

void scan_module() {
led_module.scanDisplayBySPI();
}

In setup(), initialize the timer and attach the interrupt to the function scan_module. The function clearScreen(true) is used to set all pixels to be turned off initially to clear the display panel.

void setup() {
Timer1.initialize(2000);
Timer1.attachInterrupt(scan_module);
led_module.clearScreen( true );
}

Then, to display the string in the module, use the selectFont() function to select a font and use the drawMarquee() function to print the string message "Welcome to Circuit Digest" on the display.

led_module.selectFont(FONT);
led_module.drawMarquee(“Hello World 1234567890”, 25, (32 * ROW), 0);

Finally, to scroll the text on the LED display board, use a certain period of time to move the entire message from right to left.

long start = millis();
long timming = start;
boolean flag = false;
while (!flag)
{
if ((timming + 20) < millis())
{
flag = led_module.stepMarquee(-1, 0);
timming = millis();
}
}

【HuaDiao hands-on】Interesting and fun music visualization series projects (31)-LCD1602 LCD screen
Project program 2: Comprehensive test of Freetronics DMD library

/*
  【花雕动手做】有趣好玩的音乐可视化系列项目(31)--LCD1602液晶屏
  项目程序之二:Freetronics DMD库的综合测试
*/

#include <SPI.h>   //导入相关驱动库
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"

//以 dmd 的身份启动 DMD 库
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

/*-------------------------------------------------------------------
  Timer1 (TimerOne) 驱动的 DMD 刷新扫描的中断处理程序,这得到
  在 Timer1.initialize() 中设置的周期调用;
-------------------------------------------------------------------*/
void ScanDMD() {
    
    
  dmd.scanDisplayBySPI();
}

/*-------------------------------------------------------------------
  设置
  在主循环开始之前由 Arduino 架构调用
-------------------------------------------------------------------*/
void setup(void) {
    
    
  //初始化TimerOne用于扫描和刷新显示的中断/CPU使用率
  Timer1.initialize( 5000 );           //调用 ScanDMD 的周期(以微秒为单位)。任何超过 5000 (5ms) 的时间都可以看到闪烁。
  Timer1.attachInterrupt( ScanDMD );   //将 Timer1 中断附加到 ScanDMD 到 dmd.scanDisplayBySPI()
  //清除/初始化内存中的DMD像素
  dmd.clearScreen( true );   //true 为正常(所有像素关闭),false 为负(所有像素打开)
}

/*-------------------------------------------------------------------
  环形
  Arduino架构主循环
-------------------------------------------------------------------*/
void loop(void) {
    
    
  byte b;
  // 10 x 14 字体时钟,包括OR 和 NOR 模式演示,以便可以覆盖闪烁的冒号
  dmd.clearScreen( true );
  dmd.selectFont(Arial_Black_16);
  dmd.drawChar(  0,  3, '2', GRAPHICS_NORMAL );
  dmd.drawChar(  7,  3, '3', GRAPHICS_NORMAL );
  dmd.drawChar( 17,  3, '4', GRAPHICS_NORMAL );
  dmd.drawChar( 25,  3, '5', GRAPHICS_NORMAL );
  dmd.drawChar( 15,  3, ':', GRAPHICS_OR     );   //时钟冒号覆盖
  delay( 1000 );
  dmd.drawChar( 15,  3, ':', GRAPHICS_NOR    );   //时钟冒号覆盖关闭
  delay( 1000 );
  dmd.drawChar( 15,  3, ':', GRAPHICS_OR     );   //时钟冒号覆盖
  delay( 1000 );
  dmd.drawChar( 15,  3, ':', GRAPHICS_NOR    );   //时钟冒号覆盖关闭
  delay( 1000 );
  dmd.drawChar( 15,  3, ':', GRAPHICS_OR     );   //时钟冒号覆盖
  delay( 1000 );

  //滚动文本
  dmd.drawMarquee("Scrolling Text", 14, (32 * DISPLAYS_ACROSS) - 1, 0);
  long start = millis();
  long timer = start;
  boolean ret = false;
  while (!ret) {
    
    
    if ((timer + 30) < millis()) {
    
    
      ret = dmd.stepMarquee(-1, 0);
      timer = millis();
    }
  }
  // 一半像素
  dmd.drawTestPattern( PATTERN_ALT_0 );
  delay( 1000 );

  // 另一半打开
  dmd.drawTestPattern( PATTERN_ALT_1 );
  delay( 1000 );

  // 显示一些文本
  dmd.clearScreen( true );
  dmd.selectFont(System5x7);
  for (byte x = 0; x < DISPLAYS_ACROSS; x++) {
    
    
    for (byte y = 0; y < DISPLAYS_DOWN; y++) {
    
    
      dmd.drawString(  2 + (32 * x),  1 + (16 * y), "freet", 5, GRAPHICS_NORMAL );
      dmd.drawString(  2 + (32 * x),  9 + (16 * y), "ronic", 5, GRAPHICS_NORMAL );
    }
  }
  delay( 2000 );

  // 在显示器外面画一个边框
  dmd.clearScreen( true );
  dmd.drawBox(  0,  0, (32 * DISPLAYS_ACROSS) - 1, (16 * DISPLAYS_DOWN) - 1, GRAPHICS_NORMAL );
  delay( 1000 );

  for (byte y = 0; y < DISPLAYS_DOWN; y++) {
    
    
    for (byte x = 0; x < DISPLAYS_ACROSS; x++) {
    
    
      // draw an X
      int ix = 32 * x;
      int iy = 16 * y;
      dmd.drawLine(  0 + ix,  0 + iy, 11 + ix, 15 + iy, GRAPHICS_NORMAL );
      dmd.drawLine(  0 + ix, 15 + iy, 11 + ix,  0 + iy, GRAPHICS_NORMAL );
      delay( 1000 );

      //画一个圆
      dmd.drawCircle( 16 + ix,  8 + iy,  5, GRAPHICS_NORMAL );
      delay( 1000 );

      // 绘制一个填充框
      dmd.drawFilledBox( 24 + ix, 3 + iy, 29 + ix, 13 + iy, GRAPHICS_NORMAL );
      delay( 1000 );
    }
  }

  // 条纹追逐者
  for ( b = 0 ; b < 20 ; b++ )
  {
    
    
    dmd.drawTestPattern( (b & 1) + PATTERN_STRIPE_0 );
    delay( 200 );
  }
  delay( 200 );
}

Experimental scene graph

insert image description here

insert image description here
Video recording of the experiment
https://v.youku.com/v_show/id_XNTg3MTM3MTYxNg==.html?spm=a2hcb.playlsit.page.1

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/127985947