From cd7f8e3feff7c4b7399825fcc0b7a12f886bc3d8 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 12 Jun 2018 11:17:52 +1000 Subject: [PATCH 1/2] added soundOnGPIOCounter soundOnGPIOFreq to options.txt --- src/main.cpp | 5 +++-- src/options.cpp | 4 ++++ src/options.h | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2b18c59..6a92a88 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -721,7 +721,8 @@ void emulator() int headSoundFreqCounter = 0; //const int headSoundFreq = 3333; // 300Hz = 1/300 * 10^6; //const int headSoundFreq = 1666; // 600Hz = 1/600 * 10^6; - const int headSoundFreq = 833; // 1200Hz = 1/1200 * 10^6; +// const int headSoundFreq = 833; // 1200Hz = 1/1200 * 10^6; + const int headSoundFreq = options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6; unsigned char oldHeadDir; unsigned numberOfImages = diskCaddy.GetNumberOfImages(); @@ -801,7 +802,7 @@ void emulator() oldHeadDir = headDir; if (options.SoundOnGPIO()) { - headSoundCounter = 1000000; + headSoundCounter = options.SoundOnGPIOCounter(); headSoundFreqCounter = headSoundFreq; } else diff --git a/src/options.cpp b/src/options.cpp index bb980da..809ae94 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -129,6 +129,8 @@ Options::Options(void) , quickBoot(0) , displayPNGIcons(0) , soundOnGPIO(0) + , soundOnGPIOCounter(1000000) + , soundOnGPIOFreq(833) , invertIECInputs(0) , invertIECOutputs(1) , splitIECLines(0) @@ -183,6 +185,8 @@ void Options::Process(char* buffer) ELSE_CHECK_DECIMAL_OPTION(quickBoot) ELSE_CHECK_DECIMAL_OPTION(displayPNGIcons) ELSE_CHECK_DECIMAL_OPTION(soundOnGPIO) + ELSE_CHECK_DECIMAL_OPTION(soundOnGPIOCounter) + ELSE_CHECK_DECIMAL_OPTION(soundOnGPIOFreq) ELSE_CHECK_DECIMAL_OPTION(invertIECInputs) ELSE_CHECK_DECIMAL_OPTION(invertIECOutputs) ELSE_CHECK_DECIMAL_OPTION(splitIECLines) diff --git a/src/options.h b/src/options.h index 2cd6d37..baf9f88 100644 --- a/src/options.h +++ b/src/options.h @@ -58,6 +58,8 @@ public: inline unsigned int QuickBoot() const { return quickBoot; } inline unsigned int DisplayPNGIcons() const { return displayPNGIcons; } inline unsigned int SoundOnGPIO() const { return soundOnGPIO; } + inline unsigned int SoundOnGPIOCounter() const { return soundOnGPIOCounter; } + inline unsigned int SoundOnGPIOFreq() const { return soundOnGPIOFreq; } inline unsigned int SplitIECLines() const { return splitIECLines; } inline unsigned int InvertIECInputs() const { return invertIECInputs; } inline unsigned int InvertIECOutputs() const { return invertIECOutputs; } @@ -88,6 +90,8 @@ private: unsigned int quickBoot; unsigned int displayPNGIcons; unsigned int soundOnGPIO; + unsigned int soundOnGPIOCounter; + unsigned int soundOnGPIOFreq; unsigned int invertIECInputs; unsigned int invertIECOutputs; unsigned int splitIECLines; From e05d6b0f2826721d38b9f665617e2063d12c45cf Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 12 Jun 2018 21:39:08 +1000 Subject: [PATCH 2/2] Updated gpio sound options soundOnGPIODuration = 1000 // in mSecs (1000 = 1 second) soundOnGPIOFreq = 1200 // in Hz as it should be --- src/main.cpp | 6 ++---- src/options.cpp | 6 +++--- src/options.h | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6a92a88..89916e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -719,10 +719,8 @@ void emulator() unsigned caddyIndex; int headSoundCounter = 0; int headSoundFreqCounter = 0; - //const int headSoundFreq = 3333; // 300Hz = 1/300 * 10^6; - //const int headSoundFreq = 1666; // 600Hz = 1/600 * 10^6; // const int headSoundFreq = 833; // 1200Hz = 1/1200 * 10^6; - const int headSoundFreq = options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6; + const int headSoundFreq = 1000000 / options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6; unsigned char oldHeadDir; unsigned numberOfImages = diskCaddy.GetNumberOfImages(); @@ -802,7 +800,7 @@ void emulator() oldHeadDir = headDir; if (options.SoundOnGPIO()) { - headSoundCounter = options.SoundOnGPIOCounter(); + headSoundCounter = 1000 * options.SoundOnGPIODuration(); headSoundFreqCounter = headSoundFreq; } else diff --git a/src/options.cpp b/src/options.cpp index 809ae94..82b075a 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -129,8 +129,8 @@ Options::Options(void) , quickBoot(0) , displayPNGIcons(0) , soundOnGPIO(0) - , soundOnGPIOCounter(1000000) - , soundOnGPIOFreq(833) + , soundOnGPIODuration(1000) + , soundOnGPIOFreq(1200) , invertIECInputs(0) , invertIECOutputs(1) , splitIECLines(0) @@ -185,7 +185,7 @@ void Options::Process(char* buffer) ELSE_CHECK_DECIMAL_OPTION(quickBoot) ELSE_CHECK_DECIMAL_OPTION(displayPNGIcons) ELSE_CHECK_DECIMAL_OPTION(soundOnGPIO) - ELSE_CHECK_DECIMAL_OPTION(soundOnGPIOCounter) + ELSE_CHECK_DECIMAL_OPTION(soundOnGPIODuration) ELSE_CHECK_DECIMAL_OPTION(soundOnGPIOFreq) ELSE_CHECK_DECIMAL_OPTION(invertIECInputs) ELSE_CHECK_DECIMAL_OPTION(invertIECOutputs) diff --git a/src/options.h b/src/options.h index baf9f88..6c159c3 100644 --- a/src/options.h +++ b/src/options.h @@ -58,7 +58,7 @@ public: inline unsigned int QuickBoot() const { return quickBoot; } inline unsigned int DisplayPNGIcons() const { return displayPNGIcons; } inline unsigned int SoundOnGPIO() const { return soundOnGPIO; } - inline unsigned int SoundOnGPIOCounter() const { return soundOnGPIOCounter; } + inline unsigned int SoundOnGPIODuration() const { return soundOnGPIODuration; } inline unsigned int SoundOnGPIOFreq() const { return soundOnGPIOFreq; } inline unsigned int SplitIECLines() const { return splitIECLines; } inline unsigned int InvertIECInputs() const { return invertIECInputs; } @@ -90,7 +90,7 @@ private: unsigned int quickBoot; unsigned int displayPNGIcons; unsigned int soundOnGPIO; - unsigned int soundOnGPIOCounter; + unsigned int soundOnGPIODuration; unsigned int soundOnGPIOFreq; unsigned int invertIECInputs; unsigned int invertIECOutputs;