|
Lessons from BOB : PART ONE DRAWING THE FACE
Remember BOB from one of our projects? Well, it got so popular we had to make up tutorials on how we did it. It’s pretty easy with all the libraries we wrote to get it up.
Items used in this tutorial:
HARDWARE CONFIGURATION
click for enlarged image
THE GRAPHIC LCD (GLCD) Before using the GLCD, it must be initialised and we recommend making the whole screen white. The following code does just that.
CODE:
Images can now be drawn onto the GLCD. To simplify the process of getting the project up, we shall make use of the images that are already stored in the FICE SD card. The images are as follows:
IMAGES STORED IN THE SD CARD
TECHNICAL OVERVIEW
A library has also been written to draw these images. Locate and include the DRAW_LIB library into your project (Project > Add Module). The following are subroutines found in the DRAW_LIB library:
CODE:
DRAW_EYE takes 3 arguments. The X and Y determines the position of the eye to be drawn and OPEN determines if the eye should be drawn using image EYE_OPEN or EYE_CLOSE. Type ‘True’ to draw EYE_OPEN and ‘False’ to draw EYE_CLOSE. Let’s add the following line of code to draw two eyes on the GLCD.
CODE:
Press F5 to download the program or click on the compile and download icon. If there are no compilation or download errors, you should see two eyes on the GLCD. To add a mouth, we simply use DRAW_MOUTH. DRAW_MOUTH takes 3 arguments. Xand Y being the position of the mouth and POS determines which mouth to draw. Valid values of POS are 1, 2, 3, 4 or 5. Please refer to the ‘IMAGES STORED IN THE SD CARD’ section for images of the mouth. The code for drawing a mouth is as follow.
CODE:
We have now drawn a complete face on the GLCD. In the next section, we will do some animation with the face.
CODE:
Continue to Part TWO >>>
|
Resources


