<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Thu May 23, 2013 5:09 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Thu May 23, 2013 5:09 pm</pubDate>
  <lastBuildDate>Thu May 23, 2013 5:09 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Another Python Freebie, (The EM87 Magic Eye Indicator)...</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=99277#99277</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=58561'&gt;Bazza&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sun May 15, 2011 3:58 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi all...&lt;br /&gt;
&lt;br /&gt;
This is a simple piece of Python code that simulates the EM87/6HU6&lt;br /&gt;
magic aye valve/tube of yesteryear. It is an animation that displays a&lt;br /&gt;
bargraph like in the URL inside the code.&lt;br /&gt;
&lt;br /&gt;
Enjoy finding simple solutions to often very difficult problems... ;o)&lt;br /&gt;
&lt;br /&gt;
This works in Linux AND Windows from a standard Python 3.x.x install.&lt;br /&gt;
&lt;br /&gt;
Watch for wordwrapping etc, etc...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
# MagicEye3x.py&lt;br /&gt;
#&lt;br /&gt;
# A simple animation DEMO to simulate the action of a thermionic tuning indicator valve/tube.&lt;br /&gt;
# The valve/tube type is EM87, 6HU6, CV10407, 6E2 and other equivalent numbers too.&lt;br /&gt;
# http&amp;#58;//www.akh.se/tubes/htm/em87.htm&lt;br /&gt;
#&lt;br /&gt;
# Original copyright, &amp;#40;C&amp;#41;2011, B.Walker, G0LCU.&lt;br /&gt;
# Issued to LXF, 15-05-2011, under the MIT licence...&lt;br /&gt;
#&lt;br /&gt;
# Save the file as MagicEye3x.py in the Lib and/or Modules drawer/directory/folder.&lt;br /&gt;
# To test from a normal Python Command Prompt/Terminal call as......&lt;br /&gt;
#&lt;br /&gt;
# &amp;gt;&amp;gt;&amp;gt; import MagicEye3x&lt;br /&gt;
#&lt;br /&gt;
# ......and away you go and enjoy... ;o&amp;#41;&lt;br /&gt;
#&lt;br /&gt;
# Tested on Windows Vista using Python 3.1.2 and Debian Linux using Python 3.1.2.&lt;br /&gt;
# Also tested on PCLinusOS 2009 using Python 3.1.2... &amp;#40;All are default installs.&amp;#41;&lt;br /&gt;
# This code assumes white foreground and black background colours.&lt;br /&gt;
#&lt;br /&gt;
# With careful thought and viewing between Code Page 850, &amp;#40;Windows Vista onwards&amp;#41;, and Code Page 437,&lt;br /&gt;
# &amp;#40;EFFECTIVELY Linux&amp;#41;, one can pick the &amp;quot;graphics&amp;quot; characters to generate some interesting old style&lt;br /&gt;
# text mode displays on screen.&lt;br /&gt;
#&lt;br /&gt;
# Written in such a way that anyone can understand how it works!&lt;br /&gt;
# This code CAN be simplified quite a lot but it has been left as is...&lt;br /&gt;
#&lt;br /&gt;
# It is useful for quick glance readings from say an 8 bit ADC used as a simple level&lt;br /&gt;
# indicator, for example a tuning and/or level indicator.&lt;br /&gt;
# It is at 5 bit depth.&lt;br /&gt;
#&lt;br /&gt;
# The commands, &amp;quot;CLS&amp;quot; and &amp;quot;clear&amp;quot; are used and assumed to always be available for both platforms...&lt;br /&gt;
&lt;br /&gt;
# Do any imports for this DEMO as required.&lt;br /&gt;
import os&lt;br /&gt;
import sys&lt;br /&gt;
import random&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
# Just for this DEMO set all variables as global.&lt;br /&gt;
global tlc&lt;br /&gt;
global hl&lt;br /&gt;
global trc&lt;br /&gt;
global vl&lt;br /&gt;
global blc&lt;br /&gt;
global brc&lt;br /&gt;
global fullbox&lt;br /&gt;
global shadebox&lt;br /&gt;
global topline&lt;br /&gt;
global magiceye&lt;br /&gt;
global bottomline&lt;br /&gt;
global startgap&lt;br /&gt;
global count&lt;br /&gt;
global grab&lt;br /&gt;
global darkcount&lt;br /&gt;
&lt;br /&gt;
# Set the startup variable values.&lt;br /&gt;
# tlc == Top lefthand corner character.&lt;br /&gt;
# hl == Horizontal line character.&lt;br /&gt;
# trc == Top righthand corner character.&lt;br /&gt;
# vl == Vertical line character.&lt;br /&gt;
# blc == Bottom lefthand corner character.&lt;br /&gt;
# brc == Bottom righthand corner character.&lt;br /&gt;
# fullbox == Full box character.&lt;br /&gt;
# shadebox == Dithered box character.&lt;br /&gt;
# count == A re-usable value for this DEMO.&lt;br /&gt;
# grab == The psuedo-value to display.&lt;br /&gt;
# darkcount == Specific for the shaded &amp;quot;graphics&amp;quot; area only.&lt;br /&gt;
tlc=chr&amp;#40;0x250c&amp;#41;&lt;br /&gt;
hl=chr&amp;#40;0x2500&amp;#41;&lt;br /&gt;
trc=chr&amp;#40;0x2510&amp;#41;&lt;br /&gt;
vl=chr&amp;#40;0x2502&amp;#41;&lt;br /&gt;
blc=chr&amp;#40;0x2514&amp;#41;&lt;br /&gt;
brc=chr&amp;#40;0x2518&amp;#41;&lt;br /&gt;
fullbox=chr&amp;#40;0x2588&amp;#41;&lt;br /&gt;
shadebox=chr&amp;#40;0x2592&amp;#41;&lt;br /&gt;
topline=tlc&lt;br /&gt;
magiceye=&amp;quot;&amp;#40;C&amp;#41;2011, B.Walker, G0LCU.&amp;quot;&lt;br /&gt;
bottomline=blc&lt;br /&gt;
startgap=&amp;quot;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;&lt;br /&gt;
count=0&lt;br /&gt;
grab=255&lt;br /&gt;
darkcount=0&lt;br /&gt;
&lt;br /&gt;
# Run continuously until the Ctrl-C keys are pressed.&lt;br /&gt;
def main&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;while 1&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Set the platform clear screen command for Linux and Windows.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if sys.platform==&amp;quot;win32&amp;quot;&amp;#58; print&amp;#40;os.system&amp;#40;&amp;quot;CLS&amp;quot;&amp;#41;,chr&amp;#40;13&amp;#41;,&amp;quot;&amp;nbsp; &amp;quot;,chr&amp;#40;13&amp;#41;,&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if sys.platform==&amp;quot;linux2&amp;quot;&amp;#58; print&amp;#40;os.system&amp;#40;&amp;quot;clear&amp;quot;&amp;#41;,chr&amp;#40;13&amp;#41;,&amp;quot;&amp;nbsp; &amp;quot;,chr&amp;#40;13&amp;#41;,&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Randomly generate an 8 bit value as though grabbed from a serial, parallel or USB port.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;grab=int&amp;#40;random.random&amp;#40;&amp;#41;*256&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Set to a 5 bit value for the DEMO.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;grab=int&amp;#40;grab/8&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Although no error should ever occur, never allow one.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if grab&amp;lt;=0&amp;#58; grab=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if grab&amp;gt;=31&amp;#58; grab=31&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Set up the screen per grab.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;A simple pseudo-EM87/6HU6/6E2 tuning indicator style DEMO for standard Python.&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;Original working idea copyright, &amp;#40;C&amp;#41;2011, B.Walker, G0LCU.&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;Designed to work on MS Windows, &amp;#40;Vista 32 Bit&amp;#41;, using Python 3.x.x.&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;Also at least Debian Linux using Python 3.x.x too...&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EM87/6HU6 simulator.&amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Generate the first line of the MagicEye display.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;topline=startgap+tlc&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while count&amp;lt;=61&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;topline=topline+hl&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=count+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;topline=topline+trc&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;topline&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Now generate the MagicEye start only if the grabbed value is GREATER than 0.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if grab&amp;gt;=1&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Do the left hand side very bright part first.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=startgap+vl&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while count&amp;lt;=grab&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=magiceye+fullbox&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=count+1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Now generate the dark centre section.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=grab&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;darkcount=61-&amp;#40;grab*2&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while darkcount&amp;gt;=0&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=magiceye+shadebox&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;darkcount=darkcount-1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Finally finish off with another very bright part.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;darkcount=61-&amp;#40;grab*2&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=darkcount+grab+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while count&amp;lt;=61&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=magiceye+fullbox&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=count+1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# When the grab value equals 0 override the above and generate a full dark band only.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if grab==0&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=startgap+vl&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while count&amp;lt;=61&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;magiceye=magiceye+shadebox&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=count+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Print the animation to the screen and end with a vertical line.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;magiceye+vl&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Now finish off the MagicEye display...&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;bottomline=startgap+blc&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while count&amp;lt;=61&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;bottomline=bottomline+hl&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;count=count+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;bottomline=bottomline+brc&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;bottomline&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Finish the screen display.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;Grabbed value&amp;quot;,grab,&amp;quot;\b...&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;Press Ctrl-C to STOP...&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Add a short delay for this DEMO...&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;time.sleep&amp;#40;0.1&amp;#41;&lt;br /&gt;
&lt;br /&gt;
main&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# End of MagicEye3x.py DEMO.&lt;br /&gt;
# Enjoy finding simple solutions to often very difficult problems. &amp;#58;&amp;#41;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
A version for Python 2.5.x and above is up here:-&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://code.activestate.com/recipes/577695-an-em876hu6-magic-eye-valvetube-animation-demo/?in=lang-python&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://code.activestate.com/recipes/577695-an-em876hu6-magic-eye-valvetube-animation-demo/?in=lang-python&lt;/a&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=99277#99277</comments>
                                        <author>Bazza</author>
                                        <pubDate>Sun May 15, 2011 3:58 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=99277#99277</guid>
                                      </item></channel></rss>