|
| 1 | +// |
| 2 | +// config.cpp |
| 3 | +// |
| 4 | +// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi |
| 5 | +// Copyright (C) 2022 The MiniDexed Team |
| 6 | +// |
| 7 | +// Original author of this class: |
| 8 | + |
| 9 | +// |
| 10 | +// This program is free software: you can redistribute it and/or modify |
| 11 | +// it under the terms of the GNU General Public License as published by |
| 12 | +// the Free Software Foundation, either version 3 of the License, or |
| 13 | +// (at your option) any later version. |
| 14 | +// |
| 15 | +// This program is distributed in the hope that it will be useful, |
| 16 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +// GNU General Public License for more details. |
| 19 | +// |
| 20 | +// You should have received a copy of the GNU General Public License |
| 21 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | +// |
| 23 | +#include "config.h" |
| 24 | + |
| 25 | +CConfig::CConfig (FATFS *pFileSystem) |
| 26 | +: m_Properties ("minidexed.ini", pFileSystem) |
| 27 | +{ |
| 28 | +} |
| 29 | + |
| 30 | +CConfig::~CConfig (void) |
| 31 | +{ |
| 32 | +} |
| 33 | + |
| 34 | +void CConfig::Load (void) |
| 35 | +{ |
| 36 | + m_Properties.Load (); |
| 37 | + |
| 38 | + m_SoundDevice = m_Properties.GetString ("SoundDevice", "pwm"); |
| 39 | + |
| 40 | + m_nSampleRate = m_Properties.GetNumber ("SampleRate", 48000); |
| 41 | + m_nChunkSize = m_Properties.GetNumber ("ChunkSize", m_SoundDevice == "hdmi" ? 384*6 : 256); |
| 42 | + m_nDACI2CAddress = m_Properties.GetNumber ("DACI2CAddress", 0); |
| 43 | + |
| 44 | + m_nMIDIBaudRate = m_Properties.GetNumber ("MIDIBaudRate", 31250); |
| 45 | + |
| 46 | + m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0; |
| 47 | + m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 17); |
| 48 | + m_nLCDPinRegisterSelect = m_Properties.GetNumber ("LCDPinRegisterSelect", 18); |
| 49 | + m_nLCDPinReadWrite = m_Properties.GetNumber ("LCDPinReadWrite", 19); |
| 50 | + m_nLCDPinData4 = m_Properties.GetNumber ("LCDPinData4", 22); |
| 51 | + m_nLCDPinData5 = m_Properties.GetNumber ("LCDPinData5", 23); |
| 52 | + m_nLCDPinData6 = m_Properties.GetNumber ("LCDPinData6", 24); |
| 53 | + m_nLCDPinData7 = m_Properties.GetNumber ("LCDPinData7", 25); |
| 54 | + |
| 55 | + m_bMIDIDumpEnabled = m_Properties.GetNumber ("MIDIDumpEnabled", 0) != 0; |
| 56 | + m_bProfileEnabled = m_Properties.GetNumber ("ProfileEnabled", 0) != 0; |
| 57 | +} |
| 58 | + |
| 59 | +const char *CConfig::GetSoundDevice (void) const |
| 60 | +{ |
| 61 | + return m_SoundDevice.c_str (); |
| 62 | +} |
| 63 | + |
| 64 | +unsigned CConfig::GetSampleRate (void) const |
| 65 | +{ |
| 66 | + return m_nSampleRate; |
| 67 | +} |
| 68 | + |
| 69 | +unsigned CConfig::GetChunkSize (void) const |
| 70 | +{ |
| 71 | + return m_nChunkSize; |
| 72 | +} |
| 73 | + |
| 74 | +unsigned CConfig::GetDACI2CAddress (void) const |
| 75 | +{ |
| 76 | + return m_nDACI2CAddress; |
| 77 | +} |
| 78 | + |
| 79 | +unsigned CConfig::GetMIDIBaudRate (void) const |
| 80 | +{ |
| 81 | + return m_nMIDIBaudRate; |
| 82 | +} |
| 83 | + |
| 84 | +bool CConfig::GetLCDEnabled (void) const |
| 85 | +{ |
| 86 | + return m_bLCDEnabled; |
| 87 | +} |
| 88 | + |
| 89 | +unsigned CConfig::GetLCDPinEnable (void) const |
| 90 | +{ |
| 91 | + return m_nLCDPinEnable; |
| 92 | +} |
| 93 | + |
| 94 | +unsigned CConfig::GetLCDPinRegisterSelect (void) const |
| 95 | +{ |
| 96 | + return m_nLCDPinRegisterSelect; |
| 97 | +} |
| 98 | + |
| 99 | +unsigned CConfig::GetLCDPinReadWrite (void) const |
| 100 | +{ |
| 101 | + return m_nLCDPinReadWrite; |
| 102 | +} |
| 103 | + |
| 104 | +unsigned CConfig::GetLCDPinData4 (void) const |
| 105 | +{ |
| 106 | + return m_nLCDPinData4; |
| 107 | +} |
| 108 | + |
| 109 | +unsigned CConfig::GetLCDPinData5 (void) const |
| 110 | +{ |
| 111 | + return m_nLCDPinData5; |
| 112 | +} |
| 113 | + |
| 114 | +unsigned CConfig::GetLCDPinData6 (void) const |
| 115 | +{ |
| 116 | + return m_nLCDPinData6; |
| 117 | +} |
| 118 | + |
| 119 | +unsigned CConfig::GetLCDPinData7 (void) const |
| 120 | +{ |
| 121 | + return m_nLCDPinData7; |
| 122 | +} |
| 123 | + |
| 124 | +bool CConfig::GetMIDIDumpEnabled (void) const |
| 125 | +{ |
| 126 | + return m_bMIDIDumpEnabled; |
| 127 | +} |
| 128 | + |
| 129 | +bool CConfig::GetProfileEnabled (void) const |
| 130 | +{ |
| 131 | + return m_bProfileEnabled; |
| 132 | +} |
0 commit comments