Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DMDUTILAPI Config
{
public:
static Config* GetInstance();
void parseConfigFile(const char* path);
bool IsAltColor() const { return m_altColor; }
void SetAltColor(bool altColor) { m_altColor = altColor; }
void SetAltColorPath(const char* path) { m_altColorPath = path; }
Expand Down
26 changes: 25 additions & 1 deletion src/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DMDUtil/Config.h"

#include <cstring>
#include "ini.h"

namespace DMDUtil
{
Expand Down Expand Up @@ -37,4 +37,28 @@ Config::Config()
memset(&m_pupTriggerCallbackContext, 0, sizeof(m_pupTriggerCallbackContext));
}

void Config::parseConfigFile(const char* path)
{
inih::INIReader r{path};

SetDMDServerAddr(r.Get<std::string>("DMDServer", "Addr", "localhost").c_str());
SetDMDServerPort(r.Get<int>("DMDServer", "Port", 6789));
SetAltColor(r.Get<bool>("DMDServer", "AltColor", true));
SetAltColorPath(r.Get<std::string>("DMDServer", "AltColorPath", "").c_str());
SetPUPCapture(r.Get<bool>("DMDServer", "PUPCapture", false));
SetPUPVideosPath(r.Get<std::string>("DMDServer", "PUPVideosPath", "").c_str());
SetPUPExactColorMatch(r.Get<bool>("DMDServer", "PUPExactColorMatch", false));
// ZeDMD
SetZeDMD(r.Get<bool>("ZeDMD", "Enabled", true));
SetZeDMDDevice(r.Get<std::string>("ZeDMD", "Device", "").c_str());
SetZeDMDDebug(r.Get<bool>("ZeDMD", "Debug", false));
SetZeDMDBrightness(r.Get<int>("ZeDMD", "Brightness", -1));
// ZeDMD WiFi
SetZeDMDWiFiEnabled(r.Get<bool>("ZeDMD-WiFi", "Enabled", false));
SetZeDMDWiFiAddr(r.Get<std::string>("ZeDMD-WiFi", "WiFiAddr", "").c_str());
// Pixelcade
SetPixelcade(r.Get<bool>("Pixelcade", "Enabled", true));
SetPixelcadeDevice(r.Get<std::string>("Pixelcade", "Device", "").c_str());
}

} // namespace DMDUtil
22 changes: 1 addition & 21 deletions src/dmdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "DMDUtil/DMDUtil.h"
#include "Logger.h"
#include "cargs.h"
#include "ini.h"
#include "sockpp/tcp_acceptor.h"

#define DMDSERVER_MAX_WIDTH 256
Expand Down Expand Up @@ -271,26 +270,7 @@ int main(int argc, char* argv[])
char identifier = cag_option_get_identifier(&cag_context);
if (identifier == 'c')
{
inih::INIReader r{cag_option_get_value(&cag_context)};
pConfig->SetDMDServerAddr(r.Get<string>("DMDServer", "Addr", "localhost").c_str());
pConfig->SetDMDServerPort(r.Get<int>("DMDServer", "Port", 6789));
pConfig->SetAltColor(r.Get<bool>("DMDServer", "AltColor", true));
pConfig->SetAltColorPath(r.Get<string>("DMDServer", "AltColorPath", "").c_str());
pConfig->SetPUPCapture(r.Get<bool>("DMDServer", "PUPCapture", false));
pConfig->SetPUPVideosPath(r.Get<string>("DMDServer", "PUPVideosPath", "").c_str());
pConfig->SetPUPExactColorMatch(r.Get<bool>("DMDServer", "PUPExactColorMatch", false));
// ZeDMD
pConfig->SetZeDMD(r.Get<bool>("ZeDMD", "Enabled", true));
pConfig->SetZeDMDDevice(r.Get<string>("ZeDMD", "Device", "").c_str());
pConfig->SetZeDMDDebug(r.Get<bool>("ZeDMD", "Debug", false));
pConfig->SetZeDMDBrightness(r.Get<int>("ZeDMD", "Brightness", -1));
// ZeDMD WiFi
pConfig->SetZeDMDWiFiEnabled(r.Get<bool>("ZeDMD-WiFi", "Enabled", false));
pConfig->SetZeDMDWiFiAddr(r.Get<string>("ZeDMD-WiFi", "WiFiAddr", "").c_str());
// Pixelcade
pConfig->SetPixelcade(r.Get<bool>("Pixelcade", "Enabled", true));
pConfig->SetPixelcadeDevice(r.Get<string>("Pixelcade", "Device", "").c_str());

pConfig->parseConfigFile(cag_option_get_value(&cag_context));
if (opt_verbose) DMDUtil::Log(DMDUtil_LogLevel_INFO, "Loaded config file");
}
else if (identifier == 'o')
Expand Down