The sample programmes in this directory demonstrate using the GPIO daemon.
-------------------------------------------------------------------------------------
test_pigpio generates square waves of decreasing frequency out of ten GPIO pins
and reads and displays the value from two GPIO pins.

The ten outputs correspond to D0-7 and A0-1 of the clock.

The two inputs correspond with the plus and minus inputs on the clock.


To compile, just run
   make

Before running, you need to stop the clock process and pigpio daemon!
   sudo systemctl stop alarm-clock
   sudo systemctl stop pigpiod

To run, use the following:
   sudo ./test_pigpio

You can then measure the waveforms using a logic analyser or oscilloscope.
If you operate the plus and minus switches on the clock, you'll see the inputs change.

-------------------------------------------------------------------------------------
test_sine_wave_output generates a pseudo sine wave using PWM. It works using the DMA
capabilities of the GPIO daemon to very accurately change PWM ratio at precisely the
right time so that the PWM output follows a sine wave.

If you tried to generate a sine wave without DMA, say using interrupts or some kind of
timing loop, there would be a large amoount of jitter at the PWM edges and that jitter
would create waveform distortion that would sound like squeeling in the tone. DMA is
necessary to eliminate the jitter as much as feasible in hardware so that the sine wave
is accurately reproduced.

If you listen to the output of this sine wave from this programme (after putting through
a low pass filter!) it will sould quite good / acceptible.

To run, compile as above, stop the alarm-clock and pigpio daemons, and then run
   sudo ./test_sine_wave_output

If you have an oscilloscope, its easier to view the output rather than to listen to it.
You will certainly need a simple low pass filter or the PWM will look very unlike a sine
wave.... you can make a simple low pass filter with one 1k resistor and one 0.1 microfarad
capacitor in series. Connect the open leg of the resistor to the GPIO output where the
sine wave PWM will appear, and connect the open leg of the capacitor to ground. Measure the
waveform across the capacitor using a CRO, or amplify the waveform across the capacitor
with an audio amp and listen to it. It will sound OK.
