Excel offers painless LCD initialization
Edited by Bill Travis
Alberto Bitti, Eptar, Lugo, Italy -- EDN, September 20, 2001
To display a font or a symbol on an LCD, you need to convert the desired character into numerical data. Creating the data for an entire font set requires specialized tools; even with these tools, the task can be daunting. Alternatively, you can build a font calculator using an Excel spreadsheet. This technique takes advantage of the tabular nature of a spreadsheet to automatically create the required initialization code. The example in Figure 1 applies to displays arranged in blocks comprised of eight pixels by eight pixels. You can easily adapt it to any other arrangement, such as the seven-by-five-pixel format used in the eight customizable characters found in most alphanumeric displays. Cells inside the yellow area represent the symbol "pixels." You draw the desired font character or symbol using a bold character such as "#." The formula in Figure 2 is all that you need to obtain the initialization data. For each of the eight pixels in a row, the formula tests whether the pixel is blank (LEN is zero); otherwise, it adds the pixel's "weight" (1, 2, 4, 8, 16, 32, 64, or 128) to the result.
You can prepare the spreadsheet in minutes. Type the formula in the first position (K2), then copy it to all eight rows in a symbol (the blue area from K3 to K9). Complete it with the separators for your language of choice (commas and parentheses for C). To build an entire character set, copy the whole block as many times as necessary. To edit the fonts, place the cursor over the cells and type "#" (or any other character), and use "Canc" to delete. After editing, select all of the columns K and L; then cut and paste the code into your application. Besides saving you money, this technique is convenient and flexible. You can adapt it in minutes to any language (useful when you switch between assembly dialects). Moreover, the method accommodates useful additions, such as inserting #define KEY_ICON to name a particular data set, to suit your application's requirements.
Is this the best Design Idea in this issue? Vote at www.ednmag.com.


















