From 306a0f6e80aa2386942d5fe70c7eb5969e4d47ea Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sat, 18 Mar 2023 09:39:49 -0400 Subject: [PATCH] add voltage test loop --- src/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f453b2e..e9e51b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ #define MIDI_NOTE_LENGTH 61 #define MAX_DAC_INPUT 4095 // 2^12 - 1 +#define TEST_DELAY 5 // seconds to sleep in the test loop void @@ -74,6 +75,19 @@ loopMIDI(alsa_sequencer* seq, spi_connection* spi) } } +void +loopTestVoltages(spi_connection* spi) +{ + u32 zero_volts = 0; + u32 one_volt = 816; + + for (u32 i = 0;; i++) { + u32 volts = (i % 2 == 0) ? zero_volts : one_volt; + spiSendVoltage(spi, volts); + sleep(TEST_DELAY); + } +} + i32 main(i32 argc, char* argv[]) { @@ -109,7 +123,7 @@ main(i32 argc, char* argv[]) loopMIDI(&seq, &spi); break; case 't': - printf("TODO: cycle test voltages to SPI DAC\n"); + loopTestVoltages(&spi); break; case 'h': default: