CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account

March 21, 2009 by robert Leave a Comment

Mail Light – Part 2 – Software

In part one of this project I created hardware for the Mail Light. The idea behind the Mail Light project is to indicate the presence of emails that are currently on my email server with a flashing LED. This software runs on my PC and drives the hardware I created featured in the last post.

mainwindow

The REALbasic development environment REAL Software is used for this development since it made the email code (pop protocol) very easy.

The goal of the software that I created was to connect to four different email accounts and monitor them for the presence of email. If email was found, a specific LED associated with that account should blink. The LED blinking rate should be changeable, the rate at which the email accounts are polled should be changeable, and the program should hide as a tray icon until needed.

Each of the four accounts has a quarter of the main window with a few text areas for account information. The quarter is pictured below.

quarter-window

Each account has a connect button for enabling that account. When connected, the email account is scanned for email. To the right of the connect button is a visual indicator that will blink in unison with the LED. To the right of that is a text field that shows the number of messages that are on the server of that account.

The box marked “server” should contain the server address. Something like “pop.flintstone.com”. This would need to be the right server for your email account. Below that is the name that you use to log in to your account. It might be “fred” or it might need to be “fred@flintstone.com”. Under that is the box for your password. It is a field that shows up as asterisks. My password happens to be: ******* 🙂

Under the password field is a box that contains the rate, in minutes, that the email address is queried. Below that are two connection status boxes.

The other three email addresses are repeated.

To the lower right of the main window there is a box for the blink rate in 1/100 of a second. A value of 50 is a 1/2 second blink rate. Above that is a button to exit the program.

On the upper right of the main window is a button to hide the main window. A double-click on the program’s tray icon will expose this main window again. Everything keeps running with the main window hidden.

When the program is run, it needs to build up a tray icon and set that tray icon to a graphic (in this case called cg4) that is included with the project:

maillightsopen1

When the program is closed, that icon needs to be removed from the tray:

maillightsclose

The app tray object itself has only the task of making the main window visible when the user double-clicks on the tray icon:

apptray

The hide button on the main window just makes the main window not visible:

hidebutton

When the main form is made visible for the first time that the program is run, the U421 USB interface is discovered and the defaults for the program are loaded. Communication with the U421 is done through a DLL that is opened by REALbasic when the function inside that DLL is defined. The code first declares the three functions needed (and creates a return value for the function call) before using the functions:

maillightswindowopen1

USBm_FindDevices is the first call to USBm.dll. It searches the PC’s USB bus for U401 and U421 devices. In this simplified example code the true/false return code is not used. Non example code would want to process the return values for error. Port A of the U421 is set to output with this call: USBm_DirectionA(0, &HFF, &HFF). The 0 assumes that there is only 1 (indexed to 0) USBmicro device on the bus. If there were more, then additional code would be necessary to address the correct device. See the USBmicro information in the On-line Development Notebook (ODN) for all of the port direction command information.

Once the direction is set to output, all lines are turned off (0) to disable the LEDs:

maillightswindowopen2

After that a file called “maildata.txt” in the same folder/directory as the executable maillight.exe is searched for. Again, in a program other than example code, more code should exist to handle errors such as the file not being found.

The file contains text information that is read into the text boxes in the main window. The first line of the file should contain the server name for Email 1, the second line should have the user name, etc. The last line has the LED blink rate. The comments in the code show the format:

maillightswindowopen3

The file is opened and each line read into appropriate text boxes:

maillightswindowopen4

The LED blink rate is the last of the edit field elements that are loaded on startup by loading this file. Changing the values in the text fields after the file is loaded is also possible by editing those boxes.

Four mail-checking timers, four pop email objects, and the operation of the program will be described in part three of this project.

Filed Under: Uncategorized Tagged With: email, output, programming, REALbasic, u421

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2023 · Generate Pro Theme on Genesis Framework · WordPress · Log in