Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Another Python Freebie, (The EM87 Magic Eye Indicator)...

Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
LXF regular

Joined: Sat Mar 21, 2009 11:16 am
Posts: 1476
Location: Loughborough

PostPosted: Sun May 15, 2011 3:58 pm    Post subject: Another Python Freebie, (The EM87 Magic Eye Indicator)... Reply with quote

Hi all...

This is a simple piece of Python code that simulates the EM87/6HU6
magic aye valve/tube of yesteryear. It is an animation that displays a
bargraph like in the URL inside the code.

Enjoy finding simple solutions to often very difficult problems... ;o)

This works in Linux AND Windows from a standard Python 3.x.x install.

Watch for wordwrapping etc, etc...


# A simple animation DEMO to simulate the action of a thermionic tuning indicator valve/tube.
# The valve/tube type is EM87, 6HU6, CV10407, 6E2 and other equivalent numbers too.
# Original copyright, (C)2011, B.Walker, G0LCU.
# Issued to LXF, 15-05-2011, under the MIT licence...
# Save the file as in the Lib and/or Modules drawer/directory/folder.
# To test from a normal Python Command Prompt/Terminal call as......
# >>> import MagicEye3x
# ......and away you go and enjoy... ;o)
# Tested on Windows Vista using Python 3.1.2 and Debian Linux using Python 3.1.2.
# Also tested on PCLinusOS 2009 using Python 3.1.2... (All are default installs.)
# This code assumes white foreground and black background colours.
# With careful thought and viewing between Code Page 850, (Windows Vista onwards), and Code Page 437,
# (EFFECTIVELY Linux), one can pick the "graphics" characters to generate some interesting old style
# text mode displays on screen.
# Written in such a way that anyone can understand how it works!
# This code CAN be simplified quite a lot but it has been left as is...
# It is useful for quick glance readings from say an 8 bit ADC used as a simple level
# indicator, for example a tuning and/or level indicator.
# It is at 5 bit depth.
# The commands, "CLS" and "clear" are used and assumed to always be available for both platforms...

# Do any imports for this DEMO as required.
import os
import sys
import random
import time

# Just for this DEMO set all variables as global.
global tlc
global hl
global trc
global vl
global blc
global brc
global fullbox
global shadebox
global topline
global magiceye
global bottomline
global startgap
global count
global grab
global darkcount

# Set the startup variable values.
# tlc == Top lefthand corner character.
# hl == Horizontal line character.
# trc == Top righthand corner character.
# vl == Vertical line character.
# blc == Bottom lefthand corner character.
# brc == Bottom righthand corner character.
# fullbox == Full box character.
# shadebox == Dithered box character.
# count == A re-usable value for this DEMO.
# grab == The psuedo-value to display.
# darkcount == Specific for the shaded "graphics" area only.
magiceye="(C)2011, B.Walker, G0LCU."
startgap="        "

# Run continuously until the Ctrl-C keys are pressed.
def main():
   while 1:
      # Set the platform clear screen command for Linux and Windows.
      if sys.platform=="win32": print(os.system("CLS"),chr(13),"  ",chr(13),)
      if sys.platform=="linux2": print(os.system("clear"),chr(13),"  ",chr(13),)

      # Randomly generate an 8 bit value as though grabbed from a serial, parallel or USB port.
      # Set to a 5 bit value for the DEMO.
      # Although no error should ever occur, never allow one.
      if grab<=0: grab=0
      if grab>=31: grab=31

      # Set up the screen per grab.
      print("A simple pseudo-EM87/6HU6/6E2 tuning indicator style DEMO for standard Python.")
      print("Original working idea copyright, (C)2011, B.Walker, G0LCU.")
      print("Designed to work on MS Windows, (Vista 32 Bit), using Python 3.x.x.")
      print("Also at least Debian Linux using Python 3.x.x too...")
      print("                               EM87/6HU6 simulator.")

      # Generate the first line of the MagicEye display.
      while count<=61:

      # Now generate the MagicEye start only if the grabbed value is GREATER than 0.
      if grab>=1:
         # Do the left hand side very bright part first.
         while count<=grab:

         # Now generate the dark centre section.
         while darkcount>=0:

         # Finally finish off with another very bright part.
         while count<=61:

      # When the grab value equals 0 override the above and generate a full dark band only.
      if grab==0:
         while count<=61:
      # Print the animation to the screen and end with a vertical line.

      # Now finish off the MagicEye display...
      while count<=61:

      # Finish the screen display.
      print("Grabbed value",grab,"\b...")
      print("Press Ctrl-C to STOP...")

      # Add a short delay for this DEMO...


# End of DEMO.
# Enjoy finding simple solutions to often very difficult problems. :)

A version for Python 2.5.x and above is up here:-

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 

Powered by phpBB © 2001, 2005 phpBB Group

Copyright 2011 Future Publishing, all rights reserved.

Web hosting by UKFast