Added square wave support. Cleaned up waveform drawing code.