Skip to content

Commit e5a0740

Browse files
authored
version apis (#286)
1 parent 2eec58f commit e5a0740

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

VortexEngine/VortexLib/VortexLib.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,11 @@ EMSCRIPTEN_BINDINGS(Vortex) {
602602
.function("parseJson", &Vortex::parseJson)
603603
.function("setLockEnabled", &Vortex::setLockEnabled)
604604
.function("lockEnabled", &Vortex::lockEnabled)
605-
.function("engine", &Vortex::engine);
605+
.function("engine", &Vortex::engine)
606+
.function("getVersion", &Vortex::getVersion)
607+
.function("getVersionMajor", &Vortex::getVersionMajor)
608+
.function("getVersionMinor", &Vortex::getVersionMinor)
609+
.function("getVersionBuild", &Vortex::getVersionBuild);
606610

607611
function("getDataArray", &getDataArray);
608612
function("getRawDataArray", &getRawDataArray);
@@ -1991,6 +1995,24 @@ string Vortex::getStorageFilename()
19911995
return m_engine.storage().getStorageFilename();
19921996
}
19931997

1998+
// get the engine version as a string
1999+
std::string Vortex::getVersion() const {
2000+
return VORTEX_VERSION;
2001+
}
2002+
2003+
// get the version as separated integers
2004+
uint8_t Vortex::getVersionMajor() const {
2005+
return VORTEX_VERSION_MAJOR;
2006+
}
2007+
2008+
uint8_t Vortex::getVersionMinor() const {
2009+
return VORTEX_VERSION_MINOR;
2010+
}
2011+
2012+
uint8_t Vortex::getVersionBuild() const {
2013+
return VORTEX_BUILD_NUMBER;
2014+
}
2015+
19942016
json Vortex::modeToJson(const Mode *mode)
19952017
{
19962018
if (!mode) {
@@ -2216,6 +2238,7 @@ json Vortex::saveToJson()
22162238

22172239
saveJson["version_major"] = static_cast<uint8_t>(VORTEX_VERSION_MAJOR);
22182240
saveJson["version_minor"] = static_cast<uint8_t>(VORTEX_VERSION_MINOR);
2241+
saveJson["version_build"] = static_cast<uint8_t>(VORTEX_BUILD_NUMBER);
22192242
saveJson["global_flags"] = m_engine.modes().globalFlags();
22202243
saveJson["brightness"] = static_cast<uint8_t>(m_engine.leds().getBrightness());
22212244

VortexEngine/VortexLib/VortexLib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ class Vortex
282282
void setLockEnabled(bool enable) { m_lockEnabled = enable; }
283283
bool lockEnabled() { return m_lockEnabled; }
284284

285+
// get the engine version as a string
286+
std::string getVersion() const;
287+
// get the version as separated integers
288+
uint8_t getVersionMajor() const;
289+
uint8_t getVersionMinor() const;
290+
uint8_t getVersionBuild() const;
291+
285292
// convert a mode to/from a json object
286293
json modeToJson(const Mode *mode);
287294
Mode *modeFromJson(const json &modeJson);

0 commit comments

Comments
 (0)