Skip to content

Commit 8ba9c8a

Browse files
committed
General code cleanup
Rename enums, functions parameters and class member variables so that they match the Circle coding style more closely. Replace /* ... */ comments with // comments. Fixup some indentation issues/trailing whitespace. Remove undefined functions and unused #defines.
1 parent 3ddd9ac commit 8ba9c8a

20 files changed

+570
-576
lines changed

include/config.def

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@
1414
#endif
1515

1616
BEGIN_SECTION(midi)
17-
CFG(usb, bool, mMIDIUSB, true )
18-
CFG(gpio_baud_rate, int, mMIDIGPIOBaudRate, 31250 )
19-
CFG(gpio_thru, bool, mMIDIGPIOThru, false )
17+
CFG(usb, bool, m_bMIDIUSB, true )
18+
CFG(gpio_baud_rate, int, m_nMIDIGPIOBaudRate, 31250 )
19+
CFG(gpio_thru, bool, m_bMIDIGPIOThru, false )
2020
END_SECTION
2121

2222
BEGIN_SECTION(audio)
23-
CFG(output_device, AudioOutputDevice, mAudioOutputDevice, AudioOutputDevice::PWM )
24-
CFG(sample_rate, int, mAudioSampleRate, 96000 )
25-
CFG(chunk_size, int, mAudioChunkSize, 512 )
26-
CFG(i2c_dac_address, int, mAudioI2CDACAddress, 0x4c, true )
27-
CFG(i2c_dac_init, AudioI2CDACInit, mAudioI2CDACInit, AudioI2CDACInit::PCM51xx )
23+
CFG(output_device, TAudioOutputDevice, m_AudioOutputDevice, TAudioOutputDevice::PWM )
24+
CFG(sample_rate, int, m_nAudioSampleRate, 96000 )
25+
CFG(chunk_size, int, m_nAudioChunkSize, 512 )
26+
CFG(i2c_dac_address, int, m_nAudioI2CDACAddress, 0x4c, true )
27+
CFG(i2c_dac_init, TAudioI2CDACInit, m_AudioI2CDACInit, TAudioI2CDACInit::PCM51xx )
2828
END_SECTION
2929

3030
BEGIN_SECTION(mt32emu)
31-
CFG(resampler_quality, MT32EmuResamplerQuality, mMT32EmuResamplerQuality, MT32EmuResamplerQuality::Good )
32-
CFG(midi_channels, MT32EmuMIDIChannels, mMT32EmuMIDIChannels, MT32EmuMIDIChannels::Standard )
33-
CFG(rom_set, MT32EmuROMSet, mMT32EmuROMSet, MT32EmuROMSet::MT32Old )
31+
CFG(resampler_quality, TMT32EmuResamplerQuality, m_MT32EmuResamplerQuality, TMT32EmuResamplerQuality::Good )
32+
CFG(midi_channels, TMT32EmuMIDIChannels, m_MT32EmuMIDIChannels, TMT32EmuMIDIChannels::Standard )
33+
CFG(rom_set, TMT32EmuROMSet, m_MT32EmuROMSet, TMT32EmuROMSet::MT32Old )
3434
END_SECTION
3535

3636
BEGIN_SECTION(lcd)
37-
CFG(type, LCDType, mLCDType, LCDType::None )
38-
CFG(width, int, mLCDWidth, 20 )
39-
CFG(height, int, mLCDHeight, 2 )
40-
CFG(i2c_lcd_address, int, mLCDI2CLCDAddress, 0x3c, true )
37+
CFG(type, TLCDType, m_LCDType, TLCDType::None )
38+
CFG(width, int, m_nLCDWidth, 20 )
39+
CFG(height, int, m_nLCDHeight, 2 )
40+
CFG(i2c_lcd_address, int, m_nLCDI2CLCDAddress, 0x3c, true )
4141
END_SECTION
4242

4343
#undef BEGIN_SECTION

include/config.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ class CConfig
3434

3535
#define ENUM_AUDIOI2CDACINIT(ENUM) ENUM(PCM51xx, pcm51xx)
3636

37-
using MT32EmuResamplerQuality = CMT32SynthBase::ResamplerQuality;
38-
using MT32EmuMIDIChannels = CMT32SynthBase::MIDIChannels;
39-
using MT32EmuROMSet = CROMManager::TROMSet;
37+
using TMT32EmuResamplerQuality = CMT32SynthBase::TResamplerQuality;
38+
using TMT32EmuMIDIChannels = CMT32SynthBase::TMIDIChannels;
39+
using TMT32EmuROMSet = CROMManager::TROMSet;
4040

4141
#define ENUM_LCDTYPE(ENUM) \
4242
ENUM(None, none) \
4343
ENUM(HD44780FourBit, hd44780_4bit) \
4444
ENUM(HD44780I2C, hd44780_i2c) \
4545
ENUM(SSD1306I2C, ssd1306_i2c)
4646

47-
CONFIG_ENUM(AudioOutputDevice, ENUM_AUDIOOUTPUTDEVICE);
48-
CONFIG_ENUM(AudioI2CDACInit, ENUM_AUDIOI2CDACINIT);
49-
CONFIG_ENUM(LCDType, ENUM_LCDTYPE);
47+
CONFIG_ENUM(TAudioOutputDevice, ENUM_AUDIOOUTPUTDEVICE);
48+
CONFIG_ENUM(TAudioI2CDACInit, ENUM_AUDIOI2CDACINIT);
49+
CONFIG_ENUM(TLCDType, ENUM_LCDTYPE);
5050

5151
CConfig();
5252
bool Initialize(const char* pPath);
5353

54-
static CConfig* Get() { return pThis; }
54+
static CConfig* Get() { return s_pThis; }
5555

5656
// Expand all config variables from definition file
5757
#define CFG(_1, TYPE, MEMBER_NAME, _2, _3...) TYPE MEMBER_NAME;
@@ -62,15 +62,15 @@ class CConfig
6262

6363
// Overloaded function to parse config options based on their types specified in the definition file
6464
static bool ParseOption(const char* pString, bool* pOut);
65-
static bool ParseOption(const char* pString, int* pOut, bool pHex = false);
66-
static bool ParseOption(const char* pString, AudioOutputDevice* pOut);
67-
static bool ParseOption(const char* pString, AudioI2CDACInit* pOut);
68-
static bool ParseOption(const char* pString, MT32EmuResamplerQuality* pOut);
69-
static bool ParseOption(const char* pString, MT32EmuMIDIChannels* pOut);
70-
static bool ParseOption(const char* pString, MT32EmuROMSet* pOut);
71-
static bool ParseOption(const char* pString, LCDType* pOut);
65+
static bool ParseOption(const char* pString, int* pOut, bool bHex = false);
66+
static bool ParseOption(const char* pString, TAudioOutputDevice* pOut);
67+
static bool ParseOption(const char* pString, TAudioI2CDACInit* pOut);
68+
static bool ParseOption(const char* pString, TMT32EmuResamplerQuality* pOut);
69+
static bool ParseOption(const char* pString, TMT32EmuMIDIChannels* pOut);
70+
static bool ParseOption(const char* pString, TMT32EmuROMSet* pOut);
71+
static bool ParseOption(const char* pString, TLCDType* pOut);
7272

73-
static CConfig* pThis;
73+
static CConfig* s_pThis;
7474
};
7575

7676
#endif

include/kernel.h

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,60 +41,59 @@ class CKernel : public CStdlibApp, CMIDIParser
4141
TShutdownMode Run(void);
4242

4343
protected:
44-
CCPUThrottle mCPUThrottle;
45-
CNullDevice mNull;
46-
CSerialDevice mSerial;
44+
CCPUThrottle m_CPUThrottle;
45+
CNullDevice m_Null;
46+
CSerialDevice m_Serial;
4747
#ifdef HDMI_CONSOLE
48-
CScreenDevice mScreen;
48+
CScreenDevice m_Screen;
4949
#endif
50-
CTimer mTimer;
51-
CLogger mLogger;
52-
CScheduler mScheduler;
53-
CUSBHCIDevice mUSBHCI;
54-
CEMMCDevice mEMMC;
55-
FATFS mFileSystem;
50+
CTimer m_Timer;
51+
CLogger m_Logger;
52+
CScheduler m_Scheduler;
53+
CUSBHCIDevice m_USBHCI;
54+
CEMMCDevice m_EMMC;
55+
FATFS m_FileSystem;
5656

57-
CI2CMaster mI2CMaster;
58-
CMT32LCD* mLCD;
57+
CI2CMaster m_I2CMaster;
58+
CMT32LCD* m_pLCD;
5959

6060
private:
61-
bool InitPCM51xx(u8 pAddress);
61+
bool InitPCM51xx(u8 nAddress);
6262

6363
// CMIDIParser
64-
virtual void OnShortMessage(u32 pMessage) override;
65-
virtual void OnSysExMessage(const u8* pData, size_t pSize) override;
64+
virtual void OnShortMessage(u32 nMessage) override;
65+
virtual void OnSysExMessage(const u8* pData, size_t nSize) override;
6666
virtual void OnUnexpectedStatus() override;
6767
virtual void OnSysExOverflow() override;
6868

69-
bool ParseCustomSysEx(const u8* pData, size_t pSize);
69+
bool ParseCustomSysEx(const u8* pData, size_t nSize);
7070
void UpdateSerialMIDI();
7171

7272
void LEDOn();
7373
void LCDLog(const char* pMessage);
7474

7575
// Configuration
76-
CConfig mConfig;
76+
CConfig m_Config;
7777

78-
unsigned mLCDLogTime;
79-
unsigned mLCDUpdateTime;
78+
unsigned m_nLCDLogTime;
79+
unsigned m_nLCDUpdateTime;
8080

8181
// Serial GPIO MIDI
82-
bool mSerialMIDIEnabled;
82+
bool m_bSerialMIDIEnabled;
8383

84-
bool mActiveSenseFlag;
85-
unsigned mActiveSenseTime;
84+
bool m_bActiveSenseFlag;
85+
unsigned m_nActiveSenseTime;
8686

87-
bool mShouldReboot;
88-
bool mLEDOn;
89-
unsigned mLEDOnTime;
87+
bool m_bShouldReboot;
88+
bool m_bLEDOn;
89+
unsigned m_nLEDOnTime;
9090

9191
// Synthesizer
92-
CMT32SynthBase* mSynth;
92+
CMT32SynthBase* m_pSynth;
9393

94-
static void USBMIDIPacketHandler(unsigned nCable, u8 *pPacket, unsigned nLength);
95-
static void ProgramChangedHander(u8 pPartNum, const char* pSoundGroupName, const char* pPatchName);
96-
static void LCDMessageHandler(const char* pMessage);
97-
static CKernel *pThis;
94+
static void USBMIDIPacketHandler(unsigned nCable, u8* pPacket, unsigned nLength);
95+
96+
static CKernel* s_pThis;
9897
};
9998

10099
#endif

include/lcd/hd44780.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class CHD44780Base : public CMT32LCD
4444
virtual void Update(const CMT32SynthBase& Synth) override;
4545

4646
protected:
47-
enum class WriteMode
47+
enum class TWriteMode
4848
{
4949
Data,
5050
Command
5151
};
5252

53-
virtual void WriteNybble(u8 nNybble, WriteMode Mode) = 0;
54-
void WriteByte(u8 nByte, WriteMode Mode);
53+
virtual void WriteNybble(u8 nNybble, TWriteMode Mode) = 0;
54+
void WriteByte(u8 nByte, TWriteMode Mode);
5555

5656
void WriteCommand(u8 nByte);
5757
void WriteData(u8 nByte);
@@ -62,9 +62,9 @@ class CHD44780Base : public CMT32LCD
6262
void DrawPartLevelsSingle(u8 nRow);
6363
void DrawPartLevelsDouble(u8 nFirstRow);
6464

65-
CScheduler* mScheduler;
66-
u8 mRows;
67-
u8 mColumns;
65+
CScheduler* m_pScheduler;
66+
u8 m_nRows;
67+
u8 m_nColumns;
6868

6969
static const u8 CustomCharData[7][8];
7070
static const char BarChars[9];
@@ -76,7 +76,7 @@ class CHD44780FourBit : public CHD44780Base
7676
CHD44780FourBit(u8 nColumns = 20, u8 nRows = 2);
7777

7878
protected:
79-
virtual void WriteNybble(u8 nNybble, WriteMode Mode) override;
79+
virtual void WriteNybble(u8 nNybble, TWriteMode Mode) override;
8080

8181
static constexpr u8 GPIO_PIN_RS = 10;
8282
static constexpr u8 GPIO_PIN_RW = 9;
@@ -86,13 +86,13 @@ class CHD44780FourBit : public CHD44780Base
8686
static constexpr u8 GPIO_PIN_D6 = 6;
8787
static constexpr u8 GPIO_PIN_D7 = 13;
8888

89-
CGPIOPin mRS;
90-
CGPIOPin mRW;
91-
CGPIOPin mEN;
92-
CGPIOPin mD4;
93-
CGPIOPin mD5;
94-
CGPIOPin mD6;
95-
CGPIOPin mD7;
89+
CGPIOPin m_RS;
90+
CGPIOPin m_RW;
91+
CGPIOPin m_EN;
92+
CGPIOPin m_D4;
93+
CGPIOPin m_D5;
94+
CGPIOPin m_D6;
95+
CGPIOPin m_D7;
9696
};
9797

9898
class CHD44780I2C : public CHD44780Base
@@ -101,10 +101,10 @@ class CHD44780I2C : public CHD44780Base
101101
CHD44780I2C(CI2CMaster* pI2CMaster, u8 nAddress = 0x27, u8 nColumns = 20, u8 nRows = 2);
102102

103103
protected:
104-
virtual void WriteNybble(u8 nNybble, WriteMode Mode) override;
104+
virtual void WriteNybble(u8 nNybble, TWriteMode Mode) override;
105105

106-
CI2CMaster* mI2CMaster;
107-
u8 mAddress;
106+
CI2CMaster* m_pI2CMaster;
107+
u8 m_nAddress;
108108
};
109109

110110
#endif

include/lcd/mt32lcd.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CMT32SynthBase;
3030
class CMT32LCD : public CCharacterLCD
3131
{
3232
public:
33-
enum class State
33+
enum class TState
3434
{
3535
DisplayingPartStates,
3636
DisplayingTimbreName,
@@ -55,18 +55,18 @@ class CMT32LCD : public CCharacterLCD
5555
// MIDI velocity range [1-127] to bar graph height range [0-16] scale factor
5656
static constexpr float VelocityScale = 16.f / (127.f - 1.f);
5757

58-
static constexpr unsigned MessageDisplayTimeMillis = 200;
59-
static constexpr unsigned TimbreDisplayTimeMillis = 1200;
58+
static constexpr unsigned MessageDisplayTimeMillis = 200;
59+
static constexpr unsigned TimbreDisplayTimeMillis = 1200;
6060

61-
State mState;
62-
unsigned mStateTime;
61+
TState m_State;
62+
unsigned m_nStateTime;
6363

6464
// MT-32 state
65-
char mTextBuffer[TextBufferLength];
66-
u8 mPreviousMasterVolume;
67-
u8 mPartLevels[9];
68-
u8 mPeakLevels[9];
69-
u8 mPeakTimes[9];
65+
char m_TextBuffer[TextBufferLength];
66+
u8 m_nPreviousMasterVolume;
67+
u8 m_PartLevels[9];
68+
u8 m_PeakLevels[9];
69+
u8 m_PeakTimes[9];
7070
};
7171

7272
#endif

include/lcd/ssd1306.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class CSSD1306 : public CMT32LCD
4848

4949
void DrawPartLevels(u8 nRow, bool bDrawPeaks = true);
5050

51-
CI2CMaster* mI2CMaster;
52-
u8 mAddress;
53-
u8 mHeight;
51+
CI2CMaster* m_pI2CMaster;
52+
u8 m_nAddress;
53+
u8 m_nHeight;
5454

5555
// +1 to store the 0x40 command at the beginning
56-
u8 mFramebuffer[128 * 64 / 8 + 1];
57-
56+
u8 m_Framebuffer[128 * 64 / 8 + 1];
57+
5858
static const u8 InitSequence[];
5959
};
6060

include/midiparser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CMIDIParser
3939
virtual void OnSysExOverflow();
4040

4141
private:
42-
enum class State
42+
enum class TState
4343
{
4444
StatusByte,
4545
DataByte,
@@ -54,9 +54,9 @@ class CMIDIParser
5454
u32 PrepareShortMessage() const;
5555
void ResetState(bool bClearStatusByte);
5656

57-
State mState;
58-
u8 mMessageBuffer[SysExBufferSize];
59-
size_t mMessageLength;
57+
TState m_State;
58+
u8 m_MessageBuffer[SysExBufferSize];
59+
size_t m_nMessageLength;
6060
};
6161

6262
#endif

0 commit comments

Comments
 (0)