Interface and Application Programming
April 6th, 2011
Input Devices Addendum
Because of a time limit last week, here is a small addendum to tell you how to get the programs to work after you programmed the boards.
To get the boards to work I had to plug in the FDTI cable and open the Terminal on my MacBook Pro. Typing "ls /dev" shows a list with devices, one of which has "usbserial" in the name. In my case it was "tty.usbserial-FTF4ZOXA". After you copied that name you can start the Python programs by going to their folders in the terminal and typing "python [name-of-program].py /dev/tty.usbserial-FTF4ZOXA".
The Step-Response Board
For this project I used the step-response board because it seemed to have a lot of potential. My favorite function on this board is the 'touch-screen' ability.
I started by reverse engineering the existing hello.step.45.py program because I had no experience with Python at all. The code seems sort of similar to Java, PHP, SQL etc so I was able to figure out most of it. Google helped me with the rest.
That said, things didn't go as well as I planned and in the end I don't have a lot to show for it. The plan was to use the chip to send the touch-screen value to Python where it would translate into the image of an opening/closing flower, or maybe an erupting vulcano (to keep it in the Icelandic spirits).
I started out by removing all the code I wasn't going to use to help me keep track of things.
After I made sure that everything still worked, I neede to figure out how to load pictures in Python. For this, I used a book on Python (forgot the name) to create a program that loaded a list of images and showed one when you selected it.
View the code
Next, I tried to combine this code with the stripped-down version of the step-response program. This is where the troubles started.
Things where going pretty well in the beginning. I edited the program and gave it a background image while it showed the values from the board in the terminal using the "print" command.
Next, I added an "IF ... ELSE ..." exception so that the picture would change if the value dropped below 400. While this did work to some extend, the program would soon get sluggish and stopped responding after a while. My guess is that the code I wrote kept placing the images on top of each other which resulted in a program that kept making itself more and more CPU and RAM intensive.
This program could possibly be fixed if I where to find a way to remove the pictures after the next one is placed but my inexperience with Python did not help. I think I should write the next program in Flash since I am much more familiar with that code. Unfortunatly I was out of time so the rest will have to come later.
You can view the program I wrote so far: here.