Example Code

Teasing Homer Simpson

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview: A simple little application which allows you to tease one the greatest TV characters of all time.


Description:

A simple little application which allows you to tease one the greatest TV characters of all time. When you run the vi, the mouse cursor will become a donut and Homer Simpson’s eyes will follow the cursor around the screen.

For a simple, fun, little application, this one does show a number of interesting design features, including…

      -      Custom Controls (Strict Type Defs), allowing a simple Dial Control to mimic Matt Groening's distinctive eye design.

-      Relative File Paths, which allows the application to locate the .cur file correctly when running on machines other than the development PC.

-      Event Driven Programming, for efficient non-polling applications

-      Windows DLL interaction, to programmatically change the cursor object.

-      LabVIEW’s Maths and Trigonometry functions to determine the cursor position from the central (0,0) front panel position.


Requirements: LabVIEW 2012 (or compatible), Windows OS. Hardware: none.


Steps to Implement or Execute Code:
1. Run the VI.
2. Enjoy.
3. Press F10 when tired.


 Additional Information or References: 

  Teasing Homer Simpson FP.png 

Teasing Homer Simpson BD.png

  

To completely unclutter the user interface I have hidden the front panel controls and indictors from view. This includes a few numeric indicators that I used for debugging and a Boolean stop button. However, I have associated the F10 keyboard button with the stop control (done via the properties menu for the stop button), so you can stop programmatically stop the application by hitting the F10 button.

 

If you terminate the application by aborting execution, the mouse cursor would not revert back to the original LabVIEW cursor. Therefore, I have prevented user accessing the abort button by setting the application’s “window appearance” as “dialog box”. You can do this through the vi property menu.

 

The application does break one cardinal rule of good front panel design – I have placed controls on top of an image. This means that every time the control changes, LabVIEW has to redraw the “background” image also. In this particular case, the application is not particularly processor intensive (and the image is fairly low res) so it does not matter – just please be aware that it is not generally good design practice.

More Silliness?

Would you like to antagonize an all together more formidable foe? Try this HAL 9000 example


**This document has been updated to meet the current required format for the NI Code Exchange.** 

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
mr-vizsla
Member
Member
on

Love this... ha ha

Doiron
NI Employee (retired)
on

What a cool program and great explanation! You even noted the controls on picture issue, wow I am impressed, you rock!

With warm regards,

David D.
Not applicable
on

Nice App.

On a side note, you would need LV Full or Pro because there is the Event structure in the VI.

Vincent

pallen
Active Participant
Active Participant
on

Fun app.

....I'm kinda hungry for a donut now though.

---------------------
Patrick Allen: FunctionalityUnlimited.ca
EddieV68
Member
Member
on

Nice.