Skip to content

Commit

Permalink
avoid taking or passing std::string over library interface, fix wrong…
Browse files Browse the repository at this point in the history
… declaration of m_segData1/2, avoid duplicating NumericalLayout, (most likely) fix wrong detection of pixelcade magic code string
  • Loading branch information
toxieainc committed Jan 13, 2024
1 parent 9a3abff commit 31b24b6
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 286 deletions.
33 changes: 16 additions & 17 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
#define DMDUTILCALLBACK
#endif

#include <cstdint>
#include <string>
#include <stdarg.h>
#include <cstdarg>

typedef void(DMDUTILCALLBACK *DMDUtil_LogCallback)(const char *format, va_list args);

Expand All @@ -20,32 +19,32 @@ class DMDUTILAPI Config
{
public:
static Config* GetInstance();
bool IsAltColor() { return m_altColor; }
bool IsAltColor() const { return m_altColor; }
void SetAltColor(bool altColor) { m_altColor = altColor; }
void SetAltColorPath(const std::string& path) { m_altColorPath = path; }
bool IsZeDMD() { return m_zedmd; }
void SetAltColorPath(const char* path) { m_altColorPath = path; }
bool IsZeDMD() const { return m_zedmd; }
void SetZeDMD(bool zedmd) { m_zedmd = zedmd; }
const std::string& GetZeDMDDevice() { return m_zedmdDevice; }
void SetZeDMDDevice(const std::string& port) { m_zedmdDevice = port; }
const bool IsZeDMDDebug() { return m_zedmdDebug; }
const char* GetZeDMDDevice() const { return m_zedmdDevice.c_str(); }
void SetZeDMDDevice(const char* port) { m_zedmdDevice = port; }
bool IsZeDMDDebug() const { return m_zedmdDebug; }
void SetZeDMDDebug(bool debug) { m_zedmdDebug = debug; }
const int GetZeDMDRGBOrder() { return m_zedmdRgbOrder; }
int GetZeDMDRGBOrder() const { return m_zedmdRgbOrder; }
void SetZeDMDRGBOrder(int rgbOrder) { m_zedmdRgbOrder = rgbOrder; }
const int GetZeDMDBrightness() { return m_zedmdBrightness; }
int GetZeDMDBrightness() const { return m_zedmdBrightness; }
void SetZeDMDBrightness(int brightness) { m_zedmdBrightness = brightness; }
const bool IsZeDMDSaveSettings() { return m_zedmdSaveSettings; }
bool IsZeDMDSaveSettings() const { return m_zedmdSaveSettings; }
void SetZeDMDSaveSettings(bool saveSettings) { m_zedmdSaveSettings = saveSettings; }
bool IsPixelcade() { return m_pixelcade; }
bool IsPixelcade() const { return m_pixelcade; }
void SetPixelcade(bool pixelcade) { m_pixelcade = pixelcade; }
void SetPixelcadeDevice(const std::string& port) { m_pixelcadeDevice = port; }
const std::string& GetPixelcadeDevice() { return m_pixelcadeDevice; }
DMDUtil_LogCallback GetLogCallback() { return m_logCallback; }
void SetPixelcadeDevice(const char* port) { m_pixelcadeDevice = port; }
const char* GetPixelcadeDevice() const { return m_pixelcadeDevice.c_str(); }
const DMDUtil_LogCallback GetLogCallback() const { return m_logCallback; }
void SetLogCallback(DMDUtil_LogCallback callback) { m_logCallback = callback; }
const std::string& GetAltColorPath() { return m_altColorPath; }
const char* GetAltColorPath() const { return m_altColorPath.c_str(); }

private:
Config();
~Config();
~Config() {}

static Config* m_pInstance;
bool m_altColor;
Expand Down
22 changes: 11 additions & 11 deletions include/DMDUtil/DMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ class Pixelcade;
class DMDUTILAPI DMD
{
public:
DMD(int width, int height, bool sam = false, const std::string& name = "");
DMD(int width, int height, bool sam = false, const char* name = nullptr);
~DMD();

static bool IsFinding();
bool HasDisplay();
const int GetWidth() { return m_width; }
const int GetHeight() { return m_height; }
const int GetLength() { return m_length; }
const bool IsUpdated() { return m_updated; }
bool HasDisplay() const;
int GetWidth() const { return m_width; }
int GetHeight() const { return m_height; }
int GetLength() const { return m_length; }
bool IsUpdated() const { return m_updated; }
void ResetUpdated() { m_updated = false; }
void UpdateData(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b);
void UpdateRGB24Data(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b);
void UpdateAlphaNumericData(AlphaNumericLayout layout, const uint16_t* pData1, const uint16_t* pData2, uint8_t r, uint8_t g, uint8_t b);
uint8_t* GetLevelData();
uint32_t* GetRGB32Data();
const uint8_t* GetLevelData() const { return m_pLevelData; }
const uint32_t* GetRGB32Data() const { return m_pRGB32Data; }

private:
enum class DmdMode {
Unknown,
Expand Down Expand Up @@ -103,8 +103,8 @@ class DMDUTILAPI DMD
bool m_sam;
uint8_t* m_pData;
uint8_t* m_pRGB24Data;
uint16_t* m_segData1[128];
uint16_t* m_segData2[128];
uint16_t m_segData1[128];
uint16_t m_segData2[128];
uint8_t* m_pLevelData;
uint32_t* m_pRGB32Data;
uint16_t* m_pRGB565Data;
Expand Down
Loading

0 comments on commit 31b24b6

Please sign in to comment.