diff --git a/gd32_emac_artnet_pixel_dmx_multi/firmware/main.cpp b/gd32_emac_artnet_pixel_dmx_multi/firmware/main.cpp index db17c02..7575307 100644 --- a/gd32_emac_artnet_pixel_dmx_multi/firmware/main.cpp +++ b/gd32_emac_artnet_pixel_dmx_multi/firmware/main.cpp @@ -123,7 +123,6 @@ void main() { ArtNetParams artnetParams(&storeArtNet); if (artnetParams.Load()) { - artnetParams.Dump(); artnetParams.Set(DMXPORT_OFFSET); } @@ -135,7 +134,6 @@ void main() { PixelDmxParams pixelDmxParams(&storePixelDmx); if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); pixelDmxParams.Set(&pixelDmxConfiguration); } @@ -182,7 +180,6 @@ void main() { Dmx dmx; dmxparams.Load(); - dmxparams.Dump(); dmxparams.Set(&dmx); for (uint32_t nPortIndex = DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { @@ -233,7 +230,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -248,7 +244,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(&node, DMXPORT_OFFSET); @@ -266,11 +261,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::ARTNET, remoteconfig::Output::PIXEL, node.GetActiveOutputPorts()); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_artnet_pixel_multi/firmware/main.cpp b/gd32_emac_artnet_pixel_multi/firmware/main.cpp index feaea41..a6ff89c 100644 --- a/gd32_emac_artnet_pixel_multi/firmware/main.cpp +++ b/gd32_emac_artnet_pixel_multi/firmware/main.cpp @@ -113,7 +113,6 @@ void main() { ArtNetParams artnetParams(&storeArtNet); if (artnetParams.Load()) { - artnetParams.Dump(); artnetParams.Set(DMXPORT_OFFSET); } @@ -123,7 +122,6 @@ void main() { PixelDmxParams pixelDmxParams(&storePixelDmx); if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); pixelDmxParams.Set(&pixelDmxConfiguration); } @@ -182,7 +180,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -200,7 +197,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(&node, DMXPORT_OFFSET); @@ -218,11 +214,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::ARTNET, remoteconfig::Output::PIXEL, node.GetActiveOutputPorts()); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml b/gd32_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml index f99ded0..3dd2046 100755 --- a/gd32_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml +++ b/gd32_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/gd32_emac_ddp_pixel_dmx_multi/firmware/main.cpp b/gd32_emac_ddp_pixel_dmx_multi/firmware/main.cpp index 8bfe1a1..4ea2f0a 100644 --- a/gd32_emac_ddp_pixel_dmx_multi/firmware/main.cpp +++ b/gd32_emac_ddp_pixel_dmx_multi/firmware/main.cpp @@ -118,7 +118,6 @@ void main() { PixelDmxParams pixelDmxParams(&storePixelDmx); if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); pixelDmxParams.Set(&pixelDmxConfiguration); } @@ -140,7 +139,6 @@ void main() { Dmx dmx; dmxparams.Load(); - dmxparams.Dump(); dmxparams.Set(&dmx); DmxSend dmxSend; @@ -176,7 +174,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -192,7 +189,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(); @@ -210,11 +206,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::DDP, remoteconfig::Output::PIXEL, nActivePorts); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_ddp_pixel_multi/.settings/language.settings.xml b/gd32_emac_ddp_pixel_multi/.settings/language.settings.xml index 8f0c865..03304ac 100755 --- a/gd32_emac_ddp_pixel_multi/.settings/language.settings.xml +++ b/gd32_emac_ddp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/gd32_emac_ddp_pixel_multi/firmware/main.cpp b/gd32_emac_ddp_pixel_multi/firmware/main.cpp index 327f810..b855a94 100644 --- a/gd32_emac_ddp_pixel_multi/firmware/main.cpp +++ b/gd32_emac_ddp_pixel_multi/firmware/main.cpp @@ -109,7 +109,6 @@ void main() { PixelDmxParams pixelDmxParams(&storePixelDmx); if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); pixelDmxParams.Set(&pixelDmxConfiguration); } @@ -148,7 +147,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -164,7 +162,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(); @@ -182,11 +179,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::DDP, remoteconfig::Output::PIXEL, nActivePorts); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_debug/firmware/main.cpp b/gd32_emac_debug/firmware/main.cpp index 6e434f6..ce18e6f 100644 --- a/gd32_emac_debug/firmware/main.cpp +++ b/gd32_emac_debug/firmware/main.cpp @@ -133,18 +133,14 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(); RemoteConfig remoteConfig(remoteconfig::Node::RDMNET_LLRP_ONLY, remoteconfig::Output::CONFIG, 0); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_e131_pixel_dmx_multi/firmware/main.cpp b/gd32_emac_e131_pixel_dmx_multi/firmware/main.cpp index 999054a..b5411bc 100644 --- a/gd32_emac_e131_pixel_dmx_multi/firmware/main.cpp +++ b/gd32_emac_e131_pixel_dmx_multi/firmware/main.cpp @@ -117,10 +117,8 @@ void main() { E131Bridge bridge; - if (e131params.Load()) { - e131params.Dump(); - e131params.Set(DMXPORT_OFFSET); - } + e131params.Load(); + e131params.Set(DMXPORT_OFFSET); // LightSet A - Pixel - 64 Universes @@ -129,10 +127,8 @@ void main() { StorePixelDmx storePixelDmx; PixelDmxParams pixelDmxParams(&storePixelDmx); - if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); - pixelDmxParams.Set(&pixelDmxConfiguration); - } + pixelDmxParams.Load(); + pixelDmxParams.Set(&pixelDmxConfiguration); WS28xxDmxMulti pixelDmxMulti(pixelDmxConfiguration); pixelDmxMulti.SetPixelDmxHandler(new PixelDmxStartStop); @@ -181,7 +177,6 @@ void main() { Dmx dmx; dmxparams.Load(); - dmxparams.Dump(); dmxparams.Set(&dmx); for (uint32_t nPortIndex = DMXPORT_OFFSET; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { @@ -228,7 +223,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -244,7 +238,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(&bridge, DMXPORT_OFFSET); @@ -262,11 +255,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::E131, remoteconfig::Output::PIXEL, bridge.GetActiveOutputPorts()); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/gd32_emac_e131_pixel_multi/firmware/main.cpp b/gd32_emac_e131_pixel_multi/firmware/main.cpp index a12f7b7..df23b1b 100644 --- a/gd32_emac_e131_pixel_multi/firmware/main.cpp +++ b/gd32_emac_e131_pixel_multi/firmware/main.cpp @@ -109,20 +109,15 @@ void main() { E131Bridge bridge; - if (e131params.Load()) { - e131params.Dump(); - e131params.Set(DMXPORT_OFFSET); - } + e131params.Load(); + e131params.Set(DMXPORT_OFFSET); PixelDmxConfiguration pixelDmxConfiguration; StorePixelDmx storePixelDmx; PixelDmxParams pixelDmxParams(&storePixelDmx); - - if (pixelDmxParams.Load()) { - pixelDmxParams.Dump(); - pixelDmxParams.Set(&pixelDmxConfiguration); - } + pixelDmxParams.Load(); + pixelDmxParams.Set(&pixelDmxConfiguration); WS28xxDmxMulti pixelDmxMulti(pixelDmxConfiguration); pixelDmxMulti.SetPixelDmxHandler(new PixelDmxStartStop); @@ -173,7 +168,6 @@ void main() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(); - rdmDeviceParams.Dump(); rdmDeviceParams.Set(&llrpOnlyDevice); llrpOnlyDevice.Print(); @@ -192,7 +186,6 @@ void main() { DisplayUdfParams displayUdfParams; displayUdfParams.Load(); - displayUdfParams.Dump(); displayUdfParams.Set(&display); display.Show(&bridge); @@ -210,11 +203,8 @@ void main() { RemoteConfig remoteConfig(remoteconfig::Node::E131, remoteconfig::Output::PIXEL, bridge.GetActiveOutputPorts()); - StoreRemoteConfig storeRemoteConfig; - RemoteConfigParams remoteConfigParams(&storeRemoteConfig); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); - remoteConfigParams.Dump(); remoteConfigParams.Set(&remoteConfig); while (configStore.Flash()) diff --git a/lib-artnet/include/artnetparams.h b/lib-artnet/include/artnetparams.h index 825380b..f880572 100644 --- a/lib-artnet/include/artnetparams.h +++ b/lib-artnet/include/artnetparams.h @@ -142,8 +142,6 @@ class ArtNetParams { void Set(uint32_t nPortIndexOffset); - void Dump(); - bool IsRdm() const { return isMaskSet(artnetparams::Mask::ENABLE_RDM); } @@ -187,6 +185,7 @@ class ArtNetParams { return static_cast((m_Params.nProtocol >> (nPortIndex * 2)) & 0x3); } + void Dump(); void callbackFunction(const char *pLine); void SetBool(const uint8_t nValue, const uint32_t nMask); bool isMaskSet(uint32_t nMask) const { diff --git a/lib-artnet/src/node/artnetparams.cpp b/lib-artnet/src/node/artnetparams.cpp index d2712cb..8a7aaee 100644 --- a/lib-artnet/src/node/artnetparams.cpp +++ b/lib-artnet/src/node/artnetparams.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -101,18 +102,14 @@ bool ArtNetParams::Load() { ReadConfigFile configfile(ArtNetParams::staticCallbackFunction, this); if (configfile.Read(ArtNetParamsConst::FILE_NAME)) { - // There is a configuration file - if (m_pArtNetParamsStore != nullptr) { - m_pArtNetParamsStore->Update(&m_Params); - } + m_pArtNetParamsStore->Update(&m_Params); } else #endif - if (m_pArtNetParamsStore != nullptr) { m_pArtNetParamsStore->Copy(&m_Params); - } else { - return false; - } +#ifndef NDEBUG + Dump(); +#endif return true; } @@ -131,6 +128,10 @@ void ArtNetParams::Load(const char *pBuffer, uint32_t nLength) { assert(m_pArtNetParamsStore != nullptr); m_pArtNetParamsStore->Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif + DEBUG_EXIT } @@ -335,13 +336,6 @@ void ArtNetParams::callbackFunction(const char *pLine) { } } -void ArtNetParams::staticCallbackFunction(void *p, const char *s) { - assert(p != nullptr); - assert(s != nullptr); - - (static_cast(p))->callbackFunction(s); -} - void ArtNetParams::Builder(const struct Params *pParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { DEBUG_ENTRY DEBUG_PRINTF("s_nPortsMax=%u", s_nPortsMax); @@ -505,3 +499,67 @@ void ArtNetParams::Set(uint32_t nPortIndexOffset) { DEBUG_EXIT } + +void ArtNetParams::staticCallbackFunction(void *p, const char *s) { + assert(p != nullptr); + assert(s != nullptr); + + (static_cast(p))->callbackFunction(s); +} + +void ArtNetParams::Dump() { + printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, ArtNetParamsConst::FILE_NAME); + + printf(" %s=%d [%s]\n", LightSetParamsConst::FAILSAFE, m_Params.nFailSafe, lightset::get_failsafe(static_cast(m_Params.nFailSafe))); + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=%s\n", LightSetParamsConst::NODE_LABEL[i], m_Params.aLabel[i]); + } + + printf(" %s=%s\n", LightSetParamsConst::NODE_LONG_NAME, m_Params.aLongName); + printf(" %s=1 [Yes]\n", ArtNetParamsConst::ENABLE_RDM); + + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=%d\n", LightSetParamsConst::UNIVERSE_PORT[i], m_Params.nUniverse[i]); + } + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=%s\n", LightSetParamsConst::MERGE_MODE_PORT[i], lightset::get_merge_mode(mergemode_get(i))); + } + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=%s\n", ArtNetParamsConst::PROTOCOL_PORT[i], artnet::get_protocol_mode(i)); + } + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + const auto portDir = portdir_get(i); + printf(" %s=%u [%s]\n", LightSetParamsConst::DIRECTION[i], static_cast(portDir), lightset::get_direction(portDir)); + } + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=" IPSTR "\n", ArtNetParamsConst::DESTINATION_IP_PORT[i], IP2STR(m_Params.nDestinationIp[i])); + + } + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + const auto nOutputStyle = static_cast(isOutputStyleSet(1U << i)); + printf(" %s=%u [%s]\n", LightSetParamsConst::OUTPUT_STYLE[i], nOutputStyle, lightset::get_output_style(static_cast(nOutputStyle))); + } + + /** + * Art-Net 4 + */ + + printf(" %s=1 [Yes]\n", ArtNetParamsConst::MAP_UNIVERSE0); + + for (uint32_t i = 0; i < artnet::PORTS; i++) { + printf(" %s=%u\n", LightSetParamsConst::PRIORITY[i], m_Params.nPriority[i]); + } + + /** + * Extra's + */ + + printf(" %s=1 [Yes]\n", LightSetParamsConst::DISABLE_MERGE_TIMEOUT); +} diff --git a/lib-artnet/src/node/artnetparamsdump.cpp b/lib-artnet/src/node/artnetparamsdump.cpp deleted file mode 100644 index 106748a..0000000 --- a/lib-artnet/src/node/artnetparamsdump.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file artnetparamsdump.cpp - * - */ -/** - * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. - */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - -#include - -#include "artnetparams.h" -#include "artnetparamsconst.h" - -#include "lightsetparamsconst.h" - -#include "network.h" - -void ArtNetParams::Dump() { -#ifndef NDEBUG - printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, ArtNetParamsConst::FILE_NAME); - - printf(" %s=%d [%s]\n", LightSetParamsConst::FAILSAFE, m_Params.nFailSafe, lightset::get_failsafe(static_cast(m_Params.nFailSafe))); - - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=%s\n", LightSetParamsConst::NODE_LABEL[i], m_Params.aLabel[i]); - } - - printf(" %s=%s\n", LightSetParamsConst::NODE_LONG_NAME, m_Params.aLongName); - printf(" %s=1 [Yes]\n", ArtNetParamsConst::ENABLE_RDM); - - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=%d\n", LightSetParamsConst::UNIVERSE_PORT[i], m_Params.nUniverse[i]); - } - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=%s\n", LightSetParamsConst::MERGE_MODE_PORT[i], lightset::get_merge_mode(mergemode_get(i))); - } - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=%s\n", ArtNetParamsConst::PROTOCOL_PORT[i], artnet::get_protocol_mode(i)); - } - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - const auto portDir = portdir_get(i); - printf(" %s=%u [%s]\n", LightSetParamsConst::DIRECTION[i], static_cast(portDir), lightset::get_direction(portDir)); - } - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=" IPSTR "\n", ArtNetParamsConst::DESTINATION_IP_PORT[i], IP2STR(m_Params.nDestinationIp[i])); - - } - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - const auto nOutputStyle = static_cast(isOutputStyleSet(1U << i)); - printf(" %s=%u [%s]\n", LightSetParamsConst::OUTPUT_STYLE[i], nOutputStyle, lightset::get_output_style(static_cast(nOutputStyle))); - } - - /** - * Art-Net 4 - */ - - printf(" %s=1 [Yes]\n", ArtNetParamsConst::MAP_UNIVERSE0); - - for (uint32_t i = 0; i < artnet::PORTS; i++) { - printf(" %s=%u\n", LightSetParamsConst::PRIORITY[i], m_Params.nPriority[i]); - } - - /** - * Extra's - */ - - printf(" %s=1 [Yes]\n", LightSetParamsConst::DISABLE_MERGE_TIMEOUT); -#endif -} diff --git a/lib-c++/.settings/language.settings.xml b/lib-c++/.settings/language.settings.xml index 674aa03..840cf70 100644 --- a/lib-c++/.settings/language.settings.xml +++ b/lib-c++/.settings/language.settings.xml @@ -1,14 +1,11 @@ - + + - - - - - + diff --git a/lib-configstore/include/storee131.h b/lib-configstore/include/storee131.h index dcfb131..a9df295 100755 --- a/lib-configstore/include/storee131.h +++ b/lib-configstore/include/storee131.h @@ -2,7 +2,7 @@ * @file storee131.h * */ -/* Copyright (C) 2018-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-configstore/src/storeremoteconfig.cpp b/lib-configstore/src/storeremoteconfig.cpp deleted file mode 100644 index 8c36dec..0000000 --- a/lib-configstore/src/storeremoteconfig.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file storeremoteconfig.cpp - * - */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include "storeremoteconfig.h" - -#include "debug.h" - -StoreRemoteConfig *StoreRemoteConfig::s_pThis = nullptr; - -StoreRemoteConfig::StoreRemoteConfig() { - DEBUG_ENTRY - - assert(s_pThis == nullptr); - s_pThis = this; - - DEBUG_PRINTF("%p", reinterpret_cast(s_pThis)); - DEBUG_EXIT -} diff --git a/lib-device/include/max7219.h b/lib-device/include/max7219.h index e23fa9b..b7e57e4 100644 --- a/lib-device/include/max7219.h +++ b/lib-device/include/max7219.h @@ -2,7 +2,7 @@ * @file max7219.h * */ -/* Copyright (C) 2020-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-device/include/mcp49x2.h b/lib-device/include/mcp49x2.h index 977a8db..9d48e18 100644 --- a/lib-device/include/mcp49x2.h +++ b/lib-device/include/mcp49x2.h @@ -2,7 +2,7 @@ * @file mcp49x2.h * */ -/* Copyright (C) 2014-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2014-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-displayudf/include/displayudfparams.h b/lib-displayudf/include/displayudfparams.h index 5582679..d13b2f0 100644 --- a/lib-displayudf/include/displayudfparams.h +++ b/lib-displayudf/include/displayudfparams.h @@ -62,18 +62,17 @@ class DisplayUdfParams { void Set(DisplayUdf *pDisplayUdf); - void Dump(); - static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *s); bool isMaskSet(uint32_t nMask) const { - return (m_tDisplayUdfParams.nSetList & nMask) == nMask; + return (m_Params.nSetList & nMask) == nMask; } private: - displayudfparams::Params m_tDisplayUdfParams; + displayudfparams::Params m_Params; }; #endif /* DISPLAYUDFPARAMS_H_ */ diff --git a/lib-displayudf/include/displayudfparamsconst.h b/lib-displayudf/include/displayudfparamsconst.h index bb5c9a2..993f92c 100644 --- a/lib-displayudf/include/displayudfparamsconst.h +++ b/lib-displayudf/include/displayudfparamsconst.h @@ -2,7 +2,7 @@ * @file displayudfparamsconst.h * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-displayudf/src/displayudfparams.cpp b/lib-displayudf/src/displayudfparams.cpp index d97e004..130d319 100644 --- a/lib-displayudf/src/displayudfparams.cpp +++ b/lib-displayudf/src/displayudfparams.cpp @@ -144,9 +144,9 @@ static constexpr const char *pArray[static_cast(Labels::UNKNOWN)] = { DisplayUdfParams::DisplayUdfParams() { DEBUG_ENTRY - memset(&m_tDisplayUdfParams, 0, sizeof(struct displayudfparams::Params)); - m_tDisplayUdfParams.nSleepTimeout = display::Defaults::SEEP_TIMEOUT; - m_tDisplayUdfParams.nIntensity = defaults::INTENSITY; + memset(&m_Params, 0, sizeof(struct displayudfparams::Params)); + m_Params.nSleepTimeout = display::Defaults::SEEP_TIMEOUT; + m_Params.nIntensity = defaults::INTENSITY; DEBUG_EXIT } @@ -154,17 +154,20 @@ DisplayUdfParams::DisplayUdfParams() { void DisplayUdfParams::Load() { DEBUG_ENTRY - m_tDisplayUdfParams.nSetList = 0; + m_Params.nSetList = 0; #if !defined(DISABLE_FS) ReadConfigFile configfile(DisplayUdfParams::staticCallbackFunction, this); if (configfile.Read(DisplayUdfParamsConst::FILE_NAME)) { - StoreDisplayUdf::Update(&m_tDisplayUdfParams); + StoreDisplayUdf::Update(&m_Params); } else #endif - StoreDisplayUdf::Copy(&m_tDisplayUdfParams); + StoreDisplayUdf::Copy(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -174,14 +177,17 @@ void DisplayUdfParams::Load(const char *pBuffer, uint32_t nLength) { assert(pBuffer != nullptr); assert(nLength != 0); - m_tDisplayUdfParams.nSetList = 0; + m_Params.nSetList = 0; ReadConfigFile config(DisplayUdfParams::staticCallbackFunction, this); config.Read(pBuffer, nLength); - StoreDisplayUdf::Update(&m_tDisplayUdfParams); + StoreDisplayUdf::Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -190,32 +196,32 @@ void DisplayUdfParams::callbackFunction(const char *pLine) { uint8_t value8; if (Sscan::Uint8(pLine, DisplayUdfParamsConst::INTENSITY, value8) == Sscan::OK) { - m_tDisplayUdfParams.nIntensity = value8; + m_Params.nIntensity = value8; if (value8 != defaults::INTENSITY) { - m_tDisplayUdfParams.nSetList |= displayudfparams::Mask::INTENSITY; + m_Params.nSetList |= displayudfparams::Mask::INTENSITY; } else { - m_tDisplayUdfParams.nSetList &= ~displayudfparams::Mask::INTENSITY; + m_Params.nSetList &= ~displayudfparams::Mask::INTENSITY; } return; } if (Sscan::Uint8(pLine, DisplayUdfParamsConst::SLEEP_TIMEOUT, value8) == Sscan::OK) { - m_tDisplayUdfParams.nSleepTimeout = value8; + m_Params.nSleepTimeout = value8; if (value8 != display::Defaults::SEEP_TIMEOUT) { - m_tDisplayUdfParams.nSetList |= displayudfparams::Mask::SLEEP_TIMEOUT; + m_Params.nSetList |= displayudfparams::Mask::SLEEP_TIMEOUT; } else { - m_tDisplayUdfParams.nSetList &= ~displayudfparams::Mask::SLEEP_TIMEOUT; + m_Params.nSetList &= ~displayudfparams::Mask::SLEEP_TIMEOUT; } return; } if (Sscan::Uint8(pLine, DisplayUdfParamsConst::FLIP_VERTICALLY, value8) == Sscan::OK) { if (value8 != 0) { - m_tDisplayUdfParams.nSetList |= displayudfparams::Mask::FLIP_VERTICALLY; + m_Params.nSetList |= displayudfparams::Mask::FLIP_VERTICALLY; } else { - m_tDisplayUdfParams.nSetList &= ~displayudfparams::Mask::FLIP_VERTICALLY; + m_Params.nSetList &= ~displayudfparams::Mask::FLIP_VERTICALLY; } return; } @@ -223,11 +229,11 @@ void DisplayUdfParams::callbackFunction(const char *pLine) { for (uint32_t i = 0; i < static_cast(Labels::UNKNOWN); i++) { if (Sscan::Uint8(pLine, pArray[i], value8) == Sscan::OK) { if ((value8 > 0) && (value8 <= LABEL_MAX_ROWS)) { - m_tDisplayUdfParams.nLabelIndex[i] = value8; - m_tDisplayUdfParams.nSetList |= (1U << i); + m_Params.nLabelIndex[i] = value8; + m_Params.nSetList |= (1U << i); } else { - m_tDisplayUdfParams.nLabelIndex[i] = 0; - m_tDisplayUdfParams.nSetList &= ~(1U << i); + m_Params.nLabelIndex[i] = 0; + m_Params.nSetList &= ~(1U << i); } return; } @@ -238,21 +244,21 @@ void DisplayUdfParams::Builder(const struct displayudfparams::Params *ptDisplayU assert(pBuffer != nullptr); if (ptDisplayUdfParams != nullptr) { - memcpy(&m_tDisplayUdfParams, ptDisplayUdfParams, sizeof(struct displayudfparams::Params)); + memcpy(&m_Params, ptDisplayUdfParams, sizeof(struct displayudfparams::Params)); } else { assert(m_pDisplayUdfParamsStore != nullptr); - StoreDisplayUdf::Copy(&m_tDisplayUdfParams); + StoreDisplayUdf::Copy(&m_Params); } PropertiesBuilder builder(DisplayUdfParamsConst::FILE_NAME, pBuffer, nLength); - builder.Add(DisplayUdfParamsConst::INTENSITY, m_tDisplayUdfParams.nIntensity , isMaskSet(displayudfparams::Mask::INTENSITY)); - builder.Add(DisplayUdfParamsConst::SLEEP_TIMEOUT, m_tDisplayUdfParams.nSleepTimeout , isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)); + builder.Add(DisplayUdfParamsConst::INTENSITY, m_Params.nIntensity , isMaskSet(displayudfparams::Mask::INTENSITY)); + builder.Add(DisplayUdfParamsConst::SLEEP_TIMEOUT, m_Params.nSleepTimeout , isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)); builder.Add(DisplayUdfParamsConst::FLIP_VERTICALLY, isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY) , isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY)); for (uint32_t i = 0; i < static_cast(Labels::UNKNOWN); i++) { if (pArray[i][0] != '\0') { - builder.Add(pArray[i], m_tDisplayUdfParams.nLabelIndex[i] , isMaskSet(1U << i)); + builder.Add(pArray[i], m_Params.nLabelIndex[i] , isMaskSet(1U << i)); } } @@ -263,18 +269,18 @@ void DisplayUdfParams::Set(DisplayUdf *pDisplayUdf) { assert(pDisplayUdf != nullptr); if (isMaskSet(displayudfparams::Mask::INTENSITY)) { - pDisplayUdf->SetContrast(m_tDisplayUdfParams.nIntensity); + pDisplayUdf->SetContrast(m_Params.nIntensity); } if (isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)) { - pDisplayUdf->SetSleepTimeout(m_tDisplayUdfParams.nSleepTimeout); + pDisplayUdf->SetSleepTimeout(m_Params.nSleepTimeout); } pDisplayUdf->SetFlipVertically(isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY)); for (uint32_t i = 0; i < static_cast(Labels::UNKNOWN); i++) { if (isMaskSet(1U << i)) { - pDisplayUdf->Set(m_tDisplayUdfParams.nLabelIndex[i], static_cast(i)); + pDisplayUdf->Set(m_Params.nLabelIndex[i], static_cast(i)); } } } @@ -287,15 +293,14 @@ void DisplayUdfParams::staticCallbackFunction(void *p, const char *s) { } void DisplayUdfParams::Dump() { -#ifndef NDEBUG printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, DisplayUdfParamsConst::FILE_NAME); if (isMaskSet(displayudfparams::Mask::INTENSITY)) { - printf(" %s=%d\n", DisplayUdfParamsConst::INTENSITY, m_tDisplayUdfParams.nIntensity); + printf(" %s=%d\n", DisplayUdfParamsConst::INTENSITY, m_Params.nIntensity); } if (isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)) { - printf(" %s=%d\n", DisplayUdfParamsConst::SLEEP_TIMEOUT, m_tDisplayUdfParams.nSleepTimeout); + printf(" %s=%d\n", DisplayUdfParamsConst::SLEEP_TIMEOUT, m_Params.nSleepTimeout); } if (isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY)) { @@ -304,8 +309,7 @@ void DisplayUdfParams::Dump() { for (uint32_t i = 0; i < static_cast(Labels::UNKNOWN); i++) { if (isMaskSet(1U << i)) { - printf(" %s=%d\n", pArray[i], m_tDisplayUdfParams.nLabelIndex[i]); + printf(" %s=%d\n", pArray[i], m_Params.nLabelIndex[i]); } } -#endif } diff --git a/lib-dmx/include/dmxparams.h b/lib-dmx/include/dmxparams.h index 270144d..63c04cd 100644 --- a/lib-dmx/include/dmxparams.h +++ b/lib-dmx/include/dmxparams.h @@ -70,18 +70,17 @@ class DmxParams { void Set(Dmx *); - void Dump(); - static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *s); bool isMaskSet(uint32_t nMask) const { - return (m_tDmxParams.nSetList & nMask) == nMask; + return (m_Params.nSetList & nMask) == nMask; } private: - dmxsendparams::Params m_tDmxParams; + dmxsendparams::Params m_Params; }; #endif /* DMXPARAMS_H_ */ diff --git a/lib-dmx/include/dmxparamsconst.h b/lib-dmx/include/dmxparamsconst.h index 0ff53d3..e96041a 100644 --- a/lib-dmx/include/dmxparamsconst.h +++ b/lib-dmx/include/dmxparamsconst.h @@ -3,7 +3,7 @@ * * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-dmx/src/dmxparams.cpp b/lib-dmx/src/dmxparams.cpp index 1c0c7e7..6145f37 100644 --- a/lib-dmx/src/dmxparams.cpp +++ b/lib-dmx/src/dmxparams.cpp @@ -2,7 +2,7 @@ * @file dmxparams.cpp * */ -/* Copyright (C) 2017-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -48,26 +48,33 @@ #include "debug.h" DmxParams::DmxParams() { - m_tDmxParams.nSetList = 0; - m_tDmxParams.nBreakTime = dmx::transmit::BREAK_TIME_TYPICAL; - m_tDmxParams.nMabTime = dmx::transmit::MAB_TIME_MIN; - m_tDmxParams.nRefreshRate = dmx::transmit::REFRESH_RATE_DEFAULT; - m_tDmxParams.nSlotsCount = dmxsendparams::rounddown_slots(dmx::max::CHANNELS); + m_Params.nSetList = 0; + m_Params.nBreakTime = dmx::transmit::BREAK_TIME_TYPICAL; + m_Params.nMabTime = dmx::transmit::MAB_TIME_MIN; + m_Params.nRefreshRate = dmx::transmit::REFRESH_RATE_DEFAULT; + m_Params.nSlotsCount = dmxsendparams::rounddown_slots(dmx::max::CHANNELS); - DEBUG_PRINTF("m_tDmxParams.nSlotsCount=%d", m_tDmxParams.nSlotsCount); + DEBUG_PRINTF("m_Params.nSlotsCount=%d", m_Params.nSlotsCount); } void DmxParams::Load() { - m_tDmxParams.nSetList = 0; + DEBUG_ENTRY + + m_Params.nSetList = 0; #if !defined(DISABLE_FS) ReadConfigFile configfile(DmxParams::staticCallbackFunction, this); if (configfile.Read(DmxParamsConst::FILE_NAME)) { - StoreDmxSend::Update(&m_tDmxParams); + StoreDmxSend::Update(&m_Params); } else #endif - StoreDmxSend::Copy(&m_tDmxParams); + StoreDmxSend::Copy(&m_Params); + +#ifndef NDEBUG + Dump(); +#endif + DEBUG_EXIT } void DmxParams::Load(const char* pBuffer, uint32_t nLength) { @@ -76,14 +83,17 @@ void DmxParams::Load(const char* pBuffer, uint32_t nLength) { assert(pBuffer != nullptr); assert(nLength != 0); - m_tDmxParams.nSetList = 0; + m_Params.nSetList = 0; ReadConfigFile config(DmxParams::staticCallbackFunction, this); config.Read(pBuffer, nLength); - StoreDmxSend::Update(&m_tDmxParams); + StoreDmxSend::Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -94,22 +104,22 @@ void DmxParams::callbackFunction(const char *pLine) { if (Sscan::Uint16(pLine, DmxParamsConst::BREAK_TIME, nValue16) == Sscan::OK) { if ((nValue16 >= dmx::transmit::BREAK_TIME_MIN) && (nValue16 != dmx::transmit::BREAK_TIME_TYPICAL)) { - m_tDmxParams.nBreakTime = nValue16; - m_tDmxParams.nSetList |= dmxsendparams::Mask::BREAK_TIME; + m_Params.nBreakTime = nValue16; + m_Params.nSetList |= dmxsendparams::Mask::BREAK_TIME; } else { - m_tDmxParams.nBreakTime = dmx::transmit::BREAK_TIME_TYPICAL; - m_tDmxParams.nSetList &= ~dmxsendparams::Mask::BREAK_TIME; + m_Params.nBreakTime = dmx::transmit::BREAK_TIME_TYPICAL; + m_Params.nSetList &= ~dmxsendparams::Mask::BREAK_TIME; } return; } if (Sscan::Uint16(pLine, DmxParamsConst::MAB_TIME, nValue16) == Sscan::OK) { if (nValue16 > dmx::transmit::MAB_TIME_MIN) { // && (nValue32 <= dmx::transmit::MAB_TIME_MAX)) { - m_tDmxParams.nMabTime = nValue16; - m_tDmxParams.nSetList |= dmxsendparams::Mask::MAB_TIME; + m_Params.nMabTime = nValue16; + m_Params.nSetList |= dmxsendparams::Mask::MAB_TIME; } else { - m_tDmxParams.nMabTime = dmx::transmit::MAB_TIME_MIN; - m_tDmxParams.nSetList &= ~dmxsendparams::Mask::MAB_TIME; + m_Params.nMabTime = dmx::transmit::MAB_TIME_MIN; + m_Params.nSetList &= ~dmxsendparams::Mask::MAB_TIME; } return; } @@ -118,22 +128,22 @@ void DmxParams::callbackFunction(const char *pLine) { if (Sscan::Uint8(pLine, DmxParamsConst::REFRESH_RATE, nValue8) == Sscan::OK) { if (nValue8 != dmx::transmit::REFRESH_RATE_DEFAULT) { - m_tDmxParams.nRefreshRate = nValue8; - m_tDmxParams.nSetList |= dmxsendparams::Mask::REFRESH_RATE; + m_Params.nRefreshRate = nValue8; + m_Params.nSetList |= dmxsendparams::Mask::REFRESH_RATE; } else { - m_tDmxParams.nRefreshRate = dmx::transmit::REFRESH_RATE_DEFAULT; - m_tDmxParams.nSetList &= ~dmxsendparams::Mask::REFRESH_RATE; + m_Params.nRefreshRate = dmx::transmit::REFRESH_RATE_DEFAULT; + m_Params.nSetList &= ~dmxsendparams::Mask::REFRESH_RATE; } return; } if (Sscan::Uint16(pLine, DmxParamsConst::SLOTS_COUNT, nValue16) == Sscan::OK) { if ((nValue16 >= 2) && (nValue16 < dmx::max::CHANNELS)) { - m_tDmxParams.nSlotsCount = dmxsendparams::rounddown_slots(nValue16); - m_tDmxParams.nSetList |= dmxsendparams::Mask::SLOTS_COUNT; + m_Params.nSlotsCount = dmxsendparams::rounddown_slots(nValue16); + m_Params.nSetList |= dmxsendparams::Mask::SLOTS_COUNT; } else { - m_tDmxParams.nSlotsCount = dmxsendparams::rounddown_slots(dmx::max::CHANNELS); - m_tDmxParams.nSetList &= ~dmxsendparams::Mask::SLOTS_COUNT; + m_Params.nSlotsCount = dmxsendparams::rounddown_slots(dmx::max::CHANNELS); + m_Params.nSetList &= ~dmxsendparams::Mask::SLOTS_COUNT; } return; } @@ -145,18 +155,17 @@ void DmxParams::Builder(const struct dmxsendparams::Params *ptDMXParams, char *p assert(pBuffer != nullptr); if (ptDMXParams != nullptr) { - memcpy(&m_tDmxParams, ptDMXParams, sizeof(struct dmxsendparams::Params)); + memcpy(&m_Params, ptDMXParams, sizeof(struct dmxsendparams::Params)); } else { - assert(m_pDmxParamsStore != nullptr); - StoreDmxSend::Copy(&m_tDmxParams); + StoreDmxSend::Copy(&m_Params); } PropertiesBuilder builder(DmxParamsConst::FILE_NAME, pBuffer, nLength); - builder.Add(DmxParamsConst::BREAK_TIME, m_tDmxParams.nBreakTime, isMaskSet(dmxsendparams::Mask::BREAK_TIME)); - builder.Add(DmxParamsConst::MAB_TIME, m_tDmxParams.nMabTime, isMaskSet(dmxsendparams::Mask::MAB_TIME)); - builder.Add(DmxParamsConst::REFRESH_RATE, m_tDmxParams.nRefreshRate, isMaskSet(dmxsendparams::Mask::REFRESH_RATE)); - builder.Add(DmxParamsConst::SLOTS_COUNT, dmxsendparams::roundup_slots(m_tDmxParams.nSlotsCount), isMaskSet(dmxsendparams::Mask::SLOTS_COUNT)); + builder.Add(DmxParamsConst::BREAK_TIME, m_Params.nBreakTime, isMaskSet(dmxsendparams::Mask::BREAK_TIME)); + builder.Add(DmxParamsConst::MAB_TIME, m_Params.nMabTime, isMaskSet(dmxsendparams::Mask::MAB_TIME)); + builder.Add(DmxParamsConst::REFRESH_RATE, m_Params.nRefreshRate, isMaskSet(dmxsendparams::Mask::REFRESH_RATE)); + builder.Add(DmxParamsConst::SLOTS_COUNT, dmxsendparams::roundup_slots(m_Params.nSlotsCount), isMaskSet(dmxsendparams::Mask::SLOTS_COUNT)); nSize = builder.GetSize(); @@ -168,23 +177,23 @@ void DmxParams::Set(Dmx *p) { assert(p != nullptr); if (isMaskSet(dmxsendparams::Mask::BREAK_TIME)) { - p->SetDmxBreakTime(m_tDmxParams.nBreakTime); + p->SetDmxBreakTime(m_Params.nBreakTime); } if (isMaskSet(dmxsendparams::Mask::MAB_TIME)) { - p->SetDmxMabTime(m_tDmxParams.nMabTime); + p->SetDmxMabTime(m_Params.nMabTime); } if (isMaskSet(dmxsendparams::Mask::REFRESH_RATE)) { uint32_t period = 0; - if (m_tDmxParams.nRefreshRate != 0) { - period = 1000000U / m_tDmxParams.nRefreshRate; + if (m_Params.nRefreshRate != 0) { + period = 1000000U / m_Params.nRefreshRate; } p->SetDmxPeriodTime(period); } if (isMaskSet(dmxsendparams::Mask::SLOTS_COUNT)) { - p->SetDmxSlots(dmxsendparams::roundup_slots(m_tDmxParams.nSlotsCount)); + p->SetDmxSlots(dmxsendparams::roundup_slots(m_Params.nSlotsCount)); } } @@ -196,23 +205,21 @@ void DmxParams::staticCallbackFunction(void *p, const char *s) { } void DmxParams::Dump() { -#ifndef NDEBUG printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, DmxParamsConst::FILE_NAME); if (isMaskSet(dmxsendparams::Mask::BREAK_TIME)) { - printf(" %s=%d\n", DmxParamsConst::BREAK_TIME, m_tDmxParams.nBreakTime); + printf(" %s=%d\n", DmxParamsConst::BREAK_TIME, m_Params.nBreakTime); } if (isMaskSet(dmxsendparams::Mask::MAB_TIME)) { - printf(" %s=%d\n", DmxParamsConst::MAB_TIME, m_tDmxParams.nMabTime); + printf(" %s=%d\n", DmxParamsConst::MAB_TIME, m_Params.nMabTime); } if (isMaskSet(dmxsendparams::Mask::REFRESH_RATE)) { - printf(" %s=%d\n", DmxParamsConst::REFRESH_RATE, m_tDmxParams.nRefreshRate); + printf(" %s=%d\n", DmxParamsConst::REFRESH_RATE, m_Params.nRefreshRate); } if (isMaskSet(dmxsendparams::Mask::SLOTS_COUNT)) { - printf(" %s=%d [%d]\n", DmxParamsConst::SLOTS_COUNT, m_tDmxParams.nSlotsCount, dmxsendparams::roundup_slots(m_tDmxParams.nSlotsCount)); + printf(" %s=%d [%d]\n", DmxParamsConst::SLOTS_COUNT, m_Params.nSlotsCount, dmxsendparams::roundup_slots(m_Params.nSlotsCount)); } -#endif } diff --git a/lib-e131/include/e131params.h b/lib-e131/include/e131params.h index fd256fa..9462bf3 100644 --- a/lib-e131/include/e131params.h +++ b/lib-e131/include/e131params.h @@ -132,8 +132,6 @@ class E131Params { void Set(uint32_t nPortIndexOffset); - void Dump(); - uint16_t GetUniverse(uint32_t nPortIndex, bool &IsSet) const { if (nPortIndex < e131params::MAX_PORTS) { IsSet = isMaskSet(e131params::Mask::UNIVERSE_A << nPortIndex); @@ -171,6 +169,7 @@ class E131Params { static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *s); bool isMaskSet(uint32_t nMask) const { return (m_Params.nSetList & nMask) == nMask; diff --git a/lib-e131/src/node/e131params.cpp b/lib-e131/src/node/e131params.cpp index 2084edb..f740e33 100644 --- a/lib-e131/src/node/e131params.cpp +++ b/lib-e131/src/node/e131params.cpp @@ -92,18 +92,14 @@ bool E131Params::Load() { ReadConfigFile configfile(E131Params::staticCallbackFunction, this); if (configfile.Read(E131ParamsConst::FILE_NAME)) { - if (m_pE131ParamsStore != nullptr) { - m_pE131ParamsStore->Update(&m_Params); - } + m_pE131ParamsStore->Update(&m_Params); } else #endif - if (m_pE131ParamsStore != nullptr) { m_pE131ParamsStore->Copy(&m_Params); - } else { - DEBUG_EXIT - return false; - } +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT return true; } @@ -123,6 +119,9 @@ void E131Params::Load(const char* pBuffer, uint32_t nLength) { assert(m_pE131ParamsStore != nullptr); m_pE131ParamsStore->Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -247,13 +246,6 @@ void E131Params::callbackFunction(const char *pLine) { } } -void E131Params::staticCallbackFunction(void *p, const char *s) { - assert(p != nullptr); - assert(s != nullptr); - - (static_cast(p))->callbackFunction(s); -} - void E131Params::Builder(const struct Params *pParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { DEBUG_ENTRY @@ -353,3 +345,48 @@ void E131Params::Set(uint32_t nPortIndexOffset) { p->SetDisableMergeTimeout(true); } } + +void E131Params::staticCallbackFunction(void *p, const char *s) { + assert(p != nullptr); + assert(s != nullptr); + + (static_cast(p))->callbackFunction(s); +} + +void E131Params::Dump() { + printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, E131ParamsConst::FILE_NAME); + + if (isMaskSet(e131params::Mask::FAILSAFE)) { + printf(" %s=%d [%s]\n", LightSetParamsConst::FAILSAFE, m_Params.nFailSafe, lightset::get_failsafe(static_cast(m_Params.nFailSafe))); + } + + for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { + if (isMaskSet(e131params::Mask::UNIVERSE_A << i)) { + printf(" %s=%d\n", LightSetParamsConst::UNIVERSE_PORT[i], m_Params.nUniverse[i]); + } + } + + for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { + printf(" %s=%s\n", LightSetParamsConst::MERGE_MODE_PORT[i], lightset::get_merge_mode(mergemode_get(i))); + } + + for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { + const auto portDir = static_cast(e131params::portdir_shif_right(m_Params.nDirection, i)); + printf(" %s=%d [%s]\n", LightSetParamsConst::DIRECTION[i], e131params::portdir_shif_right(m_Params.nDirection, i), lightset::get_direction(portDir)); + } + + for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { + if (isMaskSet(e131params::Mask::PRIORITY_A << i)) { + printf(" %s=%d\n", E131ParamsConst::PRIORITY[i], m_Params.nPriority[i]); + } + } + + for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { + const auto nOutputStyle = static_cast(isOutputStyleSet(1U << i)); + printf(" %s=%u [%s]\n", LightSetParamsConst::OUTPUT_STYLE[i], nOutputStyle, lightset::get_output_style(static_cast(nOutputStyle))); + } + + if (isMaskSet(e131params::Mask::DISABLE_MERGE_TIMEOUT)) { + printf(" %s=1 [Yes]\n", LightSetParamsConst::DISABLE_MERGE_TIMEOUT); + } +} diff --git a/lib-e131/src/node/e131paramsdump.cpp b/lib-e131/src/node/e131paramsdump.cpp deleted file mode 100644 index 7486385..0000000 --- a/lib-e131/src/node/e131paramsdump.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file e131paramsdump.cpp - * - */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - -#include -#include - -#include "e131params.h" -#include "e131paramsconst.h" - -#include "lightset.h" -#include "lightsetparamsconst.h" - -void E131Params::Dump() { -#ifndef NDEBUG - printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, E131ParamsConst::FILE_NAME); - - if (isMaskSet(e131params::Mask::FAILSAFE)) { - printf(" %s=%d [%s]\n", LightSetParamsConst::FAILSAFE, m_Params.nFailSafe, lightset::get_failsafe(static_cast(m_Params.nFailSafe))); - } - - for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { - if (isMaskSet(e131params::Mask::UNIVERSE_A << i)) { - printf(" %s=%d\n", LightSetParamsConst::UNIVERSE_PORT[i], m_Params.nUniverse[i]); - } - } - - for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { - printf(" %s=%s\n", LightSetParamsConst::MERGE_MODE_PORT[i], lightset::get_merge_mode(mergemode_get(i))); - } - - for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { - const auto portDir = static_cast(e131params::portdir_shif_right(m_Params.nDirection, i)); - printf(" %s=%d [%s]\n", LightSetParamsConst::DIRECTION[i], e131params::portdir_shif_right(m_Params.nDirection, i), lightset::get_direction(portDir)); - } - - for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { - if (isMaskSet(e131params::Mask::PRIORITY_A << i)) { - printf(" %s=%d\n", E131ParamsConst::PRIORITY[i], m_Params.nPriority[i]); - } - } - - for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { - const auto nOutputStyle = static_cast(isOutputStyleSet(1U << i)); - printf(" %s=%u [%s]\n", LightSetParamsConst::OUTPUT_STYLE[i], nOutputStyle, lightset::get_output_style(static_cast(nOutputStyle))); - } - - if (isMaskSet(e131params::Mask::DISABLE_MERGE_TIMEOUT)) { - printf(" %s=1 [Yes]\n", LightSetParamsConst::DISABLE_MERGE_TIMEOUT); - } -#endif -} diff --git a/lib-hal/.settings/language.settings.xml b/lib-hal/.settings/language.settings.xml index d60287e..4fec001 100644 --- a/lib-hal/.settings/language.settings.xml +++ b/lib-hal/.settings/language.settings.xml @@ -2,13 +2,13 @@ - + - + diff --git a/lib-hal/include/hal_gpio.h b/lib-hal/include/hal_gpio.h index da3fdb2..8066e94 100644 --- a/lib-hal/include/hal_gpio.h +++ b/lib-hal/include/hal_gpio.h @@ -2,7 +2,7 @@ * @file hal_gpio.h * */ -/* Copyright (C) 2020-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-network/include/networkparams.h b/lib-network/include/networkparams.h index 93ccc1e..9cd8c7e 100644 --- a/lib-network/include/networkparams.h +++ b/lib-network/include/networkparams.h @@ -97,8 +97,6 @@ class NetworkParams { Builder(nullptr, pBuffer, nLength, nSize); } - void Dump(); - bool isDhcpUsed() const { return m_Params.bIsDhcpUsed; } @@ -155,6 +153,7 @@ class NetworkParams { static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *s); bool isMaskSet(uint32_t nMask) const { return (m_Params.nSetList & nMask) == nMask; diff --git a/lib-network/src/apps/mdns/mdns.cpp b/lib-network/src/apps/mdns/mdns.cpp index 12ec1b7..e09fc59 100755 --- a/lib-network/src/apps/mdns/mdns.cpp +++ b/lib-network/src/apps/mdns/mdns.cpp @@ -830,7 +830,7 @@ bool MDNS::ServiceRecordAdd(const char *pName, const mdns::Services services, co bool MDNS::ServiceRecordDelete(const mdns::Services service) { DEBUG_ENTRY - assert(services < mdns::Services::LAST_NOT_USED); + assert(service < mdns::Services::LAST_NOT_USED); for (auto &record : s_ServiceRecords) { if (record.services == service) { diff --git a/lib-network/src/emac/network.cpp b/lib-network/src/emac/network.cpp index 8ad248a..fa67ee4 100755 --- a/lib-network/src/emac/network.cpp +++ b/lib-network/src/emac/network.cpp @@ -76,10 +76,7 @@ Network::Network(NetworkParamsStore *pNetworkParamsStore) { emac_start(m_aNetMacaddr, s_lastState); NetworkParams params(pNetworkParamsStore); - - if (params.Load()) { - params.Dump(); - } + params.Load(); m_IpInfo.ip.addr = params.GetIpAddress(); m_IpInfo.netmask.addr = params.GetNetMask(); diff --git a/lib-network/src/params/networkparams.cpp b/lib-network/src/params/networkparams.cpp index 03d4eaf..d44f162 100644 --- a/lib-network/src/params/networkparams.cpp +++ b/lib-network/src/params/networkparams.cpp @@ -63,18 +63,14 @@ bool NetworkParams::Load() { ReadConfigFile configfile(NetworkParams::staticCallbackFunction, this); if (configfile.Read(NetworkParamsConst::FILE_NAME)) { - if (m_pNetworkParamsStore != nullptr) { - m_pNetworkParamsStore->Update(&m_Params); - } + m_pNetworkParamsStore->Update(&m_Params); } else #endif - if (m_pNetworkParamsStore != nullptr) { m_pNetworkParamsStore->Copy(&m_Params); - } else { - DEBUG_EXIT - return false; - } +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT return true; } @@ -94,6 +90,9 @@ void NetworkParams::Load(const char *pBuffer, uint32_t nLength) { assert(m_pNetworkParamsStore != nullptr); m_pNetworkParamsStore->Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -270,3 +269,22 @@ void NetworkParams::Builder(const struct networkparams::Params *ptNetworkParams, DEBUG_PRINTF("nSize=%d", nSize); DEBUG_EXIT } + +void NetworkParams::Dump() { + printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, NetworkParamsConst::FILE_NAME); + + debug_print_bits(m_Params.nSetList); + + printf(" %s=%d [%s]\n", NetworkParamsConst::USE_DHCP, static_cast(m_Params.bIsDhcpUsed), m_Params.bIsDhcpUsed != 0 ? "Yes" : "No"); + printf(" %s=" IPSTR "\n", NetworkParamsConst::IP_ADDRESS, IP2STR(m_Params.nLocalIp)); + printf(" %s=" IPSTR "\n", NetworkParamsConst::NET_MASK, IP2STR(m_Params.nNetmask)); + +#if defined (ESP8266) + printf(" %s=" IPSTR "\n", NetworkParamsConst::DEFAULT_GATEWAY, IP2STR(m_Params.nGatewayIp)); + printf(" %s=" IPSTR "\n", NetworkParamsConst::NAME_SERVER, IP2STR(m_Params.nNameServerIp)); +#endif + + printf(" %s=%s\n", NetworkParamsConst::HOSTNAME, m_Params.aHostName); + printf(" %s=" IPSTR "\n", NetworkParamsConst::NTP_SERVER, IP2STR(m_Params.nNtpServerIp)); + printf(" %s=%1.1f\n", NetworkParamsConst::NTP_UTC_OFFSET, m_Params.fNtpUtcOffset); +} diff --git a/lib-network/src/params/networkparamsdump.cpp b/lib-network/src/params/networkparamsdump.cpp deleted file mode 100644 index ada0652..0000000 --- a/lib-network/src/params/networkparamsdump.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file networkparamsdump.cpp - * - */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - -#include - -#include "network.h" -#include "networkparams.h" -#include "networkparamsconst.h" - -#include "debug.h" - -void NetworkParams::Dump() { -#ifndef NDEBUG - printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, NetworkParamsConst::FILE_NAME); - - debug_print_bits(m_Params.nSetList); - - printf(" %s=%d [%s]\n", NetworkParamsConst::USE_DHCP, static_cast(m_Params.bIsDhcpUsed), m_Params.bIsDhcpUsed != 0 ? "Yes" : "No"); - printf(" %s=" IPSTR "\n", NetworkParamsConst::IP_ADDRESS, IP2STR(m_Params.nLocalIp)); - printf(" %s=" IPSTR "\n", NetworkParamsConst::NET_MASK, IP2STR(m_Params.nNetmask)); - -#if defined (ESP8266) - printf(" %s=" IPSTR "\n", NetworkParamsConst::DEFAULT_GATEWAY, IP2STR(m_Params.nGatewayIp)); - printf(" %s=" IPSTR "\n", NetworkParamsConst::NAME_SERVER, IP2STR(m_Params.nNameServerIp)); -#endif - - printf(" %s=%s\n", NetworkParamsConst::HOSTNAME, m_Params.aHostName); - printf(" %s=" IPSTR "\n", NetworkParamsConst::NTP_SERVER, IP2STR(m_Params.nNtpServerIp)); - printf(" %s=%1.1f\n", NetworkParamsConst::NTP_UTC_OFFSET, m_Params.fNtpUtcOffset); -#endif -} diff --git a/lib-properties/include/propertiesbuilder.h b/lib-properties/include/propertiesbuilder.h index e56a77c..30a3e66 100644 --- a/lib-properties/include/propertiesbuilder.h +++ b/lib-properties/include/propertiesbuilder.h @@ -2,7 +2,7 @@ * @file propertiesbuilder.h * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-properties/include/readconfigfile.h b/lib-properties/include/readconfigfile.h index 264c090..76eeb64 100644 --- a/lib-properties/include/readconfigfile.h +++ b/lib-properties/include/readconfigfile.h @@ -1,7 +1,7 @@ /** * @file readconfigfile.h */ -/* Copyright (C) 2017-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-rdm/include/rdmdeviceparams.h b/lib-rdm/include/rdmdeviceparams.h index b7415b2..430b343 100644 --- a/lib-rdm/include/rdmdeviceparams.h +++ b/lib-rdm/include/rdmdeviceparams.h @@ -64,12 +64,10 @@ class RDMDeviceParams { void Set(RDMDevice *pRDMDevice); - void Dump(); - -public: static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *s); bool isMaskSet(uint32_t nMask) const { return (m_Params.nSetList & nMask) == nMask; diff --git a/lib-rdm/include/rdmresponder.h b/lib-rdm/include/rdmresponder.h index 4e342ac..8bfc569 100644 --- a/lib-rdm/include/rdmresponder.h +++ b/lib-rdm/include/rdmresponder.h @@ -2,7 +2,7 @@ * @file rdmresponder.h * */ -/* Copyright (C) 2018-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-rdm/include/rdmslotinfo.h b/lib-rdm/include/rdmslotinfo.h index 5c99e65..5bbf0c0 100644 --- a/lib-rdm/include/rdmslotinfo.h +++ b/lib-rdm/include/rdmslotinfo.h @@ -2,7 +2,7 @@ * @file rdmslotinfo.h * */ -/* Copyright (C) 2018-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-rdm/src/rdmdeviceparams.cpp b/lib-rdm/src/rdmdeviceparams.cpp index 8e1aa79..c316ef8 100644 --- a/lib-rdm/src/rdmdeviceparams.cpp +++ b/lib-rdm/src/rdmdeviceparams.cpp @@ -30,9 +30,7 @@ #include #include -#ifndef NDEBUG -# include -#endif +#include #include #include "rdmdeviceparams.h" @@ -77,6 +75,9 @@ void RDMDeviceParams::Load() { #endif StoreRDMDevice::Copy(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -94,6 +95,9 @@ void RDMDeviceParams::Load(const char *pBuffer, uint32_t nLength) { StoreRDMDevice::Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } @@ -186,7 +190,6 @@ void RDMDeviceParams::staticCallbackFunction(void *p, const char *s) { } void RDMDeviceParams::Dump() { -#ifndef NDEBUG printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, RDMDeviceParamsConst::FILE_NAME); if (isMaskSet(rdm::deviceparams::Mask::LABEL)) { @@ -200,5 +203,4 @@ void RDMDeviceParams::Dump() { if (isMaskSet(rdm::deviceparams::Mask::PRODUCT_DETAIL)) { printf(" %s=%.4x\n", RDMDeviceParamsConst::PRODUCT_DETAIL, m_Params.nProductDetail); } -#endif } diff --git a/lib-rdmnet/include/llrppacket.h b/lib-rdmnet/include/llrppacket.h index f9a1ec4..3be2b88 100644 --- a/lib-rdmnet/include/llrppacket.h +++ b/lib-rdmnet/include/llrppacket.h @@ -2,7 +2,7 @@ * @file llrppacket.h * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-remoteconfig/include/remoteconfigconst.h b/lib-remoteconfig/include/remoteconfigconst.h index 553d5ec..9a3da1d 100644 --- a/lib-remoteconfig/include/remoteconfigconst.h +++ b/lib-remoteconfig/include/remoteconfigconst.h @@ -2,7 +2,7 @@ * @file remoteconfigconst.h * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/lib-remoteconfig/include/remoteconfigparams.h b/lib-remoteconfig/include/remoteconfigparams.h index 95e4286..ba4aa0c 100644 --- a/lib-remoteconfig/include/remoteconfigparams.h +++ b/lib-remoteconfig/include/remoteconfigparams.h @@ -2,7 +2,7 @@ * @file remoteconfigparams.h * */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,8 @@ #include "remoteconfig.h" -struct TRemoteConfigParams { +namespace remoteconfigparams { +struct Params { uint32_t nSetList; uint8_t NotUsed0; uint8_t NotUsed1; @@ -39,9 +40,9 @@ struct TRemoteConfigParams { char aDisplayName[remoteconfig::DISPLAY_NAME_LENGTH]; } __attribute__((packed)); -static_assert(sizeof(struct TRemoteConfigParams) <= 48, "struct TRemoteConfigParams is too large"); +static_assert(sizeof(struct Params) <= 48, "struct Params is too large"); -struct RemoteConfigParamsMask { +struct Mask { static constexpr auto DISABLE = (1U << 0); static constexpr auto DISABLE_WRITE = (1U << 1); static constexpr auto ENABLE_REBOOT = (1U << 2); @@ -49,23 +50,16 @@ struct RemoteConfigParamsMask { static constexpr auto DISPLAY_NAME = (1U << 4); static constexpr auto ENABLE_FACTORY = (1U << 5); }; - -class RemoteConfigParamsStore { -public: - virtual ~RemoteConfigParamsStore() = default; - - virtual void Update(const struct TRemoteConfigParams *pRemoteConfigParams)=0; - virtual void Copy(struct TRemoteConfigParams *pRemoteConfigParams)=0; -}; +} // namespace remoteconfigparams class RemoteConfigParams { public: - RemoteConfigParams(RemoteConfigParamsStore *pRemoteConfigParamsStore); + RemoteConfigParams(); void Load(); void Load(const char *pBuffer, uint32_t nLength); - void Builder(const struct TRemoteConfigParams *pRemoteConfigParams, char *pBuffer, uint32_t nLength, uint32_t& nSize); + void Builder(const struct remoteconfigparams::Params *pRemoteConfigParams, char *pBuffer, uint32_t nLength, uint32_t& nSize); void Save(char *pBuffer, uint32_t nLength, uint32_t& nSize) { Builder(nullptr, pBuffer, nLength, nSize); } @@ -73,23 +67,21 @@ class RemoteConfigParams { void Set(RemoteConfig *); const char *GetDisplayName() const { - return m_tRemoteConfigParams.aDisplayName; + return m_Params.aDisplayName; } - void Dump(); - static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *pLine); void SetBool(const uint8_t nValue, const uint32_t nMask); bool isMaskSet(uint32_t nMask) const { - return (m_tRemoteConfigParams.nSetList & nMask) == nMask; + return (m_Params.nSetList & nMask) == nMask; } private: - RemoteConfigParamsStore *m_pRemoteConfigParamsStore; - TRemoteConfigParams m_tRemoteConfigParams; + remoteconfigparams::Params m_Params; }; #endif /* REMOTECONFIGPARAMS_H_ */ diff --git a/lib-configstore/include/storeremoteconfig.h b/lib-remoteconfig/include/storeremoteconfig.h similarity index 64% rename from lib-configstore/include/storeremoteconfig.h rename to lib-remoteconfig/include/storeremoteconfig.h index 46360d4..1ce7f79 100755 --- a/lib-configstore/include/storeremoteconfig.h +++ b/lib-remoteconfig/include/storeremoteconfig.h @@ -2,7 +2,7 @@ * @file storeremoteconfig.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,27 +27,31 @@ #define STOREREMOTECONFIG_H_ #include "remoteconfigparams.h" - #include "configstore.h" -class StoreRemoteConfig final: public RemoteConfigParamsStore { +class StoreRemoteConfig { public: - StoreRemoteConfig(); - - void Update(const struct TRemoteConfigParams *pRemoteConfigParams) override { - ConfigStore::Get()->Update(configstore::Store::RCONFIG, pRemoteConfigParams, sizeof(struct TRemoteConfigParams)); + static StoreRemoteConfig& Get() { + static StoreRemoteConfig instance; + return instance; } - void Copy(struct TRemoteConfigParams *pRemoteConfigParams) override { - ConfigStore::Get()->Copy(configstore::Store::RCONFIG, pRemoteConfigParams, sizeof(struct TRemoteConfigParams)); + static void Update(const struct remoteconfigparams::Params *pParams) { + Get().IUpdate(pParams); } - static StoreRemoteConfig *Get() { - return s_pThis; + static void Copy(struct remoteconfigparams::Params *pParams) { + Get().ICopy(pParams); } private: - static StoreRemoteConfig *s_pThis; + void IUpdate(const struct remoteconfigparams::Params *pParams) { + ConfigStore::Get()->Update(configstore::Store::RCONFIG, pParams, sizeof(struct remoteconfigparams::Params)); + } + + void ICopy(struct remoteconfigparams::Params *pParams) { + ConfigStore::Get()->Copy(configstore::Store::RCONFIG, pParams, sizeof(struct remoteconfigparams::Params)); + } }; #endif /* STOREREMOTECONFIG_H_ */ diff --git a/lib-remoteconfig/src/remoteconfig.cpp b/lib-remoteconfig/src/remoteconfig.cpp index f6d0884..ae21fb0 100644 --- a/lib-remoteconfig/src/remoteconfig.cpp +++ b/lib-remoteconfig/src/remoteconfig.cpp @@ -607,7 +607,7 @@ uint32_t RemoteConfig::HandleGet(void *pBuffer, uint32_t nBufferLength) { void RemoteConfig::HandleGetRconfigTxt(uint32_t& nSize) { DEBUG_ENTRY - RemoteConfigParams remoteConfigParams(StoreRemoteConfig::Get()); + RemoteConfigParams remoteConfigParams; remoteConfigParams.Save(s_pUdpBuffer, remoteconfig::udp::BUFFER_SIZE, nSize); DEBUG_EXIT @@ -719,7 +719,6 @@ void RemoteConfig::HandleGetDevicesTxt(uint32_t& nSize) { TLC59711DmxParams tlc5911params; tlc5911params.Load(); - tlc5911params.Dump(); # if defined (OUTPUT_DMX_PIXEL) if ((bIsSetLedType = tlc5911params.IsSetLedType()) == true) { # endif @@ -962,14 +961,9 @@ void RemoteConfig::HandleSet(void *pBuffer, uint32_t nBufferLength) { void RemoteConfig::HandleSetRconfig() { DEBUG_ENTRY - assert(StoreRemoteConfig::Get() != nullptr); - RemoteConfigParams remoteConfigParams(StoreRemoteConfig::Get()); - + RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(s_pUdpBuffer, m_nBytesReceived); remoteConfigParams.Set(this); -#ifndef NDEBUG - remoteConfigParams.Dump(); -#endif DEBUG_EXIT } @@ -979,11 +973,7 @@ void RemoteConfig::HandleSetNetworkTxt() { assert(StoreNetwork::Get() != nullptr); NetworkParams params(StoreNetwork::Get()); - params.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - params.Dump(); -#endif DEBUG_EXIT } @@ -994,11 +984,7 @@ void RemoteConfig::HandleSetArtnetTxt() { assert(StoreArtNet::Get() != nullptr); ArtNetParams artnetParams(StoreArtNet::Get()); - artnetParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - artnetParams.Dump(); -#endif DEBUG_EXIT } @@ -1010,11 +996,8 @@ void RemoteConfig::HandleSetE131Txt() { assert(StoreE131::Get() != nullptr); E131Params e131params(StoreE131::Get()); - e131params.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - e131params.Dump(); -#endif + DEBUG_EXIT } #endif @@ -1025,9 +1008,6 @@ void RemoteConfig::HandleSetOscTxt() { OSCServerParams oscServerParams; oscServerParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - oscServerParams.Dump(); -#endif DEBUG_EXIT } @@ -1039,9 +1019,6 @@ void RemoteConfig::HandleSetOscClientTxt() { OscClientParams oscClientParams; oscClientParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - oscClientParams.Dump(); -#endif DEBUG_EXIT } @@ -1053,9 +1030,6 @@ void RemoteConfig::HandleSetParamsTxt() { DmxParams dmxparams; dmxparams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - dmxparams.Dump(); -#endif DEBUG_EXIT } @@ -1068,7 +1042,6 @@ void RemoteConfig::HandleSetDevicesTxt() { # if defined (OUTPUT_DMX_TLC59711) TLC59711DmxParams tlc59711params; tlc59711params.Load(s_pUdpBuffer, m_nBytesReceived); - tlc59711params.Dump(); DEBUG_PRINTF("tlc5911params.IsSetLedType()=%d", tlc59711params.IsSetLedType()); @@ -1078,7 +1051,6 @@ void RemoteConfig::HandleSetDevicesTxt() { assert(StorePixelDmx::Get() != nullptr); PixelDmxParams pixelDmxParams(StorePixelDmx::Get()); pixelDmxParams.Load(s_pUdpBuffer, m_nBytesReceived); - pixelDmxParams.Dump(); # endif # if defined (OUTPUT_DMX_TLC59711) } @@ -1094,9 +1066,6 @@ void RemoteConfig::HandleSetLtcTxt() { LtcParams ltcParams; ltcParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - ltcParams.Dump(); -#endif DEBUG_EXIT } @@ -1106,9 +1075,6 @@ void RemoteConfig::HandleSetLdisplayTxt() { LtcDisplayParams ltcDisplayParams; ltcDisplayParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - ltcDisplayParams.Dump(); -#endif DEBUG_EXIT } @@ -1118,9 +1084,6 @@ void RemoteConfig::HandleSetTCNetTxt() { TCNetParams tcnetParams; tcnetParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - tcnetParams.Dump(); -#endif DEBUG_EXIT } @@ -1130,9 +1093,6 @@ void RemoteConfig::HandleSetGpsTxt() { GPSParams gpsParams; gpsParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - gpsParams.Dump(); -#endif DEBUG_EXIT } @@ -1142,9 +1102,6 @@ void RemoteConfig::HandleSetLtcEtcTxt() { LtcEtcParams ltcEtcParams; ltcEtcParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - ltcEtcParams.Dump(); -#endif DEBUG_EXIT } @@ -1156,9 +1113,6 @@ void RemoteConfig::HandleSetMonTxt() { DMXMonitorParams monitorParams; monitorParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - monitorParams.Dump(); -#endif DEBUG_EXIT } @@ -1170,9 +1124,6 @@ void RemoteConfig::HandleSetDisplayTxt() { DisplayUdfParams displayParams; displayParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - displayParams.Dump(); -#endif DEBUG_EXIT } @@ -1184,11 +1135,7 @@ void RemoteConfig::HandleSetSparkFunTxt() { assert(StoreSparkFunDmx::Get() != nullptr); SparkFunDmxParams sparkFunDmxParams(StoreSparkFunDmx::Get()); - sparkFunDmxParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - sparkFunDmxParams.Dump(); -#endif DEBUG_EXIT } @@ -1199,33 +1146,17 @@ void RemoteConfig::HandleSetMotorTxt(uint32_t nMotorIndex) { assert(StoreSparkFunDmx::Get() != nullptr); SparkFunDmxParams sparkFunDmxParams(StoreSparkFunDmx::Get()); - sparkFunDmxParams.Load(nMotorIndex, s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - sparkFunDmxParams.Dump(); -#endif assert(StoreMotors::Get() != nullptr); ModeParams modeParams(StoreMotors::Get()); - modeParams.Load(nMotorIndex, s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - modeParams.Dump(); -#endif MotorParams motorParams(StoreMotors::Get()); - motorParams.Load(nMotorIndex, s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - motorParams.Dump(); -#endif L6470Params l6470Params(StoreMotors::Get()); - l6470Params.Load(nMotorIndex, s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - l6470Params.Dump(); -#endif DEBUG_EXIT } @@ -1237,9 +1168,6 @@ void RemoteConfig::HandleSetShowTxt() { ShowFileParams showFileParams; showFileParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - showFileParams.Dump(); -#endif DEBUG_EXIT } @@ -1251,11 +1179,7 @@ void RemoteConfig::HandleSetNodeTxt(const node::Personality personality) { assert(StoreNode::Get() != nullptr); NodeParams nodeParams(StoreNode::Get(), personality); - nodeParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - nodeParams.Dump(); -#endif DEBUG_EXIT } @@ -1267,9 +1191,6 @@ void RemoteConfig::HandleSetRdmDeviceTxt() { RDMDeviceParams rdmDeviceParams; rdmDeviceParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - rdmDeviceParams.Dump(); -#endif DEBUG_EXIT } @@ -1279,9 +1200,6 @@ void RemoteConfig::HandleSetRdmSensorsTxt() { RDMSensorsParams rdmSensorsParams; rdmSensorsParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - rdmSensorsParams.Dump(); -#endif DEBUG_EXIT } @@ -1291,11 +1209,7 @@ void RemoteConfig::HandleSetRdmSubdevTxt() { DEBUG_ENTRY RDMSubDevicesParams rdmSubDevicesParams; - rdmSubDevicesParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - rdmSubDevicesParams.Dump(); -#endif DEBUG_EXIT } @@ -1308,9 +1222,6 @@ void RemoteConfig::HandleSetSerialTxt() { DmxSerialParams dmxSerialParams; dmxSerialParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - dmxSerialParams.Dump(); -#endif DEBUG_EXIT } @@ -1322,9 +1233,6 @@ void RemoteConfig::HandleSetRgbPanelTxt() { RgbPanelParams rgbPanelParams; rgbPanelParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - rgbPanelParams.Dump(); -#endif DEBUG_EXIT } @@ -1336,9 +1244,6 @@ void RemoteConfig::HandleSetPca9685Txt() { PCA9685DmxParams pca9685DmxParams; pca9685DmxParams.Load(s_pUdpBuffer, m_nBytesReceived); -#ifndef NDEBUG - pca9685DmxParams.Dump(); -#endif DEBUG_EXIT } diff --git a/lib-remoteconfig/src/remoteconfigparams.cpp b/lib-remoteconfig/src/remoteconfigparams.cpp index dde144c..a4c136c 100644 --- a/lib-remoteconfig/src/remoteconfigparams.cpp +++ b/lib-remoteconfig/src/remoteconfigparams.cpp @@ -30,11 +30,13 @@ #include #include +#include #include #include "remoteconfigparams.h" #include "remoteconfig.h" #include "remoteconfigconst.h" +#include "storeremoteconfig.h" #include "readconfigfile.h" #include "sscan.h" @@ -42,26 +44,32 @@ #include "debug.h" -RemoteConfigParams::RemoteConfigParams(RemoteConfigParamsStore* pTRemoteConfigParamsStore): m_pRemoteConfigParamsStore(pTRemoteConfigParamsStore) { - memset(&m_tRemoteConfigParams, 0, sizeof(struct TRemoteConfigParams)); +RemoteConfigParams::RemoteConfigParams() { + DEBUG_ENTRY + + memset(&m_Params, 0, sizeof(struct remoteconfigparams::Params)); + + DEBUG_EXIT } void RemoteConfigParams::Load() { - m_tRemoteConfigParams.nSetList = 0; + DEBUG_ENTRY + + m_Params.nSetList = 0; #if !defined(DISABLE_FS) ReadConfigFile configfile(RemoteConfigParams::staticCallbackFunction, this); if (configfile.Read(RemoteConfigConst::PARAMS_FILE_NAME)) { - // There is a configuration file - if (m_pRemoteConfigParamsStore != nullptr) { - m_pRemoteConfigParamsStore->Update(&m_tRemoteConfigParams); - } + StoreRemoteConfig::Update(&m_Params); } else #endif - if (m_pRemoteConfigParamsStore != nullptr) { - m_pRemoteConfigParamsStore->Copy(&m_tRemoteConfigParams); - } + StoreRemoteConfig::Copy(&m_Params); + +#ifndef NDEBUG + Dump(); +#endif + DEBUG_EXIT } void RemoteConfigParams::Load(const char* pBuffer, uint32_t nLength) { @@ -70,23 +78,25 @@ void RemoteConfigParams::Load(const char* pBuffer, uint32_t nLength) { assert(pBuffer != nullptr); assert(nLength != 0); - m_tRemoteConfigParams.nSetList = 0; + m_Params.nSetList = 0; ReadConfigFile config(RemoteConfigParams::staticCallbackFunction, this); config.Read(pBuffer, nLength); - assert(m_pRemoteConfigParamsStore != nullptr); - m_pRemoteConfigParamsStore->Update(&m_tRemoteConfigParams); + StoreRemoteConfig::Update(&m_Params); +#ifndef NDEBUG + Dump(); +#endif DEBUG_EXIT } void RemoteConfigParams::SetBool(const uint8_t nValue, const uint32_t nMask) { if (nValue != 0) { - m_tRemoteConfigParams.nSetList |= nMask; + m_Params.nSetList |= nMask; } else { - m_tRemoteConfigParams.nSetList &= ~nMask; + m_Params.nSetList &= ~nMask; } } @@ -96,59 +106,58 @@ void RemoteConfigParams::callbackFunction(const char *pLine) { uint8_t nValue8; if (Sscan::Uint8(pLine, RemoteConfigConst::PARAMS_DISABLE, nValue8) == Sscan::OK) { - SetBool(nValue8, RemoteConfigParamsMask::DISABLE); + SetBool(nValue8, remoteconfigparams::Mask::DISABLE); return; } if (Sscan::Uint8(pLine, RemoteConfigConst::PARAMS_DISABLE_WRITE, nValue8) == Sscan::OK) { - SetBool(nValue8, RemoteConfigParamsMask::DISABLE_WRITE); + SetBool(nValue8, remoteconfigparams::Mask::DISABLE_WRITE); return; } if (Sscan::Uint8(pLine, RemoteConfigConst::PARAMS_ENABLE_REBOOT, nValue8) == Sscan::OK) { - SetBool(nValue8, RemoteConfigParamsMask::ENABLE_REBOOT); + SetBool(nValue8, remoteconfigparams::Mask::ENABLE_REBOOT); return; } if (Sscan::Uint8(pLine, RemoteConfigConst::PARAMS_ENABLE_UPTIME, nValue8) == Sscan::OK) { - SetBool(nValue8, RemoteConfigParamsMask::ENABLE_UPTIME); + SetBool(nValue8, remoteconfigparams::Mask::ENABLE_UPTIME); return; } if (Sscan::Uint8(pLine, RemoteConfigConst::PARAMS_ENABLE_FACTORY, nValue8) == Sscan::OK) { - SetBool(nValue8, RemoteConfigParamsMask::ENABLE_FACTORY); + SetBool(nValue8, remoteconfigparams::Mask::ENABLE_FACTORY); return; } uint32_t nLength = remoteconfig::DISPLAY_NAME_LENGTH - 1; - if (Sscan::Char(pLine, RemoteConfigConst::PARAMS_DISPLAY_NAME, m_tRemoteConfigParams.aDisplayName, nLength) == Sscan::OK) { - m_tRemoteConfigParams.aDisplayName[nLength] = '\0'; - m_tRemoteConfigParams.nSetList |= RemoteConfigParamsMask::DISPLAY_NAME; + if (Sscan::Char(pLine, RemoteConfigConst::PARAMS_DISPLAY_NAME, m_Params.aDisplayName, nLength) == Sscan::OK) { + m_Params.aDisplayName[nLength] = '\0'; + m_Params.nSetList |= remoteconfigparams::Mask::DISPLAY_NAME; return; } } -void RemoteConfigParams::Builder(const struct TRemoteConfigParams *pRemoteConfigParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { +void RemoteConfigParams::Builder(const struct remoteconfigparams::Params *pRemoteConfigParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { DEBUG_ENTRY assert(pBuffer != nullptr); if (pRemoteConfigParams != nullptr) { - memcpy(&m_tRemoteConfigParams, pRemoteConfigParams, sizeof(struct TRemoteConfigParams)); + memcpy(&m_Params, pRemoteConfigParams, sizeof(struct remoteconfigparams::Params)); } else { - assert(m_pRemoteConfigParamsStore != nullptr); - m_pRemoteConfigParamsStore->Copy(&m_tRemoteConfigParams); + StoreRemoteConfig::Copy(&m_Params); } PropertiesBuilder builder(RemoteConfigConst::PARAMS_FILE_NAME, pBuffer, nLength); - builder.Add(RemoteConfigConst::PARAMS_DISABLE, isMaskSet(RemoteConfigParamsMask::DISABLE)); - builder.Add(RemoteConfigConst::PARAMS_DISABLE_WRITE, isMaskSet(RemoteConfigParamsMask::DISABLE_WRITE)); - builder.Add(RemoteConfigConst::PARAMS_ENABLE_REBOOT, isMaskSet(RemoteConfigParamsMask::ENABLE_REBOOT)); - builder.Add(RemoteConfigConst::PARAMS_ENABLE_UPTIME, isMaskSet(RemoteConfigParamsMask::ENABLE_UPTIME)); - builder.Add(RemoteConfigConst::PARAMS_ENABLE_FACTORY, isMaskSet(RemoteConfigParamsMask::ENABLE_FACTORY)); + builder.Add(RemoteConfigConst::PARAMS_DISABLE, isMaskSet(remoteconfigparams::Mask::DISABLE)); + builder.Add(RemoteConfigConst::PARAMS_DISABLE_WRITE, isMaskSet(remoteconfigparams::Mask::DISABLE_WRITE)); + builder.Add(RemoteConfigConst::PARAMS_ENABLE_REBOOT, isMaskSet(remoteconfigparams::Mask::ENABLE_REBOOT)); + builder.Add(RemoteConfigConst::PARAMS_ENABLE_UPTIME, isMaskSet(remoteconfigparams::Mask::ENABLE_UPTIME)); + builder.Add(RemoteConfigConst::PARAMS_ENABLE_FACTORY, isMaskSet(remoteconfigparams::Mask::ENABLE_FACTORY)); - builder.Add(RemoteConfigConst::PARAMS_DISPLAY_NAME, m_tRemoteConfigParams.aDisplayName, isMaskSet(RemoteConfigParamsMask::DISPLAY_NAME)); + builder.Add(RemoteConfigConst::PARAMS_DISPLAY_NAME, m_Params.aDisplayName, isMaskSet(remoteconfigparams::Mask::DISPLAY_NAME)); nSize = builder.GetSize(); @@ -159,14 +168,14 @@ void RemoteConfigParams::Builder(const struct TRemoteConfigParams *pRemoteConfig void RemoteConfigParams::Set(RemoteConfig* pRemoteConfig) { assert(pRemoteConfig != nullptr); - pRemoteConfig->SetDisable(isMaskSet(RemoteConfigParamsMask::DISABLE)); - pRemoteConfig->SetDisableWrite(isMaskSet(RemoteConfigParamsMask::DISABLE_WRITE)); - pRemoteConfig->SetEnableReboot(isMaskSet(RemoteConfigParamsMask::ENABLE_REBOOT)); - pRemoteConfig->SetEnableUptime(isMaskSet(RemoteConfigParamsMask::ENABLE_UPTIME)); - pRemoteConfig->SetEnableFactory(isMaskSet(RemoteConfigParamsMask::ENABLE_FACTORY)); + pRemoteConfig->SetDisable(isMaskSet(remoteconfigparams::Mask::DISABLE)); + pRemoteConfig->SetDisableWrite(isMaskSet(remoteconfigparams::Mask::DISABLE_WRITE)); + pRemoteConfig->SetEnableReboot(isMaskSet(remoteconfigparams::Mask::ENABLE_REBOOT)); + pRemoteConfig->SetEnableUptime(isMaskSet(remoteconfigparams::Mask::ENABLE_UPTIME)); + pRemoteConfig->SetEnableFactory(isMaskSet(remoteconfigparams::Mask::ENABLE_FACTORY)); - if (isMaskSet(RemoteConfigParamsMask::DISPLAY_NAME)) { - pRemoteConfig->SetDisplayName(m_tRemoteConfigParams.aDisplayName); + if (isMaskSet(remoteconfigparams::Mask::DISPLAY_NAME)) { + pRemoteConfig->SetDisplayName(m_Params.aDisplayName); } } @@ -176,3 +185,13 @@ void RemoteConfigParams::staticCallbackFunction(void *p, const char *s) { (static_cast(p))->callbackFunction(s); } + +void RemoteConfigParams::Dump() { + printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, RemoteConfigConst::PARAMS_FILE_NAME); + printf(" %s=%d\n", RemoteConfigConst::PARAMS_DISABLE, isMaskSet(remoteconfigparams::Mask::DISABLE)); + printf(" %s=%d\n", RemoteConfigConst::PARAMS_DISABLE_WRITE, isMaskSet(remoteconfigparams::Mask::DISABLE_WRITE)); + printf(" %s=%d\n", RemoteConfigConst::PARAMS_ENABLE_REBOOT, isMaskSet(remoteconfigparams::Mask::ENABLE_REBOOT)); + printf(" %s=%d\n", RemoteConfigConst::PARAMS_ENABLE_UPTIME, isMaskSet(remoteconfigparams::Mask::ENABLE_UPTIME)); + printf(" %s=%d\n", RemoteConfigConst::PARAMS_ENABLE_FACTORY, isMaskSet(remoteconfigparams::Mask::ENABLE_FACTORY)); + printf(" %s=%s\n", RemoteConfigConst::PARAMS_DISPLAY_NAME, m_Params.aDisplayName); +} diff --git a/lib-remoteconfig/src/remoteconfigparamsdump.cpp b/lib-remoteconfig/src/remoteconfigparamsdump.cpp deleted file mode 100644 index c2bfee3..0000000 --- a/lib-remoteconfig/src/remoteconfigparamsdump.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file remoteconfigparamsdump.cpp - * - */ -/* Copyright (C) 2020-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - -#include - -#include "remoteconfigparams.h" -#include "remoteconfigconst.h" - -#include "debug.h" - -void RemoteConfigParams::Dump() { -#ifndef NDEBUG - printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, RemoteConfigConst::PARAMS_FILE_NAME); - - if (isMaskSet(RemoteConfigParamsMask::DISABLE)) { - printf(" %s=1 [Yes]\n", RemoteConfigConst::PARAMS_DISABLE); - } - - if (isMaskSet(RemoteConfigParamsMask::DISABLE_WRITE)) { - printf(" %s=1 [Yes]\n", RemoteConfigConst::PARAMS_DISABLE_WRITE); - } - - if (isMaskSet(RemoteConfigParamsMask::ENABLE_REBOOT)) { - printf(" %s=1 [Yes]\n", RemoteConfigConst::PARAMS_ENABLE_REBOOT); - } - - if (isMaskSet(RemoteConfigParamsMask::ENABLE_UPTIME)) { - printf(" %s=1 [Yes]\n", RemoteConfigConst::PARAMS_ENABLE_UPTIME); - } - - if (isMaskSet(RemoteConfigParamsMask::ENABLE_FACTORY)) { - printf(" %s=1 [Yes]\n", RemoteConfigConst::PARAMS_ENABLE_FACTORY); - } - - if (isMaskSet(RemoteConfigParamsMask::DISPLAY_NAME)) { - printf(" %s=%s\n", RemoteConfigConst::PARAMS_DISPLAY_NAME, m_tRemoteConfigParams.aDisplayName); - } -#endif -} diff --git a/lib-spiflashstore/src/storeremoteconfig.cpp b/lib-spiflashstore/src/storeremoteconfig.cpp deleted file mode 100644 index 8c36dec..0000000 --- a/lib-spiflashstore/src/storeremoteconfig.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file storeremoteconfig.cpp - * - */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include "storeremoteconfig.h" - -#include "debug.h" - -StoreRemoteConfig *StoreRemoteConfig::s_pThis = nullptr; - -StoreRemoteConfig::StoreRemoteConfig() { - DEBUG_ENTRY - - assert(s_pThis == nullptr); - s_pThis = this; - - DEBUG_PRINTF("%p", reinterpret_cast(s_pThis)); - DEBUG_EXIT -} diff --git a/lib-ws28xxdmx/include/pixeldmxparams.h b/lib-ws28xxdmx/include/pixeldmxparams.h index 7cdb8da..b3bd97a 100644 --- a/lib-ws28xxdmx/include/pixeldmxparams.h +++ b/lib-ws28xxdmx/include/pixeldmxparams.h @@ -97,12 +97,10 @@ class PixelDmxParams { void Set(PixelDmxConfiguration *pPixelDmxConfiguration); - void Dump(); - uint16_t GetStartUniversePort(uint32_t nOutputPortIndex, bool& isSet) const { if (nOutputPortIndex < pixeldmxparams::MAX_PORTS) { isSet = isMaskSet(pixeldmxparams::Mask::START_UNI_PORT_1 << nOutputPortIndex); - return m_pixelDmxParams.nStartUniverse[nOutputPortIndex]; + return m_Params.nStartUniverse[nOutputPortIndex]; } isSet = false; @@ -110,20 +108,21 @@ class PixelDmxParams { } uint8_t GetTestPattern() const { - return m_pixelDmxParams.nTestPattern; + return m_Params.nTestPattern; } static void staticCallbackFunction(void *p, const char *s); private: + void Dump(); void callbackFunction(const char *pLine); bool isMaskSet(uint32_t nMask) const { - return (m_pixelDmxParams.nSetList & nMask) == nMask; + return (m_Params.nSetList & nMask) == nMask; } private: PixelDmxParamsStore *m_pPixelDmxParamsStore; - pixeldmxparams::Params m_pixelDmxParams; + pixeldmxparams::Params m_Params; }; #endif /* PIXELDMXPARAMS_H_ */ diff --git a/lib-ws28xxdmx/src/params/pixeldmxparams.cpp b/lib-ws28xxdmx/src/params/pixeldmxparams.cpp index 55c512b..955c703 100644 --- a/lib-ws28xxdmx/src/params/pixeldmxparams.cpp +++ b/lib-ws28xxdmx/src/params/pixeldmxparams.cpp @@ -54,57 +54,65 @@ using namespace pixel; using namespace lightset; PixelDmxParams::PixelDmxParams(PixelDmxParamsStore *pPixelDmxParamsStore): m_pPixelDmxParamsStore(pPixelDmxParamsStore) { - m_pixelDmxParams.nSetList = 0; - m_pixelDmxParams.nType = static_cast(pixel::defaults::TYPE); - m_pixelDmxParams.nCount = defaults::COUNT; - m_pixelDmxParams.nDmxStartAddress = dmx::START_ADDRESS_DEFAULT; - m_pixelDmxParams.nSpiSpeedHz = spi::speed::ws2801::default_hz; - m_pixelDmxParams.nGlobalBrightness = 0xFF; - m_pixelDmxParams.nActiveOutputs = defaults::OUTPUT_PORTS; - m_pixelDmxParams.nGroupingCount = 1; - m_pixelDmxParams.nMap = static_cast(Map::UNDEFINED); - m_pixelDmxParams.nLowCode = 0; - m_pixelDmxParams.nHighCode = 0; - m_pixelDmxParams.nGammaValue = 0; - m_pixelDmxParams.nTestPattern = 0; + m_Params.nSetList = 0; + m_Params.nType = static_cast(pixel::defaults::TYPE); + m_Params.nCount = defaults::COUNT; + m_Params.nDmxStartAddress = dmx::START_ADDRESS_DEFAULT; + m_Params.nSpiSpeedHz = spi::speed::ws2801::default_hz; + m_Params.nGlobalBrightness = 0xFF; + m_Params.nActiveOutputs = defaults::OUTPUT_PORTS; + m_Params.nGroupingCount = 1; + m_Params.nMap = static_cast(Map::UNDEFINED); + m_Params.nLowCode = 0; + m_Params.nHighCode = 0; + m_Params.nGammaValue = 0; + m_Params.nTestPattern = 0; for (uint32_t nPortIndex = 0; nPortIndex < pixeldmxparams::MAX_PORTS; nPortIndex++) { - m_pixelDmxParams.nStartUniverse[nPortIndex] = static_cast(1 + (nPortIndex * 4)); + m_Params.nStartUniverse[nPortIndex] = static_cast(1 + (nPortIndex * 4)); } } bool PixelDmxParams::Load() { - m_pixelDmxParams.nSetList = 0; + DEBUG_ENTRY + + m_Params.nSetList = 0; #if !defined(DISABLE_FS) ReadConfigFile configfile(PixelDmxParams::staticCallbackFunction, this); if (configfile.Read(DevicesParamsConst::FILE_NAME)) { - if (m_pPixelDmxParamsStore != nullptr) { - m_pPixelDmxParamsStore->Update(&m_pixelDmxParams); - } + m_pPixelDmxParamsStore->Update(&m_Params); } else #endif - if (m_pPixelDmxParamsStore != nullptr) { - m_pPixelDmxParamsStore->Copy(&m_pixelDmxParams); - } else { - return false; - } + m_pPixelDmxParamsStore->Copy(&m_Params); + +#ifndef NDEBUG + Dump(); +#endif + DEBUG_EXIT return true; } void PixelDmxParams::Load(const char *pBuffer, uint32_t nLength) { + DEBUG_ENTRY + assert(pBuffer != nullptr); assert(nLength != 0); - m_pixelDmxParams.nSetList = 0; + m_Params.nSetList = 0; ReadConfigFile config(PixelDmxParams::staticCallbackFunction, this); config.Read(pBuffer, nLength); - m_pPixelDmxParamsStore->Update(&m_pixelDmxParams); + m_pPixelDmxParamsStore->Update(&m_Params); + +#ifndef NDEBUG + Dump(); +#endif + DEBUG_EXIT } void PixelDmxParams::callbackFunction(const char *pLine) { @@ -122,22 +130,22 @@ void PixelDmxParams::callbackFunction(const char *pLine) { const auto type = PixelType::GetType(cBuffer); if (type != pixel::Type::UNDEFINED) { - m_pixelDmxParams.nType = static_cast(type); - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::TYPE; + m_Params.nType = static_cast(type); + m_Params.nSetList |= pixeldmxparams::Mask::TYPE; } else { - m_pixelDmxParams.nType = static_cast(pixel::defaults::TYPE); - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::TYPE; + m_Params.nType = static_cast(pixel::defaults::TYPE); + m_Params.nSetList &= ~pixeldmxparams::Mask::TYPE; } return; } if (Sscan::Uint16(pLine, DevicesParamsConst::COUNT, nValue16) == Sscan::OK) { if (nValue16 != 0 && nValue16 <= std::max(max::ledcount::RGB, max::ledcount::RGBW)) { - m_pixelDmxParams.nCount = nValue16; - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::COUNT; + m_Params.nCount = nValue16; + m_Params.nSetList |= pixeldmxparams::Mask::COUNT; } else { - m_pixelDmxParams.nCount = defaults::COUNT; - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::COUNT; + m_Params.nCount = defaults::COUNT; + m_Params.nSetList &= ~pixeldmxparams::Mask::COUNT; } return; } @@ -149,44 +157,44 @@ void PixelDmxParams::callbackFunction(const char *pLine) { const auto map = PixelType::GetMap(cBuffer); if (map != Map::UNDEFINED) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::MAP; + m_Params.nSetList |= pixeldmxparams::Mask::MAP; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::MAP; + m_Params.nSetList &= ~pixeldmxparams::Mask::MAP; } - m_pixelDmxParams.nMap = static_cast(map); + m_Params.nMap = static_cast(map); return; } if (Sscan::Float(pLine, DevicesParamsConst::LED_T0H, fValue) == Sscan::OK) { if ((nValue8 = PixelType::ConvertTxH(fValue)) != 0) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::LOW_CODE; + m_Params.nSetList |= pixeldmxparams::Mask::LOW_CODE; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::LOW_CODE; + m_Params.nSetList &= ~pixeldmxparams::Mask::LOW_CODE; } - m_pixelDmxParams.nLowCode = nValue8; + m_Params.nLowCode = nValue8; return; } if (Sscan::Float(pLine, DevicesParamsConst::LED_T1H, fValue) == Sscan::OK) { if ((nValue8 = PixelType::ConvertTxH(fValue)) != 0) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::HIGH_CODE; + m_Params.nSetList |= pixeldmxparams::Mask::HIGH_CODE; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::HIGH_CODE; + m_Params.nSetList &= ~pixeldmxparams::Mask::HIGH_CODE; } - m_pixelDmxParams.nHighCode = nValue8; + m_Params.nHighCode = nValue8; return; } if (Sscan::Uint16(pLine, DevicesParamsConst::GROUPING_COUNT, nValue16) == Sscan::OK) { if (nValue16 > 1 && nValue16 <= std::max(max::ledcount::RGB, max::ledcount::RGBW)) { - m_pixelDmxParams.nGroupingCount = nValue16; - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::GROUPING_COUNT; + m_Params.nGroupingCount = nValue16; + m_Params.nSetList |= pixeldmxparams::Mask::GROUPING_COUNT; } else { - m_pixelDmxParams.nGroupingCount = 1; - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::GROUPING_COUNT; + m_Params.nGroupingCount = 1; + m_Params.nSetList &= ~pixeldmxparams::Mask::GROUPING_COUNT; } return; } @@ -195,21 +203,21 @@ void PixelDmxParams::callbackFunction(const char *pLine) { if (Sscan::Uint32(pLine, DevicesParamsConst::SPI_SPEED_HZ, nValue32) == Sscan::OK) { if (nValue32 != pixel::spi::speed::ws2801::default_hz) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::SPI_SPEED; + m_Params.nSetList |= pixeldmxparams::Mask::SPI_SPEED; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::SPI_SPEED; + m_Params.nSetList &= ~pixeldmxparams::Mask::SPI_SPEED; } - m_pixelDmxParams.nSpiSpeedHz = nValue32; + m_Params.nSpiSpeedHz = nValue32; return; } if (Sscan::Uint8(pLine, DevicesParamsConst::GLOBAL_BRIGHTNESS, nValue8) == Sscan::OK) { if ((nValue8 != 0) && (nValue8 != 0xFF)) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::GLOBAL_BRIGHTNESS; - m_pixelDmxParams.nGlobalBrightness = nValue8; + m_Params.nSetList |= pixeldmxparams::Mask::GLOBAL_BRIGHTNESS; + m_Params.nGlobalBrightness = nValue8; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::GLOBAL_BRIGHTNESS; - m_pixelDmxParams.nGlobalBrightness = 0xFF; + m_Params.nSetList &= ~pixeldmxparams::Mask::GLOBAL_BRIGHTNESS; + m_Params.nGlobalBrightness = 0xFF; } return; } @@ -217,11 +225,11 @@ void PixelDmxParams::callbackFunction(const char *pLine) { #if defined (PARAMS_INLCUDE_ALL) || !defined(OUTPUT_DMX_PIXEL_MULTI) if (Sscan::Uint16(pLine, LightSetParamsConst::DMX_START_ADDRESS, nValue16) == Sscan::OK) { if ((nValue16 != 0) && nValue16 <= (dmx::UNIVERSE_SIZE) && (nValue16 != dmx::START_ADDRESS_DEFAULT)) { - m_pixelDmxParams.nDmxStartAddress = nValue16; - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::DMX_START_ADDRESS; + m_Params.nDmxStartAddress = nValue16; + m_Params.nSetList |= pixeldmxparams::Mask::DMX_START_ADDRESS; } else { - m_pixelDmxParams.nDmxStartAddress = dmx::START_ADDRESS_DEFAULT; - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::DMX_START_ADDRESS; + m_Params.nDmxStartAddress = dmx::START_ADDRESS_DEFAULT; + m_Params.nSetList &= ~pixeldmxparams::Mask::DMX_START_ADDRESS; } return; } @@ -230,11 +238,11 @@ void PixelDmxParams::callbackFunction(const char *pLine) { for (uint32_t i = 0; i < pixeldmxparams::MAX_PORTS; i++) { if (Sscan::Uint16(pLine, LightSetParamsConst::START_UNI_PORT[i], nValue16) == Sscan::OK) { if (nValue16 > 0) { - m_pixelDmxParams.nStartUniverse[i] = nValue16; - m_pixelDmxParams.nSetList |= (pixeldmxparams::Mask::START_UNI_PORT_1 << i); + m_Params.nStartUniverse[i] = nValue16; + m_Params.nSetList |= (pixeldmxparams::Mask::START_UNI_PORT_1 << i); } else { - m_pixelDmxParams.nStartUniverse[i] = static_cast(1 + (i * 4)); - m_pixelDmxParams.nSetList &= ~(pixeldmxparams::Mask::START_UNI_PORT_1 << i); + m_Params.nStartUniverse[i] = static_cast(1 + (i * 4)); + m_Params.nSetList &= ~(pixeldmxparams::Mask::START_UNI_PORT_1 << i); } } } @@ -242,11 +250,11 @@ void PixelDmxParams::callbackFunction(const char *pLine) { #if defined (PARAMS_INLCUDE_ALL) || defined(OUTPUT_DMX_PIXEL_MULTI) if (Sscan::Uint8(pLine, DevicesParamsConst::ACTIVE_OUT, nValue8) == Sscan::OK) { if ((nValue8 > 0) && (nValue8 <= pixeldmxparams::MAX_PORTS) && (nValue8 != pixel::defaults::OUTPUT_PORTS)) { - m_pixelDmxParams.nActiveOutputs = nValue8; - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::ACTIVE_OUT; + m_Params.nActiveOutputs = nValue8; + m_Params.nSetList |= pixeldmxparams::Mask::ACTIVE_OUT; } else { - m_pixelDmxParams.nActiveOutputs = pixel::defaults::OUTPUT_PORTS; - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::ACTIVE_OUT; + m_Params.nActiveOutputs = pixel::defaults::OUTPUT_PORTS; + m_Params.nSetList &= ~pixeldmxparams::Mask::ACTIVE_OUT; } return; } @@ -254,20 +262,20 @@ void PixelDmxParams::callbackFunction(const char *pLine) { if (Sscan::Uint8(pLine, DevicesParamsConst::TEST_PATTERN, nValue8) == Sscan::OK) { if ((nValue8 != static_cast(pixelpatterns::Pattern::NONE)) && (nValue8 < static_cast(pixelpatterns::Pattern::LAST))) { - m_pixelDmxParams.nTestPattern = nValue8; - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::TEST_PATTERN; + m_Params.nTestPattern = nValue8; + m_Params.nSetList |= pixeldmxparams::Mask::TEST_PATTERN; } else { - m_pixelDmxParams.nTestPattern = static_cast(pixelpatterns::Pattern::NONE); - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::TEST_PATTERN; + m_Params.nTestPattern = static_cast(pixelpatterns::Pattern::NONE); + m_Params.nSetList &= ~pixeldmxparams::Mask::TEST_PATTERN; } return; } if (Sscan::Uint8(pLine, DevicesParamsConst::GAMMA_CORRECTION, nValue8) == Sscan::OK) { if (nValue8 != 0) { - m_pixelDmxParams.nSetList |= pixeldmxparams::Mask::GAMMA_CORRECTION; + m_Params.nSetList |= pixeldmxparams::Mask::GAMMA_CORRECTION; } else { - m_pixelDmxParams.nSetList &= ~pixeldmxparams::Mask::GAMMA_CORRECTION; + m_Params.nSetList &= ~pixeldmxparams::Mask::GAMMA_CORRECTION; } return; } @@ -275,89 +283,82 @@ void PixelDmxParams::callbackFunction(const char *pLine) { if (Sscan::Float(pLine, DevicesParamsConst::GAMMA_VALUE, fValue) == Sscan::OK) { const auto nValue = static_cast(fValue * 10); if ((nValue < gamma::MIN) || (nValue > gamma::MAX)) { - m_pixelDmxParams.nGammaValue = 0; + m_Params.nGammaValue = 0; } else { - m_pixelDmxParams.nGammaValue = nValue; + m_Params.nGammaValue = nValue; } } } -void PixelDmxParams::staticCallbackFunction(void *p, const char *s) { - assert(p != nullptr); - assert(s != nullptr); - - (static_cast(p))->callbackFunction(s); -} - void PixelDmxParams::Builder(const struct pixeldmxparams::Params *ptWS28xxParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { assert(pBuffer != nullptr); if (ptWS28xxParams != nullptr) { - memcpy(&m_pixelDmxParams, ptWS28xxParams, sizeof(struct pixeldmxparams::Params)); + memcpy(&m_Params, ptWS28xxParams, sizeof(struct pixeldmxparams::Params)); } else { - m_pPixelDmxParamsStore->Copy(&m_pixelDmxParams); + m_pPixelDmxParamsStore->Copy(&m_Params); } PropertiesBuilder builder(DevicesParamsConst::FILE_NAME, pBuffer, nLength); - builder.Add(DevicesParamsConst::TYPE, PixelType::GetType(static_cast(m_pixelDmxParams.nType)), isMaskSet(pixeldmxparams::Mask::TYPE)); - builder.Add(DevicesParamsConst::COUNT, m_pixelDmxParams.nCount, isMaskSet(pixeldmxparams::Mask::COUNT)); + builder.Add(DevicesParamsConst::TYPE, PixelType::GetType(static_cast(m_Params.nType)), isMaskSet(pixeldmxparams::Mask::TYPE)); + builder.Add(DevicesParamsConst::COUNT, m_Params.nCount, isMaskSet(pixeldmxparams::Mask::COUNT)); builder.Add(DevicesParamsConst::GAMMA_CORRECTION, isMaskSet(pixeldmxparams::Mask::GAMMA_CORRECTION)); - if (m_pixelDmxParams.nGammaValue == 0) { + if (m_Params.nGammaValue == 0) { builder.Add(DevicesParamsConst::GAMMA_VALUE, "", false); } else { - builder.Add(DevicesParamsConst::GAMMA_VALUE, static_cast(m_pixelDmxParams.nGammaValue) / 10, true); + builder.Add(DevicesParamsConst::GAMMA_VALUE, static_cast(m_Params.nGammaValue) / 10, true); } builder.AddComment("Overwrite datasheet"); if (!isMaskSet(pixeldmxparams::Mask::MAP)) { - m_pixelDmxParams.nMap = static_cast(PixelType::GetMap(static_cast(m_pixelDmxParams.nType))); + m_Params.nMap = static_cast(PixelType::GetMap(static_cast(m_Params.nType))); } - builder.Add(DevicesParamsConst::MAP, PixelType::GetMap(static_cast(m_pixelDmxParams.nMap)), isMaskSet(pixeldmxparams::Mask::MAP)); + builder.Add(DevicesParamsConst::MAP, PixelType::GetMap(static_cast(m_Params.nMap)), isMaskSet(pixeldmxparams::Mask::MAP)); if (!isMaskSet(pixeldmxparams::Mask::LOW_CODE) || !isMaskSet(pixeldmxparams::Mask::HIGH_CODE)) { uint8_t nLowCode; uint8_t nHighCode; - PixelConfiguration::GetTxH(static_cast(m_pixelDmxParams.nType), nLowCode, nHighCode); + PixelConfiguration::GetTxH(static_cast(m_Params.nType), nLowCode, nHighCode); if (!isMaskSet(pixeldmxparams::Mask::LOW_CODE)) { - m_pixelDmxParams.nLowCode = nLowCode; + m_Params.nLowCode = nLowCode; } if (!isMaskSet(pixeldmxparams::Mask::HIGH_CODE)) { - m_pixelDmxParams.nHighCode = nHighCode; + m_Params.nHighCode = nHighCode; } } builder.AddComment("Overwrite timing (us)"); - builder.Add(DevicesParamsConst::LED_T0H, PixelType::ConvertTxH(m_pixelDmxParams.nLowCode), isMaskSet(pixeldmxparams::Mask::LOW_CODE), 2); - builder.Add(DevicesParamsConst::LED_T1H, PixelType::ConvertTxH(m_pixelDmxParams.nHighCode), isMaskSet(pixeldmxparams::Mask::HIGH_CODE), 2); + builder.Add(DevicesParamsConst::LED_T0H, PixelType::ConvertTxH(m_Params.nLowCode), isMaskSet(pixeldmxparams::Mask::LOW_CODE), 2); + builder.Add(DevicesParamsConst::LED_T1H, PixelType::ConvertTxH(m_Params.nHighCode), isMaskSet(pixeldmxparams::Mask::HIGH_CODE), 2); builder.AddComment("Grouping"); - builder.Add(DevicesParamsConst::GROUPING_COUNT, m_pixelDmxParams.nGroupingCount, isMaskSet(pixeldmxparams::Mask::GROUPING_COUNT)); + builder.Add(DevicesParamsConst::GROUPING_COUNT, m_Params.nGroupingCount, isMaskSet(pixeldmxparams::Mask::GROUPING_COUNT)); builder.AddComment("Clock based chips"); - builder.Add(DevicesParamsConst::SPI_SPEED_HZ, m_pixelDmxParams.nSpiSpeedHz, isMaskSet(pixeldmxparams::Mask::SPI_SPEED)); + builder.Add(DevicesParamsConst::SPI_SPEED_HZ, m_Params.nSpiSpeedHz, isMaskSet(pixeldmxparams::Mask::SPI_SPEED)); builder.AddComment("APA102/SK9822"); - builder.Add(DevicesParamsConst::GLOBAL_BRIGHTNESS, m_pixelDmxParams.nGlobalBrightness, isMaskSet(pixeldmxparams::Mask::GLOBAL_BRIGHTNESS)); + builder.Add(DevicesParamsConst::GLOBAL_BRIGHTNESS, m_Params.nGlobalBrightness, isMaskSet(pixeldmxparams::Mask::GLOBAL_BRIGHTNESS)); #if defined (PARAMS_INLCUDE_ALL) || !defined(OUTPUT_DMX_PIXEL_MULTI) builder.AddComment("DMX"); - builder.Add(LightSetParamsConst::DMX_START_ADDRESS, m_pixelDmxParams.nDmxStartAddress, isMaskSet(pixeldmxparams::Mask::DMX_START_ADDRESS)); + builder.Add(LightSetParamsConst::DMX_START_ADDRESS, m_Params.nDmxStartAddress, isMaskSet(pixeldmxparams::Mask::DMX_START_ADDRESS)); #endif for (uint32_t i = 0; i < pixeldmxparams::MAX_PORTS; i++) { - builder.Add(LightSetParamsConst::START_UNI_PORT[i],m_pixelDmxParams.nStartUniverse[i], isMaskSet(pixeldmxparams::Mask::START_UNI_PORT_1 << i)); + builder.Add(LightSetParamsConst::START_UNI_PORT[i],m_Params.nStartUniverse[i], isMaskSet(pixeldmxparams::Mask::START_UNI_PORT_1 << i)); } #if defined (PARAMS_INLCUDE_ALL) || defined(OUTPUT_DMX_PIXEL_MULTI) - builder.Add(DevicesParamsConst::ACTIVE_OUT, m_pixelDmxParams.nActiveOutputs, isMaskSet(pixeldmxparams::Mask::ACTIVE_OUT)); + builder.Add(DevicesParamsConst::ACTIVE_OUT, m_Params.nActiveOutputs, isMaskSet(pixeldmxparams::Mask::ACTIVE_OUT)); #endif builder.AddComment("Test pattern"); - builder.Add(DevicesParamsConst::TEST_PATTERN, m_pixelDmxParams.nTestPattern, isMaskSet(pixeldmxparams::Mask::TEST_PATTERN)); + builder.Add(DevicesParamsConst::TEST_PATTERN, m_Params.nTestPattern, isMaskSet(pixeldmxparams::Mask::TEST_PATTERN)); nSize = builder.GetSize(); @@ -370,53 +371,82 @@ void PixelDmxParams::Set(PixelDmxConfiguration *pPixelDmxConfiguration) { // Pixel if (isMaskSet(pixeldmxparams::Mask::TYPE)) { - pPixelDmxConfiguration->SetType(static_cast(m_pixelDmxParams.nType)); + pPixelDmxConfiguration->SetType(static_cast(m_Params.nType)); } if (isMaskSet(pixeldmxparams::Mask::COUNT)) { - pPixelDmxConfiguration->SetCount(m_pixelDmxParams.nCount); + pPixelDmxConfiguration->SetCount(m_Params.nCount); } if (isMaskSet(pixeldmxparams::Mask::MAP)) { - pPixelDmxConfiguration->SetMap(static_cast(m_pixelDmxParams.nMap)); + pPixelDmxConfiguration->SetMap(static_cast(m_Params.nMap)); } if (isMaskSet(pixeldmxparams::Mask::LOW_CODE)) { - pPixelDmxConfiguration->SetLowCode(m_pixelDmxParams.nLowCode); + pPixelDmxConfiguration->SetLowCode(m_Params.nLowCode); } if (isMaskSet(pixeldmxparams::Mask::HIGH_CODE)) { - pPixelDmxConfiguration->SetHighCode(m_pixelDmxParams.nHighCode); + pPixelDmxConfiguration->SetHighCode(m_Params.nHighCode); } if (isMaskSet(pixeldmxparams::Mask::SPI_SPEED)) { - pPixelDmxConfiguration->SetClockSpeedHz(m_pixelDmxParams.nSpiSpeedHz); + pPixelDmxConfiguration->SetClockSpeedHz(m_Params.nSpiSpeedHz); } if (isMaskSet(pixeldmxparams::Mask::GLOBAL_BRIGHTNESS)) { - pPixelDmxConfiguration->SetGlobalBrightness(m_pixelDmxParams.nGlobalBrightness); + pPixelDmxConfiguration->SetGlobalBrightness(m_Params.nGlobalBrightness); } if (isMaskSet(pixeldmxparams::Mask::GAMMA_CORRECTION)) { pPixelDmxConfiguration->SetEnableGammaCorrection(true); - if (m_pixelDmxParams.nGammaValue != 0) { - pPixelDmxConfiguration->SetGammaTable(m_pixelDmxParams.nGammaValue); + if (m_Params.nGammaValue != 0) { + pPixelDmxConfiguration->SetGammaTable(m_Params.nGammaValue); } } // Dmx if (isMaskSet(pixeldmxparams::Mask::DMX_START_ADDRESS)) { - pPixelDmxConfiguration->SetDmxStartAddress(m_pixelDmxParams.nDmxStartAddress); + pPixelDmxConfiguration->SetDmxStartAddress(m_Params.nDmxStartAddress); } if (isMaskSet(pixeldmxparams::Mask::GROUPING_COUNT)) { - pPixelDmxConfiguration->SetGroupingCount(m_pixelDmxParams.nGroupingCount); + pPixelDmxConfiguration->SetGroupingCount(m_Params.nGroupingCount); } #if defined (PARAMS_INLCUDE_ALL) || defined(OUTPUT_DMX_PIXEL_MULTI) if (isMaskSet(pixeldmxparams::Mask::ACTIVE_OUT)) { - pPixelDmxConfiguration->SetOutputPorts(m_pixelDmxParams.nActiveOutputs); + pPixelDmxConfiguration->SetOutputPorts(m_Params.nActiveOutputs); } #endif } + +void PixelDmxParams::staticCallbackFunction(void *p, const char *s) { + assert(p != nullptr); + assert(s != nullptr); + + (static_cast(p))->callbackFunction(s); +} + +void PixelDmxParams::Dump() { + printf("%s::%s \'%s\':\n", __FILE__,__FUNCTION__, DevicesParamsConst::FILE_NAME); + printf(" %s=%s [%d]\n", DevicesParamsConst::TYPE, PixelType::GetType(static_cast(m_Params.nType)), static_cast(m_Params.nType)); + printf(" %s=%d [%s]\n", DevicesParamsConst::MAP, static_cast(m_Params.nMap), PixelType::GetMap(static_cast(m_Params.nMap))); + printf(" %s=%.2f [0x%X]\n", DevicesParamsConst::LED_T0H, PixelType::ConvertTxH(m_Params.nLowCode), m_Params.nLowCode); + printf(" %s=%.2f [0x%X]\n", DevicesParamsConst::LED_T1H, PixelType::ConvertTxH(m_Params.nHighCode), m_Params.nHighCode); + printf(" %s=%d\n", DevicesParamsConst::COUNT, m_Params.nCount); + + for (uint32_t i = 0; i < std::min(static_cast(pixelpatterns::MAX_PORTS), sizeof(LightSetParamsConst::START_UNI_PORT) / sizeof(LightSetParamsConst::START_UNI_PORT[0])); i++) { + printf(" %s=%d\n", LightSetParamsConst::START_UNI_PORT[i], m_Params.nStartUniverse[i]); + } + + printf(" %s=%d\n", DevicesParamsConst::ACTIVE_OUT, m_Params.nActiveOutputs); + printf(" %s=%d\n", DevicesParamsConst::GROUPING_COUNT, m_Params.nGroupingCount); + printf(" %s=%d\n", DevicesParamsConst::SPI_SPEED_HZ, m_Params.nSpiSpeedHz); + printf(" %s=%d\n", DevicesParamsConst::GLOBAL_BRIGHTNESS, m_Params.nGlobalBrightness); + printf(" %s=%d\n", LightSetParamsConst::DMX_START_ADDRESS, m_Params.nDmxStartAddress); + printf(" %s=%d\n", DevicesParamsConst::TEST_PATTERN, m_Params.nTestPattern); + printf(" %s=%d\n", DevicesParamsConst::GAMMA_CORRECTION, isMaskSet(pixeldmxparams::Mask::GAMMA_CORRECTION)); + printf(" %s=%1.1f [%u]\n", DevicesParamsConst::GAMMA_VALUE, static_cast(m_Params.nGammaValue) / 10, m_Params.nGammaValue); +} diff --git a/lib-ws28xxdmx/src/params/pixeldmxparamsdump.cpp b/lib-ws28xxdmx/src/params/pixeldmxparamsdump.cpp deleted file mode 100644 index d882256..0000000 --- a/lib-ws28xxdmx/src/params/pixeldmxparamsdump.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file pixeldmxparamsdump.cpp - * - */ -/* Copyright (C) 2016-2022 by Arjan van Vught mailto:info@orangepi-dmx.nl - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - -#ifndef NDEBUG -# include -# include -# include - -# include "pixeltype.h" - -# include "devicesparamsconst.h" -# include "lightsetparamsconst.h" -#endif - -#include "pixeldmxparams.h" - -using namespace pixeldmxparams; - -void PixelDmxParams::Dump() { -#ifndef NDEBUG - printf("%s::%s \'%s\':\n", __FILE__,__FUNCTION__, DevicesParamsConst::FILE_NAME); - - if (isMaskSet(Mask::TYPE)) { - printf(" %s=%s [%d]\n", DevicesParamsConst::TYPE, PixelType::GetType(static_cast(m_pixelDmxParams.nType)), static_cast(m_pixelDmxParams.nType)); - } - - if (isMaskSet(Mask::MAP)) { - printf(" %s=%d [%s]\n", DevicesParamsConst::MAP, static_cast(m_pixelDmxParams.nMap), PixelType::GetMap(static_cast(m_pixelDmxParams.nMap))); - } - - if (isMaskSet(Mask::LOW_CODE)) { - printf(" %s=%.2f [0x%X]\n", DevicesParamsConst::LED_T0H, PixelType::ConvertTxH(m_pixelDmxParams.nLowCode), m_pixelDmxParams.nLowCode); - } - - if (isMaskSet(Mask::HIGH_CODE)) { - printf(" %s=%.2f [0x%X]\n", DevicesParamsConst::LED_T1H, PixelType::ConvertTxH(m_pixelDmxParams.nHighCode), m_pixelDmxParams.nHighCode); - } - - if (isMaskSet(Mask::COUNT)) { - printf(" %s=%d\n", DevicesParamsConst::COUNT, m_pixelDmxParams.nCount); - } - - for (uint32_t i = 0; i < std::min(static_cast(MAX_PORTS), sizeof(LightSetParamsConst::START_UNI_PORT) / sizeof(LightSetParamsConst::START_UNI_PORT[0])); i++) { - if (isMaskSet(Mask::START_UNI_PORT_1 << i)) { - printf(" %s=%d\n", LightSetParamsConst::START_UNI_PORT[i], m_pixelDmxParams.nStartUniverse[i]); - } - } - - if (isMaskSet(Mask::ACTIVE_OUT)) { - printf(" %s=%d\n", DevicesParamsConst::ACTIVE_OUT, m_pixelDmxParams.nActiveOutputs); - } - - if (isMaskSet(Mask::GROUPING_COUNT)) { - printf(" %s=%d\n", DevicesParamsConst::GROUPING_COUNT, m_pixelDmxParams.nGroupingCount); - } - - if (isMaskSet(Mask::SPI_SPEED)) { - printf(" %s=%d\n", DevicesParamsConst::SPI_SPEED_HZ, m_pixelDmxParams.nSpiSpeedHz); - } - - if (isMaskSet(Mask::GLOBAL_BRIGHTNESS)) { - printf(" %s=%d\n", DevicesParamsConst::GLOBAL_BRIGHTNESS, m_pixelDmxParams.nGlobalBrightness); - } - - if (isMaskSet(Mask::DMX_START_ADDRESS)) { - printf(" %s=%d\n", LightSetParamsConst::DMX_START_ADDRESS, m_pixelDmxParams.nDmxStartAddress); - } - - if (isMaskSet(Mask::TEST_PATTERN)) { - printf(" %s=%d\n", DevicesParamsConst::TEST_PATTERN, m_pixelDmxParams.nTestPattern); - } - - if (isMaskSet(Mask::GAMMA_CORRECTION)) { - printf(" %s=1 [Yes]\n", DevicesParamsConst::GAMMA_CORRECTION); - printf(" %s=%1.1f [%u]\n", DevicesParamsConst::GAMMA_VALUE, static_cast(m_pixelDmxParams.nGammaValue) / 10, m_pixelDmxParams.nGammaValue); - } -#endif -}