Method of extracting fonts from Excel software using conditional formatting by single chip microcomputer

Publisher:Zhenai5201314Latest update time:2011-10-14 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

As an important display method, LED dot matrix has been widely used. An important problem that needs to be solved in the dot matrix display system program controlled by single chip microcomputer is the acquisition of character dot matrix data, which is often called font extraction. The author also encountered this problem in the work process. After learning and research, it was found that the commonly used method of font extraction is to use special font extraction software to complete it, but it also encountered the problem that the dot matrix size is fixed and cannot be selected at will. For example, in the program for controlling 5×7 LED dot matrix, it is impossible to find suitable software to obtain the font. After research and experiments, it was found that the use of Excel software can achieve font extraction of any dot matrix size.
The core idea of ​​this method is to apply Excel's "conditional formatting" function. Select any cell in the Excel table, use "conditional formatting" in the "format" menu, and set the cell format to black background when the cell value is equal to 1, as shown in Figure 1. After the setting is successful, you will find that when the value in the cell is 1, the cell will turn black. Using this function, you can vividly display the dot matrix font display effect in Excel. In Excel, select a table area that is the same size as the dot matrix to be modulated. One cell represents one LED. Set the column width to 2. Set the conditional format for each cell in this area, and fill 1 in the cell corresponding to the LED to be lit. Then you can get a graphic similar to the display effect. As shown in Figure 2, the effect of displaying the number "1" in a 5×7 dot matrix. Then you can use the Excel formula function to calculate the data of the corresponding rows and columns to get the dot matrix data. For easy reading, the row and column labels are added on the left and top respectively. The right side is the font data of each row, and the bottom is the font data of each column.

After loading Excel's "Analysis ToolPak" macro, you can use the DEC2HEX() function to convert decimal to hexadecimal, and use the TEXT() function to convert it to a two-digit character, and then use the & operator to add H after it to get the hexadecimal data format commonly used in microcontroller programs. Corresponding to the Excel table area position of Figure 2, the formula for the font data of the first row showing "1" in the 5×7 dot matrix is: =TEXT(DEC2HEX(B2+C2*2+D2*4+E2*8+F2*16), "00")&"H", and the result is 04H; the formula for the font data of the first column is: =TEXT(DEC2HEX(B2+B3*2+B4*4+B5*8+B6*16+B7*32+B8*64), "00"&"H", and the result is 00H. The formulas for other rows and columns are analogous. Similarly, the & operator can be used to combine the font data into the data table format of the single-chip microcomputer program. As shown in Figure 2, the formula for the 10th row is: ="DB"&B9&", "&C9 &", "&D9&", "", "&E9 &", "&F9, and the result is "1". The font data taken by the 5×7 dot matrix according to the column is DB 00H, 42H, 7FH, 40H, 00H; the formula for the 11th row in Figure 2 is: = "DB"&G2&", "&G3 8L", "&G4&", "&G5 &", "&G6&", "&G7&", "&G8, and the font data of the 5×7 dot matrix of "1" taken by row is DB04H, 06H, 04H, 04H, 04H, 04H, 0EH, and the font data in the microcontroller assembly language data table format is successfully generated and can be directly copied to the microcontroller program for use.

By extending this method, you can also use the seven-segment digital tube to calculate the glyph code in Excel. As shown in the 9th row of Figure 3, the formula for calculating the glyph code of the seven-segment digital tube is: =TEXT(DEC2HEX(C2+D3*2+D5*4+C6*8+B5*16+B3*32+C4*64), "00")&"H", and the glyph code of the seven-segment digital tube for "2" is 5BH.

In this method of using Excel to extract fonts:
① The high and low bit order problem of dot matrix extraction can be modified by adjusting the bit weight of each bit in the cell calculation formula.
② When extracting fonts with dot matrices of different sizes, the 5×7 dot matrix in the text can be used as an analogy. Draw the corresponding size area and modify the number of cells calculated by the formula to achieve this.
③ In this method, if the conditional format is set to "When the cell value is equal to 1, the cell format is black background", then the calculation and calculation of the font code
will display the common cathode digital tube font code, that is, the bright field is 1. If you need
a common anode digital tube font code, that is, the bright field is 0, set the conditional format to "When the cell value is equal to 0, the cell format is black background", and enter 1 in the position that does not need to be lit, and the formula remains unchanged to achieve this.

Reference address:Method of extracting fonts from Excel software using conditional formatting by single chip microcomputer

Previous article:Design of portable human physiological parameter monitor
Next article:Micro-power consumption data acquisition system based on MSp430 single chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号