From aff835ca582314408395394ee30b75c9caec8a69 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Jan 2025 02:36:35 -0800 Subject: [PATCH] version apis --- VortexEngine/VortexLib/VortexLib.cpp | 25 ++++++++++++++++++++++++- VortexEngine/VortexLib/VortexLib.h | 7 +++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/VortexEngine/VortexLib/VortexLib.cpp b/VortexEngine/VortexLib/VortexLib.cpp index fb83211261..04efe4b273 100644 --- a/VortexEngine/VortexLib/VortexLib.cpp +++ b/VortexEngine/VortexLib/VortexLib.cpp @@ -602,7 +602,11 @@ EMSCRIPTEN_BINDINGS(Vortex) { .function("parseJson", &Vortex::parseJson) .function("setLockEnabled", &Vortex::setLockEnabled) .function("lockEnabled", &Vortex::lockEnabled) - .function("engine", &Vortex::engine); + .function("engine", &Vortex::engine) + .function("getVersion", &Vortex::getVersion) + .function("getVersionMajor", &Vortex::getVersionMajor) + .function("getVersionMinor", &Vortex::getVersionMinor) + .function("getVersionBuild", &Vortex::getVersionBuild); function("getDataArray", &getDataArray); function("getRawDataArray", &getRawDataArray); @@ -1991,6 +1995,24 @@ string Vortex::getStorageFilename() return m_engine.storage().getStorageFilename(); } +// get the engine version as a string +std::string Vortex::getVersion() const { + return VORTEX_VERSION; +} + +// get the version as separated integers +uint8_t Vortex::getVersionMajor() const { + return VORTEX_VERSION_MAJOR; +} + +uint8_t Vortex::getVersionMinor() const { + return VORTEX_VERSION_MINOR; +} + +uint8_t Vortex::getVersionBuild() const { + return VORTEX_BUILD_NUMBER; +} + json Vortex::modeToJson(const Mode *mode) { if (!mode) { @@ -2216,6 +2238,7 @@ json Vortex::saveToJson() saveJson["version_major"] = static_cast(VORTEX_VERSION_MAJOR); saveJson["version_minor"] = static_cast(VORTEX_VERSION_MINOR); + saveJson["version_build"] = static_cast(VORTEX_BUILD_NUMBER); saveJson["global_flags"] = m_engine.modes().globalFlags(); saveJson["brightness"] = static_cast(m_engine.leds().getBrightness()); diff --git a/VortexEngine/VortexLib/VortexLib.h b/VortexEngine/VortexLib/VortexLib.h index 1fa0dd8308..186a353a20 100644 --- a/VortexEngine/VortexLib/VortexLib.h +++ b/VortexEngine/VortexLib/VortexLib.h @@ -282,6 +282,13 @@ class Vortex void setLockEnabled(bool enable) { m_lockEnabled = enable; } bool lockEnabled() { return m_lockEnabled; } + // get the engine version as a string + std::string getVersion() const; + // get the version as separated integers + uint8_t getVersionMajor() const; + uint8_t getVersionMinor() const; + uint8_t getVersionBuild() const; + // convert a mode to/from a json object json modeToJson(const Mode *mode); Mode *modeFromJson(const json &modeJson);