Oscilloscope Display

Bitmap Oscilloscope

After drawing basic shapes on the oscilloscope (circles, lines, and rectangles), I decided to try something more adventurous: bitmaps. Since the soundcard outputs no more than 192,000 samples per second and the oscilloscope doesn't retain data for much longer than 1/60th of a second, I knew that only small images would work.

First, I needed to read images. The Python Imaging Library does an admirable job (and is free!). It works with most formats, and is capable of reading layered images (animation, for the layman). Most of my test images were GIF files, which posed a problem: GIF's are indexed. In an indexed image, each pixel has only a single value, rather than the usual three (red, green, and blue). The GIF includes a lookup table for translating that value into a color. Unfortunately, PIL doesn't include any way of running those numbers through the lookup table. Fortunately, it allows conversion to a normal RGB image.


I've seen people attaching microcontrollers to 2-channel oscilloscopes to draw pretty patterns. It looked cool, so I decided to try it myself. One problem: I don't know heads from tails when it comes to microcontrollers. I can, however, program. And my computer has a sound card, capable of producing two channels of 8-bit wrath.

The process was actually beautifully sequential. I'll spare you the details of how I found a library - suffice it to say that PyAudio allows for injection of sound into a stream and reached maturity. I reverse-engineered the sound format using some of the sample recipes provided. PyAudio's streams store and read sound from an ASCII string. Initially, I assumed that the transform was based on chr(), where chr(0) corresponded to 0 volts, and chr(255) reflected maximum volume. I was wrong.