Added wave handling (approximation of square wave)