Status of Ledborg

Forums:

Hi , I am new to Ledborg and python , and wondering is there a way to check on the status of the Ledborg.

Just after a way to echo back to the terminal what value the ledborg is at.

For example if the LedBorg is showing a red light value "200" is there a way to return to print a line back to the terminal saying the colour showing is red ?

Thank You

piborg's picture

This should be nice and simple, below are examples for Python and the Linux terminal.

From Python:
LedBorg = open('/dev/ledborg', 'r')
colour = LedBorg.read()
LedBorg.close()
print colour

Directly from a terminal window:
cat /dev/ledborg

This should return the code number (e.g. 200), if you want to return a colour name you will need some kind of decode of the colour number back to a name from python, e.g.
LedBorg = open('/dev/ledborg', 'r')
colour = LedBorg.read()
LedBorg.close()
if colour == "200":
    name = "Red"
elif colour == "222":
    name = "White"
else:
    name = "?"
print name
or
colourNames = {
    "200":"Red",
    "222":"White"
}
LedBorg = open('/dev/ledborg', 'r')
colour = LedBorg.read()
LedBorg.close()
if colourNames.has_key(colour):
    name =colourNames[colour]
else:
    name = "?"
print name

Hopefully that helps you :)
piborg's picture

Just in case you still want help with this, we put out a Mecha Monday script today for this purpose
WhatIsYourColour.py

Subscribe to Comments for "Status of Ledborg"