mirror of https://github.com/probonopd/MiniDexed
* Add class CConfig, which holds the configuration * Add template config file minidexed.ini * Register panic handler in CKernel to allow to display assertions * Fix: Performance timer did not show correct percent value with HDMIpull/37/head
parent
1a68a427de
commit
314196e132
@ -0,0 +1,132 @@ |
||||
//
|
||||
// config.cpp
|
||||
//
|
||||
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
|
||||
// Copyright (C) 2022 The MiniDexed Team
|
||||
//
|
||||
// Original author of this class:
|
||||
// R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
#include "config.h" |
||||
|
||||
CConfig::CConfig (FATFS *pFileSystem) |
||||
: m_Properties ("minidexed.ini", pFileSystem) |
||||
{ |
||||
} |
||||
|
||||
CConfig::~CConfig (void) |
||||
{ |
||||
} |
||||
|
||||
void CConfig::Load (void) |
||||
{ |
||||
m_Properties.Load (); |
||||
|
||||
m_SoundDevice = m_Properties.GetString ("SoundDevice", "pwm"); |
||||
|
||||
m_nSampleRate = m_Properties.GetNumber ("SampleRate", 48000); |
||||
m_nChunkSize = m_Properties.GetNumber ("ChunkSize", m_SoundDevice == "hdmi" ? 384*6 : 256); |
||||
m_nDACI2CAddress = m_Properties.GetNumber ("DACI2CAddress", 0); |
||||
|
||||
m_nMIDIBaudRate = m_Properties.GetNumber ("MIDIBaudRate", 31250); |
||||
|
||||
m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0; |
||||
m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 17); |
||||
m_nLCDPinRegisterSelect = m_Properties.GetNumber ("LCDPinRegisterSelect", 18); |
||||
m_nLCDPinReadWrite = m_Properties.GetNumber ("LCDPinReadWrite", 19); |
||||
m_nLCDPinData4 = m_Properties.GetNumber ("LCDPinData4", 22); |
||||
m_nLCDPinData5 = m_Properties.GetNumber ("LCDPinData5", 23); |
||||
m_nLCDPinData6 = m_Properties.GetNumber ("LCDPinData6", 24); |
||||
m_nLCDPinData7 = m_Properties.GetNumber ("LCDPinData7", 25); |
||||
|
||||
m_bMIDIDumpEnabled = m_Properties.GetNumber ("MIDIDumpEnabled", 0) != 0; |
||||
m_bProfileEnabled = m_Properties.GetNumber ("ProfileEnabled", 0) != 0; |
||||
} |
||||
|
||||
const char *CConfig::GetSoundDevice (void) const |
||||
{ |
||||
return m_SoundDevice.c_str (); |
||||
} |
||||
|
||||
unsigned CConfig::GetSampleRate (void) const |
||||
{ |
||||
return m_nSampleRate; |
||||
} |
||||
|
||||
unsigned CConfig::GetChunkSize (void) const |
||||
{ |
||||
return m_nChunkSize; |
||||
} |
||||
|
||||
unsigned CConfig::GetDACI2CAddress (void) const |
||||
{ |
||||
return m_nDACI2CAddress; |
||||
} |
||||
|
||||
unsigned CConfig::GetMIDIBaudRate (void) const |
||||
{ |
||||
return m_nMIDIBaudRate; |
||||
} |
||||
|
||||
bool CConfig::GetLCDEnabled (void) const |
||||
{ |
||||
return m_bLCDEnabled; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinEnable (void) const |
||||
{ |
||||
return m_nLCDPinEnable; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinRegisterSelect (void) const |
||||
{ |
||||
return m_nLCDPinRegisterSelect; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinReadWrite (void) const |
||||
{ |
||||
return m_nLCDPinReadWrite; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinData4 (void) const |
||||
{ |
||||
return m_nLCDPinData4; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinData5 (void) const |
||||
{ |
||||
return m_nLCDPinData5; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinData6 (void) const |
||||
{ |
||||
return m_nLCDPinData6; |
||||
} |
||||
|
||||
unsigned CConfig::GetLCDPinData7 (void) const |
||||
{ |
||||
return m_nLCDPinData7; |
||||
} |
||||
|
||||
bool CConfig::GetMIDIDumpEnabled (void) const |
||||
{ |
||||
return m_bMIDIDumpEnabled; |
||||
} |
||||
|
||||
bool CConfig::GetProfileEnabled (void) const |
||||
{ |
||||
return m_bProfileEnabled; |
||||
} |
@ -0,0 +1,91 @@ |
||||
//
|
||||
// config.h
|
||||
//
|
||||
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
|
||||
// Copyright (C) 2022 The MiniDexed Team
|
||||
//
|
||||
// Original author of this class:
|
||||
// R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
#ifndef _config_h |
||||
#define _config_h |
||||
|
||||
#include <fatfs/ff.h> |
||||
#include <Properties/propertiesfatfsfile.h> |
||||
#include <string> |
||||
|
||||
class CConfig // Configuration for MiniDexed
|
||||
{ |
||||
public: |
||||
static const unsigned MaxNotes = 16; // polyphony
|
||||
|
||||
static const unsigned LCDColumns = 16; // HD44780 LCD
|
||||
static const unsigned LCDRows = 2; |
||||
|
||||
public: |
||||
CConfig (FATFS *pFileSystem); |
||||
~CConfig (void); |
||||
|
||||
void Load (void); |
||||
|
||||
// Sound device
|
||||
const char *GetSoundDevice (void) const; |
||||
unsigned GetSampleRate (void) const; |
||||
unsigned GetChunkSize (void) const; |
||||
unsigned GetDACI2CAddress (void) const; // 0 for auto probing
|
||||
|
||||
// MIDI
|
||||
unsigned GetMIDIBaudRate (void) const; |
||||
|
||||
// HD44780 LCD
|
||||
// GPIO pin numbers are chip numbers, not header positions
|
||||
bool GetLCDEnabled (void) const; |
||||
unsigned GetLCDPinEnable (void) const; |
||||
unsigned GetLCDPinRegisterSelect (void) const; |
||||
unsigned GetLCDPinReadWrite (void) const; // set to 0 if not connected
|
||||
unsigned GetLCDPinData4 (void) const; |
||||
unsigned GetLCDPinData5 (void) const; |
||||
unsigned GetLCDPinData6 (void) const; |
||||
unsigned GetLCDPinData7 (void) const; |
||||
|
||||
// Debug
|
||||
bool GetMIDIDumpEnabled (void) const; |
||||
bool GetProfileEnabled (void) const; |
||||
|
||||
private: |
||||
CPropertiesFatFsFile m_Properties; |
||||
|
||||
std::string m_SoundDevice; |
||||
unsigned m_nSampleRate; |
||||
unsigned m_nChunkSize; |
||||
unsigned m_nDACI2CAddress; |
||||
|
||||
unsigned m_nMIDIBaudRate; |
||||
|
||||
bool m_bLCDEnabled; |
||||
unsigned m_nLCDPinEnable; |
||||
unsigned m_nLCDPinRegisterSelect; |
||||
unsigned m_nLCDPinReadWrite; |
||||
unsigned m_nLCDPinData4; |
||||
unsigned m_nLCDPinData5; |
||||
unsigned m_nLCDPinData6; |
||||
unsigned m_nLCDPinData7; |
||||
|
||||
bool m_bMIDIDumpEnabled; |
||||
bool m_bProfileEnabled; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,26 @@ |
||||
# |
||||
# minidexed.ini |
||||
# |
||||
|
||||
# Sound device |
||||
SoundDevice=pwm |
||||
SampleRate=48000 |
||||
#ChunkSize=256 |
||||
DACI2CAddress=0 |
||||
|
||||
# MIDI |
||||
MIDIBaudRate=31250 |
||||
|
||||
# HD44780 LCD |
||||
LCDEnabled=1 |
||||
LCDPinEnable=17 |
||||
LCDPinRegisterSelect=18 |
||||
LCDPinReadWrite=19 |
||||
LCDPinData4=22 |
||||
LCDPinData5=23 |
||||
LCDPinData6=24 |
||||
LCDPinData7=25 |
||||
|
||||
# Debug |
||||
MIDIDumpEnabled=1 |
||||
ProfileEnabled=1 |
Loading…
Reference in new issue