PDF Print E-mail

 

Lessons from BOB : PART TWO

 

ANIMATING THE FACE

 

 

To animate the face, you will need to draw an image on the GLCD and then wait for a while – anything more than 50 msec and then draw a second image.

 

 EYE_DO_LOOP.png

Let’s just say we want the right eye to blink.  We first draw the whole face.  Then we draw the right eye close and wait for 500 msec.  We now draw the right eye open again.  This will give the illusion that the eye is blinking. Try the following code:

 CODE :

 

OS.GLCD.Init()

OS.GLCD.Fill(255)

 

'DRAW RIGHT EYE

DRAW_EYE(25, 70, True)

'DRAW LEFT EYE

DRAW_EYE(75, 70, True)

'DRAW MOUTH

DRAW_MOUTH(32, 30, 1)

Delay(1000) 'DELAY FOR 1 SEC

'CLOSE RIGHT EYE

DRAW_EYE(25, 70, False)

Delay(500) 'WAIT FOR A WHILE

'DRAW RIGHT EYE

DRAW_EYE(25, 70, True)

 

 

 

Most of the codes are from lesson one; the additional codes are the last 6 lines.

 

We can do the same for the mouth.  To make it look like the face is talking we will need to draw different positions of the mouth again and again.

 

To make things a little more interesting, we can make use of a random generator to randomly decide which mouth to draw. The RND function will return a random value every time it is called.  Check the ‘FIDE System Library’ documentation for details of the RND function.

 

 CODE :

 

 POS = RND(3)

 

 

The above code will randomly return a number from 0 to 2.  (Don’t forget to declare POS at the top of your code eg. Dim POS As Integer).

 

 images_SD.png

But, our mouth images for talking are positions 3, 4 and 5.  So we add 3 to get these values.

 

RND_GEN.png

 

 CODE :

 

 POS = RND(3) + 3

 

 

To draw the mouth repeatedly, we use DO LOOP.  Try out the code below.

 

 CODE :

 

Do

       POS = RND(3) + 3

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, POS)

       Delay(300)

Loop

 

 

That is all that you will need to make the GLCD face blink and talk.

 

CODE :

 

Dim POS As Integer

 

'LESSON 2

Public Sub Main()

       OS.GLCD.Init()

       OS.GLCD.Fill(255)

      

       'DRAW RIGHT EYE

       DRAW_EYE(25, 70, True)

       'DRAW LEFT EYE

       DRAW_EYE(75, 70, True)

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, 1)

      

       Delay(1000) 'DELAY FOR 1 SEC

       'CLOSE RIGHT EYE

       DRAW_EYE(25, 70, False)

      

       Delay(500) 'WAIT FOR A WHILE

      

       'DRAW RIGHT EYE

       DRAW_EYE(25, 70, True)

      

       Do

              POS = RND(3) + 3

              'DRAW MOUTH

              DRAW_MOUTH(32, 30, POS)

              Delay(300)

       Loop

End Sub

 


 


Don't understand certain parts? Try starting from Part One Here.

Continue to Part THREE >>>

 

 
Previous Next
Two New Tutorials
Learn how to control a Servo Motor with the FIDE, as well as adding a wireless peer-to-peer communication link using the EBlue Bluetooth Module.
Hoorah! We've Updated!
3 Cheers to a new tutorial, a FIDE patch, and a Language Reference Update!
New Sensor and Documentation Updates

 

We now carry the distance measuring sensor, SHARP GP2D12, WITH the compatible 3pin connector.

In other updates, we have uploaded the technical paper for our GLCD+RTC Combo complete with example configurations to our FlamingICE Boards. 

Our Hardware Reference now stands at version 1.5 with slight changes to the pin-outs on the FI28 Board. 

 

Christmas Updates

Download the latest FIDE v2.1 and get all the updated documentation that comes along with it!

Check out the new goodies that we have over at our updated Products Page!

Resource Page

Now that FIDE 2.0 is up, we published the Resource Page with 2 major tutorials to boot.

Start clicking and head over to check out those tutorials!

FIDE v2.0 RELEASED!

AIS Cube is proud to release the latest and most complete installment to date, FIDE v2.0. Delivering faster feature packed goodness, whats not to love?

Head over to the downloads tab and grab your copy!

FIDE v1.4.2 PATCH

IMPORTANT: Responding to a bug report, the FIDE v1.4.2 PATCH is a patch for a major bug fix in the FIDE SD Tool. Please ensure that you have FIDE v1.4.2 installed before proceeding with the Patch.

Patch is available over on the Downloads Tab.

FIDE v1.4 Released!
More features with the latest release of FIDE at version 1.4. Extended syntax highlighting range, greater support for FIDE system language instructions...
FIDE v1.3 Released!

FIDE v1.3 is now available for download over at the downloads tab. Featuring bug fixes and other features such as an expanded syntax highlighting coverage, it is highly recommended that you upgrade to the newest version.

AVRIL LE BOB

We have a new project named AVRIL LE BOB up over at the projects page (with videos!!). Check it out today!


Copyright © 2007-2008. AIS Cube. All Rights Reserved.
All trade and/or services marks mentioned are the property of their respective owners.
Joomla! is Free Software released under the GNU/GPL License.