Source code for adafruit_waveform.square

# SPDX-FileCopyrightText: 2017 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""
`adafruit_waveform.square`
====================================================

This library generates squard waveforms that can be used to generate
squard audio signals.

* Author(s): Scott Shawcroft, BrentRu
"""

import array

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Waveform.git"


[docs]def square_wave(sample_length=2): """Generate a single square wave of sample_length size""" square = array.array("H", [0] * sample_length) for i in range(sample_length // 2): square[i] = 0xFFFF return square