Skip to content

Commit

Permalink
libzedmd 0.9.3, logged more details
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner authored and freezy committed Feb 11, 2025
1 parent e280c01 commit d835a63
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Binary file modified LibDmd/Costura32/zedmd.dll
Binary file not shown.
Binary file modified LibDmd/Costura64/zedmd64.dll
Binary file not shown.
8 changes: 5 additions & 3 deletions LibDmd/Output/ZeDMD/ZeDMDBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public abstract class ZeDMDBase
protected ColoredFrame _lastFrame = null;
private GCHandle handle;

protected void LogHandler(IntPtr format, IntPtr args, IntPtr pUserData)
protected void LogHandler(string format, IntPtr args, IntPtr pUserData)
{
Logger.Debug("Trying to convert libzedmd log message: " + format);
Logger.Info("libzedmd: " + Marshal.PtrToStringAnsi(ZeDMD_FormatLogMessage(format, args, pUserData)));
}

protected void Init()
{
_pZeDMD = ZeDMD_GetInstance();
Logger.Info("Using libzedmd version " + DriverVersion);

ZeDMD_LogCallback callbackDelegate = new ZeDMD_LogCallback(LogHandler);
// Keep a reference to the delegate to prevent GC from collecting it
Expand Down Expand Up @@ -114,7 +116,7 @@ public void ClearColor()
protected static extern IntPtr ZeDMD_GetInstance();

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
protected delegate void ZeDMD_LogCallback(IntPtr format, IntPtr args, IntPtr pUserData);
protected delegate void ZeDMD_LogCallback(string format, IntPtr args, IntPtr pUserData);

#if PLATFORM_X64
[DllImport("zedmd64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
Expand All @@ -128,7 +130,7 @@ public void ClearColor()
#else
[DllImport("zedmd.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
#endif
protected static extern IntPtr ZeDMD_FormatLogMessage(IntPtr format, IntPtr args, IntPtr pUserData);
protected static extern IntPtr ZeDMD_FormatLogMessage(string format, IntPtr args, IntPtr pUserData);

#if PLATFORM_X64
[DllImport("zedmd64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
Expand Down
17 changes: 12 additions & 5 deletions LibDmd/Output/ZeDMD/ZeDMDUsbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ public abstract class ZeDMDUsbBase : ZeDMDBase
base.Init();

if (!string.IsNullOrEmpty(Port)) {
ZeDMD_SetDevice(_pZeDMD, @"\\.\" + Port);
ZeDMD_SetDevice(_pZeDMD, Port);
}

IsAvailable = ZeDMD_Open(_pZeDMD);

if (!IsAvailable) {
if (string.IsNullOrEmpty(Port)) {
Logger.Info(Name + " device not found at any port, libzedmd version: " + DriverVersion);
Logger.Info(Name + " device not found at any port");
}
else {
Logger.Info(Name + " device not found at port " + Port + ", libzedmd version: " + DriverVersion);
Logger.Info(Name + " device not found at port " + Port);
}
return;
}

if (string.IsNullOrEmpty(Port)) {
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found, libzedmd version: " + DriverVersion);
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found, USB package size " + ZeDMD_GetUsbPackageSize(_pZeDMD));
} else {
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found at port " + Port + ", libzedmd version: " + DriverVersion);
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found at port " + Port + ", USB package size " + ZeDMD_GetUsbPackageSize(_pZeDMD));
}
}

Expand All @@ -54,6 +54,13 @@ public abstract class ZeDMDUsbBase : ZeDMDBase
#endif
protected static extern bool ZeDMD_Open(IntPtr pZeDMD);

#if PLATFORM_X64
[DllImport("zedmd64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport("zedmd.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
#endif
protected static extern int ZeDMD_GetUsbPackageSize(IntPtr pZeDMD);

#endregion
}
}
12 changes: 10 additions & 2 deletions LibDmd/Output/ZeDMD/ZeDMDWiFiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public abstract class ZeDMDWiFiBase : ZeDMDBase

if (!IsAvailable)
{
Logger.Info(Name + " device not found, libzedmd version: " + DriverVersion);
Logger.Info(Name + " device not found");
return;
}
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found, libzedmd version: " + DriverVersion);
Logger.Info(Name + " " + Marshal.PtrToStringAnsi(ZeDMD_GetFirmwareVersion(_pZeDMD)) + " device found, UDP delay " + ZeDMD_GetUdpDelay(_pZeDMD) + "ms");
}

#region libzedmd
Expand All @@ -51,6 +51,14 @@ public abstract class ZeDMDWiFiBase : ZeDMDBase
#endif
protected static extern bool ZeDMD_OpenWiFi(IntPtr pZeDMD, string ip);

#if PLATFORM_X64
[DllImport("zedmd64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport("zedmd.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
#endif
protected static extern int ZeDMD_GetUdpDelay(IntPtr pZeDMD);


#endregion
}
}

0 comments on commit d835a63

Please sign in to comment.