Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZeDMD WiFi support #49

Merged
merged 9 commits into from
Sep 8, 2024
Prev Previous commit
Next Next commit
Changed Wifi to WiFi for consistency.
  • Loading branch information
bartdesign committed Sep 6, 2024
commit 81c1bcb96bb3557eeda3ef3234402476e4e30bf5
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ Brightness = -1
# Set to 1 to permantenly store the overwritten settings above in ZeDMD internally.
SaveSettings = 0
# ZeDMD WiFi enabled? This will disable COM port communication
WifiEnabled = 0
WiFiEnabled = 0
# ZeDMD WiFi IP address, you must fill this in for WiFi to work
WifiIP =
WiFiAddr =
# ZeDMD Wifi Port number, you can leave this empty and it will default to 3333
WifiPort =
WiFiPort =

[Pixelcade]
# Set to 1 if Pixelcade is attached
Expand Down
6 changes: 3 additions & 3 deletions dmdserver.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Brightness = -1
# Set to 1 to permantenly store the overwritten settings above in ZeDMD internally.
SaveSettings = 0
# ZeDMD WiFi enabled? This will disable COM port communication
WifiEnabled = 0
WiFiEnabled = 0
# ZeDMD WiFi IP address, you must fill this in for WiFi to work
WifiIP =
WiFiAddr =
# ZeDMD Wifi Port number, you can leave this empty and it will default to 3333
WifiPort =
WiFiPort =
bartdesign marked this conversation as resolved.
Show resolved Hide resolved

[Pixelcade]
# Set to 1 if Pixelcade is attached
Expand Down
18 changes: 9 additions & 9 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ class DMDUTILAPI Config
void SetZeDMDBrightness(int brightness) { m_zedmdBrightness = brightness; }
bool IsZeDMDSaveSettings() const { return m_zedmdSaveSettings; }
void SetZeDMDSaveSettings(bool saveSettings) { m_zedmdSaveSettings = saveSettings; }
bool IsZeDMDWifiEnabled() const { return m_zedmdWifiEnabled; }
void SetZeDMDWifiEnabled(bool wifiEnabled) { m_zedmdWifiEnabled = wifiEnabled; }
const char* GetZeDMDWifiAddr() const { return m_zedmdWifiAddr.c_str(); }
void SetZeDMDWifiAddr(const char* ipaddr) { m_zedmdWifiAddr = ipaddr; }
int GetZeDMDWifiPort() const { return m_zedmdWifiPort; }
void SetZeDMDWifiPort(int port) { m_zedmdWifiPort = port; }
bool IsZeDMDWiFiEnabled() const { return m_zedmdWiFiEnabled; }
void SetZeDMDWiFiEnabled(bool WiFiEnabled) { m_zedmdWiFiEnabled = WiFiEnabled; }
const char* GetZeDMDWiFiAddr() const { return m_zedmdWiFiAddr.c_str(); }
void SetZeDMDWiFiAddr(const char* ipaddr) { m_zedmdWiFiAddr = ipaddr; }
int GetZeDMDWiFiPort() const { return m_zedmdWiFiPort; }
void SetZeDMDWiFiPort(int port) { m_zedmdWiFiPort = port; }
bool IsPixelcade() const { return m_pixelcade; }
void SetPixelcade(bool pixelcade) { m_pixelcade = pixelcade; }
void SetPixelcadeDevice(const char* port) { m_pixelcadeDevice = port; }
Expand Down Expand Up @@ -107,9 +107,9 @@ class DMDUTILAPI Config
int m_zedmdRgbOrder;
int m_zedmdBrightness;
bool m_zedmdSaveSettings;
bool m_zedmdWifiEnabled;
std::string m_zedmdWifiAddr;
int m_zedmdWifiPort;
bool m_zedmdWiFiEnabled;
std::string m_zedmdWiFiAddr;
int m_zedmdWiFiPort;
bool m_dmdServer;
std::string m_dmdServerAddr;
int m_dmdServerPort;
Expand Down
16 changes: 8 additions & 8 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,22 @@ void DMD::FindDisplays()

bool open = false;

if (pConfig->IsZeDMDWifiEnabled())
if (pConfig->IsZeDMDWiFiEnabled())
{
std::string wifiAddr = pConfig->GetZeDMDWifiAddr() ? pConfig->GetZeDMDWifiAddr() : "";
uint16_t udpPortNumber = pConfig->GetZeDMDWifiPort() > 0 ? pConfig->GetZeDMDWifiPort() : 3333;
std::string WiFiAddr = pConfig->GetZeDMDWiFiAddr() ? pConfig->GetZeDMDWiFiAddr() : "";
uint16_t udpPortNumber = pConfig->GetZeDMDWiFiPort() > 0 ? pConfig->GetZeDMDWiFiPort() : 3333;

if (wifiAddr.empty())
if (WiFiAddr.empty())
{
DMDUtil::Log(DMDUtil_LogLevel_ERROR, "ERROR: ZeDMD Wifi IP address is not configured.");
DMDUtil::Log(DMDUtil_LogLevel_ERROR, "ERROR: ZeDMD WiFi IP address is not configured.");
}

// Proceed only if the wifiAddr is valid.
if (!wifiAddr.empty() && (open = pZeDMD->OpenWiFi(wifiAddr.c_str(), udpPortNumber)))
// Proceed only if the WiFiAddr is valid.
if (!WiFiAddr.empty() && (open = pZeDMD->OpenWiFi(WiFiAddr.c_str(), udpPortNumber)))
{
// Fix RGB and brightness
bartdesign marked this conversation as resolved.
Show resolved Hide resolved
std::stringstream logMessage;
logMessage << "ZeDMD Wifi enabled, connected to " << wifiAddr << ":" << udpPortNumber << ".";
logMessage << "ZeDMD WiFi enabled, connected to " << WiFiAddr << ":" << udpPortNumber << ".";
DMDUtil::Log(DMDUtil_LogLevel_INFO, logMessage.str().c_str());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dmdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ int main(int argc, char* argv[])
pConfig->SetZeDMDBrightness(r.Get<int>("ZeDMD", "Brightness", -1));
pConfig->SetZeDMDSaveSettings(r.Get<bool>("ZeDMD", "SaveSettings", false));
// ZeDMD WiFi
pConfig->SetZeDMDWifiEnabled(r.Get<bool>("ZeDMD", "WifiEnabled", false));
pConfig->SetZeDMDWifiAddr(r.Get<string>("ZeDMD", "WifiIP", "").c_str());
pConfig->SetZeDMDWifiPort(r.Get<int>("ZeDMD", "WifiPort", 3333));
pConfig->SetZeDMDWiFiEnabled(r.Get<bool>("ZeDMD", "WiFiEnabled", false));
pConfig->SetZeDMDWiFiAddr(r.Get<string>("ZeDMD", "WiFiAddr", "").c_str());
pConfig->SetZeDMDWiFiPort(r.Get<int>("ZeDMD", "WiFiPort", 3333));
// Pixelcade
pConfig->SetPixelcade(r.Get<bool>("Pixelcade", "Enabled", true));
pConfig->SetPixelcadeDevice(r.Get<string>("Pixelcade", "Device", "").c_str());
Expand Down