Skip to content

Commit

Permalink
add ini file support for dmdserver, add AltColorPath override (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner authored Mar 12, 2024
1 parent ba8ed0c commit 1de6517
Show file tree
Hide file tree
Showing 17 changed files with 866 additions and 129 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ void test()
Per default it listens on port 6789 on localhost and accepts "raw" TCP connections.

`dmdserver` accepts these command line options:
* -c --config
* Config file
* optional
* default is no config file
* -o --alt-color-path
* "Fixed alt color path, overwriting paths transmitted by DMDUpdates
* optional
* -a --addr
* IP address or host name
* optional
Expand Down Expand Up @@ -153,6 +160,40 @@ That means that the data of the last client that connected get displayed. All pr
As soon as the last connection gets terminated by the client, the newest previous one becomes active again (if it is still active).
The "paused" connections aren't really paused. Their data is still accepted but dropped instead of dispalyed.

### Config File

```ini
[DMDServer]
# The address (interface) to listen for TCP connections
Addr=localhost
# The port to listen for TCP connections
Port=6789
# Set to 1 if Serum colorization should be used
AltColor=
# Overwrite the AltColorPath sent by the client and set it to a fixed value
AltColorPath=

[ZeDMD]
# Set to 1 if ZeDMD is attached
Enabled=
# Disable auto-detection and provide a fixed serial port
Device=
# Enable ZeDMD debug mode
Debug=
# Overwrite ZeDMD internal RGB order setting
RGBOrder=
# Overwrite ZeDMD internal brightness setting
Brightness=
# Set to 1 to permantenly store the overwritten settings above in ZeDMD internally
SaveSettings=

[Pixelcade]
# Set to 1 if Pixelcade is attached
Enabled=
# Disable auto-detection and provide a fixed serial port
Device=
```

## Building:

#### Windows (x64)
Expand Down
3 changes: 3 additions & 0 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class DMDUTILAPI Config
static Config* GetInstance();
bool IsAltColor() const { return m_altColor; }
void SetAltColor(bool altColor) { m_altColor = altColor; }
void SetAltColorPath(const char* path) { m_altColorPath = path; }
const char* GetAltColorPath() const { return m_altColorPath.c_str(); }
void SetIgnoreUnknownFramesTimeout(int framesTimeout) { m_framesTimeout = framesTimeout; }
void SetMaximumUnknownFramesToSkip(int framesToSkip) { m_framesToSkip = framesToSkip; }
int GetIgnoreUnknownFramesTimeout() { return m_framesTimeout; }
Expand Down Expand Up @@ -57,6 +59,7 @@ class DMDUTILAPI Config

static Config* m_pInstance;
bool m_altColor;
std::string m_altColorPath;
int m_framesTimeout;
int m_framesToSkip;
bool m_zedmd;
Expand Down
6 changes: 3 additions & 3 deletions include/DMDUtil/DMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define DMDUTIL_FRAME_BUFFER_SIZE 16
#define DMDUTIL_MAX_NAME_SIZE 16
#define DMDUTIL_MAX_ALTCOLORPATH_SIZE 256
#define DMDUTIL_MAX_PATH_SIZE 256
#define DMDUTIL_MAX_TRANSITIONAL_FRAME_DURATION 25

#include <atomic>
Expand Down Expand Up @@ -110,7 +110,7 @@ class DMDUTILAPI DMD
{
char header[9] = "AltColor";
char name[DMDUTIL_MAX_NAME_SIZE] = {0};
char path[DMDUTIL_MAX_ALTCOLORPATH_SIZE] = {0};
char path[DMDUTIL_MAX_PATH_SIZE] = {0};
};
#pragma pack(pop) // Reset to default packing

Expand Down Expand Up @@ -158,7 +158,7 @@ class DMDUTILAPI DMD

uint8_t m_updateBufferQueuePosition = 0;
char m_romName[DMDUTIL_MAX_NAME_SIZE] = {0};
char m_altColorPath[DMDUTIL_MAX_ALTCOLORPATH_SIZE] = {0};
char m_altColorPath[DMDUTIL_MAX_PATH_SIZE] = {0};
AlphaNumeric* m_pAlphaNumeric;
Serum* m_pSerum;
ZeDMD* m_pZeDMD;
Expand Down
20 changes: 10 additions & 10 deletions platforms/android/arm64-v8a/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -e

LIBCARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
LIBSOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

if [[ $(uname) == "Linux" ]]; then
NUM_PROCS=$(nproc)
Expand All @@ -16,10 +16,10 @@ else
fi

echo "Building libraries..."
echo " LIBCARGS_SHA: ${LIBCARGS_SHA}"
echo " CARGS_SHA: ${CARGS_SHA}"
echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}"
echo " LIBSERUM_SHA: ${LIBSERUM_SHA}"
echo " LIBSOCKPP_SHA: ${LIBSOCKPP_SHA}"
echo " SOCKPP_SHA: ${SOCKPP_SHA}"
echo ""

if [ -z "${BUILD_TYPE}" ]; then
Expand All @@ -35,12 +35,12 @@ mkdir external
cd external

#
# libcargs
# build cargs and copy to external
#

curl -sL https://github.com/likle/cargs/archive/${LIBCARGS_SHA}.zip -o cargs.zip
curl -sL https://github.com/likle/cargs/archive/${CARGS_SHA}.zip -o cargs.zip
unzip cargs.zip
cd cargs-${LIBCARGS_SHA}
cd cargs-${CARGS_SHA}
cp include/cargs.h ../../third-party/include/
cmake -DBUILD_SHARED_LIBS=ON \
-DCMAKE_SYSTEM_NAME=Android \
Expand Down Expand Up @@ -83,12 +83,12 @@ cp build/libserum.so ../../third-party/runtime-libs/android/arm64-v8a/
cd ..

#
# build libsockpp and copy to external
# build sockpp and copy to external
#

curl -sL https://github.com/fpagliughi/sockpp/archive/${LIBSOCKPP_SHA}.zip -o sockpp.zip
curl -sL https://github.com/fpagliughi/sockpp/archive/${SOCKPP_SHA}.zip -o sockpp.zip
unzip sockpp.zip
cd sockpp-$LIBSOCKPP_SHA
cd sockpp-$SOCKPP_SHA
patch -p1 < ../../platforms/android/arm64-v8a/sockpp/001.patch
cp -r include/sockpp ../../third-party/include/
cmake -DSOCKPP_BUILD_SHARED=ON \
Expand Down
20 changes: 10 additions & 10 deletions platforms/ios/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -e

LIBCARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
LIBSOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

NUM_PROCS=$(sysctl -n hw.ncpu)

echo "Building libraries..."
echo " LIBCARGS_SHA: ${LIBCARGS_SHA}"
echo " CARGS_SHA: ${CARGS_SHA}"
echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}"
echo " LIBSERUM_SHA: ${LIBSERUM_SHA}"
echo " LIBSOCKPP_SHA: ${LIBSOCKPP_SHA}"
echo " SOCKPP_SHA: ${SOCKPP_SHA}"
echo ""

if [ -z "${BUILD_TYPE}" ]; then
Expand All @@ -29,12 +29,12 @@ mkdir external
cd external

#
# libcargs
# build cargs and copy to external
#

curl -sL https://github.com/likle/cargs/archive/${LIBCARGS_SHA}.zip -o cargs.zip
curl -sL https://github.com/likle/cargs/archive/${CARGS_SHA}.zip -o cargs.zip
unzip cargs.zip
cd cargs-${LIBCARGS_SHA}
cd cargs-${CARGS_SHA}
cp include/cargs.h ../../third-party/include/
mkdir build
cd build
Expand Down Expand Up @@ -72,12 +72,12 @@ cp build/libserum.a ../../third-party/build-libs/ios/arm64/
cd ..

#
# build libsockpp and copy to external
# build sockpp and copy to external
#

curl -sL https://github.com/fpagliughi/sockpp/archive/${LIBSOCKPP_SHA}.zip -o sockpp.zip
curl -sL https://github.com/fpagliughi/sockpp/archive/${SOCKPP_SHA}.zip -o sockpp.zip
unzip sockpp.zip
cd sockpp-$LIBSOCKPP_SHA
cd sockpp-$SOCKPP_SHA
cp -r include/sockpp ../../third-party/include/
cmake -DSOCKPP_BUILD_SHARED=OFF \
-DSOCKPP_BUILD_STATIC=ON \
Expand Down
22 changes: 11 additions & 11 deletions platforms/linux/aarch64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -e

LIBCARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
LIBSOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

NUM_PROCS=$(nproc)

echo "Building libraries..."
echo " LIBCARGS_SHA: ${LIBCARGS_SHA}"
echo " CARGS_SHA: ${CARGS_SHA}"
echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}"
echo " LIBSERUM_SHA: ${LIBSERUM_SHA}"
echo " LIBSOCKPP_SHA: ${LIBSOCKPP_SHA}"
echo " SOCKPP_SHA: ${SOCKPP_SHA}"
echo ""

if [ -z "${BUILD_TYPE}" ]; then
Expand All @@ -29,18 +29,18 @@ mkdir external
cd external

#
# libcargs
# build cargs and copy to external
#

curl -sL https://github.com/likle/cargs/archive/${LIBCARGS_SHA}.zip -o cargs.zip
curl -sL https://github.com/likle/cargs/archive/${CARGS_SHA}.zip -o cargs.zip
unzip cargs.zip
cd cargs-${LIBCARGS_SHA}
cd cargs-${CARGS_SHA}
cp include/cargs.h ../../third-party/include/
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
cp -P libcargs.so* ../../../third-party/runtime-libs/linux/aarch64/
cp -a libcargs.so* ../../../third-party/runtime-libs/linux/aarch64/
cd ../..

#
Expand Down Expand Up @@ -75,12 +75,12 @@ cp -a build/libserum.{so,so.*} ../../third-party/runtime-libs/linux/aarch64/
cd ..

#
# build libsockpp and copy to external
# build sockpp and copy to external
#

curl -sL https://github.com/fpagliughi/sockpp/archive/${LIBSOCKPP_SHA}.zip -o sockpp.zip
curl -sL https://github.com/fpagliughi/sockpp/archive/${SOCKPP_SHA}.zip -o sockpp.zip
unzip sockpp.zip
cd sockpp-$LIBSOCKPP_SHA
cd sockpp-$SOCKPP_SHA
cp -r include/sockpp ../../third-party/include/
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -B build
cmake --build build -- -j${NUM_PROCS}
Expand Down
22 changes: 11 additions & 11 deletions platforms/linux/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -e

LIBCARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
LIBSOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

NUM_PROCS=$(nproc)

echo "Building libraries..."
echo " LIBCARGS_SHA: ${LIBCARGS_SHA}"
echo " CARGS_SHA: ${CARGS_SHA}"
echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}"
echo " LIBSERUM_SHA: ${LIBSERUM_SHA}"
echo " LIBSOCKPP_SHA: ${LIBSOCKPP_SHA}"
echo " SOCKPP_SHA: ${SOCKPP_SHA}"
echo ""

if [ -z "${BUILD_TYPE}" ]; then
Expand All @@ -29,18 +29,18 @@ mkdir external
cd external

#
# libcargs
# build cargs and copy to external
#

curl -sL https://github.com/likle/cargs/archive/${LIBCARGS_SHA}.zip -o cargs.zip
curl -sL https://github.com/likle/cargs/archive/${CARGS_SHA}.zip -o cargs.zip
unzip cargs.zip
cd cargs-${LIBCARGS_SHA}
cd cargs-${CARGS_SHA}
cp include/cargs.h ../../third-party/include/
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
cp -P libcargs.so* ../../../third-party/runtime-libs/linux/x64/
cp -a libcargs.so* ../../../third-party/runtime-libs/linux/x64/
cd ../..

#
Expand Down Expand Up @@ -75,12 +75,12 @@ cp -a build/libserum.{so,so.*} ../../third-party/runtime-libs/linux/x64/
cd ..

#
# build libsockpp and copy to external
# build sockpp and copy to external
#

curl -sL https://github.com/fpagliughi/sockpp/archive/${LIBSOCKPP_SHA}.zip -o sockpp.zip
curl -sL https://github.com/fpagliughi/sockpp/archive/${SOCKPP_SHA}.zip -o sockpp.zip
unzip sockpp.zip
cd sockpp-$LIBSOCKPP_SHA
cd sockpp-$SOCKPP_SHA
cp -r include/sockpp ../../third-party/include/
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -B build
cmake --build build -- -j${NUM_PROCS}
Expand Down
21 changes: 11 additions & 10 deletions platforms/macos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

set -e

LIBCARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
LIBSOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

NUM_PROCS=$(sysctl -n hw.ncpu)

echo "Building libraries..."
echo " CARGS_SHA: ${CARGS_SHA}"
echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}"
echo " LIBSERUM_SHA: ${LIBSERUM_SHA}"
echo " LIBSOCKPP_SHA: ${LIBSOCKPP_SHA}"
echo " SOCKPP_SHA: ${SOCKPP_SHA}"
echo ""

if [ -z "${BUILD_TYPE}" ]; then
Expand All @@ -28,18 +29,18 @@ mkdir external
cd external

#
# libcargs
# build cargs and copy to external
#

curl -sL https://github.com/likle/cargs/archive/${LIBCARGS_SHA}.zip -o cargs.zip
curl -sL https://github.com/likle/cargs/archive/${CARGS_SHA}.zip -o cargs.zip
unzip cargs.zip
cd cargs-${LIBCARGS_SHA}
cd cargs-${CARGS_SHA}
cp include/cargs.h ../../third-party/include/
mkdir build
cd build
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DBUILD_SHARED_LIBS=ON ..
make
cp -P libcargs*.dylib ../../../third-party/runtime-libs/macos/arm64/
cp -a libcargs*.dylib ../../../third-party/runtime-libs/macos/arm64/
cd ../..

#
Expand Down Expand Up @@ -73,12 +74,12 @@ cp -a build/*.dylib ../../third-party/runtime-libs/macos/arm64/
cd ..

#
# build libsockpp and copy to external
# build sockpp and copy to external
#

curl -sL https://github.com/fpagliughi/sockpp/archive/${LIBSOCKPP_SHA}.zip -o sockpp.zip
curl -sL https://github.com/fpagliughi/sockpp/archive/${SOCKPP_SHA}.zip -o sockpp.zip
unzip sockpp.zip
cd sockpp-$LIBSOCKPP_SHA
cd sockpp-$SOCKPP_SHA
cp -r include/sockpp ../../third-party/include/
cmake -DSOCKPP_BUILD_SHARED=ON \
-DSOCKPP_BUILD_STATIC=OFF \
Expand Down
Loading

0 comments on commit 1de6517

Please sign in to comment.