From 7a0894a10567968098524ee7d06612e158f84654 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 14:49:22 +0200 Subject: [PATCH 01/36] Moved *ParamsConst to C++20 style --- lib-artnet/.cproject | 19 +- lib-artnet/.settings/language.settings.xml | 4 +- lib-artnet/include/artnetconst.h | 11 +- lib-artnet/include/artnetmsgconst.h | 6 +- lib-artnet/include/artnetparamsconst.h | 33 +- lib-artnet/src/artnetconst.cpp | 1 - lib-artnet/src/node/artnetmsgconst.cpp | 30 -- lib-artnet/src/node/artnetparamsconst.cpp | 59 ---- lib-configstore/include/envparamsconst.h | 5 +- lib-configstore/src/envparamsconst.cpp | 30 -- .../.settings/language.settings.xml | 2 +- .../include/displayudfparamsconst.h | 23 +- lib-displayudf/src/displayudfparams.cpp | 4 +- lib-displayudf/src/displayudfparamsconst.cpp | 38 --- lib-dmx/.cproject | 11 +- lib-dmx/.settings/language.settings.xml | 12 +- lib-dmx/include/dmxparamsconst.h | 13 +- lib-dmx/src/dmxparamsconst.cpp | 34 -- lib-dmxmonitor/.cproject | 202 ++++++++--- .../.settings/language.settings.xml | 14 +- .../include/dmxmonitorparamsconst.h | 9 +- lib-dmxmonitor/src/dmxmonitorparamsconst.cpp | 31 -- lib-dmxserial/.settings/language.settings.xml | 4 +- lib-dmxserial/include/dmxserialparamsconst.h | 26 +- lib-dmxserial/src/dmxserialparamsconst.cpp | 43 --- lib-e131/.cproject | 229 +++++++++---- lib-e131/.settings/language.settings.xml | 14 +- lib-e131/include/e131paramsconst.h | 23 +- lib-e131/src/node/e131paramsconst.cpp | 49 --- .../.settings/language.settings.xml | 2 +- .../params/flashcodeinstallparamsconst.cpp | 31 -- .../src/params/flashcodeinstallparamsconst.h | 9 +- lib-gps/.cproject | 181 +++++++--- lib-gps/.settings/language.settings.xml | 10 +- lib-gps/include/gpsparamsconst.h | 11 +- lib-gps/src/gpsparamsconst.cpp | 30 -- lib-l6470/.settings/language.settings.xml | 6 +- lib-l6470dmx/.settings/language.settings.xml | 6 +- lib-l6470dmx/include/l6470dmxconst.h | 4 +- lib-l6470dmx/include/l6470paramsconst.h | 20 +- lib-l6470dmx/include/modeparamsconst.h | 15 +- lib-l6470dmx/include/motorparamsconst.h | 12 +- lib-l6470dmx/include/sparkfundmxconst.h | 4 +- lib-l6470dmx/include/sparkfundmxparamsconst.h | 12 +- lib-l6470dmx/src/l6470dmxconst.cpp | 28 -- lib-l6470dmx/src/l6470paramsconst.cpp | 36 -- lib-l6470dmx/src/modeparamsconst.cpp | 34 -- lib-l6470dmx/src/motorparamsconst.cpp | 32 -- lib-l6470dmx/src/sparkfundmxconst.cpp | 28 -- lib-l6470dmx/src/sparkfundmxparamsconst.cpp | 34 -- lib-lightset/.cproject | 8 +- lib-lightset/.settings/language.settings.xml | 4 +- lib-lightset/include/lightsetparamsconst.h | 84 ++++- lib-lightset/src/lightsetparamsconst.cpp | 104 ------ lib-ltc/.cproject | 237 +++++++++---- lib-ltc/.settings/language.settings.xml | 6 +- lib-ltc/include/ltcdisplayparamsconst.h | 27 +- lib-ltc/include/ltcetcparamsconst.h | 17 +- lib-ltc/include/ltcparamsconst.h | 72 ++-- lib-ltc/include/timecodeconst.h | 10 +- lib-ltc/src/ltcdisplayparamsconst.cpp | 76 ----- lib-ltc/src/ltcetcparamsconst.cpp | 36 -- lib-ltc/src/ltcparamsconst.cpp | 71 ---- lib-ltc/src/timecodeconst.cpp | 35 -- lib-midi/.cproject | 200 ++++++++--- lib-midi/.settings/language.settings.xml | 12 +- lib-midi/include/midiparamsconst.h | 9 +- lib-midi/src/midiparamsconst.cpp | 32 -- lib-network/include/networkparamsconst.h | 21 +- lib-network/src/params/networkparamsconst.cpp | 46 --- lib-osc/.cproject | 218 +++++++++--- lib-osc/.settings/language.settings.xml | 10 +- lib-osc/include/oscclientparamsconst.h | 19 +- lib-osc/include/oscserverparamsconst.h | 14 +- lib-osc/src/client/oscclientparamsconst.cpp | 36 -- lib-osc/src/server/oscserverparamsconst.cpp | 34 -- lib-pca9685/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 6 +- .../include/pca9685dmxparamsconst.h | 28 +- lib-pca9685dmx/src/pca9685dmxparamsconst.cpp | 42 --- lib-rdm/.cproject | 232 +++++++++---- lib-rdm/.settings/language.settings.xml | 14 +- lib-rdm/include/rdmdeviceparamsconst.h | 11 +- lib-rdm/src/rdmdeviceparamsconst.cpp | 32 -- lib-rdmsensor/include/rdmsensorsconst.h | 4 +- lib-rdmsensor/src/rdmsensorsconst.cpp | 30 -- lib-rdmsubdevice/include/rdmsubdevicesconst.h | 4 +- lib-rdmsubdevice/src/rdmsubdevicesconst.cpp | 33 -- lib-remoteconfig/.cproject | 15 +- .../.settings/language.settings.xml | 4 +- lib-remoteconfig/include/remoteconfigconst.h | 16 +- lib-remoteconfig/src/remoteconfigconst.cpp | 38 --- lib-rgbpanel/.cproject | 183 +++++++--- lib-rgbpanel/.settings/language.settings.xml | 10 +- lib-rgbpanel/include/rgbpanelconst.h | 12 +- lib-rgbpanel/include/rgbpanelparamsconst.h | 13 +- lib-rgbpanel/src/rgbpanelconst.cpp | 37 -- lib-rgbpanel/src/rgbpanelparamsconst.cpp | 33 -- lib-showfile/.cproject | 320 ++++++++++++------ lib-showfile/.settings/language.settings.xml | 12 +- lib-showfile/include/showfileparamsconst.h | 22 +- lib-showfile/src/showfileparamsconst.cpp | 39 --- lib-tcnet/.cproject | 279 ++++++++++----- lib-tcnet/.settings/language.settings.xml | 10 +- lib-tcnet/include/tcnetparamsconst.h | 13 +- lib-tcnet/src/tcnetparamsconst.cpp | 33 -- lib-tlc59711/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 4 +- lib-usb/.settings/language.settings.xml | 4 +- lib-widget/.settings/language.settings.xml | 4 +- lib-widget/include/widgetparamsconst.h | 16 +- lib-widget/src/widgetparamsconst.cpp | 36 -- 112 files changed, 2162 insertions(+), 2401 deletions(-) delete mode 100644 lib-artnet/src/node/artnetmsgconst.cpp delete mode 100644 lib-artnet/src/node/artnetparamsconst.cpp delete mode 100755 lib-configstore/src/envparamsconst.cpp delete mode 100644 lib-displayudf/src/displayudfparamsconst.cpp delete mode 100644 lib-dmx/src/dmxparamsconst.cpp delete mode 100644 lib-dmxmonitor/src/dmxmonitorparamsconst.cpp delete mode 100644 lib-dmxserial/src/dmxserialparamsconst.cpp delete mode 100644 lib-e131/src/node/e131paramsconst.cpp delete mode 100644 lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.cpp delete mode 100644 lib-gps/src/gpsparamsconst.cpp delete mode 100644 lib-l6470dmx/src/l6470dmxconst.cpp delete mode 100644 lib-l6470dmx/src/l6470paramsconst.cpp delete mode 100644 lib-l6470dmx/src/modeparamsconst.cpp delete mode 100644 lib-l6470dmx/src/motorparamsconst.cpp delete mode 100644 lib-l6470dmx/src/sparkfundmxconst.cpp delete mode 100644 lib-l6470dmx/src/sparkfundmxparamsconst.cpp delete mode 100644 lib-lightset/src/lightsetparamsconst.cpp delete mode 100755 lib-ltc/src/ltcdisplayparamsconst.cpp delete mode 100755 lib-ltc/src/ltcetcparamsconst.cpp delete mode 100755 lib-ltc/src/ltcparamsconst.cpp delete mode 100755 lib-ltc/src/timecodeconst.cpp delete mode 100644 lib-midi/src/midiparamsconst.cpp delete mode 100755 lib-network/src/params/networkparamsconst.cpp delete mode 100755 lib-osc/src/client/oscclientparamsconst.cpp delete mode 100755 lib-osc/src/server/oscserverparamsconst.cpp delete mode 100755 lib-pca9685dmx/src/pca9685dmxparamsconst.cpp delete mode 100644 lib-rdm/src/rdmdeviceparamsconst.cpp delete mode 100644 lib-rdmsensor/src/rdmsensorsconst.cpp delete mode 100644 lib-rdmsubdevice/src/rdmsubdevicesconst.cpp delete mode 100644 lib-remoteconfig/src/remoteconfigconst.cpp delete mode 100644 lib-rgbpanel/src/rgbpanelconst.cpp delete mode 100644 lib-rgbpanel/src/rgbpanelparamsconst.cpp delete mode 100644 lib-showfile/src/showfileparamsconst.cpp delete mode 100755 lib-tcnet/src/tcnetparamsconst.cpp delete mode 100644 lib-widget/src/widgetparamsconst.cpp diff --git a/lib-artnet/.cproject b/lib-artnet/.cproject index 9574990ee..afabd1c05 100644 --- a/lib-artnet/.cproject +++ b/lib-artnet/.cproject @@ -448,12 +448,19 @@ - - - - - - + + + + + + + + + + + + + diff --git a/lib-artnet/.settings/language.settings.xml b/lib-artnet/.settings/language.settings.xml index 30e669b07..636c59c2c 100644 --- a/lib-artnet/.settings/language.settings.xml +++ b/lib-artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-artnet/include/artnetconst.h b/lib-artnet/include/artnetconst.h index 90ff54c9a..6c9c9dcba 100644 --- a/lib-artnet/include/artnetconst.h +++ b/lib-artnet/include/artnetconst.h @@ -2,10 +2,7 @@ * @file artnetconst.h * */ -/** - * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. - */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,14 +32,8 @@ struct ArtNetConst { static const uint8_t VERSION[]; - static const uint8_t ESTA_ID[artnet::ESTA_SIZE]; static const uint8_t OEM_ID[]; - - static const char MSG_NODE_PARAMS[]; - static const char MSG_NODE_START[]; - static const char MSG_NODE_STARTED[]; - static const char MSG_RDM_RUN[]; }; #endif /* ARTNETCONST_H_ */ diff --git a/lib-artnet/include/artnetmsgconst.h b/lib-artnet/include/artnetmsgconst.h index 18c540ee6..cc7093eb5 100644 --- a/lib-artnet/include/artnetmsgconst.h +++ b/lib-artnet/include/artnetmsgconst.h @@ -28,9 +28,9 @@ class ArtNetMsgConst { public: - static const char START[]; - static const char STARTED[]; - static const char RDM_RUN[]; + static inline const char START[] = "Starting Art-Net"; + static inline const char STARTED[] = "Art-Net started"; + static inline const char RDM_RUN[] = "Running RDM Discovery"; }; #endif /* ARTNETMSGCONST_H_ */ diff --git a/lib-artnet/include/artnetparamsconst.h b/lib-artnet/include/artnetparamsconst.h index 92e373181..f503dbc57 100644 --- a/lib-artnet/include/artnetparamsconst.h +++ b/lib-artnet/include/artnetparamsconst.h @@ -2,7 +2,7 @@ * @file artnetparamsconst.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,18 +30,37 @@ #include "artnet.h" struct ArtNetParamsConst { - static const char FILE_NAME[]; + static inline const char FILE_NAME[] = "artnet.txt"; - static const char ENABLE_RDM[]; - static const char DESTINATION_IP_PORT[artnet::PORTS][24]; - static const char RDM_ENABLE_PORT[artnet::PORTS][18]; + static inline const char ENABLE_RDM[] = "enable_rdm"; + + static inline const char DESTINATION_IP_PORT[artnet::PORTS][24] = { + "destination_ip_port_a", + "destination_ip_port_b", + "destination_ip_port_c", + "destination_ip_port_d" + }; + + + static inline const char RDM_ENABLE_PORT[artnet::PORTS][18] = { + "rdm_enable_port_a", + "rdm_enable_port_b", + "rdm_enable_port_c", + "rdm_enable_port_d" + }; /** * Art-Net 4 */ - static const char PROTOCOL_PORT[artnet::PORTS][16]; - static const char MAP_UNIVERSE0[]; + static inline const char PROTOCOL_PORT[artnet::PORTS][16] = { + "protocol_port_a", + "protocol_port_b", + "protocol_port_c", + "protocol_port_d" + }; + + static inline const char MAP_UNIVERSE0[] = "map_universe0"; }; #endif /* ARTNETPARAMSCONST_H_ */ diff --git a/lib-artnet/src/artnetconst.cpp b/lib-artnet/src/artnetconst.cpp index 5e36a9fb9..5acac34d0 100644 --- a/lib-artnet/src/artnetconst.cpp +++ b/lib-artnet/src/artnetconst.cpp @@ -29,6 +29,5 @@ #include "artnet.h" const uint8_t ArtNetConst::VERSION[] = { 1, 60 }; - const uint8_t ArtNetConst::ESTA_ID[artnet::ESTA_SIZE] = { 0x50, 0x00 }; ///< https://tsp.esta.org/tsp/working_groups/CP/mfctrIDs.php const uint8_t ArtNetConst::OEM_ID[] = { 0xff, 0xff }; ///< Waiting OEM from Artistic Licence Holdings Ltd. diff --git a/lib-artnet/src/node/artnetmsgconst.cpp b/lib-artnet/src/node/artnetmsgconst.cpp deleted file mode 100644 index 7e07038ba..000000000 --- a/lib-artnet/src/node/artnetmsgconst.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file artnetmsgconst.cpp - * - */ -/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "artnetmsgconst.h" - -const char ArtNetMsgConst::START[] = "Starting Art-Net"; -const char ArtNetMsgConst::STARTED[] = "Art-Net started"; -const char ArtNetMsgConst::RDM_RUN[] = "Running RDM Discovery"; diff --git a/lib-artnet/src/node/artnetparamsconst.cpp b/lib-artnet/src/node/artnetparamsconst.cpp deleted file mode 100644 index 2a91c776b..000000000 --- a/lib-artnet/src/node/artnetparamsconst.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file artnetparamsconst.cpp - * - */ -/* 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 - * 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 "artnetparamsconst.h" -#include "artnet.h" - -const char ArtNetParamsConst::FILE_NAME[] = "artnet.txt"; - -const char ArtNetParamsConst::ENABLE_RDM[] = "enable_rdm"; - -const char ArtNetParamsConst::DESTINATION_IP_PORT[artnet::PORTS][24] = { - "destination_ip_port_a", - "destination_ip_port_b", - "destination_ip_port_c", - "destination_ip_port_d" -}; - - -const char ArtNetParamsConst::RDM_ENABLE_PORT[artnet::PORTS][18] = { - "rdm_enable_port_a", - "rdm_enable_port_b", - "rdm_enable_port_c", - "rdm_enable_port_d" -}; - -/** - * Art-Net 4 - */ - -const char ArtNetParamsConst::PROTOCOL_PORT[artnet::PORTS][16] = { - "protocol_port_a", - "protocol_port_b", - "protocol_port_c", - "protocol_port_d" -}; - -const char ArtNetParamsConst::MAP_UNIVERSE0[] = "map_universe0"; diff --git a/lib-configstore/include/envparamsconst.h b/lib-configstore/include/envparamsconst.h index dcc2ea253..169e0208d 100755 --- a/lib-configstore/include/envparamsconst.h +++ b/lib-configstore/include/envparamsconst.h @@ -27,9 +27,8 @@ #define ENVPARAMSCONST_H_ struct EnvParamsConst { - static const char FILE_NAME[]; - - static const char UTC_OFFSET[]; + static inline const char FILE_NAME[] = "env.txt"; + static inline const char UTC_OFFSET[]= "utc_offset"; }; #endif /* ENVPARAMSCONST_H_ */ diff --git a/lib-configstore/src/envparamsconst.cpp b/lib-configstore/src/envparamsconst.cpp deleted file mode 100755 index 37880705f..000000000 --- a/lib-configstore/src/envparamsconst.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file envparamsconst.cpp - * - */ -/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "envparamsconst.h" - -const char EnvParamsConst::FILE_NAME[] = "env.txt"; - -const char EnvParamsConst::UTC_OFFSET[] = "utc_offset"; diff --git a/lib-displayudf/.settings/language.settings.xml b/lib-displayudf/.settings/language.settings.xml index 8dca8fd90..c160f6635 100644 --- a/lib-displayudf/.settings/language.settings.xml +++ b/lib-displayudf/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-displayudf/include/displayudfparamsconst.h b/lib-displayudf/include/displayudfparamsconst.h index 993f92c5c..6f84c99d6 100644 --- a/lib-displayudf/include/displayudfparamsconst.h +++ b/lib-displayudf/include/displayudfparamsconst.h @@ -2,7 +2,7 @@ * @file displayudfparamsconst.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,18 +27,15 @@ #define DISPLAYUDFPARAMSCONST_H_ struct DisplayUdfParamsConst { - static const char FILE_NAME[]; - - static const char INTENSITY[]; - static const char SLEEP_TIMEOUT[]; - static const char FLIP_VERTICALLY[]; - - static const char TITLE[]; - static const char BOARD_NAME[]; - static const char VERSION[]; - - static const char ACTIVE_PORTS[]; - static const char DMX_DIRECTION[]; + static inline const char FILE_NAME[] = "display.txt"; + static inline const char INTENSITY[] = "intensity"; + static inline const char SLEEP_TIMEOUT[] = "sleep_timeout"; + static inline const char FLIP_VERTICALLY[] = "flip_vertically"; + static inline const char TITLE[] = "title"; + static inline const char BOARD_NAME[] = "board_name"; + static inline const char VERSION[] = "version"; + static inline const char ACTIVE_PORTS[] = "active_ports"; + static inline const char DMX_DIRECTION[] = "dmx_direction"; }; #endif /* DISPLAYUDFPARAMSCONST_H_ */ diff --git a/lib-displayudf/src/displayudfparams.cpp b/lib-displayudf/src/displayudfparams.cpp index 50081b1b3..e234031cc 100644 --- a/lib-displayudf/src/displayudfparams.cpp +++ b/lib-displayudf/src/displayudfparams.cpp @@ -143,7 +143,7 @@ DisplayUdfParams::DisplayUdfParams() { DEBUG_ENTRY memset(&m_Params, 0, sizeof(struct displayudfparams::Params)); - m_Params.nSleepTimeout = display::Defaults::SEEP_TIMEOUT; + m_Params.nSleepTimeout = display::Defaults::SLEEP_TIMEOUT; m_Params.nIntensity = defaults::INTENSITY; DEBUG_EXIT @@ -207,7 +207,7 @@ void DisplayUdfParams::callbackFunction(const char *pLine) { if (Sscan::Uint8(pLine, DisplayUdfParamsConst::SLEEP_TIMEOUT, value8) == Sscan::OK) { m_Params.nSleepTimeout = value8; - if (value8 != display::Defaults::SEEP_TIMEOUT) { + if (value8 != display::Defaults::SLEEP_TIMEOUT) { m_Params.nSetList |= displayudfparams::Mask::SLEEP_TIMEOUT; } else { m_Params.nSetList &= ~displayudfparams::Mask::SLEEP_TIMEOUT; diff --git a/lib-displayudf/src/displayudfparamsconst.cpp b/lib-displayudf/src/displayudfparamsconst.cpp deleted file mode 100644 index 94d875ea2..000000000 --- a/lib-displayudf/src/displayudfparamsconst.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file displayudfparamsconst.cpp - * - */ -/* Copyright (C) 2019-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. - */ - -#include "displayudfparamsconst.h" - -const char DisplayUdfParamsConst::FILE_NAME[] = "display.txt"; - -const char DisplayUdfParamsConst::INTENSITY[] = "intensity"; -const char DisplayUdfParamsConst::SLEEP_TIMEOUT[] = "sleep_timeout"; -const char DisplayUdfParamsConst::FLIP_VERTICALLY[] = "flip_vertically"; - -const char DisplayUdfParamsConst::TITLE[] = "title"; -const char DisplayUdfParamsConst::BOARD_NAME[] = "board_name"; -const char DisplayUdfParamsConst::VERSION[] = "version"; -const char DisplayUdfParamsConst::ACTIVE_PORTS[] = "active_ports"; -const char DisplayUdfParamsConst::DMX_DIRECTION[] = "dmx_direction"; diff --git a/lib-dmx/.cproject b/lib-dmx/.cproject index f432a57e4..0337cc859 100644 --- a/lib-dmx/.cproject +++ b/lib-dmx/.cproject @@ -338,12 +338,11 @@ - - - - - - + + + + + diff --git a/lib-dmx/.settings/language.settings.xml b/lib-dmx/.settings/language.settings.xml index 360039aff..69ed61838 100644 --- a/lib-dmx/.settings/language.settings.xml +++ b/lib-dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,13 +26,13 @@ - - - - + + + + diff --git a/lib-dmx/include/dmxparamsconst.h b/lib-dmx/include/dmxparamsconst.h index e96041a7e..3911c298d 100644 --- a/lib-dmx/include/dmxparamsconst.h +++ b/lib-dmx/include/dmxparamsconst.h @@ -3,7 +3,7 @@ * * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,12 +28,11 @@ #define DMXPARAMSCONST_H_ struct DmxParamsConst { - static const char FILE_NAME[]; - - static const char BREAK_TIME[]; - static const char MAB_TIME[]; - static const char REFRESH_RATE[]; - static const char SLOTS_COUNT[]; + static inline const char FILE_NAME[] = "params.txt"; + static inline const char BREAK_TIME[] = "break_time"; + static inline const char MAB_TIME[] = "mab_time"; + static inline const char REFRESH_RATE[] = "refresh_rate"; + static inline const char SLOTS_COUNT[] = "slots_count"; }; #endif /* DMXPARAMSCONST_H_ */ diff --git a/lib-dmx/src/dmxparamsconst.cpp b/lib-dmx/src/dmxparamsconst.cpp deleted file mode 100644 index 3cafbfe35..000000000 --- a/lib-dmx/src/dmxparamsconst.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file dmxparamsconst.cpp - * - * - */ -/* Copyright (C) 2019-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. - */ - -#include "dmxparamsconst.h" - -const char DmxParamsConst::FILE_NAME[] = "params.txt"; - -const char DmxParamsConst::BREAK_TIME[] = "break_time"; -const char DmxParamsConst::MAB_TIME[] = "mab_time"; -const char DmxParamsConst::REFRESH_RATE[] = "refresh_rate"; -const char DmxParamsConst::SLOTS_COUNT[] = "slots_count"; diff --git a/lib-dmxmonitor/.cproject b/lib-dmxmonitor/.cproject index 2b32e748f..fe6dbdc6f 100644 --- a/lib-dmxmonitor/.cproject +++ b/lib-dmxmonitor/.cproject @@ -13,7 +13,7 @@ - + - - + + + @@ -154,63 +155,162 @@ - - - - @@ -235,20 +335,26 @@ + + + + + + + - + - + - + - \ No newline at end of file diff --git a/lib-dmxmonitor/.settings/language.settings.xml b/lib-dmxmonitor/.settings/language.settings.xml index 9f8567838..3008ff609 100644 --- a/lib-dmxmonitor/.settings/language.settings.xml +++ b/lib-dmxmonitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,22 +17,22 @@ - + - + - - - - + + + + diff --git a/lib-dmxmonitor/include/dmxmonitorparamsconst.h b/lib-dmxmonitor/include/dmxmonitorparamsconst.h index 388dafaa5..fd2ba6ccd 100644 --- a/lib-dmxmonitor/include/dmxmonitorparamsconst.h +++ b/lib-dmxmonitor/include/dmxmonitorparamsconst.h @@ -2,7 +2,7 @@ * @file dmxmonitorparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,10 +27,9 @@ #define DMXMONITORPARAMSCONST_H_ struct DMXMonitorParamsConst { - static const char FILE_NAME[]; - - static const char DMX_MAX_CHANNELS[]; - static const char FORMAT[]; + static inline const char FILE_NAME[] = "mon.txt"; + static inline const char DMX_MAX_CHANNELS[] = "dmx_max_channels"; + static inline const char FORMAT[] = "format"; }; #endif /* DMXMONITORPARAMSCONST_H_ */ diff --git a/lib-dmxmonitor/src/dmxmonitorparamsconst.cpp b/lib-dmxmonitor/src/dmxmonitorparamsconst.cpp deleted file mode 100644 index d7758538d..000000000 --- a/lib-dmxmonitor/src/dmxmonitorparamsconst.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file dmxmonitorparamsconst.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. - */ - -#include "dmxmonitorparamsconst.h" - -const char DMXMonitorParamsConst::FILE_NAME[] = "mon.txt"; - -const char DMXMonitorParamsConst::DMX_MAX_CHANNELS[] = "dmx_max_channels"; -const char DMXMonitorParamsConst::FORMAT[] = "format"; diff --git a/lib-dmxserial/.settings/language.settings.xml b/lib-dmxserial/.settings/language.settings.xml index 34dee09c5..0e1c5fb28 100644 --- a/lib-dmxserial/.settings/language.settings.xml +++ b/lib-dmxserial/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-dmxserial/include/dmxserialparamsconst.h b/lib-dmxserial/include/dmxserialparamsconst.h index 3fc338957..df819298d 100644 --- a/lib-dmxserial/include/dmxserialparamsconst.h +++ b/lib-dmxserial/include/dmxserialparamsconst.h @@ -2,7 +2,7 @@ * @file dmxserialparamsconst.h * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,20 +27,16 @@ #define DMXSERIALPARAMSCONST_H_ struct DmxSerialParamsConst { - static const char FILE_NAME[]; - - static const char TYPE[]; - - static const char UART_BAUD[]; - static const char UART_BITS[]; - static const char UART_PARITY[]; - static const char UART_STOPBITS[]; - - static const char SPI_SPEED_HZ[]; - static const char SPI_MODE[]; - - static const char I2C_ADDRESS[]; - static const char I2C_SPEED_MODE[]; + static inline const char FILE_NAME[] = "serial.txt"; + static inline const char TYPE[] = "type"; + static inline const char UART_BAUD[] = "uart_baud"; + static inline const char UART_BITS[] = "uart_bits"; + static inline const char UART_PARITY[] = "uart_parity"; + static inline const char UART_STOPBITS[] = "uart_stopbits"; + static inline const char SPI_SPEED_HZ[] = "spi_speed_hz"; + static inline const char SPI_MODE[] = "spi_mode"; + static inline const char I2C_ADDRESS[] = "i2c_address"; + static inline const char I2C_SPEED_MODE[] = "i2c_speed_mode"; }; #endif /* DMXSERIALPARAMSCONST_H_ */ diff --git a/lib-dmxserial/src/dmxserialparamsconst.cpp b/lib-dmxserial/src/dmxserialparamsconst.cpp deleted file mode 100644 index daed29723..000000000 --- a/lib-dmxserial/src/dmxserialparamsconst.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file dmxserialparamsconst.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. - */ - -#include "dmxserialparamsconst.h" - -const char DmxSerialParamsConst::FILE_NAME[] = "serial.txt"; - -const char DmxSerialParamsConst::TYPE[] = "type"; - -const char DmxSerialParamsConst::UART_BAUD[] = "uart_baud"; -const char DmxSerialParamsConst::UART_BITS[] = "uart_bits"; -const char DmxSerialParamsConst::UART_PARITY[] = "uart_parity"; -const char DmxSerialParamsConst::UART_STOPBITS[] = "uart_stopbits"; - -const char DmxSerialParamsConst::SPI_SPEED_HZ[] = "spi_speed_hz"; -const char DmxSerialParamsConst::SPI_MODE[] = "spi_mode"; - -const char DmxSerialParamsConst::I2C_ADDRESS[] = "i2c_address"; -const char DmxSerialParamsConst::I2C_SPEED_MODE[] = "i2c_speed_mode"; - - diff --git a/lib-e131/.cproject b/lib-e131/.cproject index 31fed1987..c42abcd02 100644 --- a/lib-e131/.cproject +++ b/lib-e131/.cproject @@ -187,94 +187,175 @@ - - + + + + + - - - - - - @@ -303,34 +384,40 @@ + + + - + - + - + - + - + - + - + + + + diff --git a/lib-e131/.settings/language.settings.xml b/lib-e131/.settings/language.settings.xml index 5f41054bf..18dbe0fe2 100644 --- a/lib-e131/.settings/language.settings.xml +++ b/lib-e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,22 +17,22 @@ - + - + - - - - + + + + diff --git a/lib-e131/include/e131paramsconst.h b/lib-e131/include/e131paramsconst.h index 403e274ec..95600b91e 100644 --- a/lib-e131/include/e131paramsconst.h +++ b/lib-e131/include/e131paramsconst.h @@ -2,7 +2,7 @@ * @file e131paramsconst.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,10 +28,27 @@ #include "e131params.h" +#if LIGHTSET_PORTS > 4 +# define MAX_ARRAY 4 +#else +# define MAX_ARRAY LIGHTSET_PORTS +#endif + struct E131ParamsConst { - static const char FILE_NAME[]; + static inline const char FILE_NAME[] = "e131.txt"; - static const char PRIORITY[e131params::MAX_PORTS][18]; + static inline const char PRIORITY[e131params::MAX_PORTS][18] { + "priority_port_a", +#if MAX_ARRAY >= 2 + "priority_port_b", + #endif +#if MAX_ARRAY >= 3 + "priority_port_c", + #endif +#if MAX_ARRAY == 4 + "priority_port_d" + #endif + }; }; #endif /* E131PARAMSCONST_H_ */ diff --git a/lib-e131/src/node/e131paramsconst.cpp b/lib-e131/src/node/e131paramsconst.cpp deleted file mode 100644 index 3b6cd51cd..000000000 --- a/lib-e131/src/node/e131paramsconst.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file e131paramsconst.cpp - * - */ -/* 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 - * 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 "e131paramsconst.h" -#include "e131params.h" - -#if LIGHTSET_PORTS > 4 -# define MAX_ARRAY 4 -#else -# define MAX_ARRAY LIGHTSET_PORTS -#endif - -const char E131ParamsConst::FILE_NAME[] = "e131.txt"; - -const char E131ParamsConst::PRIORITY[e131params::MAX_PORTS][18] { - "priority_port_a", -#if MAX_ARRAY >= 2 - "priority_port_b", -#endif -#if MAX_ARRAY >= 3 - "priority_port_c", -#endif -#if MAX_ARRAY == 4 - "priority_port_d" -#endif -}; - diff --git a/lib-flashcodeinstall/.settings/language.settings.xml b/lib-flashcodeinstall/.settings/language.settings.xml index 9c0161f9a..2217524fa 100755 --- a/lib-flashcodeinstall/.settings/language.settings.xml +++ b/lib-flashcodeinstall/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.cpp b/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.cpp deleted file mode 100644 index 946f01163..000000000 --- a/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file flashcodeinstallparamsconst.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. - */ - -#include "flashcodeinstallparamsconst.h" - -const char FlashCodeInstallParamsConst::FILE_NAME[] = "spiflash.txt"; - -const char FlashCodeInstallParamsConst::INSTALL_UBOOT[] = "install_uboot"; -const char FlashCodeInstallParamsConst::INSTALL_UIMAGE[] = "install_uimage"; diff --git a/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.h b/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.h index e921a5c69..5ccbac8e4 100644 --- a/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.h +++ b/lib-flashcodeinstall/src/params/flashcodeinstallparamsconst.h @@ -2,7 +2,7 @@ * @file flashcodeinstallparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 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,10 +27,9 @@ #define FLASHCODEINSTALLPARAMSCONST_H_ struct FlashCodeInstallParamsConst { - static const char FILE_NAME[]; - - static const char INSTALL_UBOOT[]; - static const char INSTALL_UIMAGE[]; + static inline const char FILE_NAME[] = "spiflash.txt"; + static inline const char INSTALL_UBOOT[] = "install_uboot"; + static inline const char INSTALL_UIMAGE[] = "install_uimage"; }; #endif /* FLASHCODEINSTALLPARAMSCONST_H_ */ diff --git a/lib-gps/.cproject b/lib-gps/.cproject index 226799320..e70f61060 100644 --- a/lib-gps/.cproject +++ b/lib-gps/.cproject @@ -1,10 +1,11 @@ - - + + + @@ -13,63 +14,159 @@ - - - - @@ -96,6 +193,12 @@ + + + + + + diff --git a/lib-gps/.settings/language.settings.xml b/lib-gps/.settings/language.settings.xml index b0aa4e913..cf04b2ce4 100644 --- a/lib-gps/.settings/language.settings.xml +++ b/lib-gps/.settings/language.settings.xml @@ -1,14 +1,14 @@ - + - - - - + + + + diff --git a/lib-gps/include/gpsparamsconst.h b/lib-gps/include/gpsparamsconst.h index b2098d5a3..ff0b10afc 100644 --- a/lib-gps/include/gpsparamsconst.h +++ b/lib-gps/include/gpsparamsconst.h @@ -2,7 +2,7 @@ * @file gpsparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,11 +25,10 @@ #define GPSPARAMSCONST_H_ struct GPSParamsConst { - static const char FILE_NAME[]; - - static const char MODULE[]; - static const char ENABLE[]; - static const char UTC_OFFSET[]; + static inline const char FILE_NAME[] = "gps.txt"; + static inline const char MODULE[] = "module"; + static inline const char ENABLE[] = "enable"; + static inline const char UTC_OFFSET[] = "utc_offset"; }; #endif /* GPSPARAMSCONST_H_ */ diff --git a/lib-gps/src/gpsparamsconst.cpp b/lib-gps/src/gpsparamsconst.cpp deleted file mode 100644 index 569c310ee..000000000 --- a/lib-gps/src/gpsparamsconst.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file gpsparamsconst.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. - */ - -#include "gpsparamsconst.h" - -const char GPSParamsConst::FILE_NAME[] = "gps.txt"; - -const char GPSParamsConst::MODULE[] = "module"; -const char GPSParamsConst::ENABLE[] = "enable"; -const char GPSParamsConst::UTC_OFFSET[] = "utc_offset"; diff --git a/lib-l6470/.settings/language.settings.xml b/lib-l6470/.settings/language.settings.xml index 37b3eb25e..a295dcfd1 100644 --- a/lib-l6470/.settings/language.settings.xml +++ b/lib-l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-l6470dmx/.settings/language.settings.xml b/lib-l6470dmx/.settings/language.settings.xml index beeb54166..3a5c58361 100644 --- a/lib-l6470dmx/.settings/language.settings.xml +++ b/lib-l6470dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-l6470dmx/include/l6470dmxconst.h b/lib-l6470dmx/include/l6470dmxconst.h index f2d0948f2..167434a3b 100644 --- a/lib-l6470dmx/include/l6470dmxconst.h +++ b/lib-l6470dmx/include/l6470dmxconst.h @@ -2,7 +2,7 @@ * @file l6470dmxconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,7 +27,7 @@ #define L6470DMXCONST_H_ struct L6470DmxConst { - static const char FILE_NAME_MOTOR[]; + static inline const char FILE_NAME_MOTOR[] = "motor?.txt"; }; #endif /* L6470DMXCONST_H_ */ diff --git a/lib-l6470dmx/include/l6470paramsconst.h b/lib-l6470dmx/include/l6470paramsconst.h index c5dcea668..c7f9cd2c2 100644 --- a/lib-l6470dmx/include/l6470paramsconst.h +++ b/lib-l6470dmx/include/l6470paramsconst.h @@ -2,7 +2,7 @@ * @file l6470paramsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,15 +27,15 @@ #define L6470PARAMSCONST_H_ struct L6470ParamsConst { - static const char MIN_SPEED[]; - static const char MAX_SPEED[]; - static const char ACC[]; - static const char DEC[]; - static const char KVAL_HOLD[]; - static const char KVAL_RUN[]; - static const char KVAL_ACC[]; - static const char KVAL_DEC[]; - static const char MICRO_STEPS[]; + static inline const char MIN_SPEED[] = "l6470_min_speed"; + static inline const char MAX_SPEED[] = "l6470_max_speed"; + static inline const char ACC[] = "l6470_acc"; + static inline const char DEC[] = "l6470_dec"; + static inline const char KVAL_HOLD[] = "l6470_kval_hold"; + static inline const char KVAL_RUN[] = "l6470_kval_run"; + static inline const char KVAL_ACC[] = "l6470_kval_acc"; + static inline const char KVAL_DEC[] = "l6470_kval_dec"; + static inline const char MICRO_STEPS[] = "l6470_micro_steps"; }; #endif /* L6470PARAMSCONST_H_ */ diff --git a/lib-l6470dmx/include/modeparamsconst.h b/lib-l6470dmx/include/modeparamsconst.h index d6d9db6a0..aca9a5e18 100644 --- a/lib-l6470dmx/include/modeparamsconst.h +++ b/lib-l6470dmx/include/modeparamsconst.h @@ -2,7 +2,7 @@ * @file modeparamsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,13 +27,12 @@ #define MODEPARAMSCONST_H_ struct ModeParamsConst { - static const char DMX_MODE[]; - - static const char MAX_STEPS[]; - static const char SWITCH_ACT[]; - static const char SWITCH_DIR[]; - static const char SWITCH_SPS[]; - static const char SWITCH[]; + static inline const char DMX_MODE[] = "dmx_mode"; + static inline const char MAX_STEPS[] = "mode_max_steps"; + static inline const char SWITCH_ACT[] = "mode_switch_act"; + static inline const char SWITCH_DIR[] = "mode_switch_dir"; + static inline const char SWITCH_SPS[] = "mode_switch_sps"; + static inline const char SWITCH[] = "mode_switch"; }; #endif /* MODEPARAMSCONST_H_ */ diff --git a/lib-l6470dmx/include/motorparamsconst.h b/lib-l6470dmx/include/motorparamsconst.h index 869fb9030..9ca08a3ec 100644 --- a/lib-l6470dmx/include/motorparamsconst.h +++ b/lib-l6470dmx/include/motorparamsconst.h @@ -2,7 +2,7 @@ * @file motorparamsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,11 +27,11 @@ #define MOTORPARAMSCONST_H_ struct MotorParamsConst { - static const char STEP_ANGEL[]; - static const char VOLTAGE[]; - static const char CURRENT[]; - static const char RESISTANCE[]; - static const char INDUCTANCE[]; + static inline const char STEP_ANGEL[] = "motor_step_angel"; + static inline const char VOLTAGE[] = "motor_voltage"; + static inline const char CURRENT[] = "motor_current"; + static inline const char RESISTANCE[] = "motor_resistance"; + static inline const char INDUCTANCE[] = "motor_inductance"; }; #endif /* MOTORPARAMSCONST_H_ */ diff --git a/lib-l6470dmx/include/sparkfundmxconst.h b/lib-l6470dmx/include/sparkfundmxconst.h index e4624f7bc..e2ca0d742 100644 --- a/lib-l6470dmx/include/sparkfundmxconst.h +++ b/lib-l6470dmx/include/sparkfundmxconst.h @@ -2,7 +2,7 @@ * @file sparkfundmxconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,7 +27,7 @@ #define SPARKFUNDMXCONST_H_ struct SparkFunDmxConst { - static const char MSG_INIT[]; + static inline const char MSG_INIT[] = "SparkFun init"; }; #endif /* SPARKFUNDMXCONST_H_ */ diff --git a/lib-l6470dmx/include/sparkfundmxparamsconst.h b/lib-l6470dmx/include/sparkfundmxparamsconst.h index c38c6e904..5e86b30c9 100644 --- a/lib-l6470dmx/include/sparkfundmxparamsconst.h +++ b/lib-l6470dmx/include/sparkfundmxparamsconst.h @@ -2,7 +2,7 @@ * @file sparkfundmxparamsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,13 +27,13 @@ #define SPARKFUNDMXPARAMSCONST_H_ struct SparkFunDmxParamsConst { - static const char FILE_NAME[]; - static const char POSITION[]; + static inline const char FILE_NAME[] = "sparkfun.txt"; + static inline const char POSITION[] = "sparkfun_position"; #if !defined (H3) - static const char SPI_CS[]; + static inline const char SPI_CS[] = "sparkfun_spi_cs"; #endif - static const char RESET_PIN[]; - static const char BUSY_PIN[]; + static inline const char RESET_PIN[] = "sparkfun_reset_pin"; + static inline const char BUSY_PIN[] = "sparkfun_busy_pin"; }; #endif /* SPARKFUNDMXPARAMSCONST_H_ */ diff --git a/lib-l6470dmx/src/l6470dmxconst.cpp b/lib-l6470dmx/src/l6470dmxconst.cpp deleted file mode 100644 index beca6a937..000000000 --- a/lib-l6470dmx/src/l6470dmxconst.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @file l6470dmxconst.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 "l6470dmxconst.h" - -const char L6470DmxConst::FILE_NAME_MOTOR[] = "motor?.txt"; diff --git a/lib-l6470dmx/src/l6470paramsconst.cpp b/lib-l6470dmx/src/l6470paramsconst.cpp deleted file mode 100644 index 6da07dae5..000000000 --- a/lib-l6470dmx/src/l6470paramsconst.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file l6470paramsconst.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 "l6470paramsconst.h" - -const char L6470ParamsConst::MIN_SPEED[] = "l6470_min_speed"; -const char L6470ParamsConst::MAX_SPEED[] = "l6470_max_speed"; -const char L6470ParamsConst::ACC[] = "l6470_acc"; -const char L6470ParamsConst::DEC[] = "l6470_dec"; -const char L6470ParamsConst::KVAL_HOLD[] = "l6470_kval_hold"; -const char L6470ParamsConst::KVAL_RUN[] = "l6470_kval_run"; -const char L6470ParamsConst::KVAL_ACC[] = "l6470_kval_acc"; -const char L6470ParamsConst::KVAL_DEC[] = "l6470_kval_dec"; -const char L6470ParamsConst::MICRO_STEPS[] = "l6470_micro_steps"; diff --git a/lib-l6470dmx/src/modeparamsconst.cpp b/lib-l6470dmx/src/modeparamsconst.cpp deleted file mode 100644 index f0882b2b0..000000000 --- a/lib-l6470dmx/src/modeparamsconst.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file modeparamsconst.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 "modeparamsconst.h" - -const char ModeParamsConst::DMX_MODE[] = "dmx_mode"; -// -const char ModeParamsConst::MAX_STEPS[] = "mode_max_steps"; -const char ModeParamsConst::SWITCH_ACT[] = "mode_switch_act"; -const char ModeParamsConst::SWITCH_DIR[] = "mode_switch_dir"; -const char ModeParamsConst::SWITCH_SPS[] = "mode_switch_sps"; -const char ModeParamsConst::SWITCH[] = "mode_switch"; diff --git a/lib-l6470dmx/src/motorparamsconst.cpp b/lib-l6470dmx/src/motorparamsconst.cpp deleted file mode 100644 index 02b663b17..000000000 --- a/lib-l6470dmx/src/motorparamsconst.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file motorparamsconst.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 "motorparamsconst.h" - -const char MotorParamsConst::STEP_ANGEL[] = "motor_step_angel"; -const char MotorParamsConst::VOLTAGE[] = "motor_voltage"; -const char MotorParamsConst::CURRENT[] = "motor_current"; -const char MotorParamsConst::RESISTANCE[] = "motor_resistance"; -const char MotorParamsConst::INDUCTANCE[] = "motor_inductance"; diff --git a/lib-l6470dmx/src/sparkfundmxconst.cpp b/lib-l6470dmx/src/sparkfundmxconst.cpp deleted file mode 100644 index b76f29066..000000000 --- a/lib-l6470dmx/src/sparkfundmxconst.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @file sparkfundmxconst.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 "sparkfundmxconst.h" - -const char SparkFunDmxConst::MSG_INIT[] = "SparkFun init"; diff --git a/lib-l6470dmx/src/sparkfundmxparamsconst.cpp b/lib-l6470dmx/src/sparkfundmxparamsconst.cpp deleted file mode 100644 index 461008cd2..000000000 --- a/lib-l6470dmx/src/sparkfundmxparamsconst.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file sparkfundmxparamsconst.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 "sparkfundmxparamsconst.h" - -const char SparkFunDmxParamsConst::FILE_NAME[] = "sparkfun.txt"; -const char SparkFunDmxParamsConst::POSITION[] = "sparkfun_position"; -#if !defined (H3) - const char SparkFunDmxParamsConst::SPI_CS[] = "sparkfun_spi_cs"; -#endif -const char SparkFunDmxParamsConst::RESET_PIN[] = "sparkfun_reset_pin"; -const char SparkFunDmxParamsConst::BUSY_PIN[] = "sparkfun_busy_pin"; diff --git a/lib-lightset/.cproject b/lib-lightset/.cproject index ac48de09b..01871b567 100644 --- a/lib-lightset/.cproject +++ b/lib-lightset/.cproject @@ -315,12 +315,8 @@ - - - - - - + + diff --git a/lib-lightset/.settings/language.settings.xml b/lib-lightset/.settings/language.settings.xml index a04cfb7f2..19f1e0948 100644 --- a/lib-lightset/.settings/language.settings.xml +++ b/lib-lightset/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-lightset/include/lightsetparamsconst.h b/lib-lightset/include/lightsetparamsconst.h index 6bc72324f..e85ddf3f7 100644 --- a/lib-lightset/include/lightsetparamsconst.h +++ b/lib-lightset/include/lightsetparamsconst.h @@ -2,7 +2,7 @@ * @file lightsetparamsconst.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,26 +33,82 @@ static constexpr uint32_t MAX_PORTS = 4; } // namespace lightsetparams struct LightSetParamsConst { - static const char PARAMS_OUTPUT[]; + static inline const char PARAMS_OUTPUT[] = "output"; - static const char NODE_LABEL[lightsetparams::MAX_PORTS][14]; - static const char NODE_LONG_NAME[]; + static inline const char UNIVERSE_PORT[lightsetparams::MAX_PORTS][16] = { + "universe_port_a", + "universe_port_b", + "universe_port_c", + "universe_port_d" + }; - static const char UNIVERSE_PORT[lightsetparams::MAX_PORTS][16]; - static const char MERGE_MODE_PORT[lightsetparams::MAX_PORTS][18]; - static const char DIRECTION[lightsetparams::MAX_PORTS][18]; - static const char OUTPUT_STYLE[lightsetparams::MAX_PORTS][16]; - static const char PRIORITY[lightsetparams::MAX_PORTS][16]; + static inline const char MERGE_MODE_PORT[lightsetparams::MAX_PORTS][18] = { + "merge_mode_port_a", + "merge_mode_port_b", + "merge_mode_port_c", + "merge_mode_port_d" + }; - static const char DMX_START_ADDRESS[]; - static const char DMX_SLOT_INFO[]; + static inline const char DIRECTION[lightsetparams::MAX_PORTS][18] = { + "direction_port_a", + "direction_port_b", + "direction_port_c", + "direction_port_d" + }; - static const char DISABLE_MERGE_TIMEOUT[]; + static inline const char OUTPUT_STYLE[lightsetparams::MAX_PORTS][16] = { + "output_style_a", + "output_style_b", + "output_style_c", + "output_style_d" + }; - static const char FAILSAFE[]; + static inline const char PRIORITY[lightsetparams::MAX_PORTS][16] = { + "priority_port_a", + "priority_port_b", + "priority_port_c", + "priority_port_d" + }; + + static inline const char NODE_LABEL[lightsetparams::MAX_PORTS][14] = { + "label_port_a", + "label_port_b", + "label_port_c", + "label_port_d" + }; + + static inline const char NODE_LONG_NAME[] = "long_name"; + + static inline const char DMX_START_ADDRESS[] = "dmx_start_address"; + static inline const char DMX_SLOT_INFO[] = "dmx_slot_info"; + + static inline const char DISABLE_MERGE_TIMEOUT[] = "disable_merge_timeout"; + + static inline const char FAILSAFE[] = "failsafe"; #if defined (CONFIG_PIXELDMX_MAX_PORTS) - static const char START_UNI_PORT[CONFIG_PIXELDMX_MAX_PORTS][20]; + static inline const char START_UNI_PORT[CONFIG_PIXELDMX_MAX_PORTS][20] = { + "start_uni_port_1", +# if CONFIG_PIXELDMX_MAX_PORTS > 2 + "start_uni_port_2", + "start_uni_port_3", + "start_uni_port_4", + "start_uni_port_5", + "start_uni_port_6", + "start_uni_port_7", + "start_uni_port_8", +# endif +# if CONFIG_PIXELDMX_MAX_PORTS == 16 + "start_uni_port_9", + "start_uni_port_10", + "start_uni_port_11", + "start_uni_port_12", + "start_uni_port_13", + "start_uni_port_14", + "start_uni_port_15", + "start_uni_port_16" +# endif + }; #endif }; diff --git a/lib-lightset/src/lightsetparamsconst.cpp b/lib-lightset/src/lightsetparamsconst.cpp deleted file mode 100644 index 1361b4e7f..000000000 --- a/lib-lightset/src/lightsetparamsconst.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @file lightsetconst.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. - */ - -#include "lightsetparamsconst.h" - -const char LightSetParamsConst::PARAMS_OUTPUT[] = "output"; - -const char LightSetParamsConst::UNIVERSE_PORT[lightsetparams::MAX_PORTS][16] = { - "universe_port_a", - "universe_port_b", - "universe_port_c", - "universe_port_d" -}; - -const char LightSetParamsConst::MERGE_MODE_PORT[lightsetparams::MAX_PORTS][18] = { - "merge_mode_port_a", - "merge_mode_port_b", - "merge_mode_port_c", - "merge_mode_port_d" -}; - -const char LightSetParamsConst::DIRECTION[lightsetparams::MAX_PORTS][18] = { - "direction_port_a", - "direction_port_b", - "direction_port_c", - "direction_port_d" -}; - -const char LightSetParamsConst::OUTPUT_STYLE[lightsetparams::MAX_PORTS][16] = { - "output_style_a", - "output_style_b", - "output_style_c", - "output_style_d" -}; - -const char LightSetParamsConst::PRIORITY[lightsetparams::MAX_PORTS][16] = { - "priority_port_a", - "priority_port_b", - "priority_port_c", - "priority_port_d" -}; - -const char LightSetParamsConst::NODE_LABEL[lightsetparams::MAX_PORTS][14] = { - "label_port_a", - "label_port_b", - "label_port_c", - "label_port_d" -}; - -const char LightSetParamsConst::NODE_LONG_NAME[] = "long_name"; - -const char LightSetParamsConst::DMX_START_ADDRESS[] = "dmx_start_address"; -const char LightSetParamsConst::DMX_SLOT_INFO[] = "dmx_slot_info"; - -const char LightSetParamsConst::DISABLE_MERGE_TIMEOUT[] = "disable_merge_timeout"; - -const char LightSetParamsConst::FAILSAFE[] = "failsafe"; - -#if defined (CONFIG_PIXELDMX_MAX_PORTS) -const char LightSetParamsConst::START_UNI_PORT[CONFIG_PIXELDMX_MAX_PORTS][20] = { - "start_uni_port_1", -#if CONFIG_PIXELDMX_MAX_PORTS > 2 - "start_uni_port_2", - "start_uni_port_3", - "start_uni_port_4", - "start_uni_port_5", - "start_uni_port_6", - "start_uni_port_7", - "start_uni_port_8", -#endif -#if CONFIG_PIXELDMX_MAX_PORTS == 16 - "start_uni_port_9", - "start_uni_port_10", - "start_uni_port_11", - "start_uni_port_12", - "start_uni_port_13", - "start_uni_port_14", - "start_uni_port_15", - "start_uni_port_16" -#endif -}; -#endif diff --git a/lib-ltc/.cproject b/lib-ltc/.cproject index 0c67f011c..f013d8c1c 100644 --- a/lib-ltc/.cproject +++ b/lib-ltc/.cproject @@ -1,10 +1,11 @@ - - + + + @@ -13,76 +14,186 @@ - - - - @@ -94,15 +205,6 @@ - - - - - - - - - @@ -113,4 +215,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib-ltc/.settings/language.settings.xml b/lib-ltc/.settings/language.settings.xml index 44936195d..26e0b6364 100644 --- a/lib-ltc/.settings/language.settings.xml +++ b/lib-ltc/.settings/language.settings.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/lib-ltc/include/ltcdisplayparamsconst.h b/lib-ltc/include/ltcdisplayparamsconst.h index e644c96a2..74f12ac21 100755 --- a/lib-ltc/include/ltcdisplayparamsconst.h +++ b/lib-ltc/include/ltcdisplayparamsconst.h @@ -31,46 +31,53 @@ #include "ltcdisplayrgb.h" struct LtcDisplayParamsConst { - static const char FILE_NAME[]; + static inline const char FILE_NAME[] = "ldisplay.txt"; /** * OLED SSD1306 / SSD1311 */ - static const char OLED_INTENSITY[]; + static inline const char OLED_INTENSITY[] = "oled_intensity"; /** * Rotary control */ - static const char ROTARY_FULLSTEP[]; + static inline const char ROTARY_FULLSTEP[] = "rotary_fullstep"; /** * MAX7219 7-segment / matrix */ - static const char MAX7219_TYPE[]; - static const char MAX7219_INTENSITY[]; + static inline const char MAX7219_TYPE[] = "max7219_type"; + static inline const char MAX7219_INTENSITY[] = "max7219_intensity"; /** * RGB Display generic */ - static const char INTENSITY[]; - static const char COLON_BLINK_MODE[]; - static const char COLOUR[static_cast(ltcdisplayrgb::ColourIndex::LAST)][24]; + static inline const char INTENSITY[] = "intensity"; + static inline const char COLON_BLINK_MODE[] = "colon_blink_mode"; + static inline const char COLOUR[static_cast(ltcdisplayrgb::ColourIndex::LAST)][24] = + { "colour_time", + "colour_colon", + "colour_message", + "colour_fps", // RGB panel specific + "colour_info", // RGB panel specific + "colour_source" // RGB panel specific + }; /** * WS28xx specific */ - static const char WS28XX_TYPE[]; + static inline const char WS28XX_TYPE[] = "ws28xx_type"; /** * RGB panel specific */ - static const char INFO_MSG[]; + static inline const char INFO_MSG[] = "info_msg"; }; #endif /* LTCDISPLAYPARAMSCONST_H_ */ diff --git a/lib-ltc/include/ltcetcparamsconst.h b/lib-ltc/include/ltcetcparamsconst.h index cd306753e..3e2a04da3 100755 --- a/lib-ltc/include/ltcetcparamsconst.h +++ b/lib-ltc/include/ltcetcparamsconst.h @@ -2,7 +2,7 @@ * @file ltcetcparamsconst.h * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,15 +28,12 @@ #define LTCETCPARAMSCONST_H_ struct LtcEtcParamsConst { - static const char FILE_NAME[]; - - static const char DESTINATION_IP[]; - static const char DESTINATION_PORT[]; - - static const char SOURCE_MULTICAST_IP[]; - static const char SOURCE_PORT[]; - - static const char UDP_TERMINATOR[]; + static inline const char FILE_NAME[] = "etc.txt"; + static inline const char DESTINATION_IP[] = "destination_ip"; + static inline const char DESTINATION_PORT[] = "destination_port"; + static inline const char SOURCE_MULTICAST_IP[] = "source_multicast_ip"; + static inline const char SOURCE_PORT[] = "source_port"; + static inline const char UDP_TERMINATOR[] = "udp_terminator"; }; #endif /* LTCETCPARAMSCONST_H_ */ diff --git a/lib-ltc/include/ltcparamsconst.h b/lib-ltc/include/ltcparamsconst.h index 01c048f56..00e9c6746 100755 --- a/lib-ltc/include/ltcparamsconst.h +++ b/lib-ltc/include/ltcparamsconst.h @@ -1,7 +1,7 @@ /** * @file ltcparamsconst.h */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,51 +26,51 @@ #define LTCPARAMSCONST_H_ struct LtcParamsConst { - static const char FILE_NAME[]; + static inline const char FILE_NAME[] = "ltc.txt"; - static const char SOURCE[]; + static inline const char SOURCE[] = "source"; // System time - static const char AUTO_START[]; - static const char GPS_START[]; + static inline const char AUTO_START[] = "auto_start"; + static inline const char GPS_START[] = "gps_start"; // Output options - static const char DISABLE_DISPLAY[]; - static const char DISABLE_MAX7219[]; - static const char DISABLE_MIDI[]; - static const char DISABLE_ARTNET[]; - static const char DISABLE_LTC[]; - static const char DISABLE_ETC[]; - static const char DISABLE_RTPMIDI[]; - static const char SHOW_SYSTIME[]; - static const char DISABLE_TIMESYNC[]; + static inline const char DISABLE_DISPLAY[] = "disable_display"; + static inline const char DISABLE_MAX7219[] = "disable_max7219"; + static inline const char DISABLE_MIDI[] = "disable_midi"; + static inline const char DISABLE_ARTNET[] = "disable_artnet"; + static inline const char DISABLE_LTC[] = "disable_ltc"; + static inline const char DISABLE_RTPMIDI[] = "disable_rtp-midi"; + static inline const char DISABLE_ETC[] = "disable_etc"; + static inline const char SHOW_SYSTIME[] = "show_systime"; + static inline const char DISABLE_TIMESYNC[] = "disable_timesync"; // NTP - static const char YEAR[]; - static const char MONTH[]; - static const char DAY[]; - static const char NTP_ENABLE[]; + static inline const char YEAR[] = "year"; + static inline const char MONTH[] = "month"; + static inline const char DAY[] = "day"; + static inline const char NTP_ENABLE[] = "ntp_enable"; // LTC - static const char VOLUME[]; + static inline const char VOLUME[] = "volume"; // Art-Net - static const char TIMECODE_IP[]; + static inline const char TIMECODE_IP[] = "timecode_ip"; // Generator - static const char FPS[]; - static const char START_FRAME[]; - static const char START_SECOND[]; - static const char START_MINUTE[]; - static const char START_HOUR[]; - static const char STOP_FRAME[]; - static const char STOP_SECOND[]; - static const char STOP_MINUTE[]; - static const char STOP_HOUR[]; - static const char ALT_FUNCTION[]; - static const char SKIP_SECONDS[]; - static const char SKIP_FREE[]; + static inline const char FPS[] = "fps"; + static inline const char START_FRAME[] = "start_frame"; + static inline const char START_SECOND[] = "start_second"; + static inline const char START_MINUTE[] = "start_minute"; + static inline const char START_HOUR[] = "start_hour"; + static inline const char STOP_FRAME[] = "stop_frame"; + static inline const char STOP_SECOND[] = "stop_second"; + static inline const char STOP_MINUTE[] = "stop_minute"; + static inline const char STOP_HOUR[] = "stop_hour"; + static inline const char ALT_FUNCTION[] = "alt_function"; + static inline const char SKIP_SECONDS[] = "skip_seconds"; + static inline const char SKIP_FREE[] = "skip_free"; // OSC - static const char OSC_ENABLE[]; - static const char OSC_PORT[]; + static inline const char OSC_ENABLE[] = "osc_enable"; + static inline const char OSC_PORT[] = "osc_port"; // WS28xx Display - static const char WS28XX_ENABLE[]; + static inline const char WS28XX_ENABLE[] = "ws28xx_enable"; // RGB led panel - static const char RGBPANEL_ENABLE[]; + static inline const char RGBPANEL_ENABLE[] = "rgbpanel_enable"; }; #endif /* LTCPARAMSCONST_H_ */ diff --git a/lib-ltc/include/timecodeconst.h b/lib-ltc/include/timecodeconst.h index cab010d57..fdd9f540e 100755 --- a/lib-ltc/include/timecodeconst.h +++ b/lib-ltc/include/timecodeconst.h @@ -28,8 +28,14 @@ #include struct TimeCodeConst { - static const uint8_t FPS[4]; - static const uint32_t TMR_INTV[4]; + static constexpr uint8_t FPS[4] = { 24, 25, 30, 30 }; +#if defined (H3) + static constexpr uint32_t TMR_INTV[4] = {12000000 / 24, 12000000 / 25, 12000000 / 30, 12000000 / 30}; +#elif defined (GD32) + static constexpr uint32_t TMR_INTV[4] = {(FREQUENCY_EFFECTIVE / 24), (FREQUENCY_EFFECTIVE / 25) - 1, (FREQUENCY_EFFECTIVE / 30) - 1, (FREQUENCY_EFFECTIVE / 30) - 1}; + static_assert((FREQUENCY_EFFECTIVE / 24) <= UINT16_MAX); +#endif + }; #if defined (GD32) diff --git a/lib-ltc/src/ltcdisplayparamsconst.cpp b/lib-ltc/src/ltcdisplayparamsconst.cpp deleted file mode 100755 index 033282176..000000000 --- a/lib-ltc/src/ltcdisplayparamsconst.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file ltcdisplayparamsconst.cpp - * - */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "ltcdisplayparamsconst.h" - -const char LtcDisplayParamsConst::FILE_NAME[] = "ldisplay.txt"; - -/** - * OLED SSD1306 / SSD1311 - */ - -const char LtcDisplayParamsConst::OLED_INTENSITY[] = "oled_intensity"; - -/** - * Rotary control - */ - -const char LtcDisplayParamsConst::ROTARY_FULLSTEP[] = "rotary_fullstep"; - -/** - * MAX7219 7-segment / matrix - */ - -const char LtcDisplayParamsConst::MAX7219_TYPE[] = "max7219_type"; -const char LtcDisplayParamsConst::MAX7219_INTENSITY[] = "max7219_intensity"; - -/** - * RGB Display generic - */ - -const char LtcDisplayParamsConst::INTENSITY[] = "intensity"; -const char LtcDisplayParamsConst::COLON_BLINK_MODE[] = "colon_blink_mode"; -const char LtcDisplayParamsConst::COLOUR[static_cast(ltcdisplayrgb::ColourIndex::LAST)][24] = - { "colour_time", - "colour_colon", - "colour_message", - "colour_fps", // RGB panel specific - "colour_info", // RGB panel specific - "colour_source" // RGB panel specific - }; - -/** - * WS28xx specific - */ - -const char LtcDisplayParamsConst::WS28XX_TYPE[] = "ws28xx_type"; - -/** - * RGB panel specific - */ - -const char LtcDisplayParamsConst::INFO_MSG[] = "info_msg"; diff --git a/lib-ltc/src/ltcetcparamsconst.cpp b/lib-ltc/src/ltcetcparamsconst.cpp deleted file mode 100755 index a06d5ebb2..000000000 --- a/lib-ltc/src/ltcetcparamsconst.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file ltcetcparamsconst.cpp - * - */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "ltcetcparamsconst.h" - -const char LtcEtcParamsConst::FILE_NAME[] = "etc.txt"; - -const char LtcEtcParamsConst::DESTINATION_IP[] = "destination_ip"; -const char LtcEtcParamsConst::DESTINATION_PORT[] = "destination_port"; - -const char LtcEtcParamsConst::SOURCE_MULTICAST_IP[] = "source_multicast_ip"; -const char LtcEtcParamsConst::SOURCE_PORT[] = "source_port"; - -const char LtcEtcParamsConst::UDP_TERMINATOR[] = "udp_terminator"; diff --git a/lib-ltc/src/ltcparamsconst.cpp b/lib-ltc/src/ltcparamsconst.cpp deleted file mode 100755 index 969abe8e2..000000000 --- a/lib-ltc/src/ltcparamsconst.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file ltcparamsconst.cpp - */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "ltcparamsconst.h" - -const char LtcParamsConst::FILE_NAME[] = "ltc.txt"; - -const char LtcParamsConst::SOURCE[] = "source"; -// System time -const char LtcParamsConst::AUTO_START[] = "auto_start"; -const char LtcParamsConst::GPS_START[] = "gps_start"; -// Output options -const char LtcParamsConst::DISABLE_DISPLAY[] = "disable_display"; -const char LtcParamsConst::DISABLE_MAX7219[] = "disable_max7219"; -const char LtcParamsConst::DISABLE_MIDI[] = "disable_midi"; -const char LtcParamsConst::DISABLE_ARTNET[] = "disable_artnet"; -const char LtcParamsConst::DISABLE_LTC[] = "disable_ltc"; -const char LtcParamsConst::DISABLE_RTPMIDI[] = "disable_rtp-midi"; -const char LtcParamsConst::DISABLE_ETC[] = "disable_etc"; -const char LtcParamsConst::SHOW_SYSTIME[] = "show_systime"; -const char LtcParamsConst::DISABLE_TIMESYNC[] = "disable_timesync"; -// NTP -const char LtcParamsConst::YEAR[] = "year"; -const char LtcParamsConst::MONTH[] = "month"; -const char LtcParamsConst::DAY[] = "day"; -const char LtcParamsConst::NTP_ENABLE[] = "ntp_enable"; -// LTC -const char LtcParamsConst::VOLUME[] = "volume"; -// Art-Net -const char LtcParamsConst::TIMECODE_IP[] = "timecode_ip"; -// Generator -const char LtcParamsConst::FPS[] = "fps"; -const char LtcParamsConst::START_FRAME[] = "start_frame"; -const char LtcParamsConst::START_SECOND[] = "start_second"; -const char LtcParamsConst::START_MINUTE[] = "start_minute"; -const char LtcParamsConst::START_HOUR[] = "start_hour"; -const char LtcParamsConst::STOP_FRAME[] = "stop_frame"; -const char LtcParamsConst::STOP_SECOND[] = "stop_second"; -const char LtcParamsConst::STOP_MINUTE[] = "stop_minute"; -const char LtcParamsConst::STOP_HOUR[] = "stop_hour"; -const char LtcParamsConst::ALT_FUNCTION[] = "alt_function"; -const char LtcParamsConst::SKIP_SECONDS[] = "skip_seconds"; -const char LtcParamsConst::SKIP_FREE[] = "skip_free"; -// OSC -const char LtcParamsConst::OSC_ENABLE[] = "osc_enable"; -const char LtcParamsConst::OSC_PORT[] = "osc_port"; -// WS28xx Display -const char LtcParamsConst::WS28XX_ENABLE[] = "ws28xx_enable"; -// RGB led panel -const char LtcParamsConst::RGBPANEL_ENABLE[] = "rgbpanel_enable"; diff --git a/lib-ltc/src/timecodeconst.cpp b/lib-ltc/src/timecodeconst.cpp deleted file mode 100755 index d47c9a188..000000000 --- a/lib-ltc/src/timecodeconst.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file timecodeconst.cpp - */ -/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 "timecodeconst.h" - -const uint8_t TimeCodeConst::FPS[4] = { 24, 25, 30, 30 }; -#if defined (H3) -const uint32_t TimeCodeConst::TMR_INTV[4] = {12000000 / 24, 12000000 / 25, 12000000 / 30, 12000000 / 30}; -#elif defined (GD32) - const uint32_t TimeCodeConst::TMR_INTV[4] = {(FREQUENCY_EFFECTIVE / 24), (FREQUENCY_EFFECTIVE / 25) - 1, (FREQUENCY_EFFECTIVE / 30) - 1, (FREQUENCY_EFFECTIVE / 30) - 1}; - static_assert((FREQUENCY_EFFECTIVE / 24) <= UINT16_MAX); -#endif diff --git a/lib-midi/.cproject b/lib-midi/.cproject index 5feda7f9d..299d62016 100644 --- a/lib-midi/.cproject +++ b/lib-midi/.cproject @@ -32,6 +32,9 @@ + + + @@ -88,12 +97,11 @@ - - - - - + + + + @@ -102,61 +110,167 @@ - - - - @@ -54,6 +56,7 @@ + @@ -93,6 +96,7 @@ + @@ -101,6 +105,7 @@ + @@ -117,6 +122,7 @@ + @@ -131,10 +137,11 @@ - - + + + @@ -143,66 +150,167 @@ - - - - @@ -233,29 +341,35 @@ - + - + - + - + - + - + - + + + + + + + \ No newline at end of file diff --git a/lib-osc/.settings/language.settings.xml b/lib-osc/.settings/language.settings.xml index eeb0ac022..eea99bb3f 100644 --- a/lib-osc/.settings/language.settings.xml +++ b/lib-osc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,19 +17,19 @@ - + - + - - + + diff --git a/lib-osc/include/oscclientparamsconst.h b/lib-osc/include/oscclientparamsconst.h index 0d0804d04..940fb4890 100755 --- a/lib-osc/include/oscclientparamsconst.h +++ b/lib-osc/include/oscclientparamsconst.h @@ -2,7 +2,7 @@ * @file oscclientparamsconst.h * */ -/* Copyright (C) 2019 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,18 +26,13 @@ #ifndef OSCCLIENTPARAMSCONST_H_ #define OSCCLIENTPARAMSCONST_H_ -#include - struct OscClientParamsConst { - static const char FILE_NAME[]; - - static const char SERVER_IP[]; - - static const char PING_DISABLE[]; - static const char PING_DELAY[]; - - static const char CMD[]; - static const char LED[]; + static inline const char FILE_NAME[] = "oscclnt.txt"; + static inline const char SERVER_IP[] = "server_ip"; + static inline const char PING_DISABLE[] = "ping_disable"; + static inline const char PING_DELAY[] = "ping_delay"; + static inline const char CMD[] = "cmd?"; + static inline const char LED[] = "led?"; }; #endif /* OSCCLIENTPARAMSCONST_H_ */ diff --git a/lib-osc/include/oscserverparamsconst.h b/lib-osc/include/oscserverparamsconst.h index 5649e1d6f..d2c4f918d 100755 --- a/lib-osc/include/oscserverparamsconst.h +++ b/lib-osc/include/oscserverparamsconst.h @@ -2,7 +2,7 @@ * @file oscserverparamsconst.h * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,13 +27,11 @@ #define OSCSERVERPARAMSCONST_H_ struct OscServerParamsConst { - static const char FILE_NAME[]; - - static const char PATH[]; - static const char PATH_INFO[]; - static const char PATH_BLACKOUT[]; - - static const char TRANSMISSION[]; + static inline const char FILE_NAME[] = "osc.txt"; + static inline const char PATH[] = "path"; + static inline const char PATH_INFO[] = "path_info"; + static inline const char PATH_BLACKOUT[] = "path_blackout"; + static inline const char TRANSMISSION[] = "partial_transmission"; }; #endif /* OSCSERVERPARAMSCONST_H_ */ diff --git a/lib-osc/src/client/oscclientparamsconst.cpp b/lib-osc/src/client/oscclientparamsconst.cpp deleted file mode 100755 index 2c5140271..000000000 --- a/lib-osc/src/client/oscclientparamsconst.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file oscclientparamsconst.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 "oscclientparamsconst.h" - -const char OscClientParamsConst::FILE_NAME[] = "oscclnt.txt"; - -const char OscClientParamsConst::SERVER_IP[] = "server_ip"; - -const char OscClientParamsConst::PING_DISABLE[] = "ping_disable"; -const char OscClientParamsConst::PING_DELAY[] = "ping_delay"; - -const char OscClientParamsConst::CMD[] = "cmd?"; -const char OscClientParamsConst::LED[] = "led?"; diff --git a/lib-osc/src/server/oscserverparamsconst.cpp b/lib-osc/src/server/oscserverparamsconst.cpp deleted file mode 100755 index e31ee24e2..000000000 --- a/lib-osc/src/server/oscserverparamsconst.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file oscserverparamsconst.cpp - * - */ -/* Copyright (C) 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. - */ - -#include "oscserverparamsconst.h" - -const char OscServerParamsConst::FILE_NAME[] = "osc.txt"; - -const char OscServerParamsConst::PATH[] = "path"; -const char OscServerParamsConst::PATH_INFO[] = "path_info"; -const char OscServerParamsConst::PATH_BLACKOUT[] = "path_blackout"; - -const char OscServerParamsConst::TRANSMISSION[] = "partial_transmission"; diff --git a/lib-pca9685/.settings/language.settings.xml b/lib-pca9685/.settings/language.settings.xml index a586af352..9ea522c4d 100644 --- a/lib-pca9685/.settings/language.settings.xml +++ b/lib-pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685dmx/.settings/language.settings.xml b/lib-pca9685dmx/.settings/language.settings.xml index 598afb662..0f9b63df2 100644 --- a/lib-pca9685dmx/.settings/language.settings.xml +++ b/lib-pca9685dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685dmx/include/pca9685dmxparamsconst.h b/lib-pca9685dmx/include/pca9685dmxparamsconst.h index fc0f31224..76e7a0c7e 100755 --- a/lib-pca9685dmx/include/pca9685dmxparamsconst.h +++ b/lib-pca9685dmx/include/pca9685dmxparamsconst.h @@ -2,7 +2,7 @@ * @file pca9685dmxparamsconst.h * */ -/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,21 +25,17 @@ #define PCA9685DMXPARAMSCONST_H_ struct PCA9685DmxParamsConst { - static const char FILE_NAME[]; - - static const char I2C_ADDRESS[]; - - static const char MODE[]; - static const char CHANNEL_COUNT[]; - static const char USE_8BIT[]; - - static const char LED_PWM_FREQUENCY[]; - static const char LED_OUTPUT_INVERT[]; - static const char LED_OUTPUT_OPENDRAIN[]; - - static const char SERVO_LEFT_US[]; - static const char SERVO_CENTER_US[]; - static const char SERVO_RIGHT_US[]; + static inline const char FILE_NAME[]= "pca9685.txt"; + static inline const char I2C_ADDRESS[] = "i2c_address"; + static inline const char MODE[] = "mode"; + static inline const char CHANNEL_COUNT[] = "channel_count"; + static inline const char USE_8BIT[] = "use_8bit"; + static inline const char LED_PWM_FREQUENCY[] = "led_pwm_frequency"; + static inline const char LED_OUTPUT_INVERT[] = "led_output_invert"; + static inline const char LED_OUTPUT_OPENDRAIN[] = "led_output_opendrain"; + static inline const char SERVO_LEFT_US[] = "servo_left_us"; + static inline const char SERVO_CENTER_US[] = "servo_center_us"; + static inline const char SERVO_RIGHT_US[] = "servo_right_us"; }; #endif /* _PCA9685DMXPARAMSCONST_H_ */ diff --git a/lib-pca9685dmx/src/pca9685dmxparamsconst.cpp b/lib-pca9685dmx/src/pca9685dmxparamsconst.cpp deleted file mode 100755 index 8b83ba0be..000000000 --- a/lib-pca9685dmx/src/pca9685dmxparamsconst.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file pca9685dmxparamsconst.cpp - * - */ -/* Copyright (C) 2023-2024 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 "pca9685dmxparamsconst.h" - -const char PCA9685DmxParamsConst::FILE_NAME[]= "pca9685.txt"; - -const char PCA9685DmxParamsConst::I2C_ADDRESS[] = "i2c_address"; - -const char PCA9685DmxParamsConst::MODE[] = "mode"; -const char PCA9685DmxParamsConst::CHANNEL_COUNT[] = "channel_count"; -const char PCA9685DmxParamsConst::USE_8BIT[] = "use_8bit"; - -const char PCA9685DmxParamsConst::LED_PWM_FREQUENCY[] = "led_pwm_frequency"; -const char PCA9685DmxParamsConst::LED_OUTPUT_INVERT[] = "led_output_invert"; -const char PCA9685DmxParamsConst::LED_OUTPUT_OPENDRAIN[] = "led_output_opendrain"; - -const char PCA9685DmxParamsConst::SERVO_LEFT_US[] = "servo_left_us"; -const char PCA9685DmxParamsConst::SERVO_CENTER_US[] = "servo_center_us"; -const char PCA9685DmxParamsConst::SERVO_RIGHT_US[] = "servo_right_us"; diff --git a/lib-rdm/.cproject b/lib-rdm/.cproject index e5d209da9..6022f9c7d 100644 --- a/lib-rdm/.cproject +++ b/lib-rdm/.cproject @@ -13,14 +13,14 @@ - + - - - - - - + + + @@ -226,74 +227,171 @@ - - - - @@ -324,17 +422,23 @@ - + - + + + + + + + \ No newline at end of file diff --git a/lib-rdm/.settings/language.settings.xml b/lib-rdm/.settings/language.settings.xml index a545d16ee..bb7455857 100644 --- a/lib-rdm/.settings/language.settings.xml +++ b/lib-rdm/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,22 +17,22 @@ - + - + - - - - + + + + diff --git a/lib-rdm/include/rdmdeviceparamsconst.h b/lib-rdm/include/rdmdeviceparamsconst.h index ec94f6c4f..5b6c99a03 100644 --- a/lib-rdm/include/rdmdeviceparamsconst.h +++ b/lib-rdm/include/rdmdeviceparamsconst.h @@ -2,7 +2,7 @@ * @file rdmdeviceparamsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,11 +27,10 @@ #define RDMDEVICEPARAMSCONST_H_ struct RDMDeviceParamsConst { - static const char FILE_NAME[]; - - static const char LABEL[]; - static const char PRODUCT_CATEGORY[]; - static const char PRODUCT_DETAIL[]; + static inline const char FILE_NAME[] = "rdm_device.txt"; + static inline const char LABEL[] = "device_label"; + static inline const char PRODUCT_CATEGORY[] = "product_category"; + static inline const char PRODUCT_DETAIL[] = "product_detail"; }; #endif /* RDMDEVICEPARAMSCONST_H_ */ diff --git a/lib-rdm/src/rdmdeviceparamsconst.cpp b/lib-rdm/src/rdmdeviceparamsconst.cpp deleted file mode 100644 index 58bec4206..000000000 --- a/lib-rdm/src/rdmdeviceparamsconst.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file rdmdeviceparamsconst.cpp - * - */ -/* Copyright (C) 2019 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 "rdmdeviceparamsconst.h" - -const char RDMDeviceParamsConst::FILE_NAME[] = "rdm_device.txt"; - -const char RDMDeviceParamsConst::LABEL[] = "device_label"; -const char RDMDeviceParamsConst::PRODUCT_CATEGORY[] = "product_category"; -const char RDMDeviceParamsConst::PRODUCT_DETAIL[] = "product_detail"; diff --git a/lib-rdmsensor/include/rdmsensorsconst.h b/lib-rdmsensor/include/rdmsensorsconst.h index 436b6ebfd..c616b27f4 100755 --- a/lib-rdmsensor/include/rdmsensorsconst.h +++ b/lib-rdmsensor/include/rdmsensorsconst.h @@ -2,7 +2,7 @@ * @file rdmsensorsconst.h * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,7 +27,7 @@ #define RDMSENSORSCONST_H_ struct RDMSensorsConst { - static const char PARAMS_FILE_NAME[]; + static inline const char PARAMS_FILE_NAME[] = "sensors.txt"; }; #endif /* RDMSENSORSCONST_H_ */ diff --git a/lib-rdmsensor/src/rdmsensorsconst.cpp b/lib-rdmsensor/src/rdmsensorsconst.cpp deleted file mode 100644 index 34c2bdcf1..000000000 --- a/lib-rdmsensor/src/rdmsensorsconst.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file rdmsensorsconst.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. - */ - -#include - -#include "rdmsensorsconst.h" - -const char RDMSensorsConst::PARAMS_FILE_NAME[] = "sensors.txt"; diff --git a/lib-rdmsubdevice/include/rdmsubdevicesconst.h b/lib-rdmsubdevice/include/rdmsubdevicesconst.h index 3a234529a..615b20ebd 100755 --- a/lib-rdmsubdevice/include/rdmsubdevicesconst.h +++ b/lib-rdmsubdevice/include/rdmsubdevicesconst.h @@ -2,7 +2,7 @@ * @file rdmsubdevicesconst.h * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,7 +27,7 @@ #define RDMSUBDEVICESCONST_H_ struct RDMSubDevicesConst { - static const char PARAMS_FILE_NAME[]; + static inline const char PARAMS_FILE_NAME[] = "subdev.txt"; }; #endif /* RDMSUBDEVICESCONST_H_ */ diff --git a/lib-rdmsubdevice/src/rdmsubdevicesconst.cpp b/lib-rdmsubdevice/src/rdmsubdevicesconst.cpp deleted file mode 100644 index 0890ef36f..000000000 --- a/lib-rdmsubdevice/src/rdmsubdevicesconst.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file rdmsubdevicesconst.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. - */ - -#include - -#include "rdmsubdevicesconst.h" - -const char RDMSubDevicesConst::PARAMS_FILE_NAME[] = "subdev.txt"; - - - diff --git a/lib-remoteconfig/.cproject b/lib-remoteconfig/.cproject index 34d18e5c8..b5a7a9ddd 100644 --- a/lib-remoteconfig/.cproject +++ b/lib-remoteconfig/.cproject @@ -29,6 +29,7 @@ + @@ -327,7 +330,11 @@ - @@ -343,7 +350,11 @@ - diff --git a/lib-remoteconfig/.settings/language.settings.xml b/lib-remoteconfig/.settings/language.settings.xml index e19ac2d6c..bbe6d95f4 100644 --- a/lib-remoteconfig/.settings/language.settings.xml +++ b/lib-remoteconfig/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-remoteconfig/include/remoteconfigconst.h b/lib-remoteconfig/include/remoteconfigconst.h index 9a3da1d43..7557bde9d 100644 --- a/lib-remoteconfig/include/remoteconfigconst.h +++ b/lib-remoteconfig/include/remoteconfigconst.h @@ -2,7 +2,7 @@ * @file remoteconfigconst.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,16 +27,16 @@ #define REMOTECONFIGCONST_H_ struct RemoteConfigConst { - static const char PARAMS_FILE_NAME[]; + static inline const char PARAMS_FILE_NAME[] = "rconfig.txt"; - static const char PARAMS_DISABLE[]; + static inline const char PARAMS_DISABLE[] = "disable"; - static const char PARAMS_DISABLE_WRITE[]; - static const char PARAMS_ENABLE_REBOOT[]; - static const char PARAMS_ENABLE_UPTIME[]; - static const char PARAMS_ENABLE_FACTORY[]; + static inline const char PARAMS_DISABLE_WRITE[] = "disable_write"; + static inline const char PARAMS_ENABLE_REBOOT[] = "enable_reboot"; + static inline const char PARAMS_ENABLE_UPTIME[] = "enable_uptime"; + static inline const char PARAMS_ENABLE_FACTORY[] = "enable_factory"; - static const char PARAMS_DISPLAY_NAME[]; + static inline const char PARAMS_DISPLAY_NAME[] = "display_name"; }; #endif /* REMOTECONFIGCONST_H_ */ diff --git a/lib-remoteconfig/src/remoteconfigconst.cpp b/lib-remoteconfig/src/remoteconfigconst.cpp deleted file mode 100644 index 38d15e01f..000000000 --- a/lib-remoteconfig/src/remoteconfigconst.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file remoteconfigconst.cpp - * - */ -/* Copyright (C) 2019-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. - */ - -#include "remoteconfigconst.h" - -const char RemoteConfigConst::PARAMS_FILE_NAME[] = "rconfig.txt"; - -const char RemoteConfigConst::PARAMS_DISABLE[] = "disable"; - -const char RemoteConfigConst::PARAMS_DISABLE_WRITE[] = "disable_write"; -const char RemoteConfigConst::PARAMS_ENABLE_REBOOT[] = "enable_reboot"; -const char RemoteConfigConst::PARAMS_ENABLE_UPTIME[] = "enable_uptime"; -const char RemoteConfigConst::PARAMS_ENABLE_FACTORY[] = "enable_factory"; - -const char RemoteConfigConst::PARAMS_DISPLAY_NAME[] = "display_name"; - diff --git a/lib-rgbpanel/.cproject b/lib-rgbpanel/.cproject index 5dcd243d5..9aa8db97a 100644 --- a/lib-rgbpanel/.cproject +++ b/lib-rgbpanel/.cproject @@ -1,10 +1,11 @@ - - + + + @@ -13,65 +14,159 @@ - - - - diff --git a/lib-rgbpanel/.settings/language.settings.xml b/lib-rgbpanel/.settings/language.settings.xml index 580f1f38c..14b487345 100644 --- a/lib-rgbpanel/.settings/language.settings.xml +++ b/lib-rgbpanel/.settings/language.settings.xml @@ -1,14 +1,14 @@ - + - - - - + + + + diff --git a/lib-rgbpanel/include/rgbpanelconst.h b/lib-rgbpanel/include/rgbpanelconst.h index 9d3155479..d5193677e 100644 --- a/lib-rgbpanel/include/rgbpanelconst.h +++ b/lib-rgbpanel/include/rgbpanelconst.h @@ -2,7 +2,7 @@ * @file rgbpanelconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,10 +51,14 @@ static constexpr auto MAX_NAME_LENGTH = 7 + 1; // + '\0' } // namespace rgbpanel struct RgbPanelConst { - static const char TYPE[static_cast(rgbpanel::Types::UNDEFINED)][rgbpanel::type::MAX_NAME_LENGTH]; + static inline const char TYPE[static_cast(rgbpanel::Types::UNDEFINED)][rgbpanel::type::MAX_NAME_LENGTH] = { + "HUB75", + "FM6126A", + "FM6127" + }; - static const uint32_t COLS[rgbpanel::config::COLS]; - static const uint32_t ROWS[rgbpanel::config::ROWS]; + static constexpr uint32_t COLS[rgbpanel::config::COLS] = { 32, 64 }; + static constexpr uint32_t ROWS[rgbpanel::config::ROWS] = { 8, 16, 32, 64 }; }; #endif /* RGBPANELCONST_H_ */ diff --git a/lib-rgbpanel/include/rgbpanelparamsconst.h b/lib-rgbpanel/include/rgbpanelparamsconst.h index 0763347d2..5ec927919 100644 --- a/lib-rgbpanel/include/rgbpanelparamsconst.h +++ b/lib-rgbpanel/include/rgbpanelparamsconst.h @@ -2,7 +2,7 @@ * @file rgbpanelparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,12 +27,11 @@ #define RGBPANELPARAMSCONST_H_ struct RgbPanelParamsConst { - static const char FILE_NAME[]; - - static const char COLS[]; - static const char ROWS[]; - static const char CHAIN[]; - static const char TYPE[]; + static inline const char FILE_NAME[] = "rgbpanel.txt"; + static inline const char COLS[] = "cols"; + static inline const char ROWS[] = "rows"; + static inline const char CHAIN[] = "chain"; + static inline const char TYPE[] = "type"; }; #endif /* RGBPANELPARAMSCONST_H_ */ diff --git a/lib-rgbpanel/src/rgbpanelconst.cpp b/lib-rgbpanel/src/rgbpanelconst.cpp deleted file mode 100644 index 2ad371844..000000000 --- a/lib-rgbpanel/src/rgbpanelconst.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file rgbpanelconst.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. - */ - -#include "rgbpanelconst.h" - -using namespace rgbpanel; - -const char RgbPanelConst::TYPE[static_cast(Types::UNDEFINED)][type::MAX_NAME_LENGTH] = { - "HUB75", - "FM6126A", - "FM6127" -}; - -const uint32_t RgbPanelConst::COLS[rgbpanel::config::COLS] = { 32, 64 }; -const uint32_t RgbPanelConst::ROWS[rgbpanel::config::ROWS] = { 8, 16, 32, 64 }; diff --git a/lib-rgbpanel/src/rgbpanelparamsconst.cpp b/lib-rgbpanel/src/rgbpanelparamsconst.cpp deleted file mode 100644 index 8d51019f6..000000000 --- a/lib-rgbpanel/src/rgbpanelparamsconst.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file rgbpanelparamsconst.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. - */ - -#include "rgbpanelparamsconst.h" - -const char RgbPanelParamsConst::FILE_NAME[] = "rgbpanel.txt"; - -const char RgbPanelParamsConst::COLS[] = "cols"; -const char RgbPanelParamsConst::ROWS[] = "rows"; -const char RgbPanelParamsConst::CHAIN[] = "chain"; -const char RgbPanelParamsConst::TYPE[] = "type"; diff --git a/lib-showfile/.cproject b/lib-showfile/.cproject index b1d9dbdfe..71ee7fc10 100644 --- a/lib-showfile/.cproject +++ b/lib-showfile/.cproject @@ -1,8 +1,8 @@ - - + + @@ -13,18 +13,15 @@ - - - - - - + + + @@ -120,92 +124,198 @@ - - - - - - - - @@ -233,6 +343,12 @@ + + + + + + diff --git a/lib-showfile/.settings/language.settings.xml b/lib-showfile/.settings/language.settings.xml index 6e8253932..723344307 100644 --- a/lib-showfile/.settings/language.settings.xml +++ b/lib-showfile/.settings/language.settings.xml @@ -1,23 +1,23 @@ - + - - + + - + - - + + diff --git a/lib-showfile/include/showfileparamsconst.h b/lib-showfile/include/showfileparamsconst.h index f403b9d1a..2bf11b8bf 100644 --- a/lib-showfile/include/showfileparamsconst.h +++ b/lib-showfile/include/showfileparamsconst.h @@ -2,7 +2,7 @@ * @file showfileparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,18 +27,14 @@ #define SHOWFILEPARAMSCONST_H_ struct ShowFileParamsConst { - static const char FILE_NAME[]; - - static const char SHOW[]; - - static const char DMX_MASTER[]; - - static const char OPTION_AUTO_PLAY[]; - static const char OPTION_LOOP[]; - static const char OPTION_DISABLE_SYNC[]; - - static const char SACN_SYNC_UNIVERSE[]; - static const char ARTNET_DISABLE_UNICAST[]; + static inline const char FILE_NAME[] = "show.txt"; + static inline const char SHOW[] = "show"; + static inline const char DMX_MASTER[] = "dmx_master"; + static inline const char OPTION_AUTO_PLAY[] = "auto_play"; + static inline const char OPTION_LOOP[] = "loop"; + static inline const char OPTION_DISABLE_SYNC[] = "disable_sync"; + static inline const char SACN_SYNC_UNIVERSE[] = "sync_universe"; + static inline const char ARTNET_DISABLE_UNICAST[] = "disable_unicast"; }; #endif /* SHOWFILEPARAMSCONST_H_ */ diff --git a/lib-showfile/src/showfileparamsconst.cpp b/lib-showfile/src/showfileparamsconst.cpp deleted file mode 100644 index 00c17a470..000000000 --- a/lib-showfile/src/showfileparamsconst.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file showfileparamsconst.cpp - * - */ -/* Copyright (C) 2020-2024 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 "showfileparamsconst.h" - -const char ShowFileParamsConst::FILE_NAME[] = "show.txt"; - -const char ShowFileParamsConst::SHOW[] = "show"; - -const char ShowFileParamsConst::DMX_MASTER[] = "dmx_master"; - -const char ShowFileParamsConst::OPTION_AUTO_PLAY[] = "auto_play"; -const char ShowFileParamsConst::OPTION_LOOP[] = "loop"; -const char ShowFileParamsConst::OPTION_DISABLE_SYNC[] = "disable_sync"; - -const char ShowFileParamsConst::SACN_SYNC_UNIVERSE[] = "sync_universe"; -const char ShowFileParamsConst::ARTNET_DISABLE_UNICAST[] = "disable_unicast"; diff --git a/lib-tcnet/.cproject b/lib-tcnet/.cproject index 8b3644a1f..7c3d39093 100644 --- a/lib-tcnet/.cproject +++ b/lib-tcnet/.cproject @@ -1,11 +1,10 @@ - - + + - @@ -14,59 +13,67 @@ - - - - - - + + - + @@ -91,62 +98,164 @@ - - - - @@ -165,25 +274,31 @@ + + + + + + - + + + + - - - - - - + + + \ No newline at end of file diff --git a/lib-tcnet/.settings/language.settings.xml b/lib-tcnet/.settings/language.settings.xml index 37286bcda..ca44c5014 100644 --- a/lib-tcnet/.settings/language.settings.xml +++ b/lib-tcnet/.settings/language.settings.xml @@ -1,23 +1,23 @@ - + - + - + - - + + diff --git a/lib-tcnet/include/tcnetparamsconst.h b/lib-tcnet/include/tcnetparamsconst.h index 41e9bb06a..0bcc47ca5 100644 --- a/lib-tcnet/include/tcnetparamsconst.h +++ b/lib-tcnet/include/tcnetparamsconst.h @@ -2,7 +2,7 @@ * @file tcnetparamsconst.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,12 +27,11 @@ #define TCNETPARAMSCONST_H_ struct TCNetParamsConst { - static const char FILE_NAME[]; - - static const char NODE_NAME[]; - static const char LAYER[]; - static const char TIMECODE_TYPE[]; - static const char USE_TIMECODE[]; + static inline const char FILE_NAME[] = "tcnet.txt"; + static inline const char NODE_NAME[] = "node_name"; + static inline const char LAYER[] = "layer"; + static inline const char TIMECODE_TYPE[] = "timecode_type"; + static inline const char USE_TIMECODE[] = "use_timecode"; }; #endif /* TCNETPARAMSCONST_H_ */ diff --git a/lib-tcnet/src/tcnetparamsconst.cpp b/lib-tcnet/src/tcnetparamsconst.cpp deleted file mode 100755 index cdb2ccdb1..000000000 --- a/lib-tcnet/src/tcnetparamsconst.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file tcnetparamsconst.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 "tcnetparamsconst.h" - -const char TCNetParamsConst::FILE_NAME[] = "tcnet.txt"; - -const char TCNetParamsConst::NODE_NAME[] = "node_name"; -const char TCNetParamsConst::LAYER[] = "layer"; -const char TCNetParamsConst::TIMECODE_TYPE[] = "timecode_type"; -const char TCNetParamsConst::USE_TIMECODE[] = "use_timecode"; diff --git a/lib-tlc59711/.settings/language.settings.xml b/lib-tlc59711/.settings/language.settings.xml index 91faeb234..9f972a06b 100644 --- a/lib-tlc59711/.settings/language.settings.xml +++ b/lib-tlc59711/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-tlc59711dmx/.settings/language.settings.xml b/lib-tlc59711dmx/.settings/language.settings.xml index d98ba97b3..2d8d2c6c2 100644 --- a/lib-tlc59711dmx/.settings/language.settings.xml +++ b/lib-tlc59711dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-usb/.settings/language.settings.xml b/lib-usb/.settings/language.settings.xml index d909b0498..f8829e8ba 100644 --- a/lib-usb/.settings/language.settings.xml +++ b/lib-usb/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-widget/.settings/language.settings.xml b/lib-widget/.settings/language.settings.xml index d909b0498..f8829e8ba 100644 --- a/lib-widget/.settings/language.settings.xml +++ b/lib-widget/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-widget/include/widgetparamsconst.h b/lib-widget/include/widgetparamsconst.h index 928cf1cee..66b9ccec5 100644 --- a/lib-widget/include/widgetparamsconst.h +++ b/lib-widget/include/widgetparamsconst.h @@ -2,7 +2,7 @@ * @file widgetparamsconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,14 +27,12 @@ #define WIDGETPARAMSCONST_H_ struct WidgetParamsConst { - static const char FILE_NAME[]; - - static const char DMXUSBPRO_BREAK_TIME[]; - static const char DMXUSBPRO_MAB_TIME[]; - static const char DMXUSBPRO_REFRESH_RATE[]; - - static const char WIDGET_MODE[]; - static const char DMX_SEND_TO_HOST_THROTTLE[]; + static inline const char FILE_NAME[] = "params.txt"; + static inline const char DMXUSBPRO_BREAK_TIME[] = "dmxusbpro_break_time"; + static inline const char DMXUSBPRO_MAB_TIME[] = "dmxusbpro_mab_time"; + static inline const char DMXUSBPRO_REFRESH_RATE[] = "dmxusbpro_refresh_rate"; + static inline const char WIDGET_MODE[] = "widget_mode"; + static inline const char DMX_SEND_TO_HOST_THROTTLE[] = "dmx_send_to_host_throttle"; }; #endif /* WIDGETPARAMSCONST_H_ */ diff --git a/lib-widget/src/widgetparamsconst.cpp b/lib-widget/src/widgetparamsconst.cpp deleted file mode 100644 index 5a3235203..000000000 --- a/lib-widget/src/widgetparamsconst.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file dmxserialparamsconst.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. - */ - -#include "widgetparamsconst.h" - - const char WidgetParamsConst::FILE_NAME[] = "params.txt"; - - const char WidgetParamsConst::DMXUSBPRO_BREAK_TIME[] = "dmxusbpro_break_time"; - const char WidgetParamsConst::DMXUSBPRO_MAB_TIME[] = "dmxusbpro_mab_time"; - const char WidgetParamsConst::DMXUSBPRO_REFRESH_RATE[] = "dmxusbpro_refresh_rate"; - - const char WidgetParamsConst::WIDGET_MODE[] = "widget_mode"; - const char WidgetParamsConst::DMX_SEND_TO_HOST_THROTTLE[] = "dmx_send_to_host_throttle"; - From bab159a477c9e06e6a5fb16a8b662200d96e7cf8 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 14:57:19 +0200 Subject: [PATCH 02/36] Moved ARM related include files to directory /arm --- lib-ltc/include/{ => arm}/artnetreader.h | 27 +++- lib-ltc/include/{ => arm}/ltcetcreader.h | 27 +++- lib-ltc/include/{ => arm}/ltcgenerator.h | 27 +++- .../include/{ => arm}/ltcmidisystemrealtime.h | 52 +++++-- lib-ltc/include/{ => arm}/ltcoutputs.h | 0 lib-ltc/include/{ => arm}/ltcreader.h | 8 +- lib-ltc/include/{ => arm}/midireader.h | 8 +- lib-ltc/include/{ => arm}/platform_ltc.h | 8 +- lib-ltc/include/{ => arm}/rtpmidireader.h | 6 +- lib-ltc/include/{ => arm}/systimereader.h | 16 +- lib-ltc/include/{ => arm}/tcnetreader.h | 32 +++- lib-ltc/include/ltc.h | 2 +- lib-ltc/src/arm/artnetreader.cpp | 23 +-- lib-ltc/src/arm/ltcetcreader.cpp | 22 +-- lib-ltc/src/arm/ltcgenerator.cpp | 147 ++++++++---------- lib-ltc/src/arm/ltcmidisystemrealtime.cpp | 115 +++++++++++--- lib-ltc/src/arm/ltcoutputs.cpp | 4 +- lib-ltc/src/arm/ltcreader.cpp | 8 +- lib-ltc/src/arm/midireader.cpp | 23 +-- lib-ltc/src/arm/rtpmidireader.cpp | 9 +- lib-ltc/src/arm/systimereader.cpp | 65 ++++---- lib-ltc/src/arm/tcnetreader.cpp | 70 +++------ lib-ltc/src/displayrgb/ltcdisplayrgb.cpp | 2 +- lib-ltc/src/ltcmidisystemrealtime.cpp | 146 ----------------- 24 files changed, 392 insertions(+), 455 deletions(-) rename lib-ltc/include/{ => arm}/artnetreader.h (71%) rename lib-ltc/include/{ => arm}/ltcetcreader.h (71%) rename lib-ltc/include/{ => arm}/ltcgenerator.h (87%) rename lib-ltc/include/{ => arm}/ltcmidisystemrealtime.h (64%) rename lib-ltc/include/{ => arm}/ltcoutputs.h (100%) rename lib-ltc/include/{ => arm}/ltcreader.h (89%) rename lib-ltc/include/{ => arm}/midireader.h (93%) rename lib-ltc/include/{ => arm}/platform_ltc.h (94%) rename lib-ltc/include/{ => arm}/rtpmidireader.h (95%) rename lib-ltc/include/{ => arm}/systimereader.h (88%) rename lib-ltc/include/{ => arm}/tcnetreader.h (69%) delete mode 100755 lib-ltc/src/ltcmidisystemrealtime.cpp diff --git a/lib-ltc/include/artnetreader.h b/lib-ltc/include/arm/artnetreader.h similarity index 71% rename from lib-ltc/include/artnetreader.h rename to lib-ltc/include/arm/artnetreader.h index 532a5c00c..9480bd7f8 100755 --- a/lib-ltc/include/artnetreader.h +++ b/lib-ltc/include/arm/artnetreader.h @@ -23,24 +23,41 @@ * THE SOFTWARE. */ -#ifndef ARTNETREADER_H_ -#define ARTNETREADER_H_ +#ifndef ARM_ARTNETREADER_H_ +#define ARM_ARTNETREADER_H_ #include #include "artnettimecode.h" #include "midi.h" +#include "ltcoutputs.h" + +#include "hardware.h" + +#include "arm/platform_ltc.h" + class ArtNetReader final : public ArtNetTimeCode { public: void Start(); void Stop(); - void Run(); + + void Run() { + LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_MidiTimeCode)); + + __DMB(); + if (gv_ltc_nUpdatesPerSecond != 0) { + Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); + } else { + LtcOutputs::Get()->ShowSysTime(); + Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); + } + } void Handler(const struct artnet::TimeCode *) override; private: - struct midi::Timecode m_MidiTimeCode; + midi::Timecode m_MidiTimeCode; }; -#endif /* ARTNETREADER_H_ */ +#endif /* ARM_ARTNETREADER_H_ */ diff --git a/lib-ltc/include/ltcetcreader.h b/lib-ltc/include/arm/ltcetcreader.h similarity index 71% rename from lib-ltc/include/ltcetcreader.h rename to lib-ltc/include/arm/ltcetcreader.h index dcc7514b6..8870c6cbc 100755 --- a/lib-ltc/include/ltcetcreader.h +++ b/lib-ltc/include/arm/ltcetcreader.h @@ -23,17 +23,34 @@ * THE SOFTWARE. */ -#ifndef LTCETCREADER_H_ -#define LTCETCREADER_H_ +#ifndef ARM_LTCETCREADER_H_ +#define ARM_LTCETCREADER_H_ #include "ltcetc.h" -#include "ltc.h" +#include "midi.h" + +#include "ltcoutputs.h" + +#include "hardware.h" + +#include "arm/platform_ltc.h" class LtcEtcReader final : public LtcEtcHandler { public: void Start(); void Stop(); - void Run(); + + void Run() { + LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_MidiTimeCode)); + + __DMB(); + if (gv_ltc_nUpdatesPerSecond != 0) { + Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); + } else { + LtcOutputs::Get()->ShowSysTime(); + Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); + } + } void Handler(const midi::Timecode *pTimeCode) override; @@ -41,4 +58,4 @@ class LtcEtcReader final : public LtcEtcHandler { struct midi::Timecode m_MidiTimeCode; }; -#endif /* LTCETCREADER_H_ */ +#endif /* ARM_LTCETCREADER_H_ */ diff --git a/lib-ltc/include/ltcgenerator.h b/lib-ltc/include/arm/ltcgenerator.h similarity index 87% rename from lib-ltc/include/ltcgenerator.h rename to lib-ltc/include/arm/ltcgenerator.h index 65cdd51d6..31e82c898 100755 --- a/lib-ltc/include/ltcgenerator.h +++ b/lib-ltc/include/arm/ltcgenerator.h @@ -23,13 +23,15 @@ * THE SOFTWARE. */ -#ifndef H3_LTCGENERATOR_H_ -#define H3_LTCGENERATOR_H_ +#ifndef ARM_LTCGENERATOR_H_ +#define ARM_LTCGENERATOR_H_ #include #include "ltc.h" +#include "hardware.h" + enum TLtcGeneratorDirection { LTC_GENERATOR_FORWARD, LTC_GENERATOR_BACKWARD }; @@ -49,7 +51,18 @@ class LtcGenerator { void Start(); void Stop(); - void Run(); + void Run() { + Update(); + + HandleButtons(); + HandleUdpRequest(); + + if (m_State == STARTED) { + Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); + } else { + Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); + } + } void Print(); @@ -107,13 +120,13 @@ class LtcGenerator { TLtcGeneratorPitch m_tPitch { LTC_GENERATOR_FASTER }; uint32_t m_nButtons { 0 }; int m_nHandle { -1 }; - uint16_t m_nBytesReceived { 0 }; + uint32_t m_nBytesReceived { 0 }; enum { STOPPED, STARTED, LIMIT } m_State { STOPPED }; - static char *s_pUdpBuffer; - static LtcGenerator *s_pThis; + static inline char *s_pUdpBuffer; + static inline LtcGenerator *s_pThis; }; -#endif /* H3_LTCGENERATOR_H_ */ +#endif /* ARM_LTCGENERATOR_H_ */ diff --git a/lib-ltc/include/ltcmidisystemrealtime.h b/lib-ltc/include/arm/ltcmidisystemrealtime.h similarity index 64% rename from lib-ltc/include/ltcmidisystemrealtime.h rename to lib-ltc/include/arm/ltcmidisystemrealtime.h index afe2015f5..07a7b363a 100755 --- a/lib-ltc/include/ltcmidisystemrealtime.h +++ b/lib-ltc/include/arm/ltcmidisystemrealtime.h @@ -23,22 +23,39 @@ * THE SOFTWARE. */ -#ifndef LTCMIDISYSTEMREALTIME_H_ -#define LTCMIDISYSTEMREALTIME_H_ +#ifndef ARM_LTCMIDISYSTEMREALTIME_H_ +#define ARM_LTCMIDISYSTEMREALTIME_H_ + +#include #include "midi.h" +#include "rtpmidi.h" + +#include "arm/ltcoutputs.h" class LtcMidiSystemRealtime { public: - LtcMidiSystemRealtime(); + LtcMidiSystemRealtime() { + assert(s_pThis == nullptr); + s_pThis = this; + } void Start(); void Stop(); void Run(); - void SendStart(); - void SendStop(); - void SendContinue(); + + void SendStart() { + Send(midi::Types::START); + } + + void SendStop() { + Send(midi::Types::STOP); + } + + void SendContinue() { + Send(midi::Types::CONTINUE); + } void SetBPM(uint32_t nBPM); @@ -47,15 +64,26 @@ class LtcMidiSystemRealtime { } private: - void Send(midi::Types tType); - void ShowBPM(uint32_t nBPM); + void Send(const midi::Types type) { + if (!ltc::g_DisabledOutputs.bRtpMidi) { + RtpMidi::Get()->SendRaw(type); + } + + if (!ltc::g_DisabledOutputs.bMidi) { + Midi::Get()->SendRaw(type); + } + } + + void ShowBPM(const uint32_t nBPM) { + LtcOutputs::Get()->ShowBPM(nBPM); + } private: - int m_nHandle { -1 }; + int32_t m_nHandle { -1 }; uint32_t m_nBPMPrevious { 999 }; - static char *s_pUdpBuffer; - static LtcMidiSystemRealtime *s_pThis; + static inline char *s_pUdpBuffer; + static inline LtcMidiSystemRealtime *s_pThis; }; -#endif /* LTCMIDISYSTEMREALTIME_H_ */ +#endif /* ARM_LTCMIDISYSTEMREALTIME_H_ */ diff --git a/lib-ltc/include/ltcoutputs.h b/lib-ltc/include/arm/ltcoutputs.h similarity index 100% rename from lib-ltc/include/ltcoutputs.h rename to lib-ltc/include/arm/ltcoutputs.h diff --git a/lib-ltc/include/ltcreader.h b/lib-ltc/include/arm/ltcreader.h similarity index 89% rename from lib-ltc/include/ltcreader.h rename to lib-ltc/include/arm/ltcreader.h index fa8311b01..c740522c2 100755 --- a/lib-ltc/include/ltcreader.h +++ b/lib-ltc/include/arm/ltcreader.h @@ -2,7 +2,7 @@ * @file ltcreader.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,8 @@ * THE SOFTWARE. */ -#ifndef LTC_READER_H_ -#define LTC_READER_H_ +#ifndef ARM_LTCREADER_H_ +#define ARM_LTCREADER_H_ #include "ltc.h" @@ -37,4 +37,4 @@ class LtcReader { ltc::Type m_nTypePrevious { ltc::Type::INVALID }; }; -#endif /* LTC_READER_H_ */ +#endif /* ARM_LTCREADER_H_ */ diff --git a/lib-ltc/include/midireader.h b/lib-ltc/include/arm/midireader.h similarity index 93% rename from lib-ltc/include/midireader.h rename to lib-ltc/include/arm/midireader.h index 4972f0f6d..ecd7fd7b8 100755 --- a/lib-ltc/include/midireader.h +++ b/lib-ltc/include/arm/midireader.h @@ -23,8 +23,8 @@ * THE SOFTWARE. */ -#ifndef MIDIREADER_H_ -#define MIDIREADER_H_ +#ifndef ARM_MIDIREADER_H_ +#define ARM_MIDIREADER_H_ #include "ltc.h" @@ -42,7 +42,7 @@ class MidiReader { void Update(); private: - struct midi::Timecode m_MidiTimeCode; + midi::Timecode m_MidiTimeCode; midi::TimecodeType m_TimeCodeType { midi::TimecodeType::UNKNOWN }; uint8_t m_nPartPrevious { 0 }; bool m_bDirection { true }; @@ -51,4 +51,4 @@ class MidiReader { MidiBPM m_MidiBPM; }; -#endif /* MIDIREADER_H_ */ +#endif /* ARM_MIDIREADER_H_ */ diff --git a/lib-ltc/include/platform_ltc.h b/lib-ltc/include/arm/platform_ltc.h similarity index 94% rename from lib-ltc/include/platform_ltc.h rename to lib-ltc/include/arm/platform_ltc.h index 7fc41e86b..9d869199b 100755 --- a/lib-ltc/include/platform_ltc.h +++ b/lib-ltc/include/arm/platform_ltc.h @@ -23,11 +23,13 @@ * THE SOFTWARE. */ -#ifndef PLATFORM_LTC_H_ -#define PLATFORM_LTC_H_ +#ifndef ARM_PLATFORM_LTC_H_ +#define ARM_PLATFORM_LTC_H_ #include +#include "ltc.h" + extern volatile uint32_t gv_ltc_nUpdatesPerSecond; extern volatile uint32_t gv_ltc_nUpdatesPrevious; extern volatile uint32_t gv_ltc_nUpdates; @@ -45,4 +47,4 @@ extern struct ltc::TimeCode g_ltc_LtcTimeCode; # include "../src/arm/gd32/gd32_platform_ltc.h" #endif -#endif /* PLATFORM_LTC_H_ */ +#endif /* ARM_PLATFORM_LTC_H_ */ diff --git a/lib-ltc/include/rtpmidireader.h b/lib-ltc/include/arm/rtpmidireader.h similarity index 95% rename from lib-ltc/include/rtpmidireader.h rename to lib-ltc/include/arm/rtpmidireader.h index 83af328fe..c96158940 100755 --- a/lib-ltc/include/rtpmidireader.h +++ b/lib-ltc/include/arm/rtpmidireader.h @@ -23,8 +23,8 @@ * THE SOFTWARE. */ -#ifndef RTPMIDIREADER_H_ -#define RTPMIDIREADER_H_ +#ifndef ARM_RTPMIDIREADER_H_ +#define ARM_RTPMIDIREADER_H_ #include @@ -55,4 +55,4 @@ class RtpMidiReader final : public RtpMidiHandler { MidiBPM m_MidiBPM; }; -#endif /* RTPMIDIREADER_H_ */ +#endif /* ARM_RTPMIDIREADER_H_ */ diff --git a/lib-ltc/include/systimereader.h b/lib-ltc/include/arm/systimereader.h similarity index 88% rename from lib-ltc/include/systimereader.h rename to lib-ltc/include/arm/systimereader.h index dbfe1bc9f..462dd99fe 100755 --- a/lib-ltc/include/systimereader.h +++ b/lib-ltc/include/arm/systimereader.h @@ -23,8 +23,8 @@ * THE SOFTWARE. */ -#ifndef SYSTIMEREADER_H_ -#define SYSTIMEREADER_H_ +#ifndef ARM_SYSTIMEREADER_H_ +#define ARM_SYSTIMEREADER_H_ #include #include @@ -39,8 +39,6 @@ class SystimeReader { void Start(bool bAutoStart = false); void Run(); - void Print(); - void HandleRequest(char *pBuffer = nullptr, uint16_t nBufferLength = 0); void ActionStart(); @@ -57,13 +55,13 @@ class SystimeReader { private: uint8_t m_nFps; time_t m_nTimePrevious { 0 }; - struct midi::Timecode m_tMidiTimeCode; + midi::Timecode m_tMidiTimeCode; int32_t m_nHandle { -1 }; - uint16_t m_nBytesReceived { 0 }; + uint32_t m_nBytesReceived { 0 }; bool m_bIsStarted { false }; - static char *s_pUdpBuffer; - static SystimeReader *s_pThis; + static inline char *s_pUdpBuffer; + static inline SystimeReader *s_pThis; }; -#endif /* SYSTIMEREADER_H_ */ +#endif /* ARM_SYSTIMEREADER_H_ */ diff --git a/lib-ltc/include/tcnetreader.h b/lib-ltc/include/arm/tcnetreader.h similarity index 69% rename from lib-ltc/include/tcnetreader.h rename to lib-ltc/include/arm/tcnetreader.h index 145670537..71d179d28 100755 --- a/lib-ltc/include/tcnetreader.h +++ b/lib-ltc/include/arm/tcnetreader.h @@ -23,19 +23,37 @@ * THE SOFTWARE. */ -#ifndef TCNETREADER_H_ -#define TCNETREADER_H_ +#ifndef ARM_TCNETREADER_H_ +#define ARM_TCNETREADER_H_ #include "tcnettimecode.h" #include "midi.h" #include "ltc.h" +#include "ltcoutputs.h" + +#include "hardware.h" + class TCNetReader final : public TCNetTimeCode { public: void Start(); void Stop(); - void Run(); + + void Run() { + LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_tMidiTimeCode)); + + __DMB(); + if (gv_ltc_nUpdatesPerSecond != 0) { + Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); + } else { + LtcOutputs::Get()->ShowSysTime(); + Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); + m_nTimeCodePrevious = static_cast(~0); + } + + HandleUdpRequest(); + } void Handler(const struct TTCNetTimeCode *pTimeCode) override; @@ -43,11 +61,11 @@ class TCNetReader final : public TCNetTimeCode { void HandleUdpRequest(); private: - struct midi::Timecode m_tMidiTimeCode; + midi::Timecode m_tMidiTimeCode; uint32_t m_nTimeCodePrevious { 0xFF }; - int m_nHandle { -1 }; + int32_t m_nHandle { -1 }; - static char *s_pUdpBuffer; + static inline char *s_pUdpBuffer; }; -#endif /* TCNETREADER_H_ */ +#endif /* ARM_TCNETREADER_H_ */ diff --git a/lib-ltc/include/ltc.h b/lib-ltc/include/ltc.h index cf8e6036c..cff35f85f 100755 --- a/lib-ltc/include/ltc.h +++ b/lib-ltc/include/ltc.h @@ -115,7 +115,7 @@ bool parse_timecode_rate(const char *pTimeCodeRate, uint8_t &nFPS); } // namespace ltc -#include "platform_ltc.h" +#include "arm/platform_ltc.h" namespace ltc { extern struct DisabledOutputs g_DisabledOutputs; diff --git a/lib-ltc/src/arm/artnetreader.cpp b/lib-ltc/src/arm/artnetreader.cpp index 3e36e6e82..2c3612e9f 100755 --- a/lib-ltc/src/arm/artnetreader.cpp +++ b/lib-ltc/src/arm/artnetreader.cpp @@ -31,21 +31,18 @@ #include #include -#include "artnetreader.h" - +#include "arm/artnetreader.h" #include "ltc.h" -#include "timecodeconst.h" #include "hardware.h" - // Input #include "artnettimecode.h" // Output #include "rtpmidi.h" #include "ltcetc.h" #include "ltcsender.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #if defined (H3) static void arm_timer_handler() { @@ -59,7 +56,7 @@ static void arm_timer_handler() { void ArtNetReader::Start() { #if defined (H3) irq_timer_arm_physical_set(static_cast(arm_timer_handler)); - irq_timer_init(); + irq_handler_init(); #elif defined (GD32) #endif @@ -93,15 +90,3 @@ void ArtNetReader::Handler(const struct artnet::TimeCode *ArtNetTimeCode) { LtcOutputs::Get()->Update(reinterpret_cast(ArtNetTimeCode)); } - -void ArtNetReader::Run() { - LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_MidiTimeCode)); - - __DMB(); - if (gv_ltc_nUpdatesPerSecond != 0) { - Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); - } else { - LtcOutputs::Get()->ShowSysTime(); - Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - } -} diff --git a/lib-ltc/src/arm/ltcetcreader.cpp b/lib-ltc/src/arm/ltcetcreader.cpp index eb892434d..1ad8d705e 100755 --- a/lib-ltc/src/arm/ltcetcreader.cpp +++ b/lib-ltc/src/arm/ltcetcreader.cpp @@ -30,17 +30,17 @@ #include #include -#include "ltcetcreader.h" +#include "arm/ltcetcreader.h" +#include "ltc.h" #include "hardware.h" - // Output #include "artnetnode.h" #include "rtpmidi.h" #include "ltcsender.h" #include "tcnetdisplay.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #if defined (H3) static void arm_timer_handler() { @@ -54,7 +54,7 @@ static void arm_timer_handler() { void LtcEtcReader::Start() { #if defined (H3) irq_timer_arm_physical_set(static_cast(arm_timer_handler)); - irq_timer_init(); + irq_handler_init(); #elif defined (GD32) #endif @@ -88,15 +88,3 @@ void LtcEtcReader::Handler(const midi::Timecode *pTimeCode) { LtcOutputs::Get()->Update(reinterpret_cast(pTimeCode)); } - -void LtcEtcReader::Run() { - LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_MidiTimeCode)); - - __DMB(); - if (gv_ltc_nUpdatesPerSecond != 0) { - Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); - } else { - LtcOutputs::Get()->ShowSysTime(); - Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - } -} diff --git a/lib-ltc/src/arm/ltcgenerator.cpp b/lib-ltc/src/arm/ltcgenerator.cpp index 23aed0cbd..eff01ce7e 100755 --- a/lib-ltc/src/arm/ltcgenerator.cpp +++ b/lib-ltc/src/arm/ltcgenerator.cpp @@ -32,7 +32,7 @@ #include #include -#include "ltcgenerator.h" +#include "arm/ltcgenerator.h" #include "ltc.h" #include "timecodeconst.h" @@ -44,9 +44,9 @@ #include "rtpmidi.h" #include "ltcetc.h" #include "ltcsender.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #include "debug.h" @@ -59,11 +59,6 @@ # define BUTTON2_GPIO GPIO_EXT_7 // PA6 Resume # define BUTTONS_MASK ((1 << BUTTON0_GPIO) | (1 << BUTTON1_GPIO) | (1 << BUTTON2_GPIO)) - -# if defined (H3) -# else -# error -# endif #endif #if defined (H3) @@ -74,31 +69,31 @@ static void irq_timer0_handler([[maybe_unused]] uint32_t clo) { // Defined in platform_ltc.cpp #endif -namespace cmd { -static constexpr char START[] = "start"; -static constexpr char STOP[] = "stop"; -static constexpr char RESUME[] = "resume"; -static constexpr char RATE[] = "rate#"; -static constexpr char DIRECTION[] = "direction#"; -static constexpr char PITCH[] = "pitch#"; -static constexpr char FORWARD[] = "forward#"; -static constexpr char BACKWARD[] = "backward#"; -} +static constexpr char CMD_START[] = "start"; +static constexpr auto START_LENGTH = sizeof(CMD_START) - 1; -namespace length { -static constexpr auto START = sizeof(cmd::START) - 1; -static constexpr auto STOP = sizeof(cmd::STOP) - 1; -static constexpr auto RESUME = sizeof(cmd::RESUME) - 1; -static constexpr auto RATE = sizeof(cmd::RATE) - 1; -static constexpr auto DIRECTION = sizeof(cmd::DIRECTION) - 1; -static constexpr auto PITCH = sizeof(cmd::PITCH) - 1; -static constexpr auto FORWARD = sizeof(cmd::FORWARD) - 1; -static constexpr auto BACKWARD = sizeof(cmd::BACKWARD) - 1; -} +static constexpr char CMD_STOP[] = "stop"; +static constexpr auto STOP_LENGTH = sizeof(CMD_STOP) - 1; -namespace udp { -static constexpr auto PORT = 0x5443; -} +static constexpr char CMD_RESUME[] = "resume"; +static constexpr auto RESUME_LENGTH = sizeof(CMD_RESUME) - 1; + +static constexpr char CMD_RATE[] = "rate#"; +static constexpr auto RATE_LENGTH = sizeof(CMD_RATE) - 1; + +static constexpr char CMD_DIRECTION[] = "direction#"; +static constexpr auto DIRECTION_LENGTH = sizeof(CMD_DIRECTION) - 1; + +static constexpr char CMD_PITCH[] = "pitch#"; +static constexpr auto PITCH_LENGTH = sizeof(CMD_PITCH) - 1; + +static constexpr char CMD_FORWARD[] = "forward#"; +static constexpr auto FORWARD_LENGTH = sizeof(CMD_FORWARD) - 1; + +static constexpr char CMD_BACKWARD[] = "backward#"; +static constexpr auto BACKWARD_LENGTH = sizeof(CMD_BACKWARD) - 1; + +static constexpr auto UDP_PORT = 0x5443; static int32_t atoi(const char *pBuffer, uint32_t nSize) { assert(pBuffer != nullptr); @@ -124,9 +119,6 @@ static int32_t atoi(const char *pBuffer, uint32_t nSize) { return sign * res; } -char *LtcGenerator::s_pUdpBuffer; -LtcGenerator *LtcGenerator::s_pThis; - LtcGenerator::LtcGenerator(const struct ltc::TimeCode* pStartLtcTimeCode, const struct ltc::TimeCode* pStopLtcTimeCode, bool bSkipFree): m_pStartLtcTimeCode(const_cast(pStartLtcTimeCode)), m_pStopLtcTimeCode(const_cast(pStopLtcTimeCode)), @@ -179,14 +171,14 @@ void LtcGenerator::Start() { # endif #endif - m_nHandle = Network::Get()->Begin(udp::PORT); + m_nHandle = Network::Get()->Begin(UDP_PORT); assert(m_nHandle != -1); const auto nType = static_cast(ltc::g_Type); const auto nTimerInterval = TimeCodeConst::TMR_INTV[nType]; #if defined (H3) - irq_timer_init(); + irq_handler_init(); irq_timer_set(IRQ_TIMER_0, static_cast(irq_timer0_handler)); H3_TIMER->TMR0_INTV = nTimerInterval; @@ -233,7 +225,7 @@ void LtcGenerator::Stop() { #elif defined (GD32) #endif - m_nHandle = Network::Get()->End(udp::PORT); + m_nHandle = Network::Get()->End(UDP_PORT); DEBUG_EXIT } @@ -508,27 +500,27 @@ void LtcGenerator::HandleRequest(char *pBuffer, uint16_t nBufferLength) { debug_dump(s_pUdpBuffer, m_nBytesReceived); - if (memcmp(&s_pUdpBuffer[4], cmd::START, length::START) == 0) { - if (m_nBytesReceived == (4 + length::START)) { + if (memcmp(&s_pUdpBuffer[4], CMD_START, START_LENGTH) == 0) { + if (m_nBytesReceived == (4 + START_LENGTH)) { ActionStart(); return; } - if (m_nBytesReceived == (4 + length::START + 1 + ltc::timecode::CODE_MAX_LENGTH)) { - if (s_pUdpBuffer[4 + length::START] == '#') { - ActionSetStart(&s_pUdpBuffer[(4 + length::START + 1)]); + if (m_nBytesReceived == (4 + START_LENGTH + 1 + ltc::timecode::CODE_MAX_LENGTH)) { + if (s_pUdpBuffer[4 + START_LENGTH] == '#') { + ActionSetStart(&s_pUdpBuffer[(4 + START_LENGTH + 1)]); return; } - if (s_pUdpBuffer[4 + length::START] == '!') { - ActionSetStart(&s_pUdpBuffer[(4 + length::START + 1)]); + if (s_pUdpBuffer[4 + START_LENGTH] == '!') { + ActionSetStart(&s_pUdpBuffer[(4 + START_LENGTH + 1)]); ActionStop(); ActionStart(); return; } - if (s_pUdpBuffer[4 + length::START] == '@') { - ActionGoto(&s_pUdpBuffer[(4 + length::START + 1)]); + if (s_pUdpBuffer[4 + START_LENGTH] == '@') { + ActionGoto(&s_pUdpBuffer[(4 + START_LENGTH + 1)]); return; } } @@ -537,14 +529,14 @@ void LtcGenerator::HandleRequest(char *pBuffer, uint16_t nBufferLength) { return; } - if (memcmp(&s_pUdpBuffer[4], cmd::STOP, length::STOP) == 0) { - if (m_nBytesReceived == (4 + length::STOP)) { + if (memcmp(&s_pUdpBuffer[4], CMD_STOP, STOP_LENGTH) == 0) { + if (m_nBytesReceived == (4 + STOP_LENGTH)) { ActionStop(); return; } - if ((m_nBytesReceived == (4 + length::STOP + 1 + ltc::timecode::CODE_MAX_LENGTH)) && (s_pUdpBuffer[4 + length::STOP] == '#')) { - ActionSetStop(&s_pUdpBuffer[(4 + length::STOP + 1)]); + if ((m_nBytesReceived == (4 + STOP_LENGTH + 1 + ltc::timecode::CODE_MAX_LENGTH)) && (s_pUdpBuffer[4 + STOP_LENGTH] == '#')) { + ActionSetStop(&s_pUdpBuffer[(4 + STOP_LENGTH + 1)]); return; } @@ -552,42 +544,42 @@ void LtcGenerator::HandleRequest(char *pBuffer, uint16_t nBufferLength) { return; } - if (memcmp(&s_pUdpBuffer[4], cmd::RESUME, length::RESUME) == 0) { + if (memcmp(&s_pUdpBuffer[4], CMD_RESUME, RESUME_LENGTH) == 0) { ActionResume(); return; } - if (m_nBytesReceived == (4 + length::RATE + ltc::timecode::RATE_MAX_LENGTH)) { - if (memcmp(&s_pUdpBuffer[4], cmd::RATE, length::RATE) == 0) { - ActionSetRate(&s_pUdpBuffer[(4 + length::RATE)]); + if (m_nBytesReceived == (4 + RATE_LENGTH + ltc::timecode::RATE_MAX_LENGTH)) { + if (memcmp(&s_pUdpBuffer[4], CMD_RATE, RATE_LENGTH) == 0) { + ActionSetRate(&s_pUdpBuffer[(4 + RATE_LENGTH)]); return; } } - if (m_nBytesReceived <= (4 + length::DIRECTION + 8)) { - if (memcmp(&s_pUdpBuffer[4], cmd::DIRECTION, length::DIRECTION) == 0) { - ActionSetDirection(&s_pUdpBuffer[(4 + length::DIRECTION)]); + if (m_nBytesReceived <= (4 + DIRECTION_LENGTH + 8)) { + if (memcmp(&s_pUdpBuffer[4], CMD_DIRECTION, DIRECTION_LENGTH) == 0) { + ActionSetDirection(&s_pUdpBuffer[(4 + DIRECTION_LENGTH)]); return; } } - if (m_nBytesReceived <= (4 + length::PITCH + 4)) { - if (memcmp(&s_pUdpBuffer[4], cmd::PITCH, length::PITCH) == 0) { - SetPitch(&s_pUdpBuffer[(4 + length::PITCH)], m_nBytesReceived - (4 + length::PITCH)); + if (m_nBytesReceived <= (4 + PITCH_LENGTH + 4)) { + if (memcmp(&s_pUdpBuffer[4], CMD_PITCH, PITCH_LENGTH) == 0) { + SetPitch(&s_pUdpBuffer[(4 + PITCH_LENGTH)], m_nBytesReceived - (4 + PITCH_LENGTH)); return; } } - if (m_nBytesReceived <= (4 + length::FORWARD + 2)) { - if (memcmp(&s_pUdpBuffer[4], cmd::FORWARD, length::FORWARD) == 0) { - SetSkip(&s_pUdpBuffer[(4 + length::FORWARD)], m_nBytesReceived - (4 + length::FORWARD), LTC_GENERATOR_FORWARD); + if (m_nBytesReceived <= (4 + FORWARD_LENGTH + 2)) { + if (memcmp(&s_pUdpBuffer[4], CMD_FORWARD, FORWARD_LENGTH) == 0) { + SetSkip(&s_pUdpBuffer[(4 + FORWARD_LENGTH)], m_nBytesReceived - (4 + FORWARD_LENGTH), LTC_GENERATOR_FORWARD); return; } } - if (m_nBytesReceived <= (4 + length::BACKWARD + 2)) { - if (memcmp(&s_pUdpBuffer[4], cmd::BACKWARD, length::BACKWARD) == 0) { - SetSkip(&s_pUdpBuffer[(4 + length::BACKWARD)], m_nBytesReceived - (4 + length::BACKWARD), LTC_GENERATOR_BACKWARD); + if (m_nBytesReceived <= (4 + BACKWARD_LENGTH + 2)) { + if (memcmp(&s_pUdpBuffer[4], CMD_BACKWARD, BACKWARD_LENGTH) == 0) { + SetSkip(&s_pUdpBuffer[(4 + BACKWARD_LENGTH)], m_nBytesReceived - (4 + BACKWARD_LENGTH), LTC_GENERATOR_BACKWARD); return; } } @@ -641,7 +633,6 @@ void LtcGenerator::Print() { } void LtcGenerator::Increment() { - if (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStopLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0)) { if (m_State == STARTED) { m_State = LIMIT; @@ -677,7 +668,6 @@ void LtcGenerator::Increment() { } void LtcGenerator::Decrement() { - if (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStartLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0)) { if (m_State == STARTED) { m_State = LIMIT; @@ -733,10 +723,10 @@ bool LtcGenerator::PitchControl() { } void LtcGenerator::SetTimeCode(int32_t nSeconds) { - g_ltc_LtcTimeCode.nHours = static_cast(nSeconds / 3600U); - nSeconds -= g_ltc_LtcTimeCode.nHours * 3600U; - g_ltc_LtcTimeCode.nMinutes = static_cast(nSeconds / 60U); - nSeconds -= g_ltc_LtcTimeCode.nMinutes * 60U; + g_ltc_LtcTimeCode.nHours = static_cast(nSeconds / 3600); + nSeconds -= g_ltc_LtcTimeCode.nHours * 3600; + g_ltc_LtcTimeCode.nMinutes = static_cast(nSeconds / 60); + nSeconds -= g_ltc_LtcTimeCode.nMinutes * 60; g_ltc_LtcTimeCode.nSeconds = static_cast(nSeconds); } @@ -800,16 +790,3 @@ void LtcGenerator::Update() { } } } - -void LtcGenerator::Run() { - Update(); - - HandleButtons(); - HandleUdpRequest(); - - if (m_State == STARTED) { - Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); - } else { - Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - } -} diff --git a/lib-ltc/src/arm/ltcmidisystemrealtime.cpp b/lib-ltc/src/arm/ltcmidisystemrealtime.cpp index a8882ebac..56e74498c 100755 --- a/lib-ltc/src/arm/ltcmidisystemrealtime.cpp +++ b/lib-ltc/src/arm/ltcmidisystemrealtime.cpp @@ -28,16 +28,37 @@ #pragma GCC optimize ("no-tree-loop-distribute-patterns") #include +#include +#include #include -#include "ltcmidisystemrealtime.h" +#include "arm/ltcmidisystemrealtime.h" + +#include "ltc.h" #include "midi.h" -#include "rtpmidi.h" -#include "ltcoutputs.h" +#include "network.h" + +#include "debug.h" -#include "platform_ltc.h" +namespace cmd { +static constexpr char START[] = "start"; +static constexpr char STOP[] = "stop"; +static constexpr char CONTINUE[] = "continue"; +static constexpr char BPM[] = "bpm#"; +} + +namespace length { +static constexpr auto START = sizeof(cmd::START) - 1; +static constexpr auto STOP = sizeof(cmd::STOP) - 1; +static constexpr auto CONTINUE = sizeof(cmd::CONTINUE) - 1; +static constexpr auto BPM = sizeof(cmd::BPM) - 1; +} + +namespace udp { +static constexpr auto PORT = 0x4444; +} #if defined (H3) static void timer_handler() { @@ -52,22 +73,14 @@ static void timer_handler() { #elif defined (GD32) #endif -char *LtcMidiSystemRealtime::s_pUdpBuffer; -LtcMidiSystemRealtime *LtcMidiSystemRealtime::s_pThis; - -LtcMidiSystemRealtime::LtcMidiSystemRealtime() { - assert(s_pThis == nullptr); - s_pThis = this; +void LtcMidiSystemRealtime::Start() { + m_nHandle = Network::Get()->Begin(udp::PORT); + assert(m_nHandle != -1); } -void LtcMidiSystemRealtime::Send(midi::Types tType) { - if (!ltc::g_DisabledOutputs.bRtpMidi) { - RtpMidi::Get()->SendRaw(tType); - } - - if (!ltc::g_DisabledOutputs.bMidi) { - Midi::Get()->SendRaw(tType); - } +void LtcMidiSystemRealtime::Stop() { + m_nHandle = Network::Get()->End(udp::PORT); + assert(m_nHandle == -1); } void LtcMidiSystemRealtime::SetBPM(uint32_t nBPM) { @@ -91,6 +104,68 @@ void LtcMidiSystemRealtime::SetBPM(uint32_t nBPM) { } } -void LtcMidiSystemRealtime::ShowBPM(uint32_t nBPM) { - LtcOutputs::Get()->ShowBPM(nBPM); +void LtcMidiSystemRealtime::Run() { + uint32_t nIPAddressFrom; + uint16_t nForeignPort; + + auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &nIPAddressFrom, &nForeignPort); + + if (__builtin_expect((nBytesReceived < 9), 1)) { + return; + } + + if (__builtin_expect((memcmp("midi!", s_pUdpBuffer, 5) != 0), 0)) { + return; + } + + if (s_pUdpBuffer[nBytesReceived - 1] == '\n') { + nBytesReceived--; + } + + debug_dump(s_pUdpBuffer, nBytesReceived); + + if (nBytesReceived == (5 + length::START)) { + if (memcmp(&s_pUdpBuffer[5], cmd::START, length::START) == 0) { + SendStart(); + DEBUG_PUTS("Start"); + return; + } + } + + if (nBytesReceived == (5 + length::STOP)) { + if (memcmp(&s_pUdpBuffer[5], cmd::STOP, length::STOP) == 0) { + SendStop(); + DEBUG_PUTS("Stop"); + return; + } + } + + if (nBytesReceived == (5 + length::CONTINUE)) { + if (memcmp(&s_pUdpBuffer[5], cmd::CONTINUE, length::CONTINUE) == 0) { + SendContinue(); + DEBUG_PUTS("Continue"); + return; + } + } + + if (nBytesReceived == (5 + length::BPM + 3)) { + if (memcmp(&s_pUdpBuffer[5], cmd::BPM, length::BPM) == 0) { + uint32_t nOfffset = 5 + length::BPM; + uint32_t nBPM; + + if (isdigit(s_pUdpBuffer[nOfffset])) { + nBPM = 100U * static_cast(s_pUdpBuffer[nOfffset++] - '0'); + if (isdigit(s_pUdpBuffer[nOfffset])) { + nBPM += 10U * static_cast(s_pUdpBuffer[nOfffset++] - '0'); + if (isdigit(s_pUdpBuffer[nOfffset])) { + nBPM += static_cast(s_pUdpBuffer[nOfffset++] - '0'); + SetBPM(nBPM); + ShowBPM(nBPM); + DEBUG_PRINTF("BPM: %u", nBPM); + } + } + } + return; + } + } } diff --git a/lib-ltc/src/arm/ltcoutputs.cpp b/lib-ltc/src/arm/ltcoutputs.cpp index b6ed187de..b324a00a9 100755 --- a/lib-ltc/src/arm/ltcoutputs.cpp +++ b/lib-ltc/src/arm/ltcoutputs.cpp @@ -33,7 +33,7 @@ #include #include -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" #include "ltc.h" #include "timecodeconst.h" @@ -51,7 +51,7 @@ # define LTC_NO_DISPLAY_RGB #endif -#include "platform_ltc.h" +#include "arm/platform_ltc.h" static volatile bool sv_isMidiQuarterFrameMessage; diff --git a/lib-ltc/src/arm/ltcreader.cpp b/lib-ltc/src/arm/ltcreader.cpp index af3b4d980..ca4504999 100755 --- a/lib-ltc/src/arm/ltcreader.cpp +++ b/lib-ltc/src/arm/ltcreader.cpp @@ -34,7 +34,7 @@ #endif #include -#include "ltcreader.h" +#include "arm/ltcreader.h" #include "ltc.h" #include "timecodeconst.h" @@ -45,9 +45,9 @@ #include "rtpmidi.h" #include "midi.h" #include "ltcetc.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #if defined (H3) # if __GNUC__ > 8 @@ -205,7 +205,7 @@ void LtcReader::Start() { * IRQ Timer */ irq_timer_arm_physical_set(static_cast(arm_timer_handler)); - irq_timer_init(); + irq_handler_init(); /** * FIQ GPIO diff --git a/lib-ltc/src/arm/midireader.cpp b/lib-ltc/src/arm/midireader.cpp index 6eea664c6..b47eeb9d1 100755 --- a/lib-ltc/src/arm/midireader.cpp +++ b/lib-ltc/src/arm/midireader.cpp @@ -31,12 +31,11 @@ #include #include -#include "midireader.h" +#include "arm/midireader.h" #include "ltc.h" #include "timecodeconst.h" #include "hardware.h" - // Input #include "midi.h" // Output @@ -44,12 +43,10 @@ #include "artnetnode.h" #include "rtpmidi.h" #include "ltcetc.h" -#include "ltcmidisystemrealtime.h" -#include "ltcoutputs.h" - -#include "platform_ltc.h" +#include "arm/ltcmidisystemrealtime.h" +#include "arm/ltcoutputs.h" -using namespace midi; +#include "arm/platform_ltc.h" static uint8_t s_qf[8] __attribute__ ((aligned (4))) = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -63,6 +60,8 @@ static void irq_timer1_handler(void) { #endif void MidiReader::Start() { + DEBUG_ENTRY + #if defined (H3) Midi::Get()->SetIrqTimer1(irq_timer1_handler); #elif defined (GD32) @@ -70,6 +69,8 @@ void MidiReader::Start() { TIMER_CNT(TIMER11) = 0; #endif Midi::Get()->Init(midi::Direction::INPUT); + + DEBUG_EXIT } void MidiReader::HandleMtc() { @@ -160,13 +161,13 @@ void MidiReader::Update() { } void MidiReader::Run() { - if (Midi::Get()->Read(static_cast(Channel::OMNI))) { + if (Midi::Get()->Read(static_cast(midi::Channel::OMNI))) { if (Midi::Get()->GetChannel() == 0) { switch (Midi::Get()->GetMessageType()) { - case Types::TIME_CODE_QUARTER_FRAME: + case midi::Types::TIME_CODE_QUARTER_FRAME: HandleMtcQf(); break; - case Types::SYSTEM_EXCLUSIVE: { + case midi::Types::SYSTEM_EXCLUSIVE: { uint8_t nSystemExclusiveLength; const auto *pSystemExclusive = Midi::Get()->GetSystemExclusive(nSystemExclusiveLength); if ((pSystemExclusive[1] == 0x7F) && (pSystemExclusive[2] == 0x7F) && (pSystemExclusive[3] == 0x01)) { @@ -174,7 +175,7 @@ void MidiReader::Run() { } } break; - case Types::CLOCK: + case midi::Types::CLOCK: uint32_t nBPM; if (m_MidiBPM.Get(Midi::Get()->GetMessageTimeStamp() * 10, nBPM)) { LtcOutputs::Get()->ShowBPM(nBPM); diff --git a/lib-ltc/src/arm/rtpmidireader.cpp b/lib-ltc/src/arm/rtpmidireader.cpp index 8ed9ad9b9..d938e32d4 100755 --- a/lib-ltc/src/arm/rtpmidireader.cpp +++ b/lib-ltc/src/arm/rtpmidireader.cpp @@ -31,19 +31,18 @@ #include #include -#include "rtpmidireader.h" +#include "arm/rtpmidireader.h" #include "timecodeconst.h" #include "hardware.h" - // Output #include "artnetnode.h" #include "midi.h" #include "ltcetc.h" #include "ltcsender.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" static uint8_t s_qf[8] __attribute__ ((aligned (4))) = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -65,7 +64,7 @@ void RtpMidiReader::Start() { #if defined (H3) irq_timer_set(IRQ_TIMER_0, static_cast(irq_timer0_handler)); irq_timer_arm_physical_set(static_cast(arm_timer_handler)); - irq_timer_init(); + irq_handler_init(); #elif defined (GD32) platform::ltc::timer11_config(); TIMER_CNT(TIMER11) = 0; diff --git a/lib-ltc/src/arm/systimereader.cpp b/lib-ltc/src/arm/systimereader.cpp index c407e5ba4..d4af55207 100755 --- a/lib-ltc/src/arm/systimereader.cpp +++ b/lib-ltc/src/arm/systimereader.cpp @@ -31,41 +31,34 @@ #include #include -#include "systimereader.h" - +#include "arm/systimereader.h" #include "ltc.h" #include "timecodeconst.h" #include "hardware.h" #include "network.h" - // Output #include "artnetnode.h" #include "rtpmidi.h" #include "ltcetc.h" #include "ltcsender.h" #include "display.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #include "debug.h" -namespace cmd { -static constexpr char START[] = "start"; -static constexpr char STOP[] = "stop"; -static constexpr char RATE[] = "rate#"; -} +static constexpr char CMD_START[] = "start"; +static constexpr auto START_LENGTH = sizeof(CMD_START) - 1; -namespace length { -static constexpr auto START = sizeof(cmd::START) - 1; -static constexpr auto STOP = sizeof(cmd::STOP) - 1; -static constexpr auto RATE = sizeof(cmd::RATE) - 1; -} +static constexpr char CMD_STOP[] = "stop"; +static constexpr auto STOP_LENGTH = sizeof(CMD_STOP) - 1; -namespace udp { -static constexpr auto PORT = 0x5443; -} +static constexpr char CMD_RATE[] = "rate#"; +static constexpr auto RATE_LENGTH = sizeof(CMD_RATE) - 1; + +static constexpr uint16_t UDP_PORT = 0x5443; #if defined (H3) static void irq_timer0_handler([[maybe_unused]] uint32_t clo) { @@ -75,9 +68,6 @@ static void irq_timer0_handler([[maybe_unused]] uint32_t clo) { // Defined in platform_ltc.cpp #endif -char *SystimeReader::s_pUdpBuffer; -SystimeReader *SystimeReader::s_pThis; - SystimeReader::SystimeReader(uint8_t nFps) : m_nFps(nFps) { assert(s_pThis == nullptr); s_pThis = this; @@ -85,18 +75,20 @@ SystimeReader::SystimeReader(uint8_t nFps) : m_nFps(nFps) { } void SystimeReader::Start(bool bAutoStart) { - m_nHandle = Network::Get()->Begin(udp::PORT); + m_nHandle = Network::Get()->Begin(UDP_PORT); assert(m_nHandle != -1); const auto nTimerInterval = TimeCodeConst::TMR_INTV[static_cast(ltc::g_Type)]; #if defined (H3) // System Time -> Frames - irq_timer_init(); irq_timer_set(IRQ_TIMER_0, static_cast(irq_timer0_handler)); H3_TIMER->TMR0_INTV = nTimerInterval; H3_TIMER->TMR0_CTRL &= ~(TIMER_CTRL_SINGLE_MODE); + + __enable_irq(); + __DMB(); #elif defined (GD32) platform::ltc::timer11_config(); TIMER_CAR(TIMER11) = nTimerInterval; @@ -113,9 +105,6 @@ void SystimeReader::Start(bool bAutoStart) { } } -void SystimeReader::Print() { -} - void SystimeReader::ActionStart() { DEBUG_ENTRY @@ -212,8 +201,8 @@ void SystimeReader::HandleRequest(char *pBuffer, uint16_t nBufferLength) { debug_dump(s_pUdpBuffer, m_nBytesReceived); - if (m_nBytesReceived == (4 + length::START)) { - if (memcmp(&s_pUdpBuffer[4], cmd::START, length::START) == 0) { + if (m_nBytesReceived == (4 + START_LENGTH)) { + if (memcmp(&s_pUdpBuffer[4], CMD_START, START_LENGTH) == 0) { ActionStart(); return; } @@ -221,8 +210,8 @@ void SystimeReader::HandleRequest(char *pBuffer, uint16_t nBufferLength) { DEBUG_PUTS("Invalid !start command"); } - if (m_nBytesReceived == (4 + length::STOP)) { - if (memcmp(&s_pUdpBuffer[4], cmd::STOP, length::STOP) == 0) { + if (m_nBytesReceived == (4 + STOP_LENGTH)) { + if (memcmp(&s_pUdpBuffer[4], CMD_STOP, STOP_LENGTH) == 0) { ActionStop(); return; } @@ -230,9 +219,9 @@ void SystimeReader::HandleRequest(char *pBuffer, uint16_t nBufferLength) { DEBUG_PUTS("Invalid !stop command"); } - if (m_nBytesReceived == (4 + length::RATE + ltc::timecode::RATE_MAX_LENGTH)) { - if (memcmp(&s_pUdpBuffer[4], cmd::RATE, length::RATE) == 0) { - ActionSetRate(&s_pUdpBuffer[(4 + length::RATE)]); + if (m_nBytesReceived == (4 + RATE_LENGTH + ltc::timecode::RATE_MAX_LENGTH)) { + if (memcmp(&s_pUdpBuffer[4], CMD_RATE, RATE_LENGTH) == 0) { + ActionSetRate(&s_pUdpBuffer[(4 + RATE_LENGTH)]); return; } } @@ -263,11 +252,11 @@ void SystimeReader::Run() { m_nTimePrevious = nTime; m_tMidiTimeCode.nFrames = 0; - m_tMidiTimeCode.nSeconds = static_cast(nTime % 60); - nTime /= 60; - m_tMidiTimeCode.nMinutes = static_cast(nTime % 60); - nTime /= 60; - m_tMidiTimeCode.nHours = static_cast(nTime % 24); + m_tMidiTimeCode.nSeconds = static_cast(nTime % 60U); + nTime /= 60U; + m_tMidiTimeCode.nMinutes = static_cast(nTime % 60U); + nTime /= 60U; + m_tMidiTimeCode.nHours = static_cast(nTime % 24U); #if defined (H3) H3_TIMER->TMR0_CTRL |= (TIMER_CTRL_EN_START | TIMER_CTRL_RELOAD); diff --git a/lib-ltc/src/arm/tcnetreader.cpp b/lib-ltc/src/arm/tcnetreader.cpp index e672debac..fbe7a9465 100755 --- a/lib-ltc/src/arm/tcnetreader.cpp +++ b/lib-ltc/src/arm/tcnetreader.cpp @@ -31,12 +31,10 @@ #include #include -#include "tcnetreader.h" - -#include "timecodeconst.h" +#include "arm/tcnetreader.h" +#include "ltc.h" #include "network.h" #include "hardware.h" - // Input #include "tcnet.h" // Output @@ -45,27 +43,22 @@ #include "ltcetc.h" #include "ltcsender.h" #include "tcnetdisplay.h" -#include "ltcoutputs.h" +#include "arm/ltcoutputs.h" -#include "platform_ltc.h" +#include "arm/platform_ltc.h" #include "debug.h" -namespace cmd { -static constexpr char LAYER[] = "layer#"; -static constexpr char TYPE[] = "type#"; -static constexpr char TIMECODE[] = "timecode#"; -} +static constexpr char CMD_LAYER[] = "layer#"; +static constexpr auto LAYER_LENGTH = sizeof(CMD_LAYER) - 1U; -namespace length { -static constexpr auto LAYER = sizeof(cmd::LAYER) - 1; -static constexpr auto TYPE = sizeof(cmd::TYPE) - 1; -static constexpr auto TIMECODE = sizeof(cmd::TIMECODE) - 1; -} +static constexpr char CMD_TYPE[] = "type#"; +static constexpr auto TYPE_LENGTH = sizeof(CMD_TYPE) - 1U; -namespace udp { -static constexpr auto PORT = 0x0ACA; -} +static constexpr char CMD_TIMECODE[] = "timecode#"; +static constexpr auto TIMECODE_LENGTH = sizeof(CMD_TIMECODE) - 1U; + +static constexpr auto UDP_PORT = 0x0ACA; #if defined (H3) static void arm_timer_handler() { @@ -76,12 +69,10 @@ static void arm_timer_handler() { // Defined in platform_ltc.cpp #endif -char *TCNetReader::s_pUdpBuffer; - void TCNetReader::Start() { #if defined (H3) irq_timer_arm_physical_set(static_cast(arm_timer_handler)); - irq_timer_init(); + irq_handler_init(); #elif defined (GD32) #endif @@ -89,7 +80,7 @@ void TCNetReader::Start() { Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - m_nHandle = Network::Get()->Begin(udp::PORT); + m_nHandle = Network::Get()->Begin(UDP_PORT); assert(m_nHandle != -1); } @@ -158,20 +149,20 @@ void TCNetReader::HandleUdpRequest() { debug_dump(s_pUdpBuffer, nBytesReceived); - if ((nBytesReceived == (6 + length::LAYER + 1)) && (memcmp(&s_pUdpBuffer[6], cmd::LAYER, length::LAYER) == 0)) { - const auto tLayer = TCNet::GetLayer(s_pUdpBuffer[6 + length::LAYER]); + if ((nBytesReceived == (6 + LAYER_LENGTH + 1)) && (memcmp(&s_pUdpBuffer[6], CMD_LAYER, LAYER_LENGTH) == 0)) { + const auto tLayer = TCNet::GetLayer(s_pUdpBuffer[6 + LAYER_LENGTH]); TCNet::Get()->SetLayer(tLayer); tcnet::display::show(); - DEBUG_PRINTF("tcnet!layer#%c -> %d", s_pUdpBuffer[6 + length::LAYER + 1], tLayer); + DEBUG_PRINTF("tcnet!layer#%c -> %d", s_pUdpBuffer[6 + LAYER_LENGTH + 1], tLayer); return; } - if ((nBytesReceived == (6 + length::TYPE + 2)) && (memcmp(&s_pUdpBuffer[6], cmd::TYPE, length::TYPE) == 0)) { - if (s_pUdpBuffer[6 + length::TYPE] == '2') { + if ((nBytesReceived == (6 + TYPE_LENGTH + 2)) && (memcmp(&s_pUdpBuffer[6], CMD_TYPE, TYPE_LENGTH) == 0)) { + if (s_pUdpBuffer[6 + TYPE_LENGTH] == '2') { - const auto nValue = 20U + s_pUdpBuffer[6 + length::TYPE + 1] - '0'; + const auto nValue = 20U + s_pUdpBuffer[6 + TYPE_LENGTH + 1] - '0'; switch (nValue) { case 24: @@ -193,7 +184,7 @@ void TCNetReader::HandleUdpRequest() { return; } - if ((s_pUdpBuffer[6 + length::TYPE] == '3') && (s_pUdpBuffer[6 + length::TYPE + 1] == '0')) { + if ((s_pUdpBuffer[6 + TYPE_LENGTH] == '3') && (s_pUdpBuffer[6 + TYPE_LENGTH + 1] == '0')) { TCNet::Get()->SetTimeCodeType(TCNET_TIMECODE_TYPE_SMPTE_30FPS); tcnet::display::show(); @@ -205,8 +196,8 @@ void TCNetReader::HandleUdpRequest() { return; } - if ((nBytesReceived == (6 + length::TIMECODE + 1)) && (memcmp(&s_pUdpBuffer[6], cmd::TIMECODE, length::TIMECODE) == 0)) { - const auto nChar = s_pUdpBuffer[6 + length::TIMECODE]; + if ((nBytesReceived == (6 + TIMECODE_LENGTH + 1)) && (memcmp(&s_pUdpBuffer[6], CMD_TIMECODE, TIMECODE_LENGTH) == 0)) { + const auto nChar = s_pUdpBuffer[6 + TIMECODE_LENGTH]; const auto bUseTimeCode = ((nChar == 'y') || (nChar == 'Y')); TCNet::Get()->SetUseTimeCode(bUseTimeCode); @@ -218,18 +209,3 @@ void TCNetReader::HandleUdpRequest() { DEBUG_PUTS("Invalid command"); } - -void TCNetReader::Run() { - LtcOutputs::Get()->UpdateMidiQuarterFrameMessage(reinterpret_cast(&m_tMidiTimeCode)); - - __DMB(); - if (gv_ltc_nUpdatesPerSecond != 0) { - Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA); - } else { - LtcOutputs::Get()->ShowSysTime(); - Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - m_nTimeCodePrevious = static_cast(~0); - } - - HandleUdpRequest(); -} diff --git a/lib-ltc/src/displayrgb/ltcdisplayrgb.cpp b/lib-ltc/src/displayrgb/ltcdisplayrgb.cpp index 6f52c0c48..91e57e535 100755 --- a/lib-ltc/src/displayrgb/ltcdisplayrgb.cpp +++ b/lib-ltc/src/displayrgb/ltcdisplayrgb.cpp @@ -333,7 +333,7 @@ void LtcDisplayRgb::Run() { if (memcmp(&s_pUdpBuffer[5], showmsg::PATH, showmsg::LENGTH) == 0) { const uint32_t nMsgLength = nBytesReceived - (5 + showmsg::LENGTH + 1); - DEBUG_PRINTF("m_nBytesReceived=%d, nMsgLength=%d [%.*s]", nBytesReceived, nMsgLength, nMsgLength, &m_Buffer[(5 + showmsg::LENGTH + 1)]); + DEBUG_PRINTF("m_nBytesReceived=%d, nMsgLength=%d [%.*s]", nBytesReceived, nMsgLength, nMsgLength, &s_pUdpBuffer[(5 + showmsg::LENGTH + 1)]); if (((nMsgLength > 0) && (nMsgLength <= MAX_MESSAGE_SIZE)) && (s_pUdpBuffer[5 + showmsg::LENGTH] == '#')) { SetMessage(&s_pUdpBuffer[(5 + showmsg::LENGTH + 1)], nMsgLength); diff --git a/lib-ltc/src/ltcmidisystemrealtime.cpp b/lib-ltc/src/ltcmidisystemrealtime.cpp deleted file mode 100755 index 4096a4e15..000000000 --- a/lib-ltc/src/ltcmidisystemrealtime.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file ltcmidisystemrealtime.cpp - * - */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 -#include -#include - -#include "ltcmidisystemrealtime.h" - -#include "ltc.h" - -#include "midi.h" -#include "rtpmidi.h" - -#include "network.h" - -#include "debug.h" - -namespace cmd { -static constexpr char START[] = "start"; -static constexpr char STOP[] = "stop"; -static constexpr char CONTINUE[] = "continue"; -static constexpr char BPM[] = "bpm#"; -} - -namespace length { -static constexpr auto START = sizeof(cmd::START) - 1; -static constexpr auto STOP = sizeof(cmd::STOP) - 1; -static constexpr auto CONTINUE = sizeof(cmd::CONTINUE) - 1; -static constexpr auto BPM = sizeof(cmd::BPM) - 1; -} - -namespace udp { -static constexpr auto PORT = 0x4444; -} - -void LtcMidiSystemRealtime::SendStart() { - Send(midi::Types::START); -} - -void LtcMidiSystemRealtime::SendStop() { - Send(midi::Types::STOP); -} - -void LtcMidiSystemRealtime::SendContinue() { - Send(midi::Types::CONTINUE); -} - -void LtcMidiSystemRealtime::Start() { - m_nHandle = Network::Get()->Begin(udp::PORT); - assert(m_nHandle != -1); -} - -void LtcMidiSystemRealtime::Stop() { - m_nHandle = Network::Get()->End(udp::PORT); - assert(m_nHandle == -1); -} - -void LtcMidiSystemRealtime::Run() { - uint32_t nIPAddressFrom; - uint16_t nForeignPort; - - auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &nIPAddressFrom, &nForeignPort); - - if (__builtin_expect((nBytesReceived < 9), 1)) { - return; - } - - if (__builtin_expect((memcmp("midi!", s_pUdpBuffer, 5) != 0), 0)) { - return; - } - - if (s_pUdpBuffer[nBytesReceived - 1] == '\n') { - nBytesReceived--; - } - - debug_dump(s_pUdpBuffer, nBytesReceived); - - if (nBytesReceived == (5 + length::START)) { - if (memcmp(&s_pUdpBuffer[5], cmd::START, length::START) == 0) { - SendStart(); - DEBUG_PUTS("Start"); - return; - } - } - - if (nBytesReceived == (5 + length::STOP)) { - if (memcmp(&s_pUdpBuffer[5], cmd::STOP, length::STOP) == 0) { - SendStop(); - DEBUG_PUTS("Stop"); - return; - } - } - - if (nBytesReceived == (5 + length::CONTINUE)) { - if (memcmp(&s_pUdpBuffer[5], cmd::CONTINUE, length::CONTINUE) == 0) { - SendContinue(); - DEBUG_PUTS("Continue"); - return; - } - } - - if (nBytesReceived == (5 + length::BPM + 3)) { - if (memcmp(&s_pUdpBuffer[5], cmd::BPM, length::BPM) == 0) { - uint32_t nOfffset = 5 + length::BPM; - uint32_t nBPM; - - if (isdigit(s_pUdpBuffer[nOfffset])) { - nBPM = 100U * static_cast(s_pUdpBuffer[nOfffset++] - '0'); - if (isdigit(s_pUdpBuffer[nOfffset])) { - nBPM += 10U * static_cast(s_pUdpBuffer[nOfffset++] - '0'); - if (isdigit(s_pUdpBuffer[nOfffset])) { - nBPM += static_cast(s_pUdpBuffer[nOfffset++] - '0'); - SetBPM(nBPM); - ShowBPM(nBPM); - DEBUG_PRINTF("BPM: %u", nBPM); - } - } - } - return; - } - } -} From 5aeda7f041a2dcb0fa6a44b004dd5fb87c35774f Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 14:58:13 +0200 Subject: [PATCH 03/36] Converted malloc.c to malloc.cpp --- lib-clib/.cproject | 258 +++++++++++++---------- lib-clib/.settings/language.settings.xml | 10 +- lib-clib/src/{malloc.c => malloc.cpp} | 188 +++++++++-------- 3 files changed, 249 insertions(+), 207 deletions(-) rename lib-clib/src/{malloc.c => malloc.cpp} (52%) diff --git a/lib-clib/.cproject b/lib-clib/.cproject index 81b51ffe9..01b0a82b1 100755 --- a/lib-clib/.cproject +++ b/lib-clib/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,126 +14,155 @@ - - - - @@ -143,15 +172,22 @@ + + + + + + + + + - - \ No newline at end of file diff --git a/lib-clib/.settings/language.settings.xml b/lib-clib/.settings/language.settings.xml index 011bec42a..fc14cbd1f 100755 --- a/lib-clib/.settings/language.settings.xml +++ b/lib-clib/.settings/language.settings.xml @@ -1,14 +1,14 @@ - + - - - - + + + + diff --git a/lib-clib/src/malloc.c b/lib-clib/src/malloc.cpp similarity index 52% rename from lib-clib/src/malloc.c rename to lib-clib/src/malloc.cpp index 58676778a..f5dd321ef 100755 --- a/lib-clib/src/malloc.c +++ b/lib-clib/src/malloc.cpp @@ -1,14 +1,14 @@ /** - * @file malloc.c + * @file malloc.cpp * */ /* This code is inspired by: * * Circle - A C++ bare metal environment for Raspberry Pi * Copyright (C) 2014-2016 R. Stange - * https://github.com/rsta2/circle/blob/master/lib/alloc.cpp + * https://github.com/rsta2/circle */ -/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,33 +30,27 @@ */ #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpointer-arith" // FIXME ignored "-Wpointer-arith" -#pragma GCC diagnostic ignored "-Wpedantic" // FIXME ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#include -#include -#include - #ifdef DEBUG_HEAP -#include +# undef NDEBUG #endif -extern void console_error(const char *); - -extern unsigned char heap_low; /* Defined by the linker */ -extern unsigned char heap_top; /* Defined by the linker */ - -#define BLOCK_MAGIC 0x424C4D43 +#include +#include +#ifdef DEBUG_HEAP +# include +#endif +#include -static unsigned char *next_block = &heap_low; -static unsigned char *block_limit = &heap_top; +extern "C" void console_error(const char *); +void debug_heap(); struct block_header { unsigned int magic; unsigned int size ; struct block_header *next; - unsigned char data[0]; + unsigned char data; } PACKED; struct block_bucket { @@ -68,6 +62,14 @@ struct block_bucket { struct block_header *free_list; }; +extern unsigned char heap_low; /* Defined by the linker */ +extern unsigned char heap_top; /* Defined by the linker */ + +static unsigned char *next_block = &heap_low; +static unsigned char *block_limit = &heap_top; + +static constexpr unsigned int BLOCK_MAGIC = 0x424C4D43; + #if defined (H3) # include "h3/malloc.h" #elif defined (GD32) @@ -77,13 +79,14 @@ struct block_bucket { #endif size_t get_allocated(void *p) { - if (p == 0) { + if (p == nullptr) { return 0; } - struct block_header *pBlockHeader = (struct block_header *) ((void *) p - sizeof(struct block_header)); + auto *pBlockHeader = reinterpret_cast(reinterpret_cast(p) - offsetof(block_header, data)); assert(pBlockHeader->magic == BLOCK_MAGIC); + if (pBlockHeader->magic != BLOCK_MAGIC) { return 0; } @@ -91,12 +94,12 @@ size_t get_allocated(void *p) { return pBlockHeader->size; } +extern "C" { void *malloc(size_t size) { struct block_bucket *bucket; - struct block_header *header; if (size == 0) { - return NULL; + return nullptr; } for (bucket = s_block_bucket; bucket->size > 0; bucket++) { @@ -111,51 +114,56 @@ void *malloc(size_t size) { } } + struct block_header *header; + if (bucket->size > 0 && (header = bucket->free_list) != 0) { assert(header->magic == BLOCK_MAGIC); bucket->free_list = header->next; } else { - header = (struct block_header *) next_block; + header = reinterpret_cast(next_block); - const size_t t1 = sizeof(struct block_header) + size; - const size_t t2 = (t1 + (size_t) 15) & ~(size_t) 15; + const auto t1 = sizeof(struct block_header) + size; + const auto t2 = (t1 + 15) & static_cast(~15); - unsigned char *next = next_block + t2; + auto *next = next_block + t2; - assert(((unsigned)header & (unsigned)3) == 0); - assert(((unsigned)next & (unsigned)3) == 0); + assert((reinterpret_cast(header) & 3U) == 0); + assert((reinterpret_cast(next) & 3U) == 0); if (next > block_limit) { - console_error("next > block_limit\n"); - return NULL; - } else { - next_block = next; + console_error("malloc: out of memory\n"); +#ifdef DEBUG_HEAP + debug_heap(); +#endif + return nullptr; } + next_block = next; + header->magic = BLOCK_MAGIC; - header->size = (unsigned) size; + header->size = size; } - header->next = 0; + header->next = nullptr; #ifdef DEBUG_HEAP - printf("malloc: pBlockHeader = %p, size = %d\n", header, (int) size); + printf("malloc(%u): pBlockHeader=%p, size=%u, data=%p\n", size, header, header->size, reinterpret_cast(&header->data)); #endif - assert(((unsigned)header->data & (unsigned)3) == 0); - return (void *)header->data; + assert((reinterpret_cast(&header->data) & 3U) == 0); + return reinterpret_cast(&header->data); } void free(void *p) { struct block_bucket *bucket; - if (p == 0) { + if (p == nullptr) { return; } - struct block_header *header = (struct block_header *) ((void *) p - sizeof(struct block_header)); + auto *header = reinterpret_cast(reinterpret_cast(p) - offsetof(block_header, data)); #ifdef DEBUG_HEAP - printf("free: pBlockHeader = %p, pBlock = %p\n", header, p); + printf("free: header= %p, p=%p, size=%u\n", header, p, header->size); #endif assert(header->magic == BLOCK_MAGIC); @@ -165,11 +173,12 @@ void free(void *p) { for (bucket = s_block_bucket; bucket->size > 0; bucket++) { if (header->size == bucket->size) { - header->next = bucket->free_list; bucket->free_list = header; #ifdef DEBUG_HEAP - bucket->count--; + if (bucket->count > 0) { + bucket->count--; + } #endif break; } @@ -177,105 +186,102 @@ void free(void *p) { } void *calloc(size_t n, size_t size) { - size_t total; - void *p; - if ((n == 0) || (size == 0)) { - return NULL; + return nullptr; } - total = n * size; - - p = malloc(total); + auto total = n * size; + auto *p = malloc(total); - if (p == NULL) { - return NULL; + if (p == nullptr) { + return nullptr; } - assert(((unsigned)p & (unsigned)3) == 0); + assert((reinterpret_cast(p) & 3U) == 0); - uint32_t *dst32 = (uint32_t *) p; + auto *dst32 = reinterpret_cast(p); while (total >= 4) { - *dst32++ = (uint32_t) 0; + *dst32++ = 0; total -= 4; } - uint8_t *dst8 = (uint8_t *) dst32; + auto *dst8 = reinterpret_cast(dst32); while (total--) { - *dst8++ = (uint8_t) 0; + *dst8++ = 0; } - assert((size_t)((void *)dst8 - (void *)p) == (n * size)); + assert((reinterpret_cast(dst8) - reinterpret_cast(p)) == (n * size)); - return (void *) p; + return p; } -void *realloc(void *ptr, size_t size) { - size_t current_size; - - if (ptr == 0) { - void *newblk = malloc(size); +void *realloc(void *ptr, size_t newsize) { + if (ptr == nullptr) { + auto *newblk = malloc(newsize); return newblk; } - if (size == 0) { + if (newsize == 0) { free(ptr); - return NULL; + return nullptr; } - current_size = get_allocated(ptr); + auto nCurrentSize = get_allocated(ptr); - if (current_size >= size) { + if (nCurrentSize >= newsize) { return ptr; } - void *newblk = malloc(size); + void *newblk = malloc(newsize); - if (newblk != NULL) { - assert(((unsigned )newblk & (unsigned )3) == 0); - assert(((unsigned )ptr & (unsigned )3) == 0); + if (newblk != nullptr) { + assert((reinterpret_cast(newblk) & 3U) == 0); + assert((reinterpret_cast(ptr) & 3U) == 0); - const uint32_t *src32 = (const uint32_t *) ptr; - uint32_t *dst32 = (uint32_t *) newblk; + auto *src32 = reinterpret_cast(ptr); + auto *dst32 = reinterpret_cast(newblk); - size_t count = size; + auto nCount = newsize; - while (count >= 4) { + while (nCount >= 4) { *dst32++ = *src32++; - count -= 4; + nCount -= 4; } - const uint8_t *src8 = (const uint8_t *) src32; - uint8_t *dst8 = (uint8_t *) dst32; + auto *src8 = reinterpret_cast(src32); + auto *dst8 = reinterpret_cast(dst32); - while (count--) { + while (nCount--) { *dst8++ = *src8++; } - assert((size_t)((void *)dst8 - (void *)newblk) == size); + assert((reinterpret_cast(dst8) - reinterpret_cast(newblk)) == newsize); free(ptr); } return newblk; } +} -void debug_heap(void) { +void debug_heap() { #ifdef DEBUG_HEAP + printf("next_block = %p\n", next_block); + struct block_bucket *pBucket; - struct block_header *pBlockHeader; - printf("s_pNextBlock = %p\n", next_block); for (pBucket = s_block_bucket; pBucket->size > 0; pBucket++) { - printf("malloc(%d): %d blocks (max %d), FreeList %p\n", (unsigned) pBucket->size, (unsigned) pBucket->count, (unsigned) pBucket->max_count, pBucket->free_list); - if ((pBlockHeader = pBucket->free_list) != 0) { - while (1==1) { - printf("\t %p:%p size %d (%p)\n", pBlockHeader, pBlockHeader->data, pBlockHeader->size, pBlockHeader->next); - if (pBlockHeader->next == 0) { - break; - } + struct block_header *pFreeList = pBucket->free_list; + printf("malloc(%d): %d blocks (max %d), FreeList %p (next %p)\n", pBucket->size, pBucket->count, pBucket->max_count, pFreeList, pFreeList->next); + struct block_header *pBlockHeader; + + auto nFreelistCount = pBucket->max_count - pBucket->count; + + if ((pBlockHeader = pBucket->free_list) != nullptr) { + while (nFreelistCount-- > 0) { + printf("\t %p:%p size %d (next %p)\n", pBlockHeader, reinterpret_cast(&pBlockHeader->data), pBlockHeader->size, pBlockHeader->next); pBlockHeader = pBlockHeader->next; } } From bdd937ecd00b9387df661136789be1b728403f1b Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 14:59:09 +0200 Subject: [PATCH 04/36] TCNet is now header file only --- lib-tcnet/include/tcnet.h | 333 ++++++++++++++++++++++++++++++++++--- lib-tcnet/src/tcnet.cpp | 342 -------------------------------------- 2 files changed, 312 insertions(+), 363 deletions(-) delete mode 100755 lib-tcnet/src/tcnet.cpp diff --git a/lib-tcnet/include/tcnet.h b/lib-tcnet/include/tcnet.h index cb9e6cbae..d94ee5634 100755 --- a/lib-tcnet/include/tcnet.h +++ b/lib-tcnet/include/tcnet.h @@ -26,12 +26,28 @@ #ifndef TCNET_H_ #define TCNET_H_ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include +#include +#include +#include +#include "tcnet.h" +#include "tcnetconst.h" #include "tcnetpackets.h" #include "tcnettimecode.h" +#include "hardware.h" +#include "network.h" + +#include "debug.h" + namespace tcnet { +static constexpr char NODE_NAME_DEFAULT[] = "AvV"; + enum class Layer { LAYER_1, LAYER_2, @@ -45,29 +61,143 @@ enum class Layer { }; } // namespace tcnet - class TCNet { public: - TCNet(); - ~TCNet(); + TCNet() { + DEBUG_ENTRY + + assert(s_pThis == nullptr); + s_pThis = this; + + memset(&m_PacketOptIn, 0, sizeof(struct TTCNetPacketOptIn)); + + // Fill the static fields for Opt-IN + m_PacketOptIn.ManagementHeader.ProtocolVersionMajor = 3; + m_PacketOptIn.ManagementHeader.ProtocolVersionMinor = 3; + memcpy(m_PacketOptIn.ManagementHeader.Header, "TCN", 3); + m_PacketOptIn.ManagementHeader.MessageType = TCNET_MESSAGE_TYPE_OPTIN; + m_PacketOptIn.ManagementHeader.SEQ = 0; + m_PacketOptIn.ManagementHeader.NodeType = TCNET_TYPE_SLAVE; + m_PacketOptIn.ManagementHeader.NodeOptions = 0; + m_PacketOptIn.NodeCount = 1; + m_PacketOptIn.NodeListenerPort = TCNETUnicast::PORT; + memcpy(&m_PacketOptIn.VendorName, "orangepi-dmx.org", TCNET_VENDOR_NAME_LENGTH); + memcpy(&m_PacketOptIn.DeviceName, "LTC SMPTE Node ", TCNET_DEVICE_NAME_LENGTH); + m_PacketOptIn.DeviceMajorVersion = static_cast(_TIME_STAMP_YEAR_ - 2000); + m_PacketOptIn.DeviceMinorVersion = _TIME_STAMP_MONTH_; + m_PacketOptIn.DeviceBugVersion = _TIME_STAMP_DAY_; + + SetNodeName(tcnet::NODE_NAME_DEFAULT); + SetLayer(tcnet::Layer::LAYER_M); + SetTimeCodeType(TCNET_TIMECODE_TYPE_SMPTE_30FPS); + + DEBUG_EXIT + } + + void Start() { + DEBUG_ENTRY + + m_aHandles[0] = Network::Get()->Begin(TCNetBroadcast::PORT_0); + assert(m_aHandles[0] >= 0); + + m_aHandles[1] = Network::Get()->Begin(TCNetBroadcast::PORT_1); + assert(m_aHandles[1] >= 0); + +#if defined(USE_PORT_60002) + m_aHandles[2] = Network::Get()->Begin(TCNetBroadcast::PORT_2); + assert(m_aHandles[2] >= 0); +#endif + +#if defined(USE_PORT_UNICAST) + m_aHandles[3] = Network::Get()->Begin(TCNETUnicast::PORT); + assert(m_aHandles[3] >= 0); +#endif + DEBUG_EXIT + } + + void Stop() { + DEBUG_ENTRY - void Start(); - void Stop(); + TTCNetPacketOptOut OptOut; - void Run(); + memcpy(&OptOut, &m_PacketOptIn, sizeof(struct TTCNetPacketOptOut)); - void Print(); + Network::Get()->SendTo(m_aHandles[0], &OptOut, sizeof(struct TTCNetPacketOptOut), Network::Get()->GetBroadcastIp(), TCNetBroadcast::PORT_0); + + DEBUG_EXIT + } + + void Run() { + uint16_t nForeignPort; + + auto nBytesReceived = Network::Get()->RecvFrom(m_aHandles[1], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); + + if (nBytesReceived != 0) { + HandlePort60001Incoming(); + } + + nBytesReceived = Network::Get()->RecvFrom(m_aHandles[0], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); + + if (nBytesReceived != 0) { + HandlePort60000Incoming(); + } + +#if defined(USE_PORT_60002) + nBytesReceived = Network::Get()->RecvFrom(m_aHandles[2], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); + + if (nBytesReceived != 0) { + HandlePort60002Incoming(); + } +#endif + +#if defined(USE_PORT_UNICAST) + nBytesReceived = Network::Get()->RecvFrom(m_aHandles[3], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); + + if (nBytesReceived != 0) { + HandlePortUnicastIncoming(); + } +#endif + + m_nCurrentMillis = Hardware::Get()->Millis(); + + if (__builtin_expect(((m_nCurrentMillis - m_nPreviousMillis) >= 1000), 0)) { + m_nPreviousMillis = m_nCurrentMillis; + HandleOptInOutgoing(); + } + } + + void Print() { + puts("TCNet"); + printf(" Node : %.8s\n", m_PacketOptIn.ManagementHeader.NodeName); + printf(" L%c", GetLayerName(m_Layer)); + if (m_bUseTimeCode) { + puts(" TC"); + } else { + printf(" T%u\n", TCNetConst::FPS[m_tTimeCodeType]); + } + + printf("%u:%u:%u\n", static_cast(m_Layer), m_nLxTimeOffset, m_nLxTimeCodeOffset); + } TTCNetNodeType GetNodeType() const { return static_cast(m_PacketOptIn.ManagementHeader.NodeType); } - void SetNodeName(const char *pNodeName); + void SetNodeName(const char *pNodeName) { + strncpy(reinterpret_cast(m_PacketOptIn.ManagementHeader.NodeName), pNodeName, sizeof m_PacketOptIn.ManagementHeader.NodeName - 1); + m_PacketOptIn.ManagementHeader.NodeName[sizeof m_PacketOptIn.ManagementHeader.NodeName - 1] = '\0'; + } + const char *GetNodeName() { return reinterpret_cast(m_PacketOptIn.ManagementHeader.NodeName); } - void SetLayer(const tcnet::Layer layer); + void SetLayer(const tcnet::Layer layer) { + m_Layer = layer; + m_nLxTimeOffset = offsetof(struct TTCNetPacketTime, L1Time) + (4 * static_cast(layer)); + m_nLxTimeCodeOffset = offsetof(struct TTCNetPacketTime, L1TimeCode) + static_cast(layer) * sizeof(struct TTCNetPacketTimeTimeCode); + } + tcnet::Layer GetLayer() const { return m_Layer; } @@ -79,7 +209,28 @@ class TCNet { return m_bUseTimeCode; } - void SetTimeCodeType(TTCNetTimeCodeType tType); + void SetTimeCodeType(const TTCNetTimeCodeType type) { + switch (type) { + case TCNET_TIMECODE_TYPE_FILM: + m_fTypeDivider = 1000.0f / 24; + break; + case TCNET_TIMECODE_TYPE_EBU_25FPS: + m_fTypeDivider = 1000.0f / 25; + break; + case TCNET_TIMECODE_TYPE_DF: + m_fTypeDivider = 1000.0f / 29.97f; + break; + case TCNET_TIMECODE_TYPE_SMPTE_30FPS: + m_fTypeDivider = 1000.0f / 30; + break; + default: + return; + break; + } + + m_tTimeCodeType = type; + } + TTCNetTimeCodeType GetTimeCodeType() const { return m_tTimeCodeType; } @@ -89,19 +240,154 @@ class TCNet { } public: - static char GetLayerName(const tcnet::Layer layer); - static tcnet::Layer GetLayer(const char nChar); + static char GetLayerName(const tcnet::Layer layer) { + switch (layer) { + case tcnet::Layer::LAYER_1: + case tcnet::Layer::LAYER_2: + case tcnet::Layer::LAYER_3: + case tcnet::Layer::LAYER_4: + return static_cast(static_cast(layer) + '1'); + break; + case tcnet::Layer::LAYER_A: + return 'A'; + break; + case tcnet::Layer::LAYER_B: + return 'B'; + break; + case tcnet::Layer::LAYER_M: + return 'M'; + break; + case tcnet::Layer::LAYER_C: + return 'C'; + break; + default: + break; + } + + return ' '; + } + + static tcnet::Layer GetLayer(const char nChar) { + switch (nChar | 0x20) { // to lower case + case '1': + case '2': + case '3': + case '4': + return static_cast(nChar - '1'); + break; + case 'a': + return tcnet::Layer::LAYER_A; + break; + case 'b': + return tcnet::Layer::LAYER_B; + break; + case 'm': + return tcnet::Layer::LAYER_M; + break; + case 'c': + return tcnet::Layer::LAYER_C; + break; + default: + break; + } + + return tcnet::Layer::LAYER_UNDEFINED; + } static TCNet *Get() { return s_pThis; } private: - void HandlePort60000Incoming(); - void HandlePort60001Incoming(); - void HandlePort60002Incoming(); - void HandlePortUnicastIncoming(); - void HandleOptInOutgoing(); + void HandlePort60000Incoming() { + const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); + const auto messageType = static_cast(pPacket->MessageType); + + DEBUG_PRINTF("MessageType = %d", static_cast(messageType)); + + if (messageType == TCNET_MESSAGE_TYPE_OPTIN) { +#ifndef NDEBUG + DumpOptIn(); +#endif + return; + } + } + + void HandlePort60001Incoming() { + if (__builtin_expect((m_pTCNetTimeCode != nullptr), 1)) { + const auto *pPacketTime = reinterpret_cast(m_pReceiveBuffer); + if (static_cast(pPacketTime->ManagementHeader.MessageType) == TCNET_MESSAGE_TYPE_TIME) { + struct TTCNetTimeCode TimeCode; + + if (!m_bUseTimeCode) { + auto nTime = *reinterpret_cast(m_pReceiveBuffer + m_nLxTimeOffset); + + const auto nHours = nTime / 3600000U; + nTime -= nHours * 3600000U; + const auto nMinutes = nTime / 60000U; + nTime -= nMinutes * 60000U; + const auto nSeconds = nTime / 1000U; + const auto nMillis = nTime - nSeconds * 1000U; + const auto nFrames = static_cast(static_cast(nMillis) / m_fTypeDivider); + + TimeCode.nFrames = static_cast(nFrames); + TimeCode.nSeconds = static_cast(nSeconds); + TimeCode.nMinutes = static_cast(nMinutes); + TimeCode.nHours = static_cast(nHours); + TimeCode.nType = m_tTimeCodeType; + } else { + const auto *pTC = reinterpret_cast(m_pReceiveBuffer + m_nLxTimeCodeOffset); + TimeCode.nFrames = pTC->Frames; + TimeCode.nSeconds = pTC->Seconds; + TimeCode.nMinutes = pTC->Minutes; + TimeCode.nHours = pTC->Hours; + + auto nSMPTEMode = pTC->SMPTEMode; + + if (nSMPTEMode < 24) { + nSMPTEMode = pPacketTime->SMPTEMode; + } + + if (nSMPTEMode == 24) { + TimeCode.nType = TCNET_TIMECODE_TYPE_FILM; + } else if (nSMPTEMode == 25) { + TimeCode.nType = TCNET_TIMECODE_TYPE_EBU_25FPS; + } else if (nSMPTEMode == 29) { + TimeCode.nType = TCNET_TIMECODE_TYPE_DF; + } else if (nSMPTEMode == 30) { + TimeCode.nType = TCNET_TIMECODE_TYPE_SMPTE_30FPS; + } else { + TimeCode.nType = TCNET_TIMECODE_TYPE_EBU_25FPS; + } + } + + m_pTCNetTimeCode->Handler(&TimeCode); + } + } + } + + void HandlePort60002Incoming() { + DEBUG_ENTRY + DEBUG_EXIT + } + + void HandlePortUnicastIncoming() { + DEBUG_ENTRY +#ifndef NDEBUG + const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); + const auto messageType = static_cast(pPacket->MessageType); +#endif + DEBUG_PRINTF("MessageType = %d", static_cast(messageType)); + DEBUG_EXIT + } + + void HandleOptInOutgoing() { + m_PacketOptIn.ManagementHeader.SEQ++; + m_PacketOptIn.ManagementHeader.TimeStamp = Hardware::Get()->Micros(); + m_PacketOptIn.Uptime = static_cast(Hardware::Get()->GetUpTime()); + + Network::Get()->SendTo(m_aHandles[0], &m_PacketOptIn, sizeof(struct TTCNetPacketOptIn), Network::Get()->GetBroadcastIp(), TCNetBroadcast::PORT_0); + } void DumpManagementHeader(); void DumpOptIn(); @@ -112,12 +398,12 @@ class TCNet { static constexpr uint16_t PORT_1 = 60001; static constexpr uint16_t PORT_2 = 60002; }; + struct TCNETUnicast { static constexpr uint16_t PORT = 65023; }; int32_t m_aHandles[4]; - TTCNetPacketOptIn m_PacketOptIn; uint8_t *m_pReceiveBuffer { nullptr }; uint32_t m_nIpAddressFrom; uint32_t m_nCurrentMillis { 0 }; @@ -125,13 +411,18 @@ class TCNet { uint32_t m_nLxTimeOffset { 0 }; uint32_t m_nLxTimeCodeOffset { 0 }; TCNetTimeCode *m_pTCNetTimeCode { nullptr }; - tcnet::Layer m_Layer = tcnet::Layer::LAYER_M; - bool m_bUseTimeCode = false; + float m_fTypeDivider { 1000.0F / 30 }; + tcnet::Layer m_Layer { tcnet::Layer::LAYER_M }; TTCNetTimeCodeType m_tTimeCodeType; + bool m_bUseTimeCode { false }; uint8_t m_nSeqTimeMessage { 0 }; - static TCNet *s_pThis; + TTCNetPacketOptIn m_PacketOptIn; + + static inline TCNet *s_pThis; }; +#pragma GCC pop_options + #endif /* TCNET_H_ */ diff --git a/lib-tcnet/src/tcnet.cpp b/lib-tcnet/src/tcnet.cpp deleted file mode 100755 index 2ea67e61b..000000000 --- a/lib-tcnet/src/tcnet.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/** - * @file tcnet.cpp - * - */ -/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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 -#include -#include -#include - -#include "tcnet.h" -#include "tcnettimecode.h" -#include "tcnetconst.h" -#include "tcnetpackets.h" - -#include "hardware.h" -#include "network.h" - -#include "debug.h" - -static constexpr char NODE_NAME_DEFAULT[] = "AvV"; - -TCNet *TCNet::s_pThis; - -TCNet::TCNet() { - assert(s_pThis == nullptr); - s_pThis = this; - - memset(&m_PacketOptIn, 0, sizeof(struct TTCNetPacketOptIn)); - - // Fill the static fields for Opt-IN - m_PacketOptIn.ManagementHeader.ProtocolVersionMajor = 3; - m_PacketOptIn.ManagementHeader.ProtocolVersionMinor = 3; - memcpy(m_PacketOptIn.ManagementHeader.Header, "TCN", 3); - m_PacketOptIn.ManagementHeader.MessageType = TCNET_MESSAGE_TYPE_OPTIN; - m_PacketOptIn.ManagementHeader.SEQ = 0; - m_PacketOptIn.ManagementHeader.NodeType = TCNET_TYPE_SLAVE; - m_PacketOptIn.ManagementHeader.NodeOptions = 0; - m_PacketOptIn.NodeCount = 1; - m_PacketOptIn.NodeListenerPort = TCNETUnicast::PORT; - memcpy(&m_PacketOptIn.VendorName, "orangepi-dmx.org", TCNET_VENDOR_NAME_LENGTH); - memcpy(&m_PacketOptIn.DeviceName, "LTC SMPTE Node ", TCNET_DEVICE_NAME_LENGTH); - m_PacketOptIn.DeviceMajorVersion = static_cast(_TIME_STAMP_YEAR_ - 2000); - m_PacketOptIn.DeviceMinorVersion = _TIME_STAMP_MONTH_; - m_PacketOptIn.DeviceBugVersion = _TIME_STAMP_DAY_; - - SetNodeName(NODE_NAME_DEFAULT); - SetLayer(tcnet::Layer::LAYER_M); - SetTimeCodeType(TCNET_TIMECODE_TYPE_SMPTE_30FPS); -} - -TCNet::~TCNet() { - Stop(); -} - -void TCNet::Start() { - m_aHandles[0] = Network::Get()->Begin(TCNetBroadcast::PORT_0); - assert(m_aHandles[0] >= 0); - - m_aHandles[1] = Network::Get()->Begin(TCNetBroadcast::PORT_1); - assert(m_aHandles[1] >= 0); - -#if defined(USE_PORT_60002) - m_aHandles[2] = Network::Get()->Begin(TCNetBroadcast::PORT_2); - assert(m_aHandles[2] >= 0); -#endif - -#if defined(USE_PORT_UNICAST) - m_aHandles[3] = Network::Get()->Begin(TCNETUnicast::PORT); - assert(m_aHandles[3] >= 0); -#endif -} - -void TCNet::Stop() { - DEBUG_ENTRY - - struct TTCNetPacketOptOut OptOut; - - memcpy(&OptOut, &m_PacketOptIn, sizeof(struct TTCNetPacketOptOut)); - - Network::Get()->SendTo(m_aHandles[0], &OptOut, sizeof(struct TTCNetPacketOptOut), Network::Get()->GetBroadcastIp(), TCNetBroadcast::PORT_0); - - DEBUG_EXIT -} - -void TCNet::HandlePort60000Incoming() { - const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); - const auto messageType = static_cast(pPacket->MessageType); - - DEBUG_PRINTF("MessageType = %d", static_cast(messageType)); - - if (messageType == TCNET_MESSAGE_TYPE_OPTIN) { -#ifndef NDEBUG - DumpOptIn(); -#endif - return; - } -} - -void TCNet::HandlePort60001Incoming() { - if (__builtin_expect((m_pTCNetTimeCode != nullptr), 1)) { - const auto *pPacketTime = reinterpret_cast(m_pReceiveBuffer); - if (static_cast(pPacketTime->ManagementHeader.MessageType) == TCNET_MESSAGE_TYPE_TIME) { - struct TTCNetTimeCode TimeCode; - - if (!m_bUseTimeCode) { - auto nTime = *reinterpret_cast(m_pReceiveBuffer + m_nLxTimeOffset); - - const auto nHours = nTime / 3600000U; - nTime -= nHours * 3600000U; - const auto nMinutes = nTime / 60000U; - nTime -= nMinutes * 60000U; - const auto nSeconds = nTime / 1000U; - const auto nMillis = nTime - nSeconds * 1000U; - const auto nFrames = static_cast(static_cast(nMillis) / m_fTypeDivider); - - TimeCode.nFrames = static_cast(nFrames); - TimeCode.nSeconds = static_cast(nSeconds); - TimeCode.nMinutes = static_cast(nMinutes); - TimeCode.nHours = static_cast(nHours); - TimeCode.nType = m_tTimeCodeType; - } else { - const auto *pTC = reinterpret_cast(m_pReceiveBuffer + m_nLxTimeCodeOffset); - TimeCode.nFrames = pTC->Frames; - TimeCode.nSeconds = pTC->Seconds; - TimeCode.nMinutes = pTC->Minutes; - TimeCode.nHours = pTC->Hours; - - uint8_t nSMPTEMode = pTC->SMPTEMode; - - if (nSMPTEMode < 24) { - nSMPTEMode = pPacketTime->SMPTEMode; - } - - if (nSMPTEMode == 24) { - TimeCode.nType = TCNET_TIMECODE_TYPE_FILM; - } else if (nSMPTEMode == 25) { - TimeCode.nType = TCNET_TIMECODE_TYPE_EBU_25FPS; - } else if (nSMPTEMode == 29) { - TimeCode.nType = TCNET_TIMECODE_TYPE_DF; - } else if (nSMPTEMode == 30) { - TimeCode.nType = TCNET_TIMECODE_TYPE_SMPTE_30FPS; - } else { - TimeCode.nType = TCNET_TIMECODE_TYPE_EBU_25FPS; - } - } - - m_pTCNetTimeCode->Handler(&TimeCode); - } - } -} - -void TCNet::HandlePort60002Incoming() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void TCNet::HandlePortUnicastIncoming() { - DEBUG_ENTRY -#ifndef NDEBUG - const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); - const auto messageType = static_cast(pPacket->MessageType); -#endif - DEBUG_PRINTF("MessageType = %d", static_cast(messageType)); - DEBUG_EXIT -} - -void TCNet::HandleOptInOutgoing() { - m_PacketOptIn.ManagementHeader.SEQ++; - m_PacketOptIn.ManagementHeader.TimeStamp = Hardware::Get()->Micros(); - m_PacketOptIn.Uptime = static_cast(Hardware::Get()->GetUpTime()); - - Network::Get()->SendTo(m_aHandles[0], &m_PacketOptIn, sizeof(struct TTCNetPacketOptIn), Network::Get()->GetBroadcastIp(), TCNetBroadcast::PORT_0); -} - -void TCNet::Run() { - uint16_t nForeignPort; - - auto nBytesReceived = Network::Get()->RecvFrom(m_aHandles[1], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); - - if (nBytesReceived != 0) { - HandlePort60001Incoming(); - } - - nBytesReceived = Network::Get()->RecvFrom(m_aHandles[0], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); - - if (nBytesReceived != 0) { - HandlePort60000Incoming(); - } - -#if defined(USE_PORT_60002) - nBytesReceived = Network::Get()->RecvFrom(m_aHandles[2], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); - - if (nBytesReceived != 0) { - HandlePort60002Incoming(); - } -#endif - -#if defined(USE_PORT_UNICAST) - nBytesReceived = Network::Get()->RecvFrom(m_aHandles[3], const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nIpAddressFrom, &nForeignPort); - - if (nBytesReceived != 0) { - HandlePortUnicastIncoming(); - } -#endif - - m_nCurrentMillis = Hardware::Get()->Millis(); - - if (__builtin_expect(((m_nCurrentMillis - m_nPreviousMillis) >= 1000), 0)) { - m_nPreviousMillis = m_nCurrentMillis; - HandleOptInOutgoing(); - } -} - -void TCNet::SetLayer(const tcnet::Layer layer) { - m_Layer = layer; - m_nLxTimeOffset = offsetof(struct TTCNetPacketTime, L1Time) + (4 * static_cast(layer)); - m_nLxTimeCodeOffset = offsetof(struct TTCNetPacketTime, L1TimeCode) + static_cast(layer) * sizeof(struct TTCNetPacketTimeTimeCode); -} - -void TCNet::SetNodeName(const char *pNodeName) { -#if (__GNUC__ > 8) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" -#endif - strncpy(reinterpret_cast(m_PacketOptIn.ManagementHeader.NodeName), pNodeName, sizeof m_PacketOptIn.ManagementHeader.NodeName - 1); - m_PacketOptIn.ManagementHeader.NodeName[sizeof m_PacketOptIn.ManagementHeader.NodeName - 1] = '\0'; -#if (__GNUC__ > 8) -#pragma GCC diagnostic pop -#endif -} - -char TCNet::GetLayerName(tcnet::Layer tLayer) { - switch (tLayer) { - case tcnet::Layer::LAYER_1: - case tcnet::Layer::LAYER_2: - case tcnet::Layer::LAYER_3: - case tcnet::Layer::LAYER_4: - return static_cast(static_cast(tLayer) + '1'); - break; - case tcnet::Layer::LAYER_A: - return 'A'; - break; - case tcnet::Layer::LAYER_B: - return 'B'; - break; - case tcnet::Layer::LAYER_M: - return 'M'; - break; - case tcnet::Layer::LAYER_C: - return 'C'; - break; - default: - break; - } - - return ' '; -} - -tcnet::Layer TCNet::GetLayer(char nChar) { - switch (nChar | 0x20) { // to lower case - case '1': - case '2': - case '3': - case '4': - return static_cast(nChar - '1'); - break; - case 'a': - return tcnet::Layer::LAYER_A; - break; - case 'b': - return tcnet::Layer::LAYER_B; - break; - case 'm': - return tcnet::Layer::LAYER_M; - break; - case 'c': - return tcnet::Layer::LAYER_C; - break; - default: - break; - } - - return tcnet::Layer::LAYER_UNDEFINED; -} - -void TCNet::SetTimeCodeType(TTCNetTimeCodeType tType) { - switch (tType) { - case TCNET_TIMECODE_TYPE_FILM: - m_fTypeDivider = 1000.0f / 24; - break; - case TCNET_TIMECODE_TYPE_EBU_25FPS: - m_fTypeDivider = 1000.0f / 25; - break; - case TCNET_TIMECODE_TYPE_DF: - m_fTypeDivider = 1000.0f / 29.97f; - break; - case TCNET_TIMECODE_TYPE_SMPTE_30FPS: - m_fTypeDivider = 1000.0f / 30; - break; - default: - return; - break; - } - - m_tTimeCodeType = tType; -} - -void TCNet::Print() { - puts("TCNet"); - printf(" Node : %.8s\n", m_PacketOptIn.ManagementHeader.NodeName); - printf(" L%c", GetLayerName(m_Layer)); - if (m_bUseTimeCode) { - puts(" TC"); - } else { - printf(" T%u\n", TCNetConst::FPS[m_tTimeCodeType]); - } - - printf("%u:%u:%u\n", static_cast(m_Layer), m_nLxTimeOffset, m_nLxTimeCodeOffset); -} From bc15291b5e50a33232c4d39c7ff693e0de167fa3 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:02:37 +0200 Subject: [PATCH 05/36] W.I.P. #186 - Moved SoftwareTimers to timers.cpp - Converted class I2cDetect to free standing function i2c_detect --- lib-dmx/src/h3/multi/dmx.cpp | 13 +- lib-dmx/src/h3/single/dmx.cpp | 4 +- lib-dmx/src/rpi/dmx.cpp | 2 +- lib-h3/.cproject | 215 +++++++++++++----- lib-h3/.settings/language.settings.xml | 10 +- lib-h3/arm/{gic.c => gic.cpp} | 82 ++----- lib-h3/include/arm/gic.h | 46 ++-- lib-h3/include/h3.h | 11 +- lib-h3/include/irq_timer.h | 10 +- lib-h3/src/debug_exception.c | 4 +- lib-h3/src/h3_codec.cpp | 2 +- lib-h3/src/{irq_timer.c => irq_timer.cpp} | 183 ++++++++------- lib-hal/.cproject | 19 +- lib-hal/.settings/language.settings.xml | 6 +- lib-hal/Makefile.Linux | 1 + lib-hal/Rules.mk | 5 + lib-hal/debug/i2c/i2cdetect.cpp | 9 +- lib-hal/debug/i2c/i2cdetect.h | 7 +- lib-hal/debug/stack/stack_debug.cpp | 4 +- lib-hal/include/gd32/hardware.h | 85 +------ lib-hal/include/h3/hardware.h | 74 +----- lib-hal/include/hal_timers.h.template | 143 ------------ lib-hal/include/hardware.h | 2 - lib-hal/include/hwclock.h | 1 - lib-hal/include/linux/hardware.h | 71 +----- lib-hal/include/superloop/timers.h | 40 ++++ .../h3/debug_exception.c => include/timers.h} | 43 +--- lib-hal/src/h3/hardware.cpp | 65 +++++- .../src/linux/{console_status.c => console.c} | 8 +- lib-hal/superloop/timers.cpp | 120 ++++++++++ 30 files changed, 600 insertions(+), 685 deletions(-) rename lib-h3/arm/{gic.c => gic.cpp} (71%) rename lib-h3/src/{irq_timer.c => irq_timer.cpp} (67%) delete mode 100755 lib-hal/include/hal_timers.h.template create mode 100755 lib-hal/include/superloop/timers.h rename lib-hal/{debug/h3/debug_exception.c => include/timers.h} (53%) rename lib-hal/src/linux/{console_status.c => console.c} (88%) create mode 100755 lib-hal/superloop/timers.cpp diff --git a/lib-dmx/src/h3/multi/dmx.cpp b/lib-dmx/src/h3/multi/dmx.cpp index cd127f0a7..8033306f9 100644 --- a/lib-dmx/src/h3/multi/dmx.cpp +++ b/lib-dmx/src/h3/multi/dmx.cpp @@ -154,9 +154,6 @@ static volatile uint32_t s_nRdmDataReadIndex[dmx::config::max::PORTS]; static volatile PortState sv_PortState[dmx::config::max::PORTS] ALIGNED; -static char CONSOLE_ERROR[] ALIGNED = "DMXDATA %\n"; -static constexpr auto CONSOLE_ERROR_LENGTH = (sizeof(CONSOLE_ERROR) / sizeof(CONSOLE_ERROR[0])); - static void irq_timer0_dmx_multi_sender([[maybe_unused]]uint32_t clo) { logic_analyzer::ch0_set(); @@ -413,21 +410,21 @@ static void __attribute__((interrupt("FIQ"))) fiq_dmx_multi(void) { if (nIIR & UART_IIR_IID_RD) { fiq_in_handler(0, reinterpret_cast(H3_UART1_BASE), nIIR); H3_GIC_CPUIF->EOI = H3_UART1_IRQn; - gic_unpend(H3_UART1_IRQn); + gic_unpend(); } nIIR = H3_UART2->O08.IIR; if (nIIR & UART_IIR_IID_RD) { fiq_in_handler(1, reinterpret_cast(H3_UART2_BASE), nIIR); H3_GIC_CPUIF->EOI = H3_UART2_IRQn; - gic_unpend(H3_UART2_IRQn); + gic_unpend(); } #if defined (ORANGE_PI_ONE) nIIR = H3_UART3->O08.IIR; if (nIIR & UART_IIR_IID_RD) { fiq_in_handler(2, reinterpret_cast(H3_UART3_BASE), nIIR); H3_GIC_CPUIF->EOI = H3_UART3_IRQn; - gic_unpend(H3_UART3_IRQn); + gic_unpend(); } # ifndef DO_NOT_USE_UART0 @@ -435,7 +432,7 @@ static void __attribute__((interrupt("FIQ"))) fiq_dmx_multi(void) { if (nIIR & UART_IIR_IID_RD) { fiq_in_handler(3, reinterpret_cast(H3_UART0_BASE), nIIR); H3_GIC_CPUIF->EOI = H3_UART0_IRQn; - gic_unpend(H3_UART0_IRQn); + gic_unpend(); } # endif #endif @@ -656,7 +653,7 @@ Dmx::Dmx() { # endif #endif - irq_timer_init(); + irq_handler_init(); irq_timer_set(IRQ_TIMER_0, irq_timer0_dmx_multi_sender); irq_timer_set(IRQ_TIMER_1, irq_timer1_dmx_receive); diff --git a/lib-dmx/src/h3/single/dmx.cpp b/lib-dmx/src/h3/single/dmx.cpp index 36e794dfd..f9014e6b0 100644 --- a/lib-dmx/src/h3/single/dmx.cpp +++ b/lib-dmx/src/h3/single/dmx.cpp @@ -422,7 +422,7 @@ static void __attribute__((interrupt("FIQ"))) fiq_dmx(void) { } H3_GIC_CPUIF->EOI = UART_IRQN; - gic_unpend(UART_IRQN); + gic_unpend(); } else { console_error("spurious interrupt\n"); } @@ -539,7 +539,7 @@ Dmx::Dmx() { sv_DmxTransmitState = IDLE; - irq_timer_init(); + irq_handler_init(); irq_timer_set(IRQ_TIMER_1, irq_timer1_dmx_receive); H3_TIMER->TMR1_INTV = 0xB71B00; // 1 second diff --git a/lib-dmx/src/rpi/dmx.cpp b/lib-dmx/src/rpi/dmx.cpp index 91e549a5c..431693b47 100644 --- a/lib-dmx/src/rpi/dmx.cpp +++ b/lib-dmx/src/rpi/dmx.cpp @@ -420,7 +420,7 @@ Dmx::Dmx() { sv_DmxTransmitState = IDLE; sv_doDmxTransmitAlways = false; - irq_timer_init(); + irq_handler_init(); irq_timer_set(IRQ_TIMER_3, irq_timer3_dmx_receive); BCM2835_ST->C3 = BCM2835_ST->CLO + (uint32_t) 1000000; diff --git a/lib-h3/.cproject b/lib-h3/.cproject index 3b1bb16df..02ac0c12e 100644 --- a/lib-h3/.cproject +++ b/lib-h3/.cproject @@ -1,10 +1,11 @@ - - + + + @@ -13,71 +14,175 @@ - - - - @@ -104,10 +209,13 @@ - + - + + + + @@ -116,22 +224,25 @@ - + - + - + - + - + + + + diff --git a/lib-h3/.settings/language.settings.xml b/lib-h3/.settings/language.settings.xml index 5daf7d09d..4c1fd3f6a 100644 --- a/lib-h3/.settings/language.settings.xml +++ b/lib-h3/.settings/language.settings.xml @@ -1,14 +1,14 @@ - + - - - - + + + + diff --git a/lib-h3/arm/gic.c b/lib-h3/arm/gic.cpp similarity index 71% rename from lib-h3/arm/gic.c rename to lib-h3/arm/gic.cpp index e27cff13b..b8acf1b95 100644 --- a/lib-h3/arm/gic.c +++ b/lib-h3/arm/gic.cpp @@ -29,12 +29,9 @@ # include #endif -#include "arm/synchronize.h" +#include "h3.h" #include "arm/gic.h" -static uint16_t max_interrupts; -static uint8_t impemented_cpu_interfaces; - #define ICENABLE_N (sizeof(H3_GIC_DIST->ICENABLE) / sizeof(H3_GIC_DIST->ICENABLE[0])) #define ICPEND_N (sizeof(H3_GIC_DIST->ICPEND) / sizeof(H3_GIC_DIST->ICPEND[0])) #define ICACTIVE_N (sizeof(H3_GIC_DIST->ICACTIVE) / sizeof(H3_GIC_DIST->ICACTIVE[0])) @@ -54,82 +51,44 @@ static uint8_t impemented_cpu_interfaces; #define GICC_CTL_ENABLE_GRP1 (1 << 1) #define GICC_CTL_ENABLE_FIQ (1 << 3) -void __attribute__((cold)) gic_init(void) { - unsigned i; - - max_interrupts = (uint16_t) (((H3_GIC_DIST->TYPE & 0x1F) + 1) * 32); - impemented_cpu_interfaces = (uint8_t) (1 + (uint8_t) ((H3_GIC_DIST->TYPE >> 5) & 0x7)); - - /* Initialize Distributor */ - - H3_GIC_DIST->CTL = 0; - - for (i = 0; i < ICENABLE_N; i++) { - H3_GIC_DIST->ICENABLE[i] = 0xFFFFFFFF; // Writing 1 to a Clear-enable bit disables forwarding - } - - for (i = 0; i < ICPEND_N; i++) { - H3_GIC_DIST->ICPEND[i] = 0xFFFFFFFF; // Writing 1 to a Clear-pending bit clears the pending states - } - - for (i = 0; i < ICACTIVE_N; i++) { - H3_GIC_DIST->ICACTIVE[i] = 0xFFFFFFFF; // Writing 1 to a Clear-active bit Deactivates the corresponding interrupt - } - - for (i = 0; i < IPRIORITY_N; i++) { - H3_GIC_DIST->IPRIORITY[i] = 0x0; // TODO What is this? - } - - for (i = 0; i < ITARGETS_N; i++) { - H3_GIC_DIST->ITARGETS[i] = 0x01010101; // TODO This needs be changed for multi-core support - } - - for (i = 0; i < ICFG_N; i++) { - H3_GIC_DIST->ICFG[i] = 0x0; // 0 => Corresponding interrupt is level-sensitive. - } +extern "C" void clean_data_cache() __attribute__ ((optimize (3))); +void __attribute__((cold)) gic_init() { + GIC_Enable(); H3_GIC_DIST->CTL = CTL_GRP0_ENABLE | CTL_GRP1_ENABLE; // Group 1 -> IRQ, Group 0 -> FIQ - - /* Initialize CPU Interface */ H3_GIC_CPUIF->PM = 0xFFFFFFFF; - - H3_GIC_CPUIF->CTL = GICC_CTL_ENABLE_GRP0 | GICC_CTL_ENABLE_GRP1 | GICC_CTL_ENABLE_FIQ; + GICInterface->CTLR = GICC_CTL_ENABLE_GRP0 | GICC_CTL_ENABLE_GRP1 | GICC_CTL_ENABLE_FIQ; } -static void int_config(H3_IRQn_TypeDef n, __attribute__((unused)) GIC_CORE_TypeDef cpu, GIC_GROUP_TypeDef group) { +static void int_config(H3_IRQn_TypeDef nIRQ, [[maybe_unused]] GIC_CORE_TypeDef cpu, GIC_GROUP_TypeDef group) { #ifndef NDEBUG - printf("int_config(H3_IRQn_TypeDef %d,cpu %d, GIC_GROUP_TypeDef %d)\n", n, cpu, group); + printf("int_config(H3_IRQn_TypeDef %d,cpu %d, GIC_GROUP_TypeDef %d)\n", nIRQ, cpu, group); #endif clean_data_cache(); - dmb(); + __DMB(); - const uint32_t index = n / 32; - uint32_t mask = 1U << (n % 32); + GIC_EnableIRQ(nIRQ); + GIC_SetGroup(nIRQ, static_cast(group)); - H3_GIC_DIST->ISENABLE[index] = mask; + __ISB(); #ifndef NDEBUG + const auto index = nIRQ / 32; + auto mask = 1U << (nIRQ % 32); printf("H3_GIC_DIST->ISENABLE[%d] = %p [%p]\n", index, mask, H3_GIC_DIST->ISENABLE[index]); -#endif - - mask = (uint32_t)group << (n % 32); - - H3_GIC_DIST->IGROUP[index] |= mask; - - isb(); - -#ifndef NDEBUG + mask = static_cast(group << (nIRQ % 32)); printf("H3_GIC_DIST->IGROUP[%d] = %p [%p]\n", index, mask, H3_GIC_DIST->IGROUP[index]); #endif } -void gic_irq_config(H3_IRQn_TypeDef n, GIC_CORE_TypeDef cpu) { - int_config(n, cpu, GIC_GROUP1); +void gic_irq_config(H3_IRQn_TypeDef nIRQ, GIC_CORE_TypeDef nCPU) { + int_config(nIRQ, nCPU, GIC_GROUP1); + gic_int_dump(nIRQ); } -void gic_fiq_config(H3_IRQn_TypeDef n, GIC_CORE_TypeDef cpu) { - int_config(n, cpu, GIC_GROUP0); +void gic_fiq_config(H3_IRQn_TypeDef nIRQ, GIC_CORE_TypeDef nCPU) { + int_config(nIRQ, nCPU, GIC_GROUP0); } void gic_init_dump(void) { @@ -174,11 +133,10 @@ void gic_int_dump(__attribute__((unused)) H3_IRQn_TypeDef n) { uint32_t index = n / 32; uint32_t mask = 1U << (n % 32); - GIC_GROUP_TypeDef group = (GIC_GROUP_TypeDef) ((H3_GIC_DIST->IGROUP[index] & mask) == mask); + GIC_GROUP_TypeDef group = static_cast((H3_GIC_DIST->IGROUP[index] & mask) == mask); bool is_enabled = (H3_GIC_DIST->ISENABLE[index] & mask) == mask; bool is_pending = (H3_GIC_DIST->ISPEND[index] & mask) == mask; printf("H3_IRQn=%d (index=%d,mask=%p), group=%d, enabled=%d, pending=%d\n", n, index, mask, group, is_enabled, is_pending); #endif } - diff --git a/lib-h3/include/arm/gic.h b/lib-h3/include/arm/gic.h index fdf853809..281618051 100644 --- a/lib-h3/include/arm/gic.h +++ b/lib-h3/include/arm/gic.h @@ -2,7 +2,7 @@ * @file gic.h * */ -/* Copyright (C) 2018-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -107,32 +107,26 @@ typedef struct { #define H3_GIC_DIST (_CAST(GIC_DIST_TypeDef *)(H3_GIC_DIST_BASE)) #define H3_GIC_CPUIF (_CAST(GIC_CPUIF_TypeDef *)(H3_GIC_CPUIF_BASE)) -#ifdef __cplusplus -extern "C" { -#endif - -extern void gic_init(void); +void gic_init(); -extern void gic_irq_config(H3_IRQn_TypeDef n, GIC_CORE_TypeDef cpu); -extern void gic_fiq_config(H3_IRQn_TypeDef n, GIC_CORE_TypeDef cpu); +void gic_irq_config(H3_IRQn_TypeDef, GIC_CORE_TypeDef); +void gic_fiq_config(H3_IRQn_TypeDef, GIC_CORE_TypeDef); -extern void gic_init_dump(void); -extern void gic_int_dump(H3_IRQn_TypeDef n); +void gic_init_dump(); +void gic_int_dump(H3_IRQn_TypeDef); -inline static void gic_unpend(H3_IRQn_TypeDef irq) { - const uint32_t index = irq / 32; - const uint32_t mask = 1U << (irq % 32); - - H3_GIC_DIST->ICPEND[index] = mask; +template +inline void gic_unpend() { + constexpr auto nIndex = IRQn / 32; + constexpr auto nMask = 1U << (IRQn % 32); + GICDistributor->ICPENDR[nIndex] = nMask; } -#include "arm/synchronize.h" - -inline static uint32_t gic_get_priority(H3_IRQn_TypeDef IRQn) { +inline uint32_t gic_get_priority(H3_IRQn_TypeDef IRQn) { return (H3_GIC_DIST->IPRIORITY[IRQn / 4U] >> ((IRQn % 4U) * 8U)) & 0xFFUL; } -inline static void gic_set_priority(H3_IRQn_TypeDef IRQn, uint32_t priority) { +inline void gic_set_priority(H3_IRQn_TypeDef IRQn, uint32_t priority) { const uint32_t mask = H3_GIC_DIST->IPRIORITY[IRQn / 4U] & ~(0xFFUL << ((IRQn % 4U) * 8U)); H3_GIC_DIST->IPRIORITY[IRQn / 4U] = mask | ((priority & 0xFFUL) << ((IRQn % 4U) * 8U)); } @@ -140,12 +134,12 @@ inline static void gic_set_priority(H3_IRQn_TypeDef IRQn, uint32_t priority) { /** * https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Core_A/Source/irq_ctrl_gic.c#L239 */ -inline static uint32_t gic_get_active_fiq() { +inline uint32_t gic_get_active_fiq() { /* Dummy read to avoid GIC 390 errata 801120 */ (void) H3_GIC_CPUIF->HPPI; const uint32_t fiqn = H3_GIC_CPUIF->IA; - dsb(); + __DSB(); /* Workaround GIC 390 errata 733075 (GIC-390_Errata_Notice_v6.pdf, 09-Jul-2014) */ /* The following workaround code is for a single-core system. It would be */ @@ -157,18 +151,14 @@ inline static uint32_t gic_get_active_fiq() { if ((fiqn == 0) || (fiqn >= 0x3FE)) { /* Unlock the CPU interface with a dummy write to Interrupt Priority Register */ - const uint32_t prio = gic_get_priority((H3_IRQn_TypeDef) 0); - gic_set_priority((H3_IRQn_TypeDef) 0, prio); + const uint32_t prio = gic_get_priority(static_cast(0)); + gic_set_priority(static_cast(0), prio); - dsb(); + __DSB(); /* End of Workaround GIC 390 errata 733075 */ } return fiqn; } -#ifdef __cplusplus -} -#endif - #endif /* GIC_H_ */ diff --git a/lib-h3/include/h3.h b/lib-h3/include/h3.h index 63ac3d818..497f8c7db 100644 --- a/lib-h3/include/h3.h +++ b/lib-h3/include/h3.h @@ -163,6 +163,7 @@ typedef enum T_H3_IRQn { H3_UART2_IRQn = 34, H3_UART3_IRQn = 35, H3_PA_EINT_IRQn = 43, + H3_PG_EINT_IRQn = 49, H3_TIMER0_IRQn = 50, H3_TIMER1_IRQn = 51, H3_AUDIO_CODEC_IRQn = 61, @@ -826,8 +827,16 @@ extern void h3_dump_memory_mapping(void); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wsign-conversion" - +#ifdef __cplusplus +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "core_ca.h" +#ifdef __cplusplus +extern "C" { +#endif #include "irq_ctrl.h" +#ifdef __cplusplus +} +#endif #endif /* H3_H_ */ diff --git a/lib-h3/include/irq_timer.h b/lib-h3/include/irq_timer.h index 44f58207f..1d28a279e 100644 --- a/lib-h3/include/irq_timer.h +++ b/lib-h3/include/irq_timer.h @@ -36,18 +36,10 @@ typedef enum irq_timers { typedef void (*thunk_irq_timer_t)(const uint32_t); typedef void (*thunk_irq_timer_arm_t)(); -#ifdef __cplusplus -extern "C" { -#endif - extern void irq_timer_set(_irq_timers, thunk_irq_timer_t); extern void irq_timer_arm_physical_set(thunk_irq_timer_arm_t); extern void irq_timer_arm_virtual_set(thunk_irq_timer_arm_t, uint32_t); -extern void irq_timer_init(void); - -#ifdef __cplusplus -} -#endif +extern void irq_handler_init(); #endif /* IRQ_TIMER_H_ */ diff --git a/lib-h3/src/debug_exception.c b/lib-h3/src/debug_exception.c index 109c78a87..e2fa90de9 100755 --- a/lib-h3/src/debug_exception.c +++ b/lib-h3/src/debug_exception.c @@ -25,9 +25,7 @@ #include -#if defined (H3) -# include "h3.h" -#endif +#include "h3.h" void console_set_fg_color(int); diff --git a/lib-h3/src/h3_codec.cpp b/lib-h3/src/h3_codec.cpp index 379140137..caf767b2e 100644 --- a/lib-h3/src/h3_codec.cpp +++ b/lib-h3/src/h3_codec.cpp @@ -425,7 +425,7 @@ static void __attribute__((interrupt("FIQ"))) codec_fiq_handler(void) { H3_DMA->IRQ_PEND0 |= H3_DMA->IRQ_PEND0; H3_GIC_CPUIF->EOI = H3_DMA_IRQn; - gic_unpend(H3_DMA_IRQn); + gic_unpend(); isb(); #ifdef LOGIC_ANALYZER diff --git a/lib-h3/src/irq_timer.c b/lib-h3/src/irq_timer.cpp similarity index 67% rename from lib-h3/src/irq_timer.c rename to lib-h3/src/irq_timer.cpp index ca1bc00b2..78a41d50d 100644 --- a/lib-h3/src/irq_timer.c +++ b/lib-h3/src/irq_timer.cpp @@ -1,5 +1,5 @@ /** - * @file irq_timer.c + * @file irq_timer.cpp * */ /* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl @@ -23,38 +23,32 @@ * THE SOFTWARE. */ +#define CONFIG_SYSTEM_CMSIS_IRQ_HANDLER + +#pragma GCC push_options +#pragma GCC optimize ("O2") + #if __GNUC__ > 8 # pragma GCC target ("general-regs-only") #endif -//#define CONFIG_SYSTEM_CMSIS_IRQ_HANDLER - -#include -#include +#include +#include +#include #include "irq_timer.h" #include "arm/arm.h" -#include "arm/synchronize.h" #include "arm/gic.h" #include "h3.h" #include "h3_timer.h" #include "h3_hs_timer.h" -#define ARM_TIMER_ENABLE (1U<<0) +#define ARM_TIMER_ENABLE (1U << 0) #define ARM_PHYSICAL_TIMER_IRQ H3_PPI13_IRQn #define ARM_VIRTUAL_TIMER_IRQ H3_PPI11_IRQn -#if !defined(CONFIG_SYSTEM_CMSIS_IRQ_HANDLER) -/** - * Generic ARM Timer - */ -static volatile thunk_irq_timer_arm_t arm_physical_timer_func = NULL; -static volatile thunk_irq_timer_arm_t arm_virtual_timer_func = NULL; - -static volatile uint32_t timer_value; - /** * H3 Timers */ @@ -63,67 +57,103 @@ static thunk_irq_timer_t h3_timer1_func = NULL; static void TIMER0_IRQHandler() { H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR0; /* Clear Timer 0 Pending bit */ - h3_timer0_func(H3_HS_TIMER->CURNT_LO); + + assert(h3_timer0_func != nullptr); + + if (__builtin_expect((h3_timer0_func != nullptr), 1)) { + h3_timer0_func(H3_HS_TIMER->CURNT_LO); + } } static void TIMER1_IRQHandler() { H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR1; /* Clear Timer 1 Pending bit */ - h3_timer1_func(H3_HS_TIMER->CURNT_LO); + + assert(h3_timer1_func != nullptr); + + if (__builtin_expect((h3_timer1_func != nullptr), 1)) { + h3_timer1_func(H3_HS_TIMER->CURNT_LO); + } } -static void ARM_Physical_Timer_IRQHandler(void) { +/** + * Generic ARM Timer + */ +static volatile thunk_irq_timer_arm_t arm_physical_timer_func = nullptr; +static volatile thunk_irq_timer_arm_t arm_virtual_timer_func = nullptr; + +static volatile uint32_t timer_value; + +static void ARM_Physical_Timer_IRQHandler() { __asm volatile ("mcr p15, 0, %0, c14, c2, 0" : : "r" (H3_F_24M)); __asm volatile ("mcr p15, 0, %0, c14, c2, 1" : : "r" (ARM_TIMER_ENABLE)); - if (arm_physical_timer_func != NULL) { + assert(arm_physical_timer_func != nullptr); + + if (__builtin_expect((arm_physical_timer_func != nullptr), 1)) { arm_physical_timer_func(); } } -static void ARM_Virtual_Timer_IRQHandler(void) { +static void ARM_Virtual_Timer_IRQHandler() { __asm volatile ("mcr p15, 0, %0, c14, c3, 0" : : "r" (timer_value)); __asm volatile ("mcr p15, 0, %0, c14, c3, 1" : : "r" (ARM_TIMER_ENABLE)); - if (arm_virtual_timer_func != NULL) { + assert(arm_virtual_timer_func != nullptr); + + if (__builtin_expect((arm_virtual_timer_func != nullptr), 1)) { arm_virtual_timer_func(); } } -static void __attribute__((interrupt("IRQ"))) irq_timer_handler(void) { - __DMB(); +void irq_timer_set(_irq_timers nIrqTimer, thunk_irq_timer_t func) { + if (nIrqTimer == IRQ_TIMER_0) { + h3_timer0_func = func; - const uint32_t irq = H3_GIC_CPUIF->AIA; + if (func != nullptr) { + H3_TIMER->TMR0_CTRL = 0x14; /* Select continuous mode, 24MHz clock source, 2 pre-scale */ + H3_TIMER->IRQ_EN |= TIMER_IRQ_EN_TMR0; /* Enable Timer 0 Interrupts */ + IRQ_SetHandler(H3_TIMER0_IRQn, TIMER0_IRQHandler); + gic_irq_config(H3_TIMER0_IRQn, GIC_CORE0); + } else { + H3_TIMER->IRQ_EN &= ~TIMER_IRQ_EN_TMR0; /* Disable Timer 0 Interrupts */ + IRQ_SetHandler(H3_TIMER0_IRQn, nullptr); + } - if ((h3_timer0_func != NULL) && (irq == H3_TIMER0_IRQn)) { - TIMER0_IRQHandler(); - H3_GIC_CPUIF->AEOI = H3_TIMER0_IRQn; - H3_GIC_DIST->ICPEND[H3_TIMER0_IRQn / 32] = 1 << (H3_TIMER0_IRQn % 32); - } else if ((h3_timer1_func != NULL) && (irq == H3_TIMER1_IRQn)) { - TIMER1_IRQHandler(); - H3_GIC_CPUIF->AEOI = H3_TIMER1_IRQn; - H3_GIC_DIST->ICPEND[H3_TIMER1_IRQn / 32] = 1 << (H3_TIMER1_IRQn % 32); - } else if (irq == ARM_PHYSICAL_TIMER_IRQ) { - ARM_Physical_Timer_IRQHandler(); - H3_GIC_CPUIF->AEOI = ARM_PHYSICAL_TIMER_IRQ; - H3_GIC_DIST->ICPEND[ARM_PHYSICAL_TIMER_IRQ / 32] = 1 << (ARM_PHYSICAL_TIMER_IRQ % 32); - } else if (irq == ARM_VIRTUAL_TIMER_IRQ) { - ARM_Virtual_Timer_IRQHandler(); - H3_GIC_CPUIF->AEOI = ARM_VIRTUAL_TIMER_IRQ; - H3_GIC_DIST->ICPEND[ARM_VIRTUAL_TIMER_IRQ / 32] = 1 << (ARM_VIRTUAL_TIMER_IRQ % 32); + __ISB(); + return; } - __DMB(); + if (nIrqTimer == IRQ_TIMER_1) { + h3_timer1_func = func; + + if (func != nullptr) { + H3_TIMER->TMR1_CTRL = 0x14; /* Select continuous mode, 24MHz clock source, 2 pre-scale */ + H3_TIMER->IRQ_EN |= TIMER_IRQ_EN_TMR1; /* Enable Timer 1 Interrupts */ + IRQ_SetHandler(H3_TIMER1_IRQn, TIMER1_IRQHandler); + gic_irq_config(H3_TIMER1_IRQn, GIC_CORE0); + } else { + H3_TIMER->IRQ_EN &= ~TIMER_IRQ_EN_TMR1; /* Disable Timer 1 Interrupts */ + IRQ_SetHandler(H3_TIMER1_IRQn, nullptr); + } + + __ISB(); + return; + } + + assert(0); } void irq_timer_arm_physical_set(thunk_irq_timer_arm_t func) { arm_physical_timer_func = func; - if (func != NULL) { + if (func != nullptr) { __asm volatile ("mcr p15, 0, %0, c14, c2, 0" : : "r" (H3_F_24M)); __asm volatile ("mcr p15, 0, %0, c14, c2, 1" : : "r" (ARM_TIMER_ENABLE)); + IRQ_SetHandler(ARM_PHYSICAL_TIMER_IRQ, ARM_Physical_Timer_IRQHandler); gic_irq_config(ARM_PHYSICAL_TIMER_IRQ, GIC_CORE0); } else { __asm volatile ("mcr p15, 0, %0, c14, c2, 1" : : "r" (0)); + IRQ_SetHandler(ARM_PHYSICAL_TIMER_IRQ, nullptr); } __ISB(); @@ -133,69 +163,48 @@ void irq_timer_arm_virtual_set(thunk_irq_timer_arm_t func, uint32_t value) { arm_virtual_timer_func = func; timer_value = value; - if (func != NULL) { + if (func != nullptr) { __asm volatile ("mcr p15, 0, %0, c14, c3, 0" : : "r" (timer_value)); __asm volatile ("mcr p15, 0, %0, c14, c3, 1" : : "r" (ARM_TIMER_ENABLE)); + IRQ_SetHandler(ARM_VIRTUAL_TIMER_IRQ, ARM_Virtual_Timer_IRQHandler); gic_irq_config(ARM_VIRTUAL_TIMER_IRQ, GIC_CORE0); - - gic_irq_config(26, GIC_CORE0); - gic_irq_config(28, GIC_CORE0); + gic_irq_config(static_cast(26), GIC_CORE0); + gic_irq_config(static_cast(28), GIC_CORE0); } else { __asm volatile ("mcr p15, 0, %0, c14, c3, 1" : : "r" (0)); + IRQ_SetHandler(ARM_VIRTUAL_TIMER_IRQ, nullptr); } __ISB(); } -void irq_timer_set(_irq_timers timer, thunk_irq_timer_t func) { +#if !defined(CONFIG_SYSTEM_CMSIS_IRQ_HANDLER) +static void __attribute__((interrupt("IRQ"))) irq_timer_handler(void) { + __DMB(); - if (timer == IRQ_TIMER_0) { - h3_timer0_func = func; - if (func != NULL) { - H3_TIMER->TMR0_CTRL = 0x14; /* Select continuous mode, 24MHz clock source, 2 pre-scale */ - H3_TIMER->IRQ_EN |= TIMER_IRQ_EN_TMR0; /* Enable Timer 0 Interrupts */ - } else { - H3_TIMER->IRQ_EN &= ~TIMER_IRQ_EN_TMR0; /* Disable Timer 0 Interrupts */ - } - } else if (timer == IRQ_TIMER_1) { - h3_timer1_func = func; - if (func != NULL) { - H3_TIMER->TMR1_CTRL = 0x14; /* Select continuous mode, 24MHz clock source, 2 pre-scale */ - H3_TIMER->IRQ_EN |= TIMER_IRQ_EN_TMR1; /* Enable Timer 1 Interrupts */ - } else { - H3_TIMER->IRQ_EN &= ~TIMER_IRQ_EN_TMR1; /* Disable Timer 1 Interrupts */ - } + const auto irq = H3_GIC_CPUIF->AIA; + + if ((h3_timer0_func != NULL) && (irq == H3_TIMER0_IRQn)) { + TIMER0_IRQHandler(); + } else if ((h3_timer1_func != NULL) && (irq == H3_TIMER1_IRQn)) { + TIMER1_IRQHandler(); + } else if (irq == ARM_PHYSICAL_TIMER_IRQ) { + ARM_Physical_Timer_IRQHandler(); + } else if (irq == ARM_VIRTUAL_TIMER_IRQ) { + ARM_Virtual_Timer_IRQHandler(); } - __ISB(); + __DMB(); } -void __attribute__((cold)) irq_timer_init(void) { - arm_install_handler((unsigned) irq_timer_handler, ARM_VECTOR(ARM_VECTOR_IRQ)); - - gic_irq_config(H3_TIMER0_IRQn, GIC_CORE0); - gic_irq_config(H3_TIMER1_IRQn, GIC_CORE0); +void __attribute__((cold)) irq_handler_init(void) { + arm_install_handler(reinterpret_cast(irq_timer_handler), ARM_VECTOR(ARM_VECTOR_IRQ)); __enable_irq(); } #else -static void __attribute__((interrupt("IRQ"))) IRQ_Handler(void) { - const IRQn_ID_t irqn = IRQ_GetActiveIRQ(); - IRQHandler_t const handler = IRQ_GetHandler(irqn); - - if (handler != NULL) { - handler(); - } - - IRQ_EndOfInterrupt(irqn); -} - -void __attribute__((cold)) irq_timer_init(void) { - arm_install_handler((unsigned) IRQ_Handler, ARM_VECTOR(ARM_VECTOR_IRQ)); - - gic_irq_config(H3_TIMER0_IRQn, GIC_CORE0); - gic_irq_config(H3_TIMER1_IRQn, GIC_CORE0); - +void __attribute__((cold)) irq_handler_init() { __enable_irq(); + __DMB(); } #endif diff --git a/lib-hal/.cproject b/lib-hal/.cproject index 9bc94addb..fc3181e04 100644 --- a/lib-hal/.cproject +++ b/lib-hal/.cproject @@ -88,7 +88,7 @@ - + @@ -98,7 +98,6 @@ - @@ -106,12 +105,13 @@ - + + @@ -199,7 +199,7 @@ - + @@ -209,7 +209,6 @@ - @@ -219,6 +218,7 @@ + @@ -335,6 +335,7 @@ + @@ -352,6 +353,7 @@ + @@ -368,6 +370,7 @@ + @@ -397,7 +400,7 @@ - + @@ -405,7 +408,6 @@ - @@ -414,9 +416,10 @@ - + + diff --git a/lib-hal/.settings/language.settings.xml b/lib-hal/.settings/language.settings.xml index 5cc8b04c4..d7152ae63 100644 --- a/lib-hal/.settings/language.settings.xml +++ b/lib-hal/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-hal/Makefile.Linux b/lib-hal/Makefile.Linux index 2dc6b09b3..13b6b3fb8 100644 --- a/lib-hal/Makefile.Linux +++ b/lib-hal/Makefile.Linux @@ -2,6 +2,7 @@ EXTRA_INCLUDES=src/linux/minimum EXTRA_SRCDIR=src/linux/minimum +EXTRA_SRCDIR+=superloop EXTRA_SRCDIR+=debug diff --git a/lib-hal/Rules.mk b/lib-hal/Rules.mk index 0ae3fcecf..6f3ba79b7 100755 --- a/lib-hal/Rules.mk +++ b/lib-hal/Rules.mk @@ -47,6 +47,10 @@ ifneq ($(MAKE_FLAGS),) ifneq (,$(findstring DEBUG_STACK,$(MAKE_FLAGS))) EXTRA_SRCDIR+=debug/stack endif + + ifeq (,$(findstring USE_FREE_RTOS,$(MAKE_FLAGS))) + EXTRA_SRCDIR+=superloop + endif else DEFINES+=DEBUG_I2C DEBUG_STACK DEBUG_POSIX DEFINES+=LOGIC_ANALYZER @@ -54,5 +58,6 @@ else EXTRA_SRCDIR+=console/i2c console/null console/uart0 EXTRA_SRCDIR+=posix EXTRA_SRCDIR+=rtc rtc/i2c + EXTRA_SRCDIR+=superloop EXTRA_INCLUDES+=../lib-properties/include endif diff --git a/lib-hal/debug/i2c/i2cdetect.cpp b/lib-hal/debug/i2c/i2cdetect.cpp index ed496fb65..7cb3dceb1 100644 --- a/lib-hal/debug/i2c/i2cdetect.cpp +++ b/lib-hal/debug/i2c/i2cdetect.cpp @@ -2,7 +2,7 @@ * @file i2cdetect.cpp * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,11 +25,9 @@ #include -#include "i2cdetect.h" - #include "hal_i2c.h" -inline static bool i2c_is_connected(uint8_t nAddress) { +inline static bool i2c_is_connected(const uint8_t nAddress) { uint8_t nResult; char buffer; @@ -48,7 +46,8 @@ inline static bool i2c_is_connected(uint8_t nAddress) { static constexpr uint32_t FIRST = 0x03; static constexpr uint32_t LAST = 0x77; -I2cDetect::I2cDetect() { +void i2c_detect() { + FUNC_PREFIX(i2c_begin()); FUNC_PREFIX(i2c_set_baudrate(100000)); puts("\n 0 1 2 3 4 5 6 7 8 9 a b c d e f"); diff --git a/lib-hal/debug/i2c/i2cdetect.h b/lib-hal/debug/i2c/i2cdetect.h index 68bf63e77..a4dc9592b 100644 --- a/lib-hal/debug/i2c/i2cdetect.h +++ b/lib-hal/debug/i2c/i2cdetect.h @@ -2,7 +2,7 @@ * @file i2cdetect.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,9 +26,6 @@ #ifndef I2CDETECT_H_ #define I2CDETECT_H_ -class I2cDetect { -public: - I2cDetect(); -}; +void i2c_detect(); #endif /* I2CDETECT_H_ */ diff --git a/lib-hal/debug/stack/stack_debug.cpp b/lib-hal/debug/stack/stack_debug.cpp index 9a0dc231a..8ef751b8b 100755 --- a/lib-hal/debug/stack/stack_debug.cpp +++ b/lib-hal/debug/stack/stack_debug.cpp @@ -2,7 +2,7 @@ * @file stack_debug.cpp * */ -/* Copyright (C) 2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -78,7 +78,7 @@ void stack_debug_print() { #ifndef NDEBUG printf("Stack: Size %uKB, [%p:%p:%p], Used: %u, Free: %u [%u]", nSize / (1024 / 4), pStart, p, pEnd, nUsedBytes, nFreeBytes, nFreePct); #else - printf("Stack: Size %uKB, Used: %u, Free: %u", nSize / (1024 / 4), nUsedBytes, nFreeBytes); + printf("Stack: Size %uKB, Used: %u, Free: %u", nSize / (1024 / 4), nUsedBytes, nFreeBytes); #endif printf("\x1b[39m\n"); } diff --git a/lib-hal/include/gd32/hardware.h b/lib-hal/include/gd32/hardware.h index 98254b615..7a34deb0f 100644 --- a/lib-hal/include/gd32/hardware.h +++ b/lib-hal/include/gd32/hardware.h @@ -62,6 +62,10 @@ extern "C" { extern "C" void console_error(const char *); #endif +#if !defined(USE_FREE_RTOS) +# include "superloop/timers.h" +#endif + #include "panel_led.h" #include "debug.h" @@ -198,67 +202,6 @@ class Hardware { return m_Mode; } - struct Timer { - uint32_t nExpireTime; - uint32_t nIntervalMillis; - int32_t nId; - hal::TimerCallback callback; - }; - - int32_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const hal::TimerCallback callback) { - if (m_nTimersCount >= hal::SOFTWARE_TIMERS_MAX) { -#ifdef NDEBUG - console_error("SoftwareTimerAdd\n"); -#endif - return -1; - } - - const auto nCurrentTime = Hardware::Millis(); - - Timer newTimer = { - .nExpireTime = nCurrentTime + nIntervalMillis, - .nIntervalMillis = nIntervalMillis, - .nId = m_nNextId++, - .callback = callback, - }; - - m_Timers[m_nTimersCount++] = newTimer; - - return newTimer.nId; - } - - bool SoftwareTimerDelete(int32_t& nId) { - if (nId >= 0) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - for (uint32_t j = i; j < m_nTimersCount - 1; ++j) { - m_Timers[j] = m_Timers[j + 1]; - } - --m_nTimersCount; - nId = -1; - return true; - } - } - } - - return false; - } - - bool SoftwareTimerChange(const int32_t nId, const uint32_t nIntervalMillis) { - if (nId >= 0) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - m_Timers[i].nExpireTime = Hardware::Millis() + nIntervalMillis; - m_Timers[i].nIntervalMillis = nIntervalMillis; - - return true; - } - } - } - - return false; - } - void Run() { #if defined (ENABLE_USB_HOST) && defined (CONFIG_USB_HOST_MSC) # if defined (GD32H7XX) || defined (GD32F4XX) @@ -267,21 +210,13 @@ class Hardware { usbh_core_task(&usb_host); # endif #endif - const auto nCurrentTime = Hardware::Get()->Millis(); - - for (uint32_t i = 0; i < m_nTimersCount; i++) { - if (m_Timers[i].nExpireTime <= nCurrentTime) { - m_Timers[i].callback(); - m_Timers[i].nExpireTime = nCurrentTime + m_Timers[i].nIntervalMillis; - } - } - +#if !defined(USE_FREE_RTOS) + SoftwareTimerRun(); +#endif hal::panel_led_run(); - #if defined (DEBUG_STACK) stack_debug_run(); #endif - #if defined (DEBUG_EMAC) emac_debug_run(); #endif @@ -294,7 +229,7 @@ class Hardware { private: void RebootHandler(); - static void ledblink() { + static void ledblink([[maybe_unused]] TimerHandle_t nHandle) { #if defined(HAL_HAVE_PORT_BIT_TOGGLE) GPIO_TG(LED_BLINK_GPIO_PORT) = LED_BLINK_PIN; #else @@ -375,10 +310,6 @@ class Hardware { bool m_doLock { false }; int32_t m_nTimerId { -1 }; - Timer m_Timers[hal::SOFTWARE_TIMERS_MAX]; - uint32_t m_nTimersCount { 0 }; - int32_t m_nNextId { 0 }; - #if !defined(HAL_HAVE_PORT_BIT_TOGGLE) static inline int32_t m_nToggleLed { 1 }; #endif diff --git a/lib-hal/include/h3/hardware.h b/lib-hal/include/h3/hardware.h index 81b858ef6..d748e42c3 100644 --- a/lib-hal/include/h3/hardware.h +++ b/lib-hal/include/h3/hardware.h @@ -39,6 +39,8 @@ #include "h3_watchdog.h" #include "h3_thermal.h" +#include "superloop/timers.h" + #include "debug.h" #if defined (DEBUG_STACK) @@ -159,72 +161,8 @@ class Hardware { return m_Mode; } - struct Timer { - uint32_t nExpireTime; - uint32_t nIntervalMillis; - int32_t nId; - hal::TimerCallback callback; - }; - - int32_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const hal::TimerCallback callback) { - if (m_nTimersCount >= hal::SOFTWARE_TIMERS_MAX) { -#ifdef NDEBUG - console_error("SoftwareTimerAdd\n"); -#endif - return -1; - } - - const auto nCurrentTime = Hardware::Millis(); - - Timer newTimer = { - .nExpireTime = nCurrentTime + nIntervalMillis, - .nIntervalMillis = nIntervalMillis, - .nId = m_nNextId++, - .callback = callback, - }; - - m_Timers[m_nTimersCount++] = newTimer; - - return newTimer.nId; - } - - bool SoftwareTimerDelete(int32_t& nId) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - for (uint32_t j = i; j < m_nTimersCount - 1; ++j) { - m_Timers[j] = m_Timers[j + 1]; - } - --m_nTimersCount; - nId = -1; - return true; - } - } - - return false; - } - - bool SoftwareTimerChange(const int32_t nId, const uint32_t nIntervalMillis) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - m_Timers[i].nExpireTime = Hardware::Millis() + nIntervalMillis; - m_Timers[i].nIntervalMillis = nIntervalMillis; - return true; - } - } - - return false; - } - void Run() { - const auto nCurrentTime = Hardware::Get()->Millis(); - - for (uint32_t i = 0; i < m_nTimersCount; i++) { - if (m_Timers[i].nExpireTime <= nCurrentTime) { - m_Timers[i].callback(); - m_Timers[i].nExpireTime = nCurrentTime + m_Timers[i].nIntervalMillis; - } - } - + SoftwareTimerRun(); #if defined (DEBUG_STACK) stack_debug_run(); #endif @@ -237,7 +175,7 @@ class Hardware { private: void RebootHandler(); - static void ledblink() { + static void ledblink([[maybe_unused]] TimerHandle_t nHandle) { m_nToggleLed ^= 0x1; hardware_led_set(m_nToggleLed); } @@ -276,10 +214,6 @@ class Hardware { bool m_doLock { false }; int32_t m_nTimerId { -1 }; - Timer m_Timers[hal::SOFTWARE_TIMERS_MAX]; - uint32_t m_nTimersCount { 0 }; - int32_t m_nNextId { 0 }; - static inline int32_t m_nToggleLed { 0 }; static Hardware *s_pThis; }; diff --git a/lib-hal/include/hal_timers.h.template b/lib-hal/include/hal_timers.h.template deleted file mode 100755 index b50162319..000000000 --- a/lib-hal/include/hal_timers.h.template +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file hal_timers.h - * - */ -/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org - * - * 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. - */ - -#ifndef HAL_TIMERS_H_ -#define HAL_TIMERS_H_ - -#include - -#include "hardware.h" - -namespace hal { -#if !defined (CONFIG_HAL_TIMERS_COUNT) -# define CONFIG_HAL_TIMERS_COUNT 8 -#endif - -static constexpr uint32_t SOFTWARE_TIMERS_MAX = CONFIG_HAL_TIMERS_COUNT; - -typedef void (*TimerCallback)(); - - -class SoftwareTimer { -public: - struct Timer { - uint32_t nExpireTime; - uint32_t nIntervalMillis; - int32_t nId; - TimerCallback callback; - }; - - static SoftwareTimer& Get() { - static SoftwareTimer instance; - return instance; - } - - static int32_t Add(const uint32_t nIntervalMillis, const TimerCallback callback) { - return Get().IAdd(nIntervalMillis, callback); - } - - static bool Delete(const int32_t nId) { - return Get().IDelete(nId); - } - - static bool Change(const int32_t nId, const uint32_t nIntervalMillis) { - return Get().IChange(nId, nIntervalMillis); - } - - static void Run() { - Get().IRun(); - } - -private: - int32_t IAdd(const uint32_t nIntervalMillis, const TimerCallback callback) { - if (m_nTimersCount >= SOFTWARE_TIMERS_MAX) { -#ifdef NDEBUG - console_error("SoftwareTimerAdd\n"); -#endif - return -1; - } - - const auto nCurrentTime = Hardware::Millis(); - - Timer newTimer = { - .nExpireTime = nCurrentTime + nIntervalMillis, - .nIntervalMillis = nIntervalMillis, - .callback = callback, - .nId = m_nNextId++ - }; - - m_Timers[m_nTimersCount++] = newTimer; - - return newTimer.nId; - } - - bool IDelete(const int32_t nId) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - for (uint32_t j = i; j < m_nTimersCount - 1; ++j) { - m_Timers[j] = m_Timers[j + 1]; - } - --m_nTimersCount; - - return true; - } - } - - return false; - } - - bool IChange(const int32_t nId, const uint32_t nIntervalMillis) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - m_Timers[i].nExpireTime = Hardware::Millis() + nIntervalMillis; - m_Timers[i].nIntervalMillis = nIntervalMillis; - - return true; - } - } - - return false; - } - - void IRun() { - const auto nCurrentTime = Hardware::Millis(); - - for (uint32_t i = 0; i < m_nTimersCount; i++) { - if (m_Timers[i].nExpireTime <= nCurrentTime) { - m_Timers[i].callback(); - m_Timers[i].nExpireTime = nCurrentTime + m_Timers[i].nIntervalMillis; - } - } - } - -private: - Timer m_Timers[SOFTWARE_TIMERS_MAX]; - uint32_t m_nTimersCount; - int32_t m_nNextId; -}; - -} // namespace hal - -#endif /* HAL_TIMERS_H_ */ diff --git a/lib-hal/include/hardware.h b/lib-hal/include/hardware.h index e7a2d94d7..a648b101f 100644 --- a/lib-hal/include/hardware.h +++ b/lib-hal/include/hardware.h @@ -53,8 +53,6 @@ namespace hal { #endif static constexpr uint32_t SOFTWARE_TIMERS_MAX = CONFIG_HAL_TIMERS_COUNT; - -typedef void (*TimerCallback)(); } // namespace hal #if defined(__linux__) || defined (__APPLE__) diff --git a/lib-hal/include/hwclock.h b/lib-hal/include/hwclock.h index 01b2f5cd6..9333290a6 100644 --- a/lib-hal/include/hwclock.h +++ b/lib-hal/include/hwclock.h @@ -1,4 +1,3 @@ - /** * @file hwclock.h * diff --git a/lib-hal/include/linux/hardware.h b/lib-hal/include/linux/hardware.h index 268917ba2..2f9aa6a70 100644 --- a/lib-hal/include/linux/hardware.h +++ b/lib-hal/include/linux/hardware.h @@ -44,6 +44,8 @@ #include "linux/hal_api.h" +#include "superloop/timers.h" + namespace hardware { enum class LedStatus { OFF, ON, HEARTBEAT, FLASH @@ -118,71 +120,8 @@ class Hardware { return m_Mode; } - struct Timer { - uint32_t nExpireTime; - uint32_t nIntervalMillis; - int32_t nId; - hal::TimerCallback callback; - }; - - int32_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const hal::TimerCallback callback) { - if (m_nTimersCount >= hal::SOFTWARE_TIMERS_MAX) { -#ifdef NDEBUG - fprintf(stderr, "SoftwareTimerAdd\n"); -#endif - return -1; - } - - const auto nCurrentTime = Hardware::Millis(); - - Timer newTimer = { - .nExpireTime = nCurrentTime + nIntervalMillis, - .nIntervalMillis = nIntervalMillis, - .nId = m_nNextId++, - .callback = callback, - }; - - m_Timers[m_nTimersCount++] = newTimer; - - return newTimer.nId; - } - - bool SoftwareTimerDelete(int32_t& nId) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - for (uint32_t j = i; j < m_nTimersCount - 1; ++j) { - m_Timers[j] = m_Timers[j + 1]; - } - --m_nTimersCount; - nId = -1; - return true; - } - } - - return false; - } - - bool SoftwareTimerChange(const int32_t nId, const uint32_t nIntervalMillis) { - for (uint32_t i = 0; i < m_nTimersCount; ++i) { - if (m_Timers[i].nId == nId) { - m_Timers[i].nExpireTime = Hardware::Millis() + nIntervalMillis; - m_Timers[i].nIntervalMillis = nIntervalMillis; - return true; - } - } - - return false; - } - void Run() { - const auto nCurrentTime = Hardware::Get()->Millis(); - - for (uint32_t i = 0; i < m_nTimersCount; i++) { - if (m_Timers[i].nExpireTime <= nCurrentTime) { - m_Timers[i].callback(); - m_Timers[i].nExpireTime = nCurrentTime + m_Timers[i].nIntervalMillis; - } - } + SoftwareTimerRun(); } static Hardware *Get() { @@ -230,10 +169,6 @@ class Hardware { hardware::ledblink::Mode m_Mode { hardware::ledblink::Mode::UNKNOWN }; bool m_doLock { false }; - Timer m_Timers[hal::SOFTWARE_TIMERS_MAX]; - uint32_t m_nTimersCount { 0 }; - int32_t m_nNextId { 0 }; - static Hardware *s_pThis; }; diff --git a/lib-hal/include/superloop/timers.h b/lib-hal/include/superloop/timers.h new file mode 100755 index 000000000..76b473bc8 --- /dev/null +++ b/lib-hal/include/superloop/timers.h @@ -0,0 +1,40 @@ +/** + * @file timers.h + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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. + */ + +#ifndef HAL_SUPERLOOP_TIMERS_H_ +#define HAL_SUPERLOOP_TIMERS_H_ + +#include + +typedef int32_t TimerHandle_t; +typedef void (*TimerCallbackFunction_t)(TimerHandle_t); + +TimerHandle_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const TimerCallbackFunction_t callback); +bool SoftwareTimerDelete(TimerHandle_t& nId); +bool SoftwareTimerChange(const TimerHandle_t nId, const uint32_t nIntervalMillis); + +void SoftwareTimerRun(); + +#endif /* HAL_SUPERLOOP_TIMERS_H_ */ diff --git a/lib-hal/debug/h3/debug_exception.c b/lib-hal/include/timers.h similarity index 53% rename from lib-hal/debug/h3/debug_exception.c rename to lib-hal/include/timers.h index 0687db75d..15809052f 100755 --- a/lib-hal/debug/h3/debug_exception.c +++ b/lib-hal/include/timers.h @@ -1,8 +1,8 @@ /** - * @file debug_exception.c + * @file timers.h * */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,40 +23,13 @@ * THE SOFTWARE. */ -#include +#ifndef HAL_TIMERS_H_ +#define HAL_TIMERS_H_ -#include "console.h" - -#if defined (H3) -# include "h3.h" -#else -void bcm2835_watchdog_stop(void); -#endif - -void debug_exception(unsigned int type, unsigned int address) { - __sync_synchronize(); - - console_set_fg_color(CONSOLE_RED); - - if (type == 0) { - printf("\nUndefined exception at address: %p\n", (void *)address); - } else if (type == 1) { - printf("\nPrefetch abort at address: %p\n", (void *)address); - } else if (type == 2) { - volatile unsigned int datafaultaddr; - asm volatile ("mrc p15, 0, %[dfa], c6, c0, 0\n\t" : [dfa] "=r" (datafaultaddr)); - printf("\nData abort at address: %p -> %p\n", (void *)address, (void *)datafaultaddr); - } else { - printf("\nUnknown exception! [%u]\n", type); - } - - console_set_fg_color(CONSOLE_WHITE); - -#if defined (H3) - H3_TIMER->WDOG0_MODE = 0; +#if defined(USE_FREE_RTOS) +# include "../FreeRTOS/FreeRTOS-Kernel/include/timers.h" #else - bcm2835_watchdog_stop(); +# include "superloop/timers.h" #endif - for(;;); -} +#endif /* HAL_TIMERS_H_ */ diff --git a/lib-hal/src/h3/hardware.cpp b/lib-hal/src/h3/hardware.cpp index 29bec431c..972d8fbe7 100644 --- a/lib-hal/src/h3/hardware.cpp +++ b/lib-hal/src/h3/hardware.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_HAL) +# undef NDEBUG +#endif + #include #include #include @@ -32,10 +36,14 @@ #include "hardware.h" +#include "h3.h" #include "h3_watchdog.h" #include "h3_gpio.h" #include "h3_board.h" +#include "irq_timer.h" +#include "arm/arm.h" +#include "arm/gic.h" #include "arm/synchronize.h" #if defined (DEBUG_I2C) @@ -48,10 +56,53 @@ #include "logic_analyzer.h" +#pragma GCC push_options +#pragma GCC optimize ("O2") + +#if __GNUC__ > 8 +# pragma GCC target ("general-regs-only") +#endif + +static void EXTIA_IRQHandler() { + DEBUG_PUTS("EXTIA_IRQHandler"); + + H3_PIO_PA_INT->STA = ~0; +} + +static void EXTIG_IRQHandler() { + DEBUG_PUTS("EXTIG_IRQHandler"); + + H3_PIO_PG_INT->STA = ~0; +} + +static void __attribute__((interrupt("IRQ"))) IRQ_Handler() { + __DMB(); + + const auto nIRQ = GICInterface->AIAR; + IRQHandler_t const handler = IRQ_GetHandler(nIRQ); + + if (handler != nullptr) { + handler(); + } + + GICInterface->AEOIR = nIRQ; + const auto nIndex = nIRQ / 32; + const auto nMask = 1U << (nIRQ % 32); + GICDistributor->ICPENDR[nIndex] = nMask; + + __DMB(); +} + +#pragma GCC pop_options + namespace net { void net_shutdown(); } // namespace net +namespace hal { +void uuid_init(uuid_t); +} // namespace hardware + namespace soc { #if defined (ORANGE_PI) static constexpr char NAME[] = "H2+"; @@ -79,10 +130,6 @@ namespace sysname { static constexpr auto NAME_LENGTH = sizeof(NAME) - 1; } -namespace hal { -void uuid_init(uuid_t); -} // namespace hardware - Hardware *Hardware::s_pThis; void hardware_init(); @@ -95,7 +142,7 @@ Hardware::Hardware() { hal::uuid_init(m_uuid); #if defined (DEBUG_I2C) - I2cDetect i2cdetect; + i2c_detect(); #endif #if !defined(DISABLE_RTC) @@ -107,6 +154,14 @@ Hardware::Hardware() { hardware_led_set(1); logic_analyzer::init(); + + IRQ_SetHandler(H3_PA_EINT_IRQn, EXTIA_IRQHandler); +// gic_irq_config(H3_PA_EINT_IRQn, GIC_CORE0); +// + IRQ_SetHandler(H3_PG_EINT_IRQn, EXTIG_IRQHandler); +// gic_irq_config(H3_PG_EINT_IRQn, GIC_CORE0); + + arm_install_handler((unsigned) IRQ_Handler, ARM_VECTOR(ARM_VECTOR_IRQ)); } const char *Hardware::GetMachine(uint8_t &nLength) { diff --git a/lib-hal/src/linux/console_status.c b/lib-hal/src/linux/console.c similarity index 88% rename from lib-hal/src/linux/console_status.c rename to lib-hal/src/linux/console.c index fdecb2997..3a37adc87 100644 --- a/lib-hal/src/linux/console_status.c +++ b/lib-hal/src/linux/console.c @@ -1,8 +1,8 @@ /** - * @file console_status.c + * @file console.c * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 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 @@ -29,3 +29,7 @@ void console_status(__attribute__((unused)) uint32_t color, const char *s) { puts(s); } + +void console_error(const char *s) { + fprintf(stderr, "%s", s); +} diff --git a/lib-hal/superloop/timers.cpp b/lib-hal/superloop/timers.cpp new file mode 100755 index 000000000..29ebcd70b --- /dev/null +++ b/lib-hal/superloop/timers.cpp @@ -0,0 +1,120 @@ +/** + * @file timers.cpp + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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(DEBUG_HAL_TIMERS) +# undef NDEBUG +#endif + +#if !defined (CONFIG_REMOTECONFIG_MINIMUM) +# pragma GCC push_options +# pragma GCC optimize ("O2") +#endif + +#include + +#include "superloop/timers.h" +#include "hardware.h" + +extern "C" void console_error(const char *); + +struct Timer { + uint32_t nExpireTime; + uint32_t nIntervalMillis; + int32_t nId; + TimerCallbackFunction_t pCallbackFunction; +}; + +static Timer m_Timers[hal::SOFTWARE_TIMERS_MAX]; +static uint32_t m_nTimersCount; +static int32_t m_nNextId; + +TimerHandle_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const TimerCallbackFunction_t pCallbackFunction) { + if (m_nTimersCount >= hal::SOFTWARE_TIMERS_MAX) { +#ifdef NDEBUG + console_error("SoftwareTimerAdd: Max timer limit reached\n"); +#endif + return -1; + } + + const auto nCurrentTime = Hardware::Get()->Millis(); + // TODO Prevent potential overflow when calculating expiration time. + + Timer newTimer = { + .nExpireTime = nCurrentTime + nIntervalMillis, + .nIntervalMillis = nIntervalMillis, + .nId = m_nNextId++, + .pCallbackFunction = pCallbackFunction, + }; + + m_Timers[m_nTimersCount++] = newTimer; + + return newTimer.nId; +} + +bool SoftwareTimerDelete(TimerHandle_t& nId) { + for (uint32_t i = 0; i < m_nTimersCount; ++i) { + if (m_Timers[i].nId == nId) { + // Swap with the last timer to efficiently remove the current timer + m_Timers[i] = m_Timers[m_nTimersCount - 1]; + --m_nTimersCount; + nId = -1; + return true; + } + } + +#ifndef NDEBUG + console_error("SoftwareTimerDelete: Timer not found\n"); +#endif + + return false; +} + +bool SoftwareTimerChange(const TimerHandle_t nId, const uint32_t nIntervalMillis) { + for (uint32_t i = 0; i < m_nTimersCount; ++i) { + if (m_Timers[i].nId == nId) { + const auto nCurrentTime = Hardware::Get()->Millis(); + m_Timers[i].nExpireTime = nCurrentTime + nIntervalMillis; + m_Timers[i].nIntervalMillis = nIntervalMillis; + return true; + } + } + +#ifndef NDEBUG + console_error("SoftwareTimerChange: Timer not found\n"); +#endif + + return false; +} + +void SoftwareTimerRun() { + const auto nCurrentTime = Hardware::Get()->Millis(); + + for (uint32_t i = 0; i < m_nTimersCount; i++) { + if (m_Timers[i].nExpireTime <= nCurrentTime) { + m_Timers[i].pCallbackFunction(m_Timers[i].nId); + m_Timers[i].nExpireTime = nCurrentTime + m_Timers[i].nIntervalMillis; + } + } +} From 3e285d9dd66b69c4dc5783c3b8c55e08a82c032c Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:07:52 +0200 Subject: [PATCH 06/36] Introduced callback handler for UDP packets Removed Run() for: - MDNS - DmxConfigUdp - TFTPDaemon --- lib-artnet/include/artnetnode.h | 10 - lib-display/.cproject | 238 +++++++++++----- lib-display/.settings/language.settings.xml | 16 +- lib-display/Makefile.H3 | 12 + lib-display/Rules.mk | 7 +- lib-display/include/display.h | 2 +- lib-display/include/i2c/display.h | 31 +-- lib-display/include/spi/display.h | 19 +- lib-display/src/arm/gd32/display.cpp | 73 +++++ lib-display/src/arm/h3/display.cpp | 63 +++++ lib-display/src/i2c/display.cpp | 18 +- lib-display/src/sleep/display.cpp | 63 +++++ lib-display/src/spi/display.cpp | 6 +- lib-dmx/include/dmxconfigudp.h | 160 +++++++---- lib-midi/include/applemidi.h | 9 +- lib-midi/src/arm/midi.cpp | 73 +++-- lib-midi/src/net/applemidi.cpp | 2 +- lib-network/.settings/language.settings.xml | 4 +- lib-network/include/emac/network.h | 11 +- lib-network/include/linux/minimum/network.h | 7 +- lib-network/include/linux/network.h | 8 +- lib-network/include/net.h | 15 +- lib-network/include/net/apps/mdns.h | 58 +--- lib-network/include/net/apps/tftpdaemon.h | 8 +- lib-network/include/net/dhcp.h | 13 +- lib-network/include/net/protocol/ieee.h | 4 +- lib-network/include/net/protocol/tcp.h | 2 - lib-network/include/net/protocol/udp.h | 1 + lib-network/include/networkparams.h | 8 +- lib-network/src/emac/gd32/f/net.cpp | 72 ++--- lib-network/src/emac/gd32/h/net.cpp | 84 +++--- lib-network/src/emac/gd32/net_link_check.cpp | 2 +- lib-network/src/emac/h3/net.cpp | 15 +- lib-network/src/emac/network.cpp | 24 +- lib-network/src/linux/network.cpp | 2 +- lib-network/src/net/acd.cpp | 28 +- lib-network/src/net/apps/mdns/mdns.cpp | 258 ++++++++++-------- lib-network/src/net/apps/ntp/ntpclient.cpp | 6 +- lib-network/src/net/apps/tftp/tftpdaemon.cpp | 165 ++++++----- lib-network/src/net/arp.cpp | 6 +- lib-network/src/net/autoip.cpp | 3 + lib-network/src/net/dhcp.cpp | 35 ++- lib-network/src/net/igmp.cpp | 8 +- lib-network/src/net/ip.cpp | 32 --- lib-network/src/net/net.cpp | 36 ++- lib-network/src/net/net_chksum.cpp | 8 +- lib-network/src/net/net_platform.h | 9 + lib-network/src/net/net_private.h | 2 +- lib-network/src/net/netif.cpp | 3 + lib-network/src/net/tcp.cpp | 6 +- lib-network/src/net/udp.cpp | 50 ++-- lib-network/src/params/networkparams.cpp | 12 - lib-remoteconfig/include/remoteconfig.h | 25 +- lib-remoteconfig/src/httpd/httpd.cpp | 8 +- .../src/httpd/httpdhandlerequest.cpp | 8 +- lib-remoteconfig/src/remoteconfig.cpp | 29 +- lib-remoteconfig/src/shell/shellcmd.cpp | 2 +- lib-remoteconfig/src/tftp/remoteconfig.cpp | 6 +- lib-remoteconfig/src/tftp/tftpfileserver.cpp | 6 +- 59 files changed, 1172 insertions(+), 719 deletions(-) create mode 100644 lib-display/src/arm/gd32/display.cpp create mode 100755 lib-display/src/arm/h3/display.cpp create mode 100755 lib-display/src/sleep/display.cpp diff --git a/lib-artnet/include/artnetnode.h b/lib-artnet/include/artnetnode.h index 566fc61cd..6a780bddb 100755 --- a/lib-artnet/include/artnetnode.h +++ b/lib-artnet/include/artnetnode.h @@ -246,10 +246,6 @@ class ArtNetNode { #endif } } - -#if defined (DMXCONFIGUDP_H) - m_DmxConfigUdp.Run(); -#endif } #if defined (ARTNET_SHOWFILE) @@ -461,12 +457,6 @@ class ArtNetNode { #if defined (ARTNET_HAVE_TIMECODE) void SendTimeCode(const struct artnet::TimeCode *pArtNetTimeCode) { assert(pArtNetTimeCode != nullptr); - assert(pArtNetTimeCode->Frames < 30); - assert(pArtNetTimeCode->Hours < 60); - assert(pArtNetTimeCode->Minutes < 60); - assert(pArtNetTimeCode->Seconds < 60); - assert(pArtNetTimeCode->Type < 4); - memcpy(&m_ArtTimeCode.Frames, pArtNetTimeCode, sizeof(struct artnet::TimeCode)); Network::Get()->SendTo(m_nHandle, &m_ArtTimeCode, sizeof(struct artnet::ArtTimeCode), m_Node.IPAddressTimeCode, artnet::UDP_PORT); } diff --git a/lib-display/.cproject b/lib-display/.cproject index a91552d0d..7bbb68379 100755 --- a/lib-display/.cproject +++ b/lib-display/.cproject @@ -5,7 +5,6 @@ - @@ -31,7 +30,6 @@ - @@ -47,7 +45,6 @@ - @@ -72,8 +69,11 @@ - + + + + @@ -84,7 +84,6 @@ - @@ -110,7 +109,6 @@ - @@ -125,7 +123,6 @@ - @@ -151,19 +148,22 @@ - + + + + - - + + - + @@ -172,70 +172,174 @@ - - - - @@ -269,7 +373,13 @@ - + + + + + + + @@ -281,13 +391,13 @@ - + - + - + diff --git a/lib-display/.settings/language.settings.xml b/lib-display/.settings/language.settings.xml index b30fd3a92..8190dcd7d 100755 --- a/lib-display/.settings/language.settings.xml +++ b/lib-display/.settings/language.settings.xml @@ -4,8 +4,8 @@ - - + + @@ -17,22 +17,22 @@ - + - + - - - - + + + + diff --git a/lib-display/Makefile.H3 b/lib-display/Makefile.H3 index 58e7b62e2..0ea7de690 100644 --- a/lib-display/Makefile.H3 +++ b/lib-display/Makefile.H3 @@ -2,5 +2,17 @@ DEFINES=NDEBUG EXTRA_INCLUDES= +ifneq ($(MAKE_FLAGS),) + ifneq (,$(findstring CONFIG_DISPLAY_USE_SPI,$(MAKE_FLAGS))) + else + ifneq (,$(findstring CONFIG_DISPLAY_USE_CUSTOM,$(MAKE_FLAGS))) + else + EXTRA_SRCDIR+=src/arm/h3 + endif + endif +else + EXTRA_SRCDIR+=src/arm/h3 +endif + include Rules.mk include ../firmware-template-h3/lib/Rules.mk diff --git a/lib-display/Rules.mk b/lib-display/Rules.mk index 71e8f49cf..ebd1d1c4b 100644 --- a/lib-display/Rules.mk +++ b/lib-display/Rules.mk @@ -1,15 +1,14 @@ ifneq ($(MAKE_FLAGS),) ifneq (,$(findstring CONFIG_DISPLAY_USE_SPI,$(MAKE_FLAGS))) - EXTRA_SRCDIR+=src/spi + EXTRA_SRCDIR+=src/spi src/sleep else ifneq (,$(findstring CONFIG_DISPLAY_USE_CUSTOM,$(MAKE_FLAGS))) else - EXTRA_SRCDIR+=src/i2c + EXTRA_SRCDIR+=src/i2c src/sleep endif endif else DEFINES+=CONFIG_DISPLAY_ENABLE_CURSOR_MODE DEFINES+=CONFIG_DISPLAY_FIX_FLIP_VERTICALLY - DEFINES+=CONFIG_DISPLAY_ENABLE_RUN - EXTRA_SRCDIR+=src/i2c + EXTRA_SRCDIR+=src/i2c src/sleep endif diff --git a/lib-display/include/display.h b/lib-display/include/display.h index ab4d374b2..f4ef355b9 100644 --- a/lib-display/include/display.h +++ b/lib-display/include/display.h @@ -32,7 +32,7 @@ namespace display { struct Defaults { - static constexpr uint32_t SEEP_TIMEOUT = 5; + static constexpr uint32_t SLEEP_TIMEOUT = 5; }; } // namespace display diff --git a/lib-display/include/i2c/display.h b/lib-display/include/i2c/display.h index 24f7671d0..65a90fbb8 100644 --- a/lib-display/include/i2c/display.h +++ b/lib-display/include/i2c/display.h @@ -211,14 +211,6 @@ class Display { m_LcdDisplay->SetCursorPos(nCol, nRow); } - void SetSleepTimeout(uint32_t nSleepTimeout = display::Defaults::SEEP_TIMEOUT) { - m_nSleepTimeout = 1000U * 60U * nSleepTimeout; - } - - uint32_t GetSleepTimeout() const { - return m_nSleepTimeout / 1000U / 60U; - } - void SetContrast(uint8_t nContrast) { m_nContrast = nContrast; @@ -293,7 +285,7 @@ class Display { m_LcdDisplay->SetSleep(bSleep); if (!bSleep) { - m_nMillis = Hardware::Get()->Millis(); + SetSleepTimer(m_nSleepTimeout != 0); } } @@ -301,16 +293,21 @@ class Display { return m_bIsSleep; } + void SetSleepTimeout(uint32_t nSleepTimeout = display::Defaults::SLEEP_TIMEOUT) { + m_nSleepTimeout = 1000U * 60U * nSleepTimeout; + SetSleepTimer(m_nSleepTimeout != 0); + } + + uint32_t GetSleepTimeout() const { + return m_nSleepTimeout / 1000U / 60U; + } + void Run() { if (m_nSleepTimeout == 0) { return; } - if (!m_bIsSleep) { - if (__builtin_expect(((Hardware::Get()->Millis() - m_nMillis) > m_nSleepTimeout), 0)) { - SetSleep(true); - } - } else { + if (m_bIsSleep) { #if defined (DISPLAYTIMEOUT_GPIO) if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == LOW)), 0)) { SetSleep(false); @@ -319,19 +316,19 @@ class Display { } } - static Display* Get() { + static Display *Get() { return s_pThis; } private: void Detect(display::Type tDisplayType); void Detect(uint32_t nRows); + void SetSleepTimer(const bool bActive); private: display::Type m_tType { display::Type::UNKNOWN }; - uint32_t m_nMillis { 0 }; HAL_I2C m_I2C; - uint32_t m_nSleepTimeout { 1000 * 60 * display::Defaults::SEEP_TIMEOUT }; + uint32_t m_nSleepTimeout { 1000 * 60 * display::Defaults::SLEEP_TIMEOUT }; uint8_t m_nContrast { 0x7F }; bool m_bIsSleep { false }; diff --git a/lib-display/include/spi/display.h b/lib-display/include/spi/display.h index 0db5ee376..9d4080875 100644 --- a/lib-display/include/spi/display.h +++ b/lib-display/include/spi/display.h @@ -190,7 +190,7 @@ class Display { SpiLcd.EnableSleep(bSleep); if (!bSleep) { - m_nMillis = Hardware::Get()->Millis(); + SetSleepTimer(m_nSleepTimeout != 0); } } @@ -198,8 +198,9 @@ class Display { return m_bIsSleep; } - void SetSleepTimeout(uint32_t nSleepTimeout = display::Defaults::SEEP_TIMEOUT) { + void SetSleepTimeout(uint32_t nSleepTimeout = display::Defaults::SLEEP_TIMEOUT) { m_nSleepTimeout = 1000U * 60U * nSleepTimeout; + SetSleepTimer(m_nSleepTimeout != 0); } uint32_t GetSleepTimeout() const { @@ -231,11 +232,7 @@ class Display { return; } - if (!m_bIsSleep) { - if (__builtin_expect(((Hardware::Get()->Millis() - m_nMillis) > m_nSleepTimeout), 0)) { - SetSleep(true); - } - } else { + if (m_bIsSleep) { #if defined (DISPLAYTIMEOUT_GPIO) if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == LOW)), 0)) { SetSleep(false); @@ -244,10 +241,13 @@ class Display { } } - static Display* Get() { + static Display *Get() { return s_pThis; } +private: + void SetSleepTimer(const bool bActive); + private: #if defined (CONFIG_USE_ILI9341) ILI9341 SpiLcd; @@ -256,8 +256,7 @@ class Display { #endif uint32_t m_nCols; uint32_t m_nRows; - uint32_t m_nSleepTimeout { 1000U * 60U * display::Defaults::SEEP_TIMEOUT }; - uint32_t m_nMillis { 0 }; + uint32_t m_nSleepTimeout { 1000U * 60U * display::Defaults::SLEEP_TIMEOUT }; bool m_bIsFlippedVertically { false }; bool m_bIsSleep { false }; diff --git a/lib-display/src/arm/gd32/display.cpp b/lib-display/src/arm/gd32/display.cpp new file mode 100644 index 000000000..37481784d --- /dev/null +++ b/lib-display/src/arm/gd32/display.cpp @@ -0,0 +1,73 @@ +/** + * @file display.cpp + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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 (DEBUG_DISPLAY) +# undef NDEBUG +#endif + +#include +#include + +#include "display.h" + +#include "gd32.h" +#include "gd32_gpio.h" + +#include "debug.h" + +#if defined (DISPLAYTIMEOUT_CONFIG_IRQ) && !defined (CONFIG_USE_EXTI10_15_IRQHandler) +extern "C" { +void DISPLAYTIMEOUT_IRQ_HANDLE() { + if (RESET != exti_interrupt_flag_get(DISPLAYTIMEOUT_EXTI_LINE)) { + exti_interrupt_flag_clear(DISPLAYTIMEOUT_EXTI_LINE); + Display::Get()->SetSleep(false); + DEBUG_PUTS("Key pressed."); + } +} +} +#endif + +namespace display::timeout { +void irq_init() { +#if defined (DISPLAYTIMEOUT_CONFIG_IRQ) && !defined (CONFIG_USE_EXTI10_15_IRQHandler) + DEBUG_ENTRY + + rcu_periph_clock_enable(DISPLAYTIMEOUT_GPIO_CLK); + DISPLAYTIMEOUT_GPIO_CONFIG; + + rcu_periph_clock_enable(DISPLAYTIMEOUT_EXTI_CLK); + + NVIC_SetPriority(DISPLAYTIMEOUT_EXTI_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); // Lowest priority + NVIC_EnableIRQ(DISPLAYTIMEOUT_EXTI_IRQn); + + DISPLAYTIMEOUT_EXTI_SOURCE_CONFIG(DISPLAYTIMEOUT_EXTI_PORT_SOURCE, DISPLAYTIMEOUT_EXTI_PIN_SOURCE); + + exti_init(DISPLAYTIMEOUT_EXTI_LINE, EXTI_INTERRUPT, EXTI_TRIG_FALLING); + exti_interrupt_flag_clear(DISPLAYTIMEOUT_EXTI_LINE); + + DEBUG_EXIT +#endif +} +} // namespace display::timeout diff --git a/lib-display/src/arm/h3/display.cpp b/lib-display/src/arm/h3/display.cpp new file mode 100755 index 000000000..c018e5a3d --- /dev/null +++ b/lib-display/src/arm/h3/display.cpp @@ -0,0 +1,63 @@ +/** + * @file display.cpp + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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 (DEBUG_DISPLAY) +# undef NDEBUG +#endif + +#include + +#include "h3.h" +#include "h3_board.h" +#include "h3_gpio.h" + +#include "debug.h" + +namespace display::timeout { +#define GPIO_PORTx (H3_GPIO_TO_PORT(DISPLAYTIMEOUT_GPIO)) +#define INT_MASK (1U << H3_GPIO_TO_NUMBER(DISPLAYTIMEOUT_GPIO)) + + void irq_init() { + DEBUG_ENTRY + DEBUG_PRINTF("GPIO_PORTx=%u, INT_MASK=0x%x", GPIO_PORTx, INT_MASK); +#if 0 + h3_gpio_fsel(DISPLAYTIMEOUT_GPIO, GPIO_FSEL_EINT); + h3_gpio_int_cfg(DISPLAYTIMEOUT_GPIO, GPIO_INT_CFG_NEG_EDGE); + + if constexpr (GPIO_PORTx == H3_GPIO_PORTA) { + H3_PIO_PA_INT->STA = INT_MASK; + H3_PIO_PA_INT->CTL |= INT_MASK; + H3_PIO_PA_INT->DEB = (0x0 << 0) | (0x7U << 4); + } else if constexpr (GPIO_PORTx == H3_GPIO_PORTG) { + H3_PIO_PG_INT->STA = INT_MASK; + H3_PIO_PG_INT->CTL |= INT_MASK; + H3_PIO_PG_INT->DEB = (0x0 << 0) | (0x7U << 4); + } else { + static_assert("IRQ is not available"); + } +#endif + DEBUG_EXIT + } +} // namespace display::timeout diff --git a/lib-display/src/i2c/display.cpp b/lib-display/src/i2c/display.cpp index ba2efcb1a..aa3325841 100644 --- a/lib-display/src/i2c/display.cpp +++ b/lib-display/src/i2c/display.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAY) +# undef NDEBUG +#endif + #include #include @@ -40,20 +44,20 @@ #include "hal_i2c.h" #include "hal_gpio.h" -namespace display { -namespace timeout { +namespace display::timeout { +void irq_init(); static void gpio_init() { #if defined (DISPLAYTIMEOUT_GPIO) FUNC_PREFIX(gpio_fsel(DISPLAYTIMEOUT_GPIO, GPIO_FSEL_INPUT)); FUNC_PREFIX(gpio_set_pud(DISPLAYTIMEOUT_GPIO, GPIO_PULL_UP)); + irq_init(); #endif } -} // namespace timeout -} // namespace display +} // namespace display::timeout Display *Display::s_pThis; -Display::Display() : m_nMillis(Hardware::Get()->Millis()), m_I2C(display::segment7::I2C_ADDRESS) { +Display::Display() : m_I2C(display::segment7::I2C_ADDRESS) { assert(s_pThis == nullptr); s_pThis = this; @@ -72,7 +76,7 @@ Display::Display() : m_nMillis(Hardware::Get()->Millis()), m_I2C(display::segmen PrintInfo(); } -Display::Display(uint32_t nRows) : m_nMillis(Hardware::Get()->Millis()), m_I2C(display::segment7::I2C_ADDRESS) { +Display::Display(uint32_t nRows) : m_I2C(display::segment7::I2C_ADDRESS) { assert(s_pThis == nullptr); s_pThis = this; @@ -85,7 +89,7 @@ Display::Display(uint32_t nRows) : m_nMillis(Hardware::Get()->Millis()), m_I2C(d PrintInfo(); } -Display::Display(display::Type type): m_tType(type), m_nMillis(Hardware::Get()->Millis()), m_I2C(display::segment7::I2C_ADDRESS) { +Display::Display(display::Type type): m_tType(type), m_I2C(display::segment7::I2C_ADDRESS) { assert(s_pThis == nullptr); s_pThis = this; diff --git a/lib-display/src/sleep/display.cpp b/lib-display/src/sleep/display.cpp new file mode 100755 index 000000000..80db81472 --- /dev/null +++ b/lib-display/src/sleep/display.cpp @@ -0,0 +1,63 @@ +/** + * @file display.cpp + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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 (DEBUG_DISPLAY) +# undef NDEBUG +#endif + +#include +#include + +#include "display.h" + +#include "timers.h" + +#include "debug.h" + +static int32_t s_nTimerId = -1; + +static void sleep_timer([[maybe_unused]] TimerHandle_t nHandle) { + Display::Get()->SetSleep(true); + SoftwareTimerDelete(s_nTimerId); +} + +void Display::SetSleepTimer(const bool bActive) { + DEBUG_ENTRY + + if (!bActive) { + SoftwareTimerDelete(s_nTimerId); + DEBUG_EXIT + return; + } + + if (s_nTimerId < 0) { + s_nTimerId = SoftwareTimerAdd(m_nSleepTimeout, sleep_timer); + DEBUG_EXIT + return; + } + + SoftwareTimerChange(s_nTimerId, m_nSleepTimeout); + DEBUG_EXIT +} diff --git a/lib-display/src/spi/display.cpp b/lib-display/src/spi/display.cpp index 33018c23b..3fd3fd9c4 100644 --- a/lib-display/src/spi/display.cpp +++ b/lib-display/src/spi/display.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAY) +# undef NDEBUG +#endif + #include #include @@ -47,7 +51,7 @@ static constexpr auto COLOR_FOREGROUND = 0xFFE0; Display *Display::s_pThis; -Display::Display() : m_nMillis(Hardware::Get()->Millis()) { +Display::Display() { DEBUG_ENTRY assert(s_pThis == nullptr); diff --git a/lib-dmx/include/dmxconfigudp.h b/lib-dmx/include/dmxconfigudp.h index a0b928310..89fb79eeb 100755 --- a/lib-dmx/include/dmxconfigudp.h +++ b/lib-dmx/include/dmxconfigudp.h @@ -42,101 +42,147 @@ */ namespace dmxconfigudp { -static constexpr uint32_t MIN_SIZE = 10U; -static constexpr uint32_t MAX_SIZE = 16U; -static constexpr uint16_t UDP_PORT = 5120U; +static constexpr uint32_t MIN_SIZE = 10; +static constexpr uint32_t MAX_SIZE = 16; +static constexpr uint16_t UDP_PORT = 5120; + +static constexpr const char CMD_BREAK[] = "break#"; +static constexpr uint32_t CMD_BREAK_LENGTH = sizeof(CMD_BREAK) - 1U; // Exclude null terminator + +static constexpr const char CMD_MAB[] = "mab#"; +static constexpr uint32_t CMD_MAB_LENGTH = sizeof(CMD_MAB) - 1U; + +static constexpr const char CMD_REFRESH[] = "refresh#"; +static constexpr uint32_t CMD_REFRESH_LENGTH = sizeof(CMD_REFRESH) - 1U; + +static constexpr const char CMD_SLOTS[] = "slots#"; +static constexpr uint32_t CMD_SLOTS_LENGTH = sizeof(CMD_SLOTS) - 1U; + template static constexpr bool validate(const T& n, const T& min, const T& max) { return (n >= min) && (n <= max); } -static uint32_t atoi(const char *pBuffer, uint32_t nSize) { - assert(pBuffer != nullptr); - assert(nSize <= 7); // 1000000 - - const char *p = pBuffer; - uint32_t res = 0; - for (; (nSize > 0) && (*p >= '0' && *p <= '9'); nSize--) { - res = res * 10 + static_cast(*p - '0'); - p++; - } - - return res; +inline uint32_t atoi(const char *pBuffer, const uint32_t nSize) { + uint32_t nResult = 0; + for (uint32_t i = 0; i < nSize && pBuffer[i] >= '0' && pBuffer[i] <= '9'; ++i) { + nResult = nResult * 10 + static_cast(pBuffer[i] - '0'); + } + return nResult; } } // namespace dmxconfigudp class DmxConfigUdp { public: DmxConfigUdp() { + DEBUG_ENTRY + + assert(s_pThis == nullptr); + s_pThis = this; + assert(s_nHandle == -1); - s_nHandle = Network::Get()->Begin(dmxconfigudp::UDP_PORT); + s_nHandle = Network::Get()->Begin(dmxconfigudp::UDP_PORT, DmxConfigUdp::staticCallbackFunction); + + DEBUG_EXIT } ~DmxConfigUdp() { assert(s_nHandle != -1); Network::Get()->End(dmxconfigudp::UDP_PORT); s_nHandle = -1; + + s_pThis = nullptr; + + DEBUG_EXIT } - void Run() { - uint32_t nIPAddressFrom; - uint16_t nForeignPort; - auto nBytesReceived = Network::Get()->RecvFrom(s_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &nIPAddressFrom, &nForeignPort); + void Input(const uint8_t *pBuffer, uint32_t nSize, [[maybe_unused]] uint32_t nFromIp, [[maybe_unused]] uint16_t nFromPort) { + DEBUG_ENTRY - if (__builtin_expect((!dmxconfigudp::validate(nBytesReceived, dmxconfigudp::MIN_SIZE, dmxconfigudp::MAX_SIZE)), 1)) { + if (!dmxconfigudp::validate(nSize, dmxconfigudp::MIN_SIZE, dmxconfigudp::MAX_SIZE)) { + DEBUG_EXIT return; } - if (memcmp("dmx!", s_pUdpBuffer, 4) != 0) { + if (memcmp("dmx!", pBuffer, 4) != 0) { + DEBUG_EXIT return; } - if (s_pUdpBuffer[nBytesReceived - 1] == '\n') { - nBytesReceived--; + if (pBuffer[nSize - 1] == '\n') { + nSize--; } - DEBUG_PRINTF("nBytesReceived=%u", nBytesReceived); + DEBUG_PRINTF("nSize=%u", nSize); - const auto *pCmd = &s_pUdpBuffer[4]; + struct CommandHandler { + const char *command; + const uint32_t commandLength; + void (DmxConfigUdp::*handler)(const uint8_t *, const uint32_t); + }; - if (dmxconfigudp::validate(nBytesReceived, static_cast(12), static_cast(13)) && (memcmp("break#", pCmd, 6) == 0)) { - const auto nBreakTime = dmxconfigudp::atoi(reinterpret_cast(&s_pUdpBuffer[10]), nBytesReceived - 10U); - if (nBreakTime >= dmx::transmit::BREAK_TIME_MIN) { - Dmx::Get()->SetDmxBreakTime(nBreakTime); - } - return; - } + constexpr CommandHandler commandHandlers[] = { + {dmxconfigudp::CMD_BREAK, dmxconfigudp::CMD_BREAK_LENGTH, &DmxConfigUdp::HandleBreak}, + {dmxconfigudp::CMD_MAB, dmxconfigudp::CMD_MAB_LENGTH, &DmxConfigUdp::HandleMab}, + {dmxconfigudp::CMD_REFRESH, dmxconfigudp::CMD_REFRESH_LENGTH, &DmxConfigUdp::HandleRefresh}, + {dmxconfigudp::CMD_SLOTS, dmxconfigudp::CMD_SLOTS_LENGTH, &DmxConfigUdp::HandleSlots} + }; - if (dmxconfigudp::validate(nBytesReceived, static_cast(10), static_cast(16)) && (memcmp("mab#", pCmd, 4) == 0)) { - const auto nMapTime = dmxconfigudp::atoi(reinterpret_cast(&s_pUdpBuffer[8]), nBytesReceived - 8U); - if (dmxconfigudp::validate(nMapTime, dmx::transmit::MAB_TIME_MIN, dmx::transmit::MAB_TIME_MAX)) { - Dmx::Get()->SetDmxMabTime(nMapTime); - } - return; - } + for (const auto& handler : commandHandlers) { + if (memcmp(handler.command, &pBuffer[4], handler.commandLength) == 0) { + (this->*handler.handler)(pBuffer, nSize); - if (dmxconfigudp::validate(nBytesReceived, static_cast(13), static_cast(14)) && (memcmp("refresh#", pCmd, 8) == 0)) { - const auto nRefreshRate = dmxconfigudp::atoi(reinterpret_cast(&s_pUdpBuffer[12]), nBytesReceived - 12U); - uint32_t nPeriodTime = 0; - if (nRefreshRate != 0) { - nPeriodTime = 1000000U / nRefreshRate; - } - Dmx::Get()->SetDmxPeriodTime(nPeriodTime); - return; - } + DEBUG_EXIT + return; + } + } - if (dmxconfigudp::validate(nBytesReceived, static_cast(11), static_cast(13)) && (memcmp("slots#", pCmd, 6) == 0)) { - const auto nSlots = dmxconfigudp::atoi(reinterpret_cast(&s_pUdpBuffer[10]), nBytesReceived - 10U); - if (dmxconfigudp::validate(nSlots, dmx::min::CHANNELS, dmx::max::CHANNELS)) { - Dmx::Get()->SetDmxSlots(static_cast(nSlots)); - } - return; - } + DEBUG_EXIT + } + +private: + void HandleBreak(const uint8_t *pBuffer, const uint32_t nSize) { + static constexpr auto nOffset = dmxconfigudp::CMD_BREAK_LENGTH + 4; + const auto nBreakTime = dmxconfigudp::atoi(reinterpret_cast(&pBuffer[nOffset]), nSize - nOffset); + if (nBreakTime >= dmx::transmit::BREAK_TIME_MIN) { + Dmx::Get()->SetDmxBreakTime(nBreakTime); + DEBUG_PRINTF("nBreakTime=%u", nBreakTime); + } + } + + void HandleMab(const uint8_t *pBuffer, const uint32_t nSize) { + static constexpr auto nOffset = dmxconfigudp::CMD_MAB_LENGTH + 4; + const auto nMabTime = dmxconfigudp::atoi(reinterpret_cast(&pBuffer[nOffset]), nSize - nOffset); + if (dmxconfigudp::validate(nMabTime, dmx::transmit::MAB_TIME_MIN, dmx::transmit::MAB_TIME_MAX)) { + Dmx::Get()->SetDmxMabTime(nMabTime); + DEBUG_PRINTF("nMabTime=%u", nMabTime); + } + } + + void HandleRefresh(const uint8_t *pBuffer, const uint32_t nSize) { + static constexpr auto nOffset = dmxconfigudp::CMD_REFRESH_LENGTH + 4; + const auto nRefreshRate = dmxconfigudp::atoi(reinterpret_cast(&pBuffer[nOffset]), nSize - nOffset); + uint32_t nPeriodTime = (nRefreshRate != 0) ? 1000000U / nRefreshRate : 0; + Dmx::Get()->SetDmxPeriodTime(nPeriodTime); + DEBUG_PRINTF("nPeriodTime=%u", nPeriodTime); + } + + void HandleSlots(const uint8_t *pBuffer, const uint32_t nSize) { + static constexpr auto nOffset = dmxconfigudp::CMD_SLOTS_LENGTH + 4; + const auto nSlots = dmxconfigudp::atoi(reinterpret_cast(&pBuffer[nOffset]), nSize - nOffset); + if (dmxconfigudp::validate(nSlots, dmx::min::CHANNELS, dmx::max::CHANNELS)) { + Dmx::Get()->SetDmxSlots(static_cast(nSlots)); + DEBUG_PRINTF("nSlots=%u", nSlots); + } + } + + void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + s_pThis->Input(pBuffer, nSize, nFromIp, nFromPort); } private: int32_t s_nHandle { -1 }; - char *s_pUdpBuffer { nullptr }; + static inline DmxConfigUdp *s_pThis; }; #endif /* DMXCONFIGUDP_H_ */ diff --git a/lib-midi/include/applemidi.h b/lib-midi/include/applemidi.h index d91906d27..1e6eaa855 100644 --- a/lib-midi/include/applemidi.h +++ b/lib-midi/include/applemidi.h @@ -2,7 +2,7 @@ * @file applemidi.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -82,8 +82,9 @@ class AppleMidi { void Start() { DEBUG_ENTRY - assert(MDNS::Get() != nullptr); - MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::MIDI, nullptr, m_nPort); +// assert(MDNS::Get() != nullptr); +// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::MIDI, nullptr, m_nPort); + mdns_service_record_add(nullptr, mdns::Services::MIDI, nullptr, m_nPort); m_nHandleControl = Network::Get()->Begin(m_nPort); assert(m_nHandleControl != -1); @@ -162,10 +163,10 @@ class AppleMidi { int32_t m_nHandleControl { -1 }; int32_t m_nHandleMidi { -1 }; uint32_t m_nRemoteIp { 0 }; + uint32_t m_nBytesReceived { 0 }; uint16_t m_nExchangePacketReplySize; uint16_t m_nPort { applemidi::UPD_PORT_CONTROL_DEFAULT }; uint16_t m_nRemotePort { 0 }; - uint16_t m_nBytesReceived { 0 }; applemidi::ExchangePacket m_ExchangePacketReply; applemidi::SessionStatus m_SessionStatus; uint8_t *m_pBuffer { nullptr }; diff --git a/lib-midi/src/arm/midi.cpp b/lib-midi/src/arm/midi.cpp index f99e9f906..68ca6c2c4 100755 --- a/lib-midi/src/arm/midi.cpp +++ b/lib-midi/src/arm/midi.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "midi.h" @@ -88,50 +89,41 @@ void Midi::SetIrqTimer1(midi::thunk_irq_timer1_t pFunc) { } } -static void __attribute__((interrupt("IRQ"))) irq_midi_in_handler() { - __DMB(); - - const auto irq = H3_GIC_CPUIF->AIA; +void TIMER0_IRQHandler() { // 100ms Tick + H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR0; /* Clear Timer 0 Pending bit */ - if (H3_UART2->O08.IIR & UART_IIR_IID_RD) { - - sv_RxBuffer.midi[sv_RxBuffer.nIndexHead].nData = (H3_UART2->O00.RBR & 0xFF); - sv_RxBuffer.midi[sv_RxBuffer.nIndexHead].nTimestamp = H3_TIMER->AVS_CNT0; - sv_RxBuffer.nIndexHead = (sv_RxBuffer.nIndexHead + 1) & midi::RX_BUFFER_INDEX_MASK; - - H3_GIC_CPUIF->AEOI = H3_UART2_IRQn; - gic_unpend(H3_UART2_IRQn); - } else if (irq == H3_TIMER0_IRQn) { // 100ms Tick - H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR0; // Clear Timer 0 Pending bit + if (sv_nTick100ms == 10) { + sv_nTick100ms = 0; + sv_nUpdatesPerSecond = sv_nUpdates - sv_nUpdatesPrevious; + sv_nUpdatesPrevious = sv_nUpdates; + } else { + sv_nTick100ms++; + } - if (sv_nTick100ms == 10) { - sv_nTick100ms = 0; - sv_nUpdatesPerSecond = sv_nUpdates - sv_nUpdatesPrevious; - sv_nUpdatesPrevious = sv_nUpdates; - } else { - sv_nTick100ms++; + if (sv_ActiveSenseState == midi::ActiveSenseState::ENABLED) { + sv_nActiveSenseTimeout++; + if (sv_nActiveSenseTimeout > 3) { // > 300 ms + sv_ActiveSenseState = midi::ActiveSenseState::FAILED; // Turn All Notes Off } + } +} - if (sv_ActiveSenseState == midi::ActiveSenseState::ENABLED) { - sv_nActiveSenseTimeout++; - if (sv_nActiveSenseTimeout > 3) { // > 300 ms - sv_ActiveSenseState = midi::ActiveSenseState::FAILED; // Turn All Notes Off - } - } +void TIMER1_IRQHandler() { + H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR1; /* Clear Timer 1 Pending bit */ - H3_GIC_CPUIF->AEOI = H3_TIMER0_IRQn; - gic_unpend(H3_TIMER0_IRQn); - } else if (irq == H3_TIMER1_IRQn) { - H3_TIMER->IRQ_STA = TIMER_IRQ_PEND_TMR1; + assert(irq_handler_timer1_func != nullptr); - if (irq_handler_timer1_func != nullptr) { - irq_handler_timer1_func(); - } - H3_GIC_CPUIF->AEOI = H3_TIMER1_IRQn; - gic_unpend(H3_TIMER1_IRQn); + if (__builtin_expect((irq_handler_timer1_func != nullptr), 1)) { + irq_handler_timer1_func(); } +} - __DMB(); +void USART2_IRQHandler() { + if (H3_UART2->O08.IIR & UART_IIR_IID_RD) { + sv_RxBuffer.midi[sv_RxBuffer.nIndexHead].nData = (H3_UART2->O00.RBR & 0xFF); + sv_RxBuffer.midi[sv_RxBuffer.nIndexHead].nTimestamp = H3_TIMER->AVS_CNT0; + sv_RxBuffer.nIndexHead = (sv_RxBuffer.nIndexHead + 1) & midi::RX_BUFFER_INDEX_MASK; + } } #elif defined (GD32) #if defined(GD32H7XX) @@ -243,9 +235,13 @@ void Midi::Init(midi::Direction direction) { H3_UART2->O08.FCR = 0; H3_UART2->O04.IER = UART_IER_ERBFI; - arm_install_handler(reinterpret_cast(irq_midi_in_handler), ARM_VECTOR(ARM_VECTOR_IRQ)); - + IRQ_SetHandler(H3_TIMER0_IRQn, TIMER0_IRQHandler); gic_irq_config(H3_TIMER0_IRQn, GIC_CORE0); + + IRQ_SetHandler(H3_TIMER1_IRQn, TIMER1_IRQHandler); + gic_irq_config(H3_TIMER1_IRQn, GIC_CORE0); + + IRQ_SetHandler(H3_UART2_IRQn, USART2_IRQHandler); gic_irq_config(H3_UART2_IRQn, GIC_CORE0); __enable_irq(); @@ -269,6 +265,7 @@ void Midi::Init(midi::Direction direction) { #if defined (H3) H3_UART2->O08.FCR = UART_FCR_EFIFO | UART_FCR_TRESET; H3_UART2->O04.IER = 0; + IRQ_SetHandler(H3_UART2_IRQn, nullptr); #elif defined (GD32) NVIC_DisableIRQ(USART5_IRQn); #endif diff --git a/lib-midi/src/net/applemidi.cpp b/lib-midi/src/net/applemidi.cpp index 3b456467f..e11f2afb4 100644 --- a/lib-midi/src/net/applemidi.cpp +++ b/lib-midi/src/net/applemidi.cpp @@ -2,7 +2,7 @@ * @file applemidi.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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/.settings/language.settings.xml b/lib-network/.settings/language.settings.xml index 6b3d0f05c..35b522821 100644 --- a/lib-network/.settings/language.settings.xml +++ b/lib-network/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-network/include/emac/network.h b/lib-network/include/emac/network.h index ffd368aef..0bb1cb76a 100755 --- a/lib-network/include/emac/network.h +++ b/lib-network/include/emac/network.h @@ -180,16 +180,12 @@ class Network { * UDP/IP */ - int32_t Begin(uint16_t nPort) { - const auto nIndex = net::udp_begin(nPort); - assert(nIndex != -1); - return nIndex; + int32_t Begin(uint16_t nPort, net::UdpCallbackFunctionPtr callback = nullptr) { + return net::udp_begin(nPort, callback); } int32_t End(uint16_t nPort) { - const auto nIndex = net::udp_end(nPort); - assert(nIndex == 0); - return nIndex; + return net::udp_end(nPort); } uint32_t RecvFrom(int32_t nHandle, void *pBuffer, uint32_t nLength, uint32_t *from_ip, uint16_t *from_port) { @@ -289,7 +285,6 @@ class Network { net::link_handle_change(link_state); } #endif - net::dhcp_run(); } static Network *Get() { diff --git a/lib-network/include/linux/minimum/network.h b/lib-network/include/linux/minimum/network.h index 3439a83df..393e27d63 100755 --- a/lib-network/include/linux/minimum/network.h +++ b/lib-network/include/linux/minimum/network.h @@ -2,7 +2,7 @@ * @file network.h * */ -/* Copyright (C) 2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,8 @@ #define MAX_SEGMENT_LENGTH 1400 +typedef void (*UdpCallbackFunctionPtr)(const uint8_t *, uint32_t, uint32_t, uint16_t); + class Network { public: static Network *Get() { @@ -49,7 +51,8 @@ class Network { return m_aHostName; } - int32_t Begin(const uint16_t nPort) { + int32_t Begin(const uint16_t nPort, [[maybe_unused]] UdpCallbackFunctionPtr callback = nullptr) { + assert(func == nullptr); int nSocket; if ((nSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { diff --git a/lib-network/include/linux/network.h b/lib-network/include/linux/network.h index 2df099687..629981d58 100644 --- a/lib-network/include/linux/network.h +++ b/lib-network/include/linux/network.h @@ -2,7 +2,7 @@ * @file network.h * */ -/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,6 +37,10 @@ #include "networkparams.h" +namespace net { +typedef void (*UdpCallbackFunctionPtr)(const uint8_t *, uint32_t, uint32_t, uint16_t); +} // namespace net + class Network { public: Network(int argc, char **argv); @@ -46,7 +50,7 @@ class Network { void Shutdown() {} - int32_t Begin(uint16_t nPort); + int32_t Begin(uint16_t nPort, net::UdpCallbackFunctionPtr callback = nullptr); int32_t End(uint16_t nPort); void MacAddressCopyTo(uint8_t *pMacAddress); diff --git a/lib-network/include/net.h b/lib-network/include/net.h index a60df0048..514dc7d13 100755 --- a/lib-network/include/net.h +++ b/lib-network/include/net.h @@ -32,13 +32,12 @@ #include "emac/phy.h" #include "net/dhcp.h" #include "net/protocol/dhcp.h" +#if !defined(CONFIG_NET_APPS_NO_MDNS) +# include "net/apps/mdns.h" +#endif #include "debug.h" -namespace network { -void mdns_shutdown(); -} // namespace network - namespace net { void tcp_shutdown(); void igmp_shutdown(); @@ -51,7 +50,9 @@ void net_set_secondary_ip(); void net_handle(); inline void net_link_down() { - network::mdns_shutdown(); +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_send_announcement(0); +#endif #if defined (ENABLE_HTTPD) tcp_shutdown(); #endif @@ -59,7 +60,9 @@ inline void net_link_down() { dhcp_release_and_stop(); } -int udp_begin(uint16_t); +typedef void (*UdpCallbackFunctionPtr)(const uint8_t *, uint32_t, uint32_t, uint16_t); + +int udp_begin(uint16_t, UdpCallbackFunctionPtr callback = nullptr); int udp_end(uint16_t); uint32_t udp_recv1(int, uint8_t *, uint32_t, uint32_t *, uint16_t *); uint32_t udp_recv2(int, const uint8_t **, uint32_t *, uint16_t *); diff --git a/lib-network/include/net/apps/mdns.h b/lib-network/include/net/apps/mdns.h index 4cf05e60c..58c8093dc 100755 --- a/lib-network/include/net/apps/mdns.h +++ b/lib-network/include/net/apps/mdns.h @@ -28,12 +28,11 @@ #include -#include "network.h" -#include "net/protocol/dns.h" - #include "../config/apps_config.h" namespace mdns { +static constexpr uint32_t MDNS_RESPONSE_TTL = 3600; ///< (in seconds) + enum class Services { CONFIG, TFTP, HTTP, RDMNET_LLRP, NTP, MIDI, OSC, DDP, PP, LAST_NOT_USED }; @@ -47,54 +46,17 @@ struct ServiceRecord { }; } // namespace mdns -class MDNS { -public: - MDNS(); - ~MDNS(); - - bool ServiceRecordAdd(const char *pName, const mdns::Services service, const char *pTextContent = nullptr, const uint16_t nPort = 0); - bool ServiceRecordDelete(const mdns::Services service); - - void Print(); - - void SendAnnouncement(const uint32_t nTTL); - - void Run() { - s_nBytesReceived = Network::Get()->RecvFrom(s_nHandle, const_cast(reinterpret_cast(&s_pReceiveBuffer)), &s_nRemoteIp, &s_nRemotePort); +void mdns_init(); +void mdns_start(); +void mdns_stop(); - if (__builtin_expect((s_nBytesReceived < sizeof(struct net::dns::Header)), 1)) { - return; - } +bool mdns_service_record_add(const char *pName, const mdns::Services service, const char *pTextContent = nullptr, const uint16_t nPort = 0); +bool mdns_service_record_delete(const mdns::Services service); - const auto *const pHeader = reinterpret_cast(s_pReceiveBuffer); - const auto nFlag1 = pHeader->nFlag1; +void mdns_print(); - if ((nFlag1 >> 3) & 0xF) { - return; - } +void mdns_send_announcement(const uint32_t nTTL); - HandleQuestions(static_cast(__builtin_bswap16(pHeader->nQueryCount))); - } - - static MDNS *Get() { - return s_pThis; - } - -private: - void Parse(); - void HandleQuestions(const uint32_t nQuestions); - void SendAnswerLocalIpAddress(const uint16_t nTransActionID, const uint32_t nTTL); - void SendMessage(mdns::ServiceRecord const& serviceRecord, const uint16_t nTransActionID, const uint32_t nTTL); - void SendTo(const uint32_t nLength); - -private: - static int32_t s_nHandle; - static uint32_t s_nRemoteIp; - static uint32_t s_nBytesReceived; - static uint8_t *s_pReceiveBuffer; - static uint16_t s_nRemotePort; - - static MDNS *s_pThis; -}; +void mdns_run(); #endif /* NET_APPS_MDNS_H_ */ diff --git a/lib-network/include/net/apps/tftpdaemon.h b/lib-network/include/net/apps/tftpdaemon.h index 2c194b13c..7f70172c9 100755 --- a/lib-network/include/net/apps/tftpdaemon.h +++ b/lib-network/include/net/apps/tftpdaemon.h @@ -40,6 +40,8 @@ class TFTPDaemon { TFTPDaemon(); virtual ~TFTPDaemon(); + void Input(const uint8_t *, uint32_t, uint32_t, uint16_t); + void Run(); virtual bool FileOpen(const char *pFileName, tftp::Mode mode)=0; @@ -51,6 +53,7 @@ class TFTPDaemon { virtual void Exit()=0; private: + void Init(); void HandleRequest(); void HandleRecvAck(); void HandleRecvData(); @@ -83,7 +86,10 @@ class TFTPDaemon { } private: - static TFTPDaemon *s_pThis; + void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + TFTPDaemon::Get()->Input(pBuffer, nSize, nFromIp, nFromPort); + } + static inline TFTPDaemon *s_pThis; }; #endif /* NET_APPS_TFTPDAEMON_H_ */ diff --git a/lib-network/include/net/dhcp.h b/lib-network/include/net/dhcp.h index 1c6f1670d..9554cc813 100755 --- a/lib-network/include/net/dhcp.h +++ b/lib-network/include/net/dhcp.h @@ -101,6 +101,8 @@ void dhcp_network_changed_link_up(); uint32_t udp_recv2(int, const uint8_t **, uint32_t *, uint16_t *); void dhcp_process(const dhcp::Message *const, const uint32_t nSize); +void dhcp_input(const uint8_t *, uint32_t, uint32_t, uint16_t); + inline void dhcp_run() { auto *dhcp = reinterpret_cast(globals::netif_default.dhcp); if (dhcp == nullptr) { @@ -114,16 +116,7 @@ inline void dhcp_run() { const auto nSize = udp_recv2(dhcp->nHandle, const_cast(&pResponse), &nFromIp, &nFromPort); if (__builtin_expect((nSize > 0), 0)) { - if (nFromPort == net::iana::IANA_PORT_DHCP_SERVER) { - const auto *const p = reinterpret_cast(pResponse); - - if (p->xid != dhcp->xid) { - DEBUG_PRINTF("pDhcpMessage->xid=%u, dhcp->xid=%u", p->xid, dhcp->xid); - return; - } - - dhcp_process(p, nSize); - } + dhcp_input(pResponse, nSize, nFromIp, nFromPort); } } diff --git a/lib-network/include/net/protocol/ieee.h b/lib-network/include/net/protocol/ieee.h index c65ef0530..af8cf3c10 100755 --- a/lib-network/include/net/protocol/ieee.h +++ b/lib-network/include/net/protocol/ieee.h @@ -30,8 +30,8 @@ enum ETHER_TYPE { ETHER_TYPE_IPv4 = 0x0800, - ETHER_TYPE_ARP = 0x0806, - ETHER_TYPE_PTP = 0x88F7 /* IEEE1588v2 (PTPv2) over Ethernet */ + ETHER_TYPE_ARP = 0x0806, + ETHER_TYPE_PTP = 0x88F7 /* IEEE1588v2 (PTPv2) over Ethernet */ }; #endif /* NET_PROTOCOL_IEEE_H_ */ diff --git a/lib-network/include/net/protocol/tcp.h b/lib-network/include/net/protocol/tcp.h index b20047f2e..1c98a49ec 100755 --- a/lib-network/include/net/protocol/tcp.h +++ b/lib-network/include/net/protocol/tcp.h @@ -57,6 +57,4 @@ struct t_tcp { struct t_tcp_packet tcp; } PACKED; -#define IPv4_UDP_HEADERS_SIZE (sizeof(struct ip4_header) + UDP_HEADER_SIZE) /* IP | UDP */ - #endif /* NET_PROTOCOL_TCP_H_ */ diff --git a/lib-network/include/net/protocol/udp.h b/lib-network/include/net/protocol/udp.h index 49bd5ec22..45fdeb1a0 100755 --- a/lib-network/include/net/protocol/udp.h +++ b/lib-network/include/net/protocol/udp.h @@ -51,6 +51,7 @@ struct t_udp { struct t_udp_packet udp; } PACKED; +#define IPv4_UDP_HEADERS_SIZE (sizeof(struct ip4_header) + UDP_HEADER_SIZE) /* IP | UDP */ #define UDP_PACKET_HEADERS_SIZE (sizeof(struct ether_header) + IPv4_UDP_HEADERS_SIZE) /* ETH | IP | UDP */ #endif /* NET_PROTOCOL_UDP_H_ */ diff --git a/lib-network/include/networkparams.h b/lib-network/include/networkparams.h index 33008df03..a5dc13dd8 100644 --- a/lib-network/include/networkparams.h +++ b/lib-network/include/networkparams.h @@ -34,7 +34,6 @@ namespace networkparams { namespace defaults { static constexpr auto IS_DHCP_USED = true; -static constexpr auto DHCP_RETRY_TIME = 0; } // namespace defaults struct Params { @@ -47,7 +46,7 @@ struct Params { char aHostName[network::HOSTNAME_SIZE]; uint32_t nNtpServerIp; float fNtpUtcOffset; - uint8_t nDhcpRetryTime; + uint8_t nNotUsed; #if defined (ESP8266) char aSsid[34]; char aPassword[34]; @@ -67,7 +66,6 @@ struct Mask { static constexpr auto HOSTNAME = (1U << 5); static constexpr auto NTP_SERVER = (1U << 6); static constexpr auto NTP_UTC_OFFSET = (1U << 7); - static constexpr auto DHCP_RETRY_TIME = (1U << 8); static constexpr auto PTP_ENABLE = (1U << 9); static constexpr auto PTP_DOMAIN = (1U << 10); #if defined (ESP8266) @@ -105,10 +103,6 @@ class NetworkParams { return m_Params.bIsDhcpUsed; } - uint8_t GetDhcpRetryTime() const { - return m_Params.nDhcpRetryTime; - } - uint32_t GetIpAddress() const { return m_Params.nLocalIp; } diff --git a/lib-network/src/emac/gd32/f/net.cpp b/lib-network/src/emac/gd32/f/net.cpp index 713d281be..718f58230 100644 --- a/lib-network/src/emac/gd32/f/net.cpp +++ b/lib-network/src/emac/gd32/f/net.cpp @@ -33,6 +33,7 @@ #include #include "gd32.h" +#include "gd32_enet.h" #include "../src/net/net_memcpy.h" #include "debug.h" @@ -51,8 +52,8 @@ extern uint32_t ptpTimestamp[2]; extern enet_descriptors_struct *dma_current_rxdesc; extern enet_descriptors_struct *dma_current_txdesc; -int emac_eth_recv(uint8_t **ppPacket) { - const auto nLength = enet_desc_information_get(dma_current_rxdesc, RXDESC_FRAME_LENGTH); +uint32_t emac_eth_recv(uint8_t **ppPacket) { + const auto nLength = gd32_enet_desc_information_get(dma_current_rxdesc); if (nLength > 0) { #if defined (CONFIG_ENET_ENABLE_PTP) @@ -63,7 +64,7 @@ int emac_eth_recv(uint8_t **ppPacket) { return nLength; } - return -1; + return 0; } #if defined (CONFIG_ENET_ENABLE_PTP) @@ -75,6 +76,7 @@ static void ptpframe_receive_normal_mode() { dma_current_rxdesc->buffer2_next_desc_addr = dma_current_ptp_rxdesc->buffer2_next_desc_addr; dma_current_rxdesc->status = ENET_RDES0_DAV; + /* check Rx buffer unavailable flag status */ if (0 != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)) { /* clear RBU flag */ ENET_DMA_STAT = ENET_DMA_STAT_RBU; @@ -82,17 +84,18 @@ static void ptpframe_receive_normal_mode() { ENET_DMA_RPEN = 0U; } - assert(0 != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)); - - dma_current_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->buffer2_next_desc_addr); - /* if it is the last ptp descriptor */ - if (0 != dma_current_ptp_rxdesc->status) { - /* pointer back to the first ptp descriptor address in the desc_ptptab list address */ - dma_current_ptp_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->status); - } else { - /* ponter to the next ptp descriptor */ - dma_current_ptp_rxdesc++; - } + assert(0 != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)); /* chained mode */ + + /* update the current RxDMA descriptor pointer to the next descriptor in RxDMA descriptor table */ + dma_current_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->buffer2_next_desc_addr); + /* if it is the last ptp descriptor */ + if (0 != dma_current_ptp_rxdesc->status) { + /* pointer back to the first ptp descriptor address in the desc_ptptab list address */ + dma_current_ptp_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->status); + } else { + /* pointer to the next ptp descriptor */ + dma_current_ptp_rxdesc++; + } } #else static void frame_receive() { @@ -103,7 +106,7 @@ static void frame_receive() { /* clear RBU flag */ ENET_DMA_STAT = ENET_DMA_STAT_RBU; /* resume DMA reception by writing to the RPEN register*/ - ENET_DMA_RPEN = 0U; + ENET_DMA_RPEN = 0; } assert(0 != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)); @@ -116,22 +119,23 @@ void emac_free_pkt() { while(0 != (dma_current_rxdesc->status & ENET_RDES0_DAV)) { __DMB(); } + #if defined (CONFIG_ENET_ENABLE_PTP) ptpframe_receive_normal_mode(); #else - frame_receive(); + frame_receive(); #endif } #if defined (CONFIG_ENET_ENABLE_PTP) -inline static void ptpframe_transmit(const uint8_t *pBuffer, const uint32_t nLength, const bool bCaptureTimestamp) { +inline static void ptpframe_transmit(const void *pBuffer, const uint32_t nLength, const bool bCaptureTimestamp) { assert (nullptr != pBuffer); assert(nLength <= ENET_MAX_FRAME_SIZE); auto *pDst = reinterpret_cast(dma_current_ptp_txdesc->buffer1_addr); net::memcpy(pDst, pBuffer, nLength); - dma_current_txdesc->control_buffer_size = (nLength & (uint32_t)0x1FFF); + dma_current_txdesc->control_buffer_size = (nLength & 0x00001FFFU); /* set the segment of frame, frame is transmitted in one descriptor */ dma_current_txdesc->status |= ENET_TDES0_LSG | ENET_TDES0_FSG; /* enable the DMA transmission */ @@ -151,20 +155,20 @@ inline static void ptpframe_transmit(const uint8_t *pBuffer, const uint32_t nLen uint32_t timeout = 0; uint32_t tdes0_ttmss_flag; - if (bCaptureTimestamp) { - do { - tdes0_ttmss_flag = (dma_current_txdesc->status & ENET_TDES0_TTMSS); - __DMB(); - timeout++; - } while((0 == tdes0_ttmss_flag) && (timeout < UINT32_MAX)); + if (bCaptureTimestamp) { + do { + tdes0_ttmss_flag = (dma_current_txdesc->status & ENET_TDES0_TTMSS); + __DMB(); + timeout++; + } while ((0 == tdes0_ttmss_flag) && (timeout < UINT32_MAX)); - DEBUG_PRINTF("timeout=%x %d", timeout, (dma_current_txdesc->status & ENET_TDES0_TTMSS)); + DEBUG_PRINTF("timeout=%x %d", timeout, (dma_current_txdesc->status & ENET_TDES0_TTMSS)); - dma_current_txdesc->status &= ~ENET_TDES0_TTMSS; + dma_current_txdesc->status &= ~ENET_TDES0_TTMSS; - net::globals::ptpTimestamp[0] = dma_current_txdesc->buffer1_addr; - net::globals::ptpTimestamp[1] = dma_current_txdesc->buffer2_next_desc_addr; - } + net::globals::ptpTimestamp[0] = dma_current_txdesc->buffer1_addr; + net::globals::ptpTimestamp[1] = dma_current_txdesc->buffer2_next_desc_addr; + } dma_current_txdesc->buffer1_addr = dma_current_ptp_txdesc->buffer1_addr; dma_current_txdesc->buffer2_next_desc_addr = dma_current_ptp_txdesc->buffer2_next_desc_addr; @@ -184,6 +188,9 @@ inline static void ptpframe_transmit(const uint8_t *pBuffer, const uint32_t nLen } void emac_eth_send(void *pBuffer, uint32_t nLength) { + assert(nullptr != pBuffer); + assert(nLength <= static_cast(ENET_MAX_FRAME_SIZE)); + while (0 != (dma_current_txdesc->status & ENET_TDES0_DAV)) { __DMB(); } @@ -192,10 +199,13 @@ void emac_eth_send(void *pBuffer, uint32_t nLength) { nStatus &= ~ENET_TDES0_TTSEN; dma_current_txdesc->status = nStatus; - ptpframe_transmit(reinterpret_cast(pBuffer), nLength, false); + ptpframe_transmit(pBuffer, nLength, false); } void emac_eth_send_timestamp(void *pBuffer, uint32_t nLength) { + assert(nullptr != pBuffer); + assert(nLength <= static_cast(ENET_MAX_FRAME_SIZE)); + while (0 != (dma_current_txdesc->status & ENET_TDES0_DAV)) { __DMB(); } @@ -204,7 +214,7 @@ void emac_eth_send_timestamp(void *pBuffer, uint32_t nLength) { nStatus |= ENET_TDES0_TTSEN; dma_current_txdesc->status = nStatus; - ptpframe_transmit(reinterpret_cast(pBuffer), nLength, true); + ptpframe_transmit(pBuffer, nLength, true); } #else void emac_eth_send(void *pBuffer, uint32_t nLength) { diff --git a/lib-network/src/emac/gd32/h/net.cpp b/lib-network/src/emac/gd32/h/net.cpp index a3d8114f4..761ad5550 100644 --- a/lib-network/src/emac/gd32/h/net.cpp +++ b/lib-network/src/emac/gd32/h/net.cpp @@ -23,15 +23,17 @@ * THE SOFTWARE. */ -#pragma GCC push_options -#pragma GCC optimize ("O2") -#pragma GCC optimize ("no-tree-loop-distribute-patterns") +#if !defined (CONFIG_REMOTECONFIG_MINIMUM) +# pragma GCC push_options +# pragma GCC optimize ("O2") +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +#endif #include -#include #include #include "gd32.h" +#include "gd32_enet.h" #include "../src/net/net_memcpy.h" #include "debug.h" @@ -50,10 +52,8 @@ extern uint32_t ptpTimestamp[2]; extern enet_descriptors_struct *dma_current_rxdesc; extern enet_descriptors_struct *dma_current_txdesc; -extern "C" int console_error(const char *); - -int emac_eth_recv(uint8_t **ppPacket) { - const auto nLength = enet_desc_information_get(ENETx, dma_current_rxdesc, RXDESC_FRAME_LENGTH); +uint32_t emac_eth_recv(uint8_t **ppPacket) { + const auto nLength = gd32_enet_desc_information_get(dma_current_rxdesc); if (nLength > 0) { #if defined (CONFIG_ENET_ENABLE_PTP) @@ -64,7 +64,7 @@ int emac_eth_recv(uint8_t **ppPacket) { return nLength; } - return -1; + return 0; } #if defined (CONFIG_ENET_ENABLE_PTP) @@ -72,31 +72,31 @@ static void ptpframe_receive_normal_mode() { net::globals::ptpTimestamp[0] = dma_current_rxdesc->buffer1_addr; net::globals::ptpTimestamp[1] = dma_current_rxdesc->buffer2_next_desc_addr; - dma_current_rxdesc->buffer1_addr = dma_current_ptp_rxdesc ->buffer1_addr ; - dma_current_rxdesc->buffer2_next_desc_addr = dma_current_ptp_rxdesc ->buffer2_next_desc_addr; - dma_current_rxdesc->status = ENET_RDES0_DAV; + dma_current_rxdesc->buffer1_addr = dma_current_ptp_rxdesc->buffer1_addr; + dma_current_rxdesc->buffer2_next_desc_addr = dma_current_ptp_rxdesc->buffer2_next_desc_addr; + dma_current_rxdesc->status = ENET_RDES0_DAV; __DMB(); - /* check Rx buffer unavailable flag status */ - if(0 != (ENET_DMA_STAT(ENETx) & ENET_DMA_STAT_RBU)) { - /* clear RBU flag */ - ENET_DMA_STAT(ENETx) = ENET_DMA_STAT_RBU; - /* resume DMA reception by writing to the RPEN register*/ - ENET_DMA_RPEN(ENETx) = 0; - } - - assert(0 != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)); /* chained mode */ + /* check Rx buffer unavailable flag status */ + if (0 != (ENET_DMA_STAT(ENETx) & ENET_DMA_STAT_RBU)) { + /* clear RBU flag */ + ENET_DMA_STAT(ENETx) = ENET_DMA_STAT_RBU; + /* resume DMA reception by writing to the RPEN register*/ + ENET_DMA_RPEN(ENETx) = 0; + } - /* update the current RxDMA descriptor pointer to the next descriptor in RxDMA descriptor table */ - dma_current_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->buffer2_next_desc_addr); - /* if it is the last ptp descriptor */ - if(0 != dma_current_ptp_rxdesc->status) { - /* pointer back to the first ptp descriptor address in the desc_ptptab list address */ - dma_current_ptp_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->status); - } else { - /* pointer to the next ptp descriptor */ - dma_current_ptp_rxdesc++; - } + assert(0 != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)); /* chained mode */ + + /* update the current RxDMA descriptor pointer to the next descriptor in RxDMA descriptor table */ + dma_current_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->buffer2_next_desc_addr); + /* if it is the last ptp descriptor */ + if (0 != dma_current_ptp_rxdesc->status) { + /* pointer back to the first ptp descriptor address in the desc_ptptab list address */ + dma_current_ptp_rxdesc = reinterpret_cast(dma_current_ptp_rxdesc->status); + } else { + /* pointer to the next ptp descriptor */ + dma_current_ptp_rxdesc++; + } } #else static void frame_receive() { @@ -116,7 +116,7 @@ static void frame_receive() { } #endif -void emac_free_pkt(void) { +void emac_free_pkt() { while(0 != (dma_current_rxdesc->status & ENET_RDES0_DAV)) { __DMB(); } @@ -129,11 +129,13 @@ void emac_free_pkt(void) { } #if defined (CONFIG_ENET_ENABLE_PTP) -inline static void ptpframe_transmit(void *pBuffer, const uint32_t nLength, const bool bCaptureTimestamp) { +inline static void ptpframe_transmit(const void *pBuffer, const uint32_t nLength, const bool bCaptureTimestamp) { + assert (nullptr != pBuffer); + assert(nLength <= ENET_MAX_FRAME_SIZE); + auto *pDst = reinterpret_cast(dma_current_txdesc->buffer1_addr); net::memcpy(pDst, pBuffer, nLength); - /* set the frame length */ dma_current_txdesc->control_buffer_size = (nLength & 0x00001FFFU); /* set the segment of frame, frame is transmitted in one descriptor */ dma_current_txdesc->status |= ENET_TDES0_LSG | ENET_TDES0_FSG; @@ -162,7 +164,7 @@ inline static void ptpframe_transmit(void *pBuffer, const uint32_t nLength, cons timeout++; } while ((0 == tdes0_ttmss_flag) && (timeout < UINT32_MAX)); - DEBUG_PRINTF("timeout=%x %d", timeout, (dma_current_txdesc->status & ENET_TDES0_TTMSS)); + DEBUG_PRINTF("timeout=%x %d", timeout, (dma_current_txdesc->status & ENET_TDES0_TTMSS)); dma_current_txdesc->status &= ~ENET_TDES0_TTMSS; @@ -170,19 +172,19 @@ inline static void ptpframe_transmit(void *pBuffer, const uint32_t nLength, cons net::globals::ptpTimestamp[1] = dma_current_txdesc->buffer2_next_desc_addr; } - dma_current_txdesc->buffer1_addr = dma_current_ptp_txdesc ->buffer1_addr ; - dma_current_txdesc->buffer2_next_desc_addr = dma_current_ptp_txdesc ->buffer2_next_desc_addr; + dma_current_txdesc->buffer1_addr = dma_current_ptp_txdesc->buffer1_addr; + dma_current_txdesc->buffer2_next_desc_addr = dma_current_ptp_txdesc->buffer2_next_desc_addr; assert(0 != (dma_current_txdesc->status & ENET_TDES0_TCHM)); /* chained mode */ /* update the current TxDMA descriptor pointer to the next descriptor in TxDMA descriptor table */ dma_current_txdesc = reinterpret_cast(dma_current_ptp_txdesc->buffer2_next_desc_addr); /* if it is the last ptp descriptor */ - if(0U != dma_current_ptp_txdesc->status) { + if(0 != dma_current_ptp_txdesc->status) { /* pointer back to the first ptp descriptor address in the desc_ptptab list address */ dma_current_ptp_txdesc = reinterpret_cast(dma_current_ptp_txdesc->status); } else { - /* ponter to the next ptp descriptor */ + /* pointer to the next ptp descriptor */ dma_current_ptp_txdesc++; } } @@ -251,7 +253,7 @@ void emac_eth_send(void *pBuffer, uint32_t nLength) { assert(0 != (dma_current_txdesc->status & ENET_TDES0_TCHM)); /* chained mode */ - /* update the current TxDMA descriptor pointer to the next descriptor in TxDMA descriptor table*/ - dma_current_txdesc = reinterpret_cast(dma_current_txdesc->buffer2_next_desc_addr); + /* update the current TxDMA descriptor pointer to the next descriptor in TxDMA descriptor table*/ + dma_current_txdesc = reinterpret_cast(dma_current_txdesc->buffer2_next_desc_addr); } #endif diff --git a/lib-network/src/emac/gd32/net_link_check.cpp b/lib-network/src/emac/gd32/net_link_check.cpp index f3efe054d..5ce94140f 100644 --- a/lib-network/src/emac/gd32/net_link_check.cpp +++ b/lib-network/src/emac/gd32/net_link_check.cpp @@ -68,7 +68,7 @@ void link_pin_poll() { #if defined (ENET_LINK_CHECK_USE_INT) extern "C" { -void LINK_CHECK_IRQ_HANDLE(void) { +void LINK_CHECK_IRQ_HANDLE() { if (RESET != exti_interrupt_flag_get(LINK_CHECK_EXTI_LINE)) { exti_interrupt_flag_clear(LINK_CHECK_EXTI_LINE); net::link_pin_recovery(); diff --git a/lib-network/src/emac/h3/net.cpp b/lib-network/src/emac/h3/net.cpp index 43aadeae7..866d6f11f 100644 --- a/lib-network/src/emac/h3/net.cpp +++ b/lib-network/src/emac/h3/net.cpp @@ -32,24 +32,23 @@ extern struct coherent_region *p_coherent_region; -__attribute__((hot)) int emac_eth_recv(uint8_t **packetp) { +__attribute__((hot)) uint32_t emac_eth_recv(uint8_t **packetp) { uint32_t status, desc_num = p_coherent_region->rx_currdescnum; struct emac_dma_desc *desc_p = &p_coherent_region->rx_chain[desc_num]; - int length; status = desc_p->status; /* Check for DMA own bit */ if (!(status & (1U << 31))) { - length = (desc_p->status >> 16) & 0x3FFF; + uint32_t length = (desc_p->status >> 16) & 0x3FFF; if (length < 0x40) { DEBUG_PUTS("Bad Packet (length < 0x40)"); - return -1; + return 0; } else { if (length > CONFIG_ETH_RXSIZE) { DEBUG_PRINTF("Received packet is too big (length=%d)\n", length); - return -1; + return 0; } *packetp = reinterpret_cast(desc_p->buf_addr); @@ -60,7 +59,7 @@ __attribute__((hot)) int emac_eth_recv(uint8_t **packetp) { } } - return -1; + return 0; } void emac_eth_send(void *packet, uint32_t len) { @@ -77,7 +76,7 @@ void emac_eth_send(void *packet, uint32_t len) { debug_dump(reinterpret_cast(data_start), static_cast(len)); #endif /* frame end */ - desc_p->st |= (1 << 30); + desc_p->st |= (1U << 30); desc_p->st |= (1U << 31); /*frame begin */ @@ -94,7 +93,7 @@ void emac_eth_send(void *packet, uint32_t len) { /* Start the DMA */ uint32_t value = H3_EMAC->TX_CTL1; value |= (1U << 31);/* mandatory */ - value |= (1 << 30);/* mandatory */ + value |= (1U << 30);/* mandatory */ H3_EMAC->TX_CTL1 = value; } diff --git a/lib-network/src/emac/network.cpp b/lib-network/src/emac/network.cpp index e993f43b4..63e0eedec 100755 --- a/lib-network/src/emac/network.cpp +++ b/lib-network/src/emac/network.cpp @@ -47,15 +47,13 @@ #include "netif.h" #include "net/autoip.h" #include "net/dhcp.h" - +#if !defined(CONFIG_NET_APPS_NO_MDNS) +# include "net/apps/mdns.h" +#endif #include "../../config/net_config.h" #include "debug.h" -namespace network { -void __attribute__((weak)) mdns_announcement() {} -} // namespace network - static constexpr char TO_HEX(const char i) { return static_cast(((i) < 10) ? '0' + i : 'A' + (i - 10)); } @@ -69,8 +67,9 @@ static void netif_ext_callback(const uint16_t reason, [[maybe_unused]] const net if ((reason & net::NetifReason::NSC_IPV4_ADDRESS_CHANGED) == net::NetifReason::NSC_IPV4_ADDRESS_CHANGED) { net::display_ip(); - network::mdns_announcement(); - +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_start(); +#endif printf("ip: " IPSTR " -> " IPSTR "\n", IP2STR(args->ipv4_changed.old_address.addr), IP2STR(net::netif_ipaddr())); } @@ -93,6 +92,9 @@ static void netif_ext_callback(const uint16_t reason, [[maybe_unused]] const net DEBUG_EXIT return; } +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_start(); +#endif } DEBUG_EXIT @@ -172,6 +174,9 @@ Network::Network() { net::link_pin_poll_init(); #elif defined (ENET_LINK_CHECK_REG_POLL) net::link_status_read(); +#endif +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_init(); #endif DEBUG_EXIT } @@ -237,8 +242,9 @@ void Network::SetHostName(const char *pHostName) { m_aHostName[network::HOSTNAME_SIZE - 1] = '\0'; NetworkStore::SaveHostName(m_aHostName, static_cast(strlen(m_aHostName))); - - network::mdns_announcement(); +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_send_announcement(mdns::MDNS_RESPONSE_TTL); +#endif net::display_hostname(); DEBUG_EXIT diff --git a/lib-network/src/linux/network.cpp b/lib-network/src/linux/network.cpp index 6281b0ff1..e4e9143ce 100644 --- a/lib-network/src/linux/network.cpp +++ b/lib-network/src/linux/network.cpp @@ -156,7 +156,7 @@ Network::~Network() { } } -int32_t Network::Begin(uint16_t nPort) { +int32_t Network::Begin(uint16_t nPort, [[maybe_unused]] net::UdpCallbackFunctionPtr callback) { DEBUG_ENTRY DEBUG_PRINTF("port = %d", nPort); diff --git a/lib-network/src/net/acd.cpp b/lib-network/src/net/acd.cpp index ea97ef630..61469e891 100755 --- a/lib-network/src/net/acd.cpp +++ b/lib-network/src/net/acd.cpp @@ -49,7 +49,7 @@ #include "net/protocol/arp.h" #include "net_memcpy.h" -#include "hardware.h" +#include "timers.h" #include "debug.h" namespace net { @@ -60,7 +60,7 @@ static constexpr uint32_t ACD_TICKS_PER_SECOND = (1000U / ACD_TMR_INTERVAL); static int32_t nTimerId; -static void acd_timer() { +static void acd_timer([[maybe_unused]] TimerHandle_t nHandle) { auto *acd = reinterpret_cast(globals::netif_default.acd); assert(acd != nullptr); @@ -87,7 +87,7 @@ static void acd_timer() { acd->sent_num = 0; acd->ttw = static_cast(ANNOUNCE_WAIT * acd::ACD_TICKS_PER_SECOND); } else { - acd->ttw = static_cast(random() % (((PROBE_MAX - PROBE_MIN) * acd::ACD_TICKS_PER_SECOND)) + (PROBE_MIN * acd::ACD_TICKS_PER_SECOND)); + acd->ttw = static_cast(static_cast(random()) % (((PROBE_MAX - PROBE_MIN) * acd::ACD_TICKS_PER_SECOND)) + (PROBE_MIN * acd::ACD_TICKS_PER_SECOND)); } } break; @@ -206,9 +206,9 @@ void acd_start(struct acd::Acd *acd, const ip4_addr_t ipaddr) { acd->ipaddr.addr = ipaddr.addr; acd->state = acd::State::ACD_STATE_PROBE_WAIT; - acd->ttw = static_cast(random() % (PROBE_WAIT * acd::ACD_TICKS_PER_SECOND)); + acd->ttw = static_cast(static_cast(random()) % (PROBE_WAIT * acd::ACD_TICKS_PER_SECOND)); - nTimerId = Hardware::Get()->SoftwareTimerAdd(acd::ACD_TMR_INTERVAL, acd_timer); + nTimerId = SoftwareTimerAdd(acd::ACD_TMR_INTERVAL, acd_timer); assert(nTimerId >= 0); DEBUG_EXIT @@ -221,7 +221,7 @@ void acd_stop(struct acd::Acd *acd) { acd->state = acd::State::ACD_STATE_OFF; assert(nTimerId >= 0); - Hardware::Get()->SoftwareTimerDelete(nTimerId); + SoftwareTimerDelete(nTimerId); nTimerId = -1; DEBUG_EXIT @@ -231,15 +231,29 @@ void acd_network_changed_link_down() { DEBUG_ENTRY auto *acd = reinterpret_cast(globals::netif_default.acd); - acd_stop(acd); + + if (acd == nullptr) { + DEBUG_EXIT + return; + } + + acd_stop(acd); DEBUG_EXIT } +/** + * Handles every incoming ARP Packet, called by arp_handle + */ void acd_arp_reply(struct t_arp *pArp) { DEBUG_ENTRY auto *acd = reinterpret_cast(globals::netif_default.acd); + if (acd == nullptr) { + DEBUG_EXIT + return; + } + switch (acd->state) { case acd::State::ACD_STATE_OFF: case acd::State::ACD_STATE_RATE_LIMIT: diff --git a/lib-network/src/net/apps/mdns/mdns.cpp b/lib-network/src/net/apps/mdns/mdns.cpp index 669588ce9..d198f67f6 100755 --- a/lib-network/src/net/apps/mdns/mdns.cpp +++ b/lib-network/src/net/apps/mdns/mdns.cpp @@ -24,9 +24,7 @@ */ #if defined (DEBUG_NET_APPS_MDNS) -# if defined (NDEBUG) -# undef NDEBUG -# endif +# undef NDEBUG #endif #include @@ -36,6 +34,7 @@ #include #include "net/apps/mdns.h" +#include "net/protocol/dns.h" #include "net/protocol/ip4.h" #include "net/protocol/iana.h" @@ -51,8 +50,6 @@ static constexpr auto SERVICE_RECORDS_MAX = 8; static constexpr auto SERVICE_RECORDS_MAX = MDNS_SERVICE_RECORDS_MAX; #endif -static constexpr uint32_t MDNS_RESPONSE_TTL = 3600; ///< (in seconds) - static constexpr size_t DOMAIN_MAXLEN = 256; static constexpr size_t LABEL_MAXLEN = 63; static constexpr size_t TXT_MAXLEN = 256; @@ -214,35 +211,14 @@ static constexpr mdns::ServiceReply operator& (mdns::ServiceReply a, mdns::Servi return static_cast((static_cast(a) & static_cast(b))); } -int32_t MDNS::s_nHandle; -uint32_t MDNS::s_nRemoteIp; -uint16_t MDNS::s_nRemotePort; -uint32_t MDNS::s_nBytesReceived; -uint8_t *MDNS::s_pReceiveBuffer; -MDNS *MDNS::s_pThis; +int32_t s_nHandle; +uint32_t s_nRemoteIp; +uint16_t s_nRemotePort; +uint32_t s_nBytesReceived; +uint8_t *s_pReceiveBuffer; using namespace mdns; -namespace network { -void mdns_announcement() { - DEBUG_ENTRY - - assert(MDNS::Get() != nullptr); - MDNS::Get()->SendAnnouncement(MDNS_RESPONSE_TTL); - - DEBUG_ENTRY -} - -void mdns_shutdown() { - DEBUG_ENTRY - - assert(MDNS::Get() != nullptr); - MDNS::Get()->SendAnnouncement(0); - - DEBUG_ENTRY -} -} // namespace network - static void create_service_domain(Domain& domain, ServiceRecord const& serviceRecord, const bool bIncludeName) { DEBUG_ENTRY @@ -649,7 +625,49 @@ const uint8_t *get_domain_name(const uint8_t *const msg, const uint8_t *ptr, con return (ptr); } -void MDNS::SendAnswerLocalIpAddress(const uint16_t nTransActionID, const uint32_t nTTL) { +void mdns_start() { + DEBUG_ENTRY + + Network::Get()->JoinGroup(s_nHandle, net::dns::MULTICAST_ADDRESS); + Network::Get()->SetDomainName(&DOMAIN_LOCAL[1]); + + mdns_send_announcement(MDNS_RESPONSE_TTL); + + DEBUG_EXIT +} + +void mdns_stop() { + DEBUG_ENTRY + + mdns_send_announcement(0); + + for (auto &record : s_ServiceRecords) { + if (record.pName != nullptr) { + delete[] record.pName; + } + + if (record.pTextContent != nullptr) { + delete[] record.pTextContent; + } + } + + Network::Get()->LeaveGroup(s_nHandle, net::dns::MULTICAST_ADDRESS); + Network::Get()->End(net::iana::IANA_PORT_MDNS); + s_nHandle = -1; + + DEBUG_EXIT +} + +static void mdns_sendto(const uint32_t nLength) { + if (!s_isUnicast) { + Network::Get()->SendTo(s_nHandle, s_RecordsData, nLength, net::dns::MULTICAST_ADDRESS, net::iana::IANA_PORT_MDNS); + return; + } + + Network::Get()->SendTo(s_nHandle, s_RecordsData, nLength, s_nRemoteIp, s_nRemotePort); +} + +void mdns_send_answer_local_ip_address(const uint16_t nTransActionID, const uint32_t nTTL) { DEBUG_ENTRY uint32_t nAnswers = 0; @@ -691,53 +709,62 @@ void MDNS::SendAnswerLocalIpAddress(const uint16_t nTransActionID, const uint32_ pHeader->nAdditionalCount = 0; const auto nSize = static_cast(pDst - reinterpret_cast(pHeader)); - SendTo(nSize); + mdns_sendto(nSize); DEBUG_EXIT } -MDNS::MDNS() { - assert(s_pThis == nullptr); - s_pThis = this; +static void mdns_send_message(mdns::ServiceRecord const& serviceRecord, const uint16_t nTransActionID, const uint32_t nTT) { + DEBUG_ENTRY - for (auto &record : s_ServiceRecords) { - record.services = Services::LAST_NOT_USED; + uint32_t nAnswers = 0; + auto *pDst = reinterpret_cast(&s_RecordsData) + sizeof(struct net::dns::Header); + + if ((s_ServiceReplies & ServiceReply::TYPE_PTR) == ServiceReply::TYPE_PTR) { + nAnswers++; + pDst += add_answer_dnsd_ptr(serviceRecord, pDst, nTT); } - s_nHandle = Network::Get()->Begin(net::iana::IANA_PORT_MDNS); - assert(s_nHandle != -1); + if ((s_ServiceReplies & ServiceReply::NAME_PTR) == ServiceReply::NAME_PTR) { + nAnswers++; + pDst += add_answer_ptr(serviceRecord, pDst, nTT); + } - Network::Get()->JoinGroup(s_nHandle, net::dns::MULTICAST_ADDRESS); - Network::Get()->SetDomainName(&DOMAIN_LOCAL[1]); + if ((s_ServiceReplies & ServiceReply::SRV) == ServiceReply::SRV) { + nAnswers++; + pDst += add_answer_srv(serviceRecord, pDst, nTT); + } - SendAnnouncement(MDNS_RESPONSE_TTL); -} + if ((s_ServiceReplies & ServiceReply::TXT) == ServiceReply::TXT) { + nAnswers++; + pDst += add_answer_txt(serviceRecord, pDst, nTT); + } -MDNS::~MDNS() { - SendAnnouncement(0); + pDst += add_answer_a(pDst, nTT); - for (auto &record : s_ServiceRecords) { - if (record.pName != nullptr) { - delete[] record.pName; - } + auto *pHeader = reinterpret_cast(&s_RecordsData); - if (record.pTextContent != nullptr) { - delete[] record.pTextContent; - } - } + pHeader->xid = nTransActionID; + pHeader->nFlag1 = net::dns::Flag1::FLAG1_RESPONSE | net::dns::Flag1::FLAG1_AUTHORATIVE; + pHeader->nFlag2 = 0; + pHeader->nQueryCount = 0; + pHeader->nAnswerCount = __builtin_bswap16(static_cast(nAnswers)); + pHeader->nAuthorityCount = __builtin_bswap16(1); + pHeader->nAdditionalCount = __builtin_bswap16(0); - Network::Get()->LeaveGroup(s_nHandle, net::dns::MULTICAST_ADDRESS); - Network::Get()->End(net::iana::IANA_PORT_MDNS); - s_nHandle = -1; + const auto nSize = static_cast(pDst - reinterpret_cast(pHeader)); + mdns_sendto(nSize); + + DEBUG_EXIT } -void MDNS::SendAnnouncement(const uint32_t nTTL) { +void mdns_send_announcement(const uint32_t nTTL) { DEBUG_ENTRY s_nRemotePort = net::iana::IANA_PORT_MDNS; //FIXME Hack ;-) s_HostReplies = HostReply::A; - SendAnswerLocalIpAddress(0, nTTL); + mdns_send_answer_local_ip_address(0, nTTL); for (auto &record : s_ServiceRecords) { if (record.services < Services::LAST_NOT_USED) { @@ -745,14 +772,14 @@ void MDNS::SendAnnouncement(const uint32_t nTTL) { | ServiceReply::NAME_PTR | ServiceReply::SRV | ServiceReply::TXT; - SendMessage(record, 0, nTTL); + mdns_send_message(record, 0, nTTL); } } DEBUG_EXIT } -bool MDNS::ServiceRecordAdd(const char *pName, const mdns::Services services, const char *pTextContent, const uint16_t nPort) { +bool mdns_service_record_add(const char *pName, const mdns::Services services, const char *pTextContent, const uint16_t nPort) { DEBUG_ENTRY assert(services < mdns::Services::LAST_NOT_USED); @@ -797,7 +824,7 @@ bool MDNS::ServiceRecordAdd(const char *pName, const mdns::Services services, co | ServiceReply::SRV | ServiceReply::TXT; - SendMessage(record, 0, MDNS_RESPONSE_TTL); + mdns_send_message(record, 0, MDNS_RESPONSE_TTL); return true; } } @@ -806,13 +833,13 @@ bool MDNS::ServiceRecordAdd(const char *pName, const mdns::Services services, co return false; } -bool MDNS::ServiceRecordDelete(const mdns::Services service) { +bool mdns_service_record_delete(const mdns::Services service) { DEBUG_ENTRY assert(service < mdns::Services::LAST_NOT_USED); for (auto &record : s_ServiceRecords) { if (record.services == service) { - SendMessage(record, 0, 0); + mdns_send_message(record, 0, 0); if (record.pName != nullptr) { delete[] record.pName; @@ -831,60 +858,7 @@ bool MDNS::ServiceRecordDelete(const mdns::Services service) { return false; } -void MDNS::SendTo(const uint32_t nLength) { - if (!s_isUnicast) { - Network::Get()->SendTo(s_nHandle, s_RecordsData, nLength, net::dns::MULTICAST_ADDRESS, net::iana::IANA_PORT_MDNS); - return; - } - - Network::Get()->SendTo(s_nHandle, s_RecordsData, nLength, s_nRemoteIp, s_nRemotePort); -} - -void MDNS::SendMessage(mdns::ServiceRecord const& serviceRecord, const uint16_t nTransActionID, const uint32_t nTT) { - DEBUG_ENTRY - - uint32_t nAnswers = 0; - auto *pDst = reinterpret_cast(&s_RecordsData) + sizeof(struct net::dns::Header); - - if ((s_ServiceReplies & ServiceReply::TYPE_PTR) == ServiceReply::TYPE_PTR) { - nAnswers++; - pDst += add_answer_dnsd_ptr(serviceRecord, pDst, nTT); - } - - if ((s_ServiceReplies & ServiceReply::NAME_PTR) == ServiceReply::NAME_PTR) { - nAnswers++; - pDst += add_answer_ptr(serviceRecord, pDst, nTT); - } - - if ((s_ServiceReplies & ServiceReply::SRV) == ServiceReply::SRV) { - nAnswers++; - pDst += add_answer_srv(serviceRecord, pDst, nTT); - } - - if ((s_ServiceReplies & ServiceReply::TXT) == ServiceReply::TXT) { - nAnswers++; - pDst += add_answer_txt(serviceRecord, pDst, nTT); - } - - pDst += add_answer_a(pDst, nTT); - - auto *pHeader = reinterpret_cast(&s_RecordsData); - - pHeader->xid = nTransActionID; - pHeader->nFlag1 = net::dns::Flag1::FLAG1_RESPONSE | net::dns::Flag1::FLAG1_AUTHORATIVE; - pHeader->nFlag2 = 0; - pHeader->nQueryCount = 0; - pHeader->nAnswerCount = __builtin_bswap16(static_cast(nAnswers)); - pHeader->nAuthorityCount = __builtin_bswap16(1); - pHeader->nAdditionalCount = __builtin_bswap16(0); - - const auto nSize = static_cast(pDst - reinterpret_cast(pHeader)); - SendTo(nSize); - - DEBUG_EXIT -} - -void MDNS::HandleQuestions(const uint32_t nQuestions) { +void mdns_handle_questions(const uint32_t nQuestions) { DEBUG_ENTRY DEBUG_PRINTF("nQuestions=%u", nQuestions); @@ -984,7 +958,7 @@ void MDNS::HandleQuestions(const uint32_t nQuestions) { } if (s_ServiceReplies != static_cast(0)) { - SendMessage(record, nTransactionID, MDNS_RESPONSE_TTL); + mdns_send_message(record, nTransactionID, MDNS_RESPONSE_TTL); } } } @@ -992,13 +966,54 @@ void MDNS::HandleQuestions(const uint32_t nQuestions) { if (s_HostReplies != static_cast(0)) { DEBUG_PUTS(""); - SendAnswerLocalIpAddress(nTransactionID, MDNS_RESPONSE_TTL); + mdns_send_answer_local_ip_address(nTransactionID, MDNS_RESPONSE_TTL); } DEBUG_EXIT } -void MDNS::Print() { +static void mdns_input(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + if (pBuffer != nullptr) { + s_pReceiveBuffer = const_cast(pBuffer); + s_nBytesReceived = nSize; + s_nRemoteIp = nFromIp; + s_nRemotePort = nFromPort; + } + + const auto *const pHeader = reinterpret_cast(s_pReceiveBuffer); + const auto nFlag1 = pHeader->nFlag1; + + if ((nFlag1 >> 3) & 0xF) { + return; + } + + mdns_handle_questions(static_cast(__builtin_bswap16(pHeader->nQueryCount))); +} + +void mdns_init() { + DEBUG_ENTRY + + for (auto &record : s_ServiceRecords) { + record.services = Services::LAST_NOT_USED; + } + + s_nHandle = Network::Get()->Begin(net::iana::IANA_PORT_MDNS, mdns_input); + assert(s_nHandle != -1); + + DEBUG_EXIT +} + +void mdns_run() { + s_nBytesReceived = Network::Get()->RecvFrom(s_nHandle, const_cast(reinterpret_cast(&s_pReceiveBuffer)), &s_nRemoteIp, &s_nRemotePort); + + if (__builtin_expect((s_nBytesReceived < sizeof(struct net::dns::Header)), 1)) { + return; + } + + mdns_input(nullptr, 0, 0, 0); +} + +void mdns_print() { printf("mDNS\n"); Domain domain; @@ -1014,3 +1029,4 @@ void MDNS::Print() { } } } + diff --git a/lib-network/src/net/apps/ntp/ntpclient.cpp b/lib-network/src/net/apps/ntp/ntpclient.cpp index 4db22dce1..3787bd208 100755 --- a/lib-network/src/net/apps/ntp/ntpclient.cpp +++ b/lib-network/src/net/apps/ntp/ntpclient.cpp @@ -98,7 +98,7 @@ NtpClient::NtpClient() { void NtpClient::GetTimeNtpFormat(uint32_t &nSeconds, uint32_t &nFraction) { struct timeval now; gettimeofday(&now, nullptr); - nSeconds = now.tv_sec + ntp::JAN_1970; + nSeconds = static_cast(now.tv_sec) + ntp::JAN_1970; nFraction = NTPFRAC(now.tv_usec); } @@ -165,8 +165,8 @@ void NtpClient::SetTimeOfDay() { auto nOffsetSeconds = static_cast(nDiffSeconds1) + static_cast(nDiffSeconds2); auto nOffsetMicroSeconds = static_cast(nDiffMicroSeconds1) + static_cast(nDiffMicroSeconds2); - const int32_t nOffsetSecondsAverage = nOffsetSeconds / 2; - const int32_t nOffsetMicrosAverage = nOffsetMicroSeconds / 2; + const auto nOffsetSecondsAverage = static_cast(nOffsetSeconds / 2); + const auto nOffsetMicrosAverage = static_cast(nOffsetMicroSeconds / 2); ntp::time_t ptpOffset = {.tv_sec = nOffsetSecondsAverage, .tv_usec = nOffsetMicrosAverage}; ntp::normalize_time(&ptpOffset); diff --git a/lib-network/src/net/apps/tftp/tftpdaemon.cpp b/lib-network/src/net/apps/tftp/tftpdaemon.cpp index 3d0c3d9d1..9f860ce7a 100644 --- a/lib-network/src/net/apps/tftp/tftpdaemon.cpp +++ b/lib-network/src/net/apps/tftp/tftpdaemon.cpp @@ -27,48 +27,48 @@ * https://tools.ietf.org/html/rfc1350 */ +#if defined (DEBUG_NET_APPS_TFTP) +# undef NDEBUG +#endif + #include #include #include +#include "net.h" #include "net/apps/tftpdaemon.h" +#include "net/protocol/iana.h" #include "network.h" #include "debug.h" -enum TOpCode { - OP_CODE_RRQ = 1, ///< Read request (RRQ) - OP_CODE_WRQ = 2, ///< Write request (WRQ) - OP_CODE_DATA = 3, ///< Data (DATA) - OP_CODE_ACK = 4, ///< Acknowledgment (ACK) - OP_CODE_ERROR = 5 ///< Error (ERROR) -}; - -enum TErrorCode { - ERROR_CODE_OTHER = 0, ///< Not defined, see error message (if any). - ERROR_CODE_NO_FILE = 1, ///< File not found. - ERROR_CODE_ACCESS = 2, ///< Access violation. - ERROR_CODE_DISK_FULL = 3, ///< Disk full or allocation exceeded. - ERROR_CODE_ILL_OPER = 4, ///< Illegal TFTP operation. - ERROR_CODE_INV_ID = 5, ///< Unknown transfer ID. - ERROR_CODE_EXISTS = 6, ///< File already exists. - ERROR_CODE_INV_USER = 7 ///< No such user. -}; +static constexpr uint16_t OP_CODE_RRQ = 1; ///< Read request (RRQ) +static constexpr uint16_t OP_CODE_WRQ = 2; ///< Write request (WRQ) +static constexpr uint16_t OP_CODE_DATA = 3; ///< Data (DATA) +static constexpr uint16_t OP_CODE_ACK = 4; ///< Acknowledgment (ACK) +static constexpr uint16_t OP_CODE_ERROR = 5; ///< Error (ERROR) + +static constexpr uint16_t ERROR_CODE_OTHER = 0; ///< Not defined, see error message (if any). +static constexpr uint16_t ERROR_CODE_NO_FILE = 1; ///< File not found. +static constexpr uint16_t ERROR_CODE_ACCESS = 2; ///< Access violation. +static constexpr uint16_t ERROR_CODE_DISK_FULL = 3; ///< Disk full or allocation exceeded. +static constexpr uint16_t ERROR_CODE_ILL_OPER = 4; ///< Illegal TFTP operation. +//static constexpr uint16_t ERROR_CODE_INV_ID = 5; ///< Unknown transfer ID. +//static constexpr uint16_t ERROR_CODE_EXISTS = 6; ///< File already exists. +//static constexpr uint16_t ERROR_CODE_INV_USER = 7;///< No such user. namespace tftp { -static constexpr uint16_t UDP_PORT = 69; - namespace min { - static constexpr auto FILENAME_MODE_LEN = (1 + 1 + 1 + 1); +static constexpr uint32_t FILENAME_MODE_LEN = (1 + 1 + 1 + 1); } namespace max { - static constexpr auto FILENAME_LEN = 128; - static constexpr auto MODE_LEN = 16; - static constexpr auto FILENAME_MODE_LEN = (FILENAME_LEN + 1 + MODE_LEN + 1); - static constexpr auto DATA_LEN = 512; - static constexpr auto ERRMSG_LEN = 128; +static constexpr uint32_t FILENAME_LEN = 128; +static constexpr uint32_t MODE_LEN = 16; +static constexpr uint32_t FILENAME_MODE_LEN = (FILENAME_LEN + 1 + MODE_LEN + 1); +static constexpr uint32_t DATA_LEN = 512; +static constexpr uint32_t ERRMSG_LEN = 128; } #if !defined (PACKED) @@ -98,8 +98,6 @@ struct DataPacket { } PACKED; } // namespace tftp -TFTPDaemon *TFTPDaemon::s_pThis; - TFTPDaemon::TFTPDaemon() { DEBUG_ENTRY DEBUG_PRINTF("s_pThis=%p", reinterpret_cast(s_pThis)); @@ -110,6 +108,8 @@ TFTPDaemon::TFTPDaemon() { s_pThis = this; + Init(); + DEBUG_PRINTF("s_pThis=%p", reinterpret_cast(s_pThis)); DEBUG_EXIT } @@ -125,50 +125,70 @@ TFTPDaemon::~TFTPDaemon() { DEBUG_EXIT } -void TFTPDaemon::Run() { - if (m_nState == TFTPState::INIT) { - if (m_nFromPort != 0) { - Network::Get()->End(m_nFromPort); - m_nIdx = -1; - } +void TFTPDaemon::Init() { + DEBUG_ENTRY + assert(m_nState == TFTPState::INIT); - m_nIdx = Network::Get()->Begin(tftp::UDP_PORT); - DEBUG_PRINTF("m_nIdx=%d", m_nIdx); + if (m_nFromPort != 0) { + Network::Get()->End(m_nFromPort); + m_nIdx = -1; + } - m_nFromPort = tftp::UDP_PORT; - m_nBlockNumber = 0; - m_nState = TFTPState::WAITING_RQ; - m_bIsLastBlock = false; - } else { - m_nLength = Network::Get()->RecvFrom(m_nIdx, const_cast(reinterpret_cast(&m_pBuffer)), &m_nFromIp, &m_nFromPort); + m_nIdx = Network::Get()->Begin(net::iana::IANA_PORT_TFTP, TFTPDaemon::staticCallbackFunction); + DEBUG_PRINTF("m_nIdx=%d", m_nIdx); - switch (m_nState) { - case TFTPState::WAITING_RQ: - if (m_nLength > tftp::min::FILENAME_MODE_LEN) { - HandleRequest(); - } - break; - case TFTPState::RRQ_SEND_PACKET: - DoRead(); - break; - case TFTPState::RRQ_RECV_ACK: - if (m_nLength == sizeof(struct tftp::AckPacket)) { - HandleRecvAck(); - } - break; - case TFTPState::WRQ_RECV_PACKET: - if (m_nLength <= sizeof(struct tftp::DataPacket)) { - HandleRecvData(); - } - break; - default: - assert(0); - __builtin_unreachable(); - break; + m_nFromPort = net::iana::IANA_PORT_TFTP; + m_nBlockNumber = 0; + m_nState = TFTPState::WAITING_RQ; + m_bIsLastBlock = false; + + DEBUG_EXIT +} + +void TFTPDaemon::Input(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + if (pBuffer != nullptr) { + m_pBuffer = const_cast(pBuffer); + m_nLength = nSize; + m_nFromIp = nFromIp; + m_nFromPort = nFromPort; + } + + switch (m_nState) { + case TFTPState::WAITING_RQ: + if (m_nLength > tftp::min::FILENAME_MODE_LEN) { + HandleRequest(); + } + break; + case TFTPState::RRQ_SEND_PACKET: + DoRead(); + break; + case TFTPState::RRQ_RECV_ACK: + if (m_nLength == sizeof(struct tftp::AckPacket)) { + HandleRecvAck(); + } + break; + case TFTPState::WRQ_RECV_PACKET: + if (m_nLength <= sizeof(struct tftp::DataPacket)) { + HandleRecvData(); } + break; + default: + assert(0); + __builtin_unreachable(); + break; } } +void TFTPDaemon::Run() { + m_nLength = Network::Get()->RecvFrom(m_nIdx, const_cast(reinterpret_cast(&m_pBuffer)), &m_nFromIp, &m_nFromPort); + + if (__builtin_expect((m_nLength <= tftp::min::FILENAME_MODE_LEN), 1)) { + return; + } + + Input(nullptr, 0, 0, 0); +} + void TFTPDaemon::HandleRequest() { auto *const pPacket = reinterpret_cast(m_pBuffer); assert(pPacket != nullptr); @@ -208,8 +228,8 @@ void TFTPDaemon::HandleRequest() { SendError(ERROR_CODE_NO_FILE, "File not found"); m_nState = TFTPState::WAITING_RQ; } else { - Network::Get()->End(tftp::UDP_PORT); - m_nIdx = Network::Get()->Begin(m_nFromPort); + Network::Get()->End(net::iana::IANA_PORT_TFTP); + m_nIdx = Network::Get()->Begin(m_nFromPort, TFTPDaemon::staticCallbackFunction); m_nState = TFTPState::RRQ_SEND_PACKET; DoRead(); } @@ -219,8 +239,8 @@ void TFTPDaemon::HandleRequest() { SendError(ERROR_CODE_ACCESS, "Access violation"); m_nState = TFTPState::WAITING_RQ; } else { - Network::Get()->End(tftp::UDP_PORT); - m_nIdx = Network::Get()->Begin(m_nFromPort); + Network::Get()->End(net::iana::IANA_PORT_TFTP); + m_nIdx = Network::Get()->Begin(m_nFromPort, TFTPDaemon::staticCallbackFunction); m_nState = TFTPState::WRQ_SEND_ACK; DoWriteAck(); } @@ -252,7 +272,7 @@ void TFTPDaemon::DoRead() { pDataPacket->OpCode = __builtin_bswap16(OP_CODE_DATA); pDataPacket->BlockNumber = __builtin_bswap16(m_nBlockNumber); - m_nPacketLength = static_cast(sizeof pDataPacket->OpCode + sizeof pDataPacket->BlockNumber + m_nDataLength); + m_nPacketLength = sizeof pDataPacket->OpCode + sizeof pDataPacket->BlockNumber + m_nDataLength; m_bIsLastBlock = m_nDataLength < tftp::max::DATA_LEN; if (m_bIsLastBlock) { @@ -294,6 +314,10 @@ void TFTPDaemon::DoWriteAck() { DEBUG_PRINTF("Sending to " IPSTR ":%d, m_nState=%d", IP2STR(m_nFromIp), m_nFromPort, static_cast(m_nState)); Network::Get()->SendTo(m_nIdx, m_pBuffer, sizeof(struct tftp::AckPacket), m_nFromIp, m_nFromPort); + + if (m_nState == TFTPState::INIT) { + Init(); + } } void TFTPDaemon::HandleRecvData() { @@ -317,6 +341,7 @@ void TFTPDaemon::HandleRecvData() { } else { SendError(ERROR_CODE_DISK_FULL, "Write failed"); m_nState = TFTPState::INIT; + Init(); } } } diff --git a/lib-network/src/net/arp.cpp b/lib-network/src/net/arp.cpp index 466e92357..043491dae 100755 --- a/lib-network/src/net/arp.cpp +++ b/lib-network/src/net/arp.cpp @@ -55,7 +55,7 @@ #include "net/protocol/udp.h" #include "netif.h" -#include "hardware.h" +#include "timers.h" #include "debug.h" @@ -280,7 +280,7 @@ static void arp_send_request_unicast(const uint32_t nIp, const uint8_t *pMacAddr memset(s_arp_request.ether.dst, 0xFF , ETH_ADDR_LEN); } -static void arp_timer() { +static void arp_timer([[maybe_unused]] TimerHandle_t nHandle) { for (auto &record : s_ArpRecords) { const auto state = record.state; if (state != net::arp::State::STATE_EMPTY) { @@ -372,7 +372,7 @@ void __attribute__((cold)) arp_init() { std::memcpy(s_arp_reply.arp.sender_mac, net::globals::netif_default.hwaddr, ETH_ADDR_LEN); - Hardware::Get()->SoftwareTimerAdd(net::arp::TIMER_INTERVAL, arp_timer); + SoftwareTimerAdd(net::arp::TIMER_INTERVAL, arp_timer); DEBUG_EXIT } diff --git a/lib-network/src/net/autoip.cpp b/lib-network/src/net/autoip.cpp index cb2fedfd0..e675fb8a6 100755 --- a/lib-network/src/net/autoip.cpp +++ b/lib-network/src/net/autoip.cpp @@ -34,6 +34,9 @@ # undef NDEBUG #endif +#pragma GCC push_options +#pragma GCC optimize ("Os") + #include #include diff --git a/lib-network/src/net/dhcp.cpp b/lib-network/src/net/dhcp.cpp index 7bc1f3095..fdbd715d1 100755 --- a/lib-network/src/net/dhcp.cpp +++ b/lib-network/src/net/dhcp.cpp @@ -40,7 +40,7 @@ #include "net_memcpy.h" #include "net_private.h" -#include "hardware.h" +#include "timers.h" #include "network.h" #include "../../config/net_config.h" @@ -216,6 +216,29 @@ static void dhcp_send_release(const uint32_t nDestinationIp) { DEBUG_EXIT } +void dhcp_input(const uint8_t *pBuffer, uint32_t nSize, [[maybe_unused]] uint32_t nFromIp, uint16_t nFromPort) { + DEBUG_ENTRY + + if (nFromPort == net::iana::IANA_PORT_DHCP_SERVER) { + auto *dhcp = reinterpret_cast(globals::netif_default.dhcp); + assert(dhcp != nullptr); + + const auto *const p = reinterpret_cast(pBuffer); + + if (p->xid != dhcp->xid) { + DEBUG_PRINTF("pDhcpMessage->xid=%u, dhcp->xid=%u", p->xid, dhcp->xid); + return; + } + + dhcp_process(p, nSize); + + DEBUG_EXIT + return; + } + + DEBUG_EXIT +} + void dhcp_inform() { DEBUG_ENTRY @@ -552,7 +575,7 @@ static void dhcp_t2_timeout() { } } -void dhcp_coarse_tmr() { +void dhcp_coarse_tmr([[maybe_unused]] TimerHandle_t nHandle) { auto *dhcp = reinterpret_cast(globals::netif_default.dhcp); if ((dhcp != nullptr) && (dhcp->state != dhcp::State::STATE_OFF)) { @@ -573,7 +596,7 @@ void dhcp_coarse_tmr() { } } -static void dhcp_fine_tmr() { +static void dhcp_fine_tmr([[maybe_unused]] TimerHandle_t nHandle) { auto *dhcp = reinterpret_cast(globals::netif_default.dhcp); if (dhcp != nullptr) { @@ -625,7 +648,7 @@ static void dhcp_handle_ack(const dhcp::Message *const pResponse) { if (dhcp->offered.offered_sn_mask.addr != 0) { dhcp->flags |= DHCP_FLAG_SUBNET_MASK_GIVEN; } else { - dhcp->flags &= ~DHCP_FLAG_SUBNET_MASK_GIVEN; + dhcp->flags &= static_cast(~DHCP_FLAG_SUBNET_MASK_GIVEN); } DEBUG_PRINTF("t0=%u, t1=%u, t2=%u", dhcp->offered.offered_t0_lease, dhcp->offered.offered_t1_renew, dhcp->offered.offered_t2_rebind); @@ -658,12 +681,12 @@ bool dhcp_start() { assert(dhcp != nullptr); globals::netif_default.dhcp = dhcp; - nTimerId = Hardware::Get()->SoftwareTimerAdd(dhcp::DHCP_FINE_TIMER_MSECS, dhcp_fine_tmr); + nTimerId = SoftwareTimerAdd(dhcp::DHCP_FINE_TIMER_MSECS, dhcp_fine_tmr); assert(nTimerId >= 0); } memset(dhcp, 0, sizeof(struct dhcp::Dhcp)); - dhcp->nHandle = udp_begin(net::iana::IANA_PORT_DHCP_CLIENT); + dhcp->nHandle = udp_begin(net::iana::IANA_PORT_DHCP_CLIENT, dhcp_input); #ifndef NDEBUG if (dhcp->nHandle < 0) { diff --git a/lib-network/src/net/igmp.cpp b/lib-network/src/net/igmp.cpp index 35456eec4..6ac3ec32a 100644 --- a/lib-network/src/net/igmp.cpp +++ b/lib-network/src/net/igmp.cpp @@ -48,7 +48,7 @@ #include "net_memcpy.h" #include "net_private.h" -#include "hardware.h" +#include "timers.h" #include "debug.h" @@ -120,7 +120,7 @@ static void igmp_send_report(const uint32_t nGroupAddress) { } static void igmp_start_timer(struct t_group_info &group, const uint32_t max_time) { - group.nTimer = (max_time > 2 ? (random() % max_time) : 1); + group.nTimer = static_cast((max_time > 2U ? (static_cast(random()) % max_time) : 1U)); if (group.nTimer == 0) { group.nTimer = 1; @@ -134,7 +134,7 @@ static void igmp_timeout(struct t_group_info &group) { } } -static void igmp_timer() { +static void igmp_timer([[maybe_unused]] TimerHandle_t nHandle) { for (auto &group : s_groups) { if (group.nTimer > 0) { group.nTimer--; @@ -198,7 +198,7 @@ void __attribute__((cold)) igmp_init() { s_leave.igmp.report.igmp.type = IGMP_TYPE_LEAVE; s_leave.igmp.report.igmp.max_resp_time = 0; - nTimerId = Hardware::Get()->SoftwareTimerAdd(IGMP_TMR_INTERVAL, igmp_timer); + nTimerId = SoftwareTimerAdd(IGMP_TMR_INTERVAL, igmp_timer); assert(nTimerId >= 0); } diff --git a/lib-network/src/net/ip.cpp b/lib-network/src/net/ip.cpp index b2f3c6bf2..5c6faebff 100644 --- a/lib-network/src/net/ip.cpp +++ b/lib-network/src/net/ip.cpp @@ -59,36 +59,4 @@ void __attribute__((cold)) ip_init() { DEBUG_EXIT } - -__attribute__((hot)) void ip_handle(struct t_ip4 *p_ip4) { - if (__builtin_expect((p_ip4->ip4.ver_ihl != 0x45), 0)) { - if (p_ip4->ip4.proto == IPv4_PROTO_IGMP) { - igmp_handle(reinterpret_cast(p_ip4)); - } else { - DEBUG_PRINTF("p_ip4->ip4.ver_ihl=0x%x", p_ip4->ip4.ver_ihl); - } - return; - } - - switch (p_ip4->ip4.proto) { - case IPv4_PROTO_UDP: - udp_handle(reinterpret_cast(p_ip4)); - break; - case IPv4_PROTO_IGMP: - igmp_handle(reinterpret_cast(p_ip4)); - break; - case IPv4_PROTO_ICMP: - icmp_handle(reinterpret_cast(p_ip4)); - break; -#if defined (ENABLE_HTTPD) - case IPv4_PROTO_TCP: - tcp_handle(reinterpret_cast(p_ip4)); - tcp_run(); - break; -#endif - default: - DEBUG_PRINTF("proto %d not implemented", p_ip4->ip4.proto); - break; - } -} } // namespace net diff --git a/lib-network/src/net/net.cpp b/lib-network/src/net/net.cpp index ae8402e2f..5809a6aac 100755 --- a/lib-network/src/net/net.cpp +++ b/lib-network/src/net/net.cpp @@ -51,10 +51,6 @@ static struct net::acd::Acd s_acd; -namespace network { -__attribute__((weak)) void mdns_shutdown() {} -} // namespace network - namespace net { namespace globals { uint32_t nBroadcastMask; @@ -169,7 +165,37 @@ __attribute__((hot)) void net_handle() { } else #endif if (eth->type == __builtin_bswap16(ETHER_TYPE_IPv4)) { - ip_handle(reinterpret_cast(s_p)); + auto *p_ip4 = reinterpret_cast(s_p); + if (__builtin_expect((p_ip4->ip4.ver_ihl != 0x45), 0)) { + if (p_ip4->ip4.proto == IPv4_PROTO_IGMP) { + igmp_handle(reinterpret_cast(p_ip4)); + } else { + DEBUG_PRINTF("p_ip4->ip4.ver_ihl=0x%x", p_ip4->ip4.ver_ihl); + } + } else { + switch (p_ip4->ip4.proto) { + case IPv4_PROTO_UDP: + udp_handle(reinterpret_cast(p_ip4)); + // NOTE: emac_free_pkt(); is done in udp_handle + return; + break; + case IPv4_PROTO_IGMP: + igmp_handle(reinterpret_cast(p_ip4)); + break; + case IPv4_PROTO_ICMP: + icmp_handle(reinterpret_cast(p_ip4)); + break; +#if defined (ENABLE_HTTPD) + case IPv4_PROTO_TCP: + tcp_handle(reinterpret_cast(p_ip4)); + tcp_run(); + break; +#endif + default: + DEBUG_PRINTF("proto %d not implemented", p_ip4->ip4.proto); + break; + } + } } else if (eth->type == __builtin_bswap16(ETHER_TYPE_ARP)) { net::arp_handle(reinterpret_cast(s_p)); } else { diff --git a/lib-network/src/net/net_chksum.cpp b/lib-network/src/net/net_chksum.cpp index 408ebaa7c..05ad77008 100644 --- a/lib-network/src/net/net_chksum.cpp +++ b/lib-network/src/net/net_chksum.cpp @@ -23,9 +23,11 @@ * THE SOFTWARE. */ -#pragma GCC push_options -#pragma GCC optimize ("O2") -#pragma GCC optimize ("no-tree-loop-distribute-patterns") +#if !defined (CONFIG_REMOTECONFIG_MINIMUM) +# pragma GCC push_options +# pragma GCC optimize ("O2") +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +#endif #include diff --git a/lib-network/src/net/net_platform.h b/lib-network/src/net/net_platform.h index 8f5ce4475..68512a450 100644 --- a/lib-network/src/net/net_platform.h +++ b/lib-network/src/net/net_platform.h @@ -37,7 +37,16 @@ # define SECTION_NETWORK # endif #else +# include "h3.h" # define SECTION_NETWORK +# include "../../src/emac/h3/emac.h" +inline void *get_tx_dma() { + extern struct coherent_region *p_coherent_region; + auto desc_num = p_coherent_region->tx_currdescnum; + auto *desc_p = &p_coherent_region->tx_chain[desc_num]; + auto data_start = static_cast(desc_p->buf_addr); + return reinterpret_cast(data_start); +} #endif #endif /* NET_PLATFORM_H_ */ diff --git a/lib-network/src/net/net_private.h b/lib-network/src/net/net_private.h index 336c4c58d..0d499db7d 100644 --- a/lib-network/src/net/net_private.h +++ b/lib-network/src/net/net_private.h @@ -55,7 +55,7 @@ void emac_eth_send(void *, uint32_t); #if defined CONFIG_ENET_ENABLE_PTP void emac_eth_send_timestamp(void *, uint32_t); #endif -int emac_eth_recv(uint8_t **); +uint32_t emac_eth_recv(uint8_t **); void emac_free_pkt(); namespace net { diff --git a/lib-network/src/net/netif.cpp b/lib-network/src/net/netif.cpp index 975b1e6f5..0e86b1d14 100755 --- a/lib-network/src/net/netif.cpp +++ b/lib-network/src/net/netif.cpp @@ -27,6 +27,9 @@ # undef NDEBUG #endif +#pragma GCC push_options +#pragma GCC optimize ("Os") + #include #include "netif.h" diff --git a/lib-network/src/net/tcp.cpp b/lib-network/src/net/tcp.cpp index 5ead59c85..d20d0d584 100644 --- a/lib-network/src/net/tcp.cpp +++ b/lib-network/src/net/tcp.cpp @@ -100,7 +100,7 @@ struct tcb { struct { uint8_t *data; - uint16_t size; + uint32_t size; } TX; /* Receive Sequence Variables */ @@ -449,7 +449,7 @@ static void send_package(const struct tcb *pTcb, const struct SendInfo &sendInfo DEBUG_PRINTF("SEQ=%u, ACK=%u, tcplen=%u, data_offset=%u, p_tcb->TX.size=%u", s_tcp.tcp.seqnum, s_tcp.tcp.acknum, tcplen, nDataOffset, pTcb->TX.size); if (pTcb->TX.data != nullptr) { - for (auto i = 0; i < pTcb->TX.size; i++) { + for (uint32_t i = 0; i < pTcb->TX.size; i++) { *pData++ = pTcb->TX.data[i]; } } @@ -462,7 +462,7 @@ static void send_package(const struct tcb *pTcb, const struct SendInfo &sendInfo s_tcp.tcp.checksum = _chksum(&s_tcp, pTcb, static_cast(tcplen)); - emac_eth_send(reinterpret_cast(&s_tcp), static_cast(tcplen + sizeof(struct ip4_header) + sizeof(struct ether_header))); + emac_eth_send(reinterpret_cast(&s_tcp), tcplen + sizeof(struct ip4_header) + sizeof(struct ether_header)); } static void send_reset(struct t_tcp *pTcp, const struct tcb *pTcb) { diff --git a/lib-network/src/net/udp.cpp b/lib-network/src/net/udp.cpp index f34f76889..1aa90a58a 100644 --- a/lib-network/src/net/udp.cpp +++ b/lib-network/src/net/udp.cpp @@ -53,6 +53,11 @@ namespace globals { extern uint32_t nBroadcastMask; } // namespace globals +struct PortInfo { + UdpCallbackFunctionPtr callback; + uint16_t nPort; +}; + struct data_entry { uint32_t from_ip; uint32_t size; @@ -60,9 +65,9 @@ struct data_entry { uint8_t data[UDP_DATA_SIZE]; } ALIGNED; -static uint16_t s_Port[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; -static struct data_entry s_data[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; -static struct t_udp s_send_packet SECTION_NETWORK ALIGNED; +static PortInfo s_PortInfo[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; +static data_entry s_data[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; +static t_udp s_send_packet SECTION_NETWORK ALIGNED; static uint16_t s_id SECTION_NETWORK ALIGNED; static uint8_t s_multicast_mac[ETH_ADDR_LEN] SECTION_NETWORK ALIGNED; @@ -99,12 +104,13 @@ __attribute__((hot)) void udp_handle(struct t_udp *pUdp) { const auto nDestinationPort = __builtin_bswap16(pUdp->udp.destination_port); for (uint32_t nPortIndex = 0; nPortIndex < UDP_MAX_PORTS_ALLOWED; nPortIndex++) { - if (s_Port[nPortIndex] == nDestinationPort) { + if (s_PortInfo[nPortIndex].nPort == nDestinationPort) { if (__builtin_expect ((s_data[nPortIndex].size != 0), 0)) { DEBUG_PRINTF(IPSTR ":%d[%x]", pUdp->ip4.src[0],pUdp->ip4.src[1],pUdp->ip4.src[2],pUdp->ip4.src[3], nDestinationPort, nDestinationPort); } auto *p_queue_entry = &s_data[nPortIndex]; + const auto nDataLength = static_cast(__builtin_bswap16(pUdp->udp.len) - UDP_HEADER_SIZE); const auto i = std::min(static_cast(UDP_DATA_SIZE), nDataLength); @@ -114,10 +120,18 @@ __attribute__((hot)) void udp_handle(struct t_udp *pUdp) { p_queue_entry->from_port = __builtin_bswap16(pUdp->udp.source_port); p_queue_entry->size = static_cast(i); + emac_free_pkt(); + + if (s_PortInfo[nPortIndex].callback != nullptr) { + s_PortInfo[nPortIndex].callback(p_queue_entry->data, nDataLength, p_queue_entry->from_ip, p_queue_entry->from_port); + } + return; } } + emac_free_pkt(); + DEBUG_PRINTF(IPSTR ":%d[%x] " MACSTR, pUdp->ip4.src[0],pUdp->ip4.src[1],pUdp->ip4.src[2],pUdp->ip4.src[3], nDestinationPort, nDestinationPort, MAC2STR(pUdp->ether.dst)); } @@ -125,7 +139,7 @@ template static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { assert(nIndex >= 0); assert(nIndex < UDP_MAX_PORTS_ALLOWED); - assert(s_Port[nIndex] != 0); + assert(s_PortInfo[nIndex].nPort != 0); //IPv4 s_send_packet.ip4.id = s_id++; @@ -133,7 +147,7 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n s_send_packet.ip4.chksum = 0; //UDP - s_send_packet.udp.source_port = __builtin_bswap16( s_Port[nIndex]); + s_send_packet.udp.source_port = __builtin_bswap16( s_PortInfo[nIndex].nPort); s_send_packet.udp.destination_port = __builtin_bswap16(nRemotePort); s_send_packet.udp.len = __builtin_bswap16(static_cast(nSize + UDP_HEADER_SIZE)); @@ -163,11 +177,11 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n std::memcpy(s_send_packet.ether.dst, s_multicast_mac, ETH_ADDR_LEN); net::memcpy_ip(s_send_packet.ip4.dst, nRemoteIp); } else { - if (S == net::arp::EthSend::IS_NORMAL) { + if constexpr (S == net::arp::EthSend::IS_NORMAL) { net::arp_send(&s_send_packet, nSize + UDP_PACKET_HEADERS_SIZE, nRemoteIp); } #if defined CONFIG_ENET_ENABLE_PTP - else if (S == net::arp::EthSend::IS_TIMESTAMP) { + else if constexpr (S == net::arp::EthSend::IS_TIMESTAMP) { net::arp_send_timestamp(&s_send_packet, nSize + UDP_PACKET_HEADERS_SIZE, nRemoteIp); } #endif @@ -179,11 +193,11 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n s_send_packet.ip4.chksum = net_chksum(reinterpret_cast(&s_send_packet.ip4), sizeof(s_send_packet.ip4)); #endif - if (S == net::arp::EthSend::IS_NORMAL) { + if constexpr (S == net::arp::EthSend::IS_NORMAL) { emac_eth_send(reinterpret_cast(&s_send_packet), nSize + UDP_PACKET_HEADERS_SIZE); } #if defined CONFIG_ENET_ENABLE_PTP - else if (S == net::arp::EthSend::IS_TIMESTAMP) { + else if constexpr (S == net::arp::EthSend::IS_TIMESTAMP) { emac_eth_send_timestamp(reinterpret_cast(&s_send_packet), nSize); } #endif @@ -192,18 +206,19 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n // --> -int udp_begin(uint16_t nLocalPort) { +int udp_begin(uint16_t nLocalPort, UdpCallbackFunctionPtr callback) { DEBUG_PRINTF("nLocalPort=%u", nLocalPort); for (int i = 0; i < UDP_MAX_PORTS_ALLOWED; i++) { - if (s_Port[i] == nLocalPort) { + if (s_PortInfo[i].nPort == nLocalPort) { return i; } - if (s_Port[i] == 0) { - s_Port[i] = nLocalPort; + if (s_PortInfo[i].nPort == 0) { + s_PortInfo[i].callback = callback; + s_PortInfo[i].nPort = nLocalPort; - DEBUG_PRINTF("i=%d, local_port=%d[%x]", i, nLocalPort, nLocalPort); + DEBUG_PRINTF("i=%d, local_port=%d[%x], callback=%p", i, nLocalPort, nLocalPort, callback); return i; } } @@ -218,8 +233,9 @@ int udp_end(uint16_t nLocalPort) { DEBUG_PRINTF("nLocalPort=%u[%x]", nLocalPort, nLocalPort); for (auto i = 0; i < UDP_MAX_PORTS_ALLOWED; i++) { - if (s_Port[i] == nLocalPort) { - s_Port[i] = 0; + if (s_PortInfo[i].nPort == nLocalPort) { + s_PortInfo[i].callback = nullptr; + s_PortInfo[i].nPort = 0; s_data[i].size = 0; return 0; } diff --git a/lib-network/src/params/networkparams.cpp b/lib-network/src/params/networkparams.cpp index 76c9ebe14..453218181 100644 --- a/lib-network/src/params/networkparams.cpp +++ b/lib-network/src/params/networkparams.cpp @@ -51,7 +51,6 @@ NetworkParams::NetworkParams() { memset(&m_Params, 0, sizeof(struct networkparams::Params)); m_Params.bIsDhcpUsed = defaults::IS_DHCP_USED; - m_Params.nDhcpRetryTime = defaults::DHCP_RETRY_TIME; DEBUG_EXIT } @@ -110,16 +109,6 @@ void NetworkParams::callbackFunction(const char *pLine) { return; } - if (Sscan::Uint8(pLine, NetworkParamsConst::DHCP_RETRY_TIME, nValue8) == Sscan::OK) { - if ((nValue8 != defaults::DHCP_RETRY_TIME) && (nValue8 <= 5)) { - m_Params.nSetList |= networkparams::Mask::DHCP_RETRY_TIME; - m_Params.nDhcpRetryTime = nValue8; - } else { - m_Params.nSetList &= ~networkparams::Mask::DHCP_RETRY_TIME; - m_Params.nDhcpRetryTime = defaults::DHCP_RETRY_TIME; - } - } - uint32_t nValue32; if (Sscan::IpAddress(pLine, NetworkParamsConst::IP_ADDRESS, nValue32) == Sscan::OK) { @@ -233,7 +222,6 @@ void NetworkParams::Builder(const struct networkparams::Params *ptNetworkParams, } builder.Add(NetworkParamsConst::USE_DHCP, m_Params.bIsDhcpUsed, isMaskSet(networkparams::Mask::DHCP)); - builder.Add(NetworkParamsConst::DHCP_RETRY_TIME, m_Params.nDhcpRetryTime, isMaskSet(networkparams::Mask::DHCP_RETRY_TIME)); builder.AddComment("Static IP"); builder.AddIpAddress(NetworkParamsConst::IP_ADDRESS, m_Params.nLocalIp, isMaskSet(networkparams::Mask::IP_ADDRESS)); diff --git a/lib-remoteconfig/include/remoteconfig.h b/lib-remoteconfig/include/remoteconfig.h index b851f56c2..994829ff7 100644 --- a/lib-remoteconfig/include/remoteconfig.h +++ b/lib-remoteconfig/include/remoteconfig.h @@ -205,20 +205,22 @@ class RemoteConfig { uint32_t HandleGet(void *pBuffer, uint32_t nBufferLength); void HandleSet(void *pBuffer, uint32_t nBufferLength); + void Input(const uint8_t *, uint32_t, uint32_t, uint16_t); + void Run() { +#if defined (ENABLE_HTTPD) + m_pHttpDaemon->Run(); +#endif + if (__builtin_expect((m_bDisable), 1)) { return; } -#if defined (ENABLE_TFTP_SERVER) - if (__builtin_expect((m_pTFTPFileServer != nullptr), 0)) { - m_pTFTPFileServer->Run(); - } -#endif - -#if defined (ENABLE_HTTPD) - m_pHttpDaemon->Run(); -#endif +//#if defined (ENABLE_TFTP_SERVER) +// if (__builtin_expect((m_pTFTPFileServer != nullptr), 0)) { +// m_pTFTPFileServer->Run(); +// } +//#endif uint16_t nForeignPort; m_nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &m_nIPAddressFrom, &nForeignPort); @@ -227,7 +229,7 @@ class RemoteConfig { return; } - HandleRequest(); + Input(nullptr, 0, m_nIPAddressFrom, nForeignPort); } static RemoteConfig *Get() { @@ -535,6 +537,9 @@ class RemoteConfig { static char *s_pUdpBuffer; + void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + RemoteConfig::Get()->Input(pBuffer, nSize, nFromIp, nFromPort); + } static RemoteConfig *s_pThis; }; diff --git a/lib-remoteconfig/src/httpd/httpd.cpp b/lib-remoteconfig/src/httpd/httpd.cpp index 29844d171..914f66c89 100755 --- a/lib-remoteconfig/src/httpd/httpd.cpp +++ b/lib-remoteconfig/src/httpd/httpd.cpp @@ -51,8 +51,9 @@ HttpDaemon::HttpDaemon() { assert(pHandleRequest[nIndex] != nullptr); } - assert(MDNS::Get() != nullptr); - MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::HTTP); +// assert(MDNS::Get() != nullptr); +// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::HTTP); + mdns_service_record_add(nullptr, mdns::Services::HTTP); DEBUG_EXIT } @@ -60,7 +61,8 @@ HttpDaemon::HttpDaemon() { HttpDaemon::~HttpDaemon() { DEBUG_ENTRY - MDNS::Get()->ServiceRecordDelete(mdns::Services::HTTP); +// MDNS::Get()->ServiceRecordDelete(mdns::Services::HTTP); + mdns_service_record_delete(mdns::Services::HTTP); for (uint32_t nIndex = 0; nIndex < TCP_MAX_TCBS_ALLOWED; nIndex++) { if (pHandleRequest[nIndex] != nullptr) { diff --git a/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp b/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp index de9e6b8c2..69a34d702 100755 --- a/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp +++ b/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp @@ -174,13 +174,13 @@ void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char "\n", static_cast(m_Status), pStatusMsg, pStatusMsg)); } - const auto nHeaderLength = snprintf(m_RequestHeaderResponse, sizeof(m_DynamicContent) - 1U, + const auto nHeaderLength = static_cast(snprintf(m_RequestHeaderResponse, sizeof(m_DynamicContent) - 1U, "HTTP/1.1 %u %s\r\n" "Server: %s\r\n" "Content-Type: %s\r\n" "Content-Length: %u\r\n" "Connection: close\r\n" - "\r\n", static_cast(m_Status), pStatusMsg, Network::Get()->GetHostName(), s_contentType[static_cast(m_ContentType)], static_cast(m_nContentSize)); + "\r\n", static_cast(m_Status), pStatusMsg, Network::Get()->GetHostName(), s_contentType[static_cast(m_ContentType)], static_cast(m_nContentSize))); Network::Get()->TcpWrite(m_nHandle, reinterpret_cast(m_RequestHeaderResponse), nHeaderLength, m_nConnectionHandle); Network::Get()->TcpWrite(m_nHandle, reinterpret_cast(m_pContent), m_nContentSize, m_nConnectionHandle); @@ -651,11 +651,11 @@ http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { } DEBUG_PRINTF("identify=%d", value8 != 0); } else if (memcmp(m_pFileData, "date=", 5) == 0) { - remoteconfig::timedate::json_set_timeofday(m_pFileData, nJsonLength); + remoteconfig::timedate::json_set_timeofday(m_pFileData, static_cast(nJsonLength)); } #if !defined (DISABLE_RTC) else if (memcmp(m_pFileData, "rtc=", 4) == 0) { - remoteconfig::rtc::json_set_rtc(m_pFileData, nJsonLength); + remoteconfig::rtc::json_set_rtc(m_pFileData, static_cast(nJsonLength)); } #endif #if defined (RDM_CONTROLLER) diff --git a/lib-remoteconfig/src/remoteconfig.cpp b/lib-remoteconfig/src/remoteconfig.cpp index dfa594cc9..954ce492f 100644 --- a/lib-remoteconfig/src/remoteconfig.cpp +++ b/lib-remoteconfig/src/remoteconfig.cpp @@ -263,15 +263,18 @@ RemoteConfig::RemoteConfig(const remoteconfig::Node node, const remoteconfig::Ou s_RemoteConfigListBin.nActiveOutputs = static_cast(nActiveOutputs); s_RemoteConfigListBin.aDisplayName[0] = '\0'; +// m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT); assert(m_nHandle != -1); #if !defined (CONFIG_REMOTECONFIG_MINIMUM) - assert(MDNS::Get() != nullptr); - MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); +// assert(MDNS::Get() != nullptr); +// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); + mdns_service_record_add(nullptr, mdns::Services::CONFIG); # if defined(ENABLE_TFTP_SERVER) - MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::TFTP); +// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::TFTP); + mdns_service_record_add(nullptr, mdns::Services::TFTP); # endif # if defined (ENABLE_HTTPD) @@ -293,7 +296,8 @@ RemoteConfig::~RemoteConfig() { } # endif - MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); +// MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); + mdns_service_record_delete(mdns::Services::CONFIG); #endif Network::Get()->End(remoteconfig::udp::PORT); @@ -317,14 +321,17 @@ void RemoteConfig::SetDisable(bool bDisable) { Network::Get()->End(remoteconfig::udp::PORT); m_nHandle = -1; #if !defined (CONFIG_REMOTECONFIG_MINIMUM) - MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); +// MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); + mdns_service_record_delete(mdns::Services::CONFIG); #endif m_bDisable = true; } else if (!bDisable && m_bDisable) { +// m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT); assert(m_nHandle != -1); #if !defined (CONFIG_REMOTECONFIG_MINIMUM) - MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); +// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); + mdns_service_record_add(nullptr, mdns::Services::CONFIG); #endif m_bDisable = false; } @@ -346,9 +353,15 @@ void RemoteConfig::SetDisplayName(const char *pDisplayName) { DEBUG_EXIT } -void RemoteConfig::HandleRequest() { +void RemoteConfig::Input(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, [[maybe_unused]] uint16_t nFromPort) { + if (pBuffer != nullptr) { + s_pUdpBuffer = const_cast(reinterpret_cast(pBuffer)); + m_nBytesReceived = nSize; + m_nIPAddressFrom = nFromIp; + } + #ifndef NDEBUG - debug_dump(s_pUdpBuffer, static_cast(m_nBytesReceived)); + debug_dump(s_pUdpBuffer, m_nBytesReceived); #endif if (s_pUdpBuffer[m_nBytesReceived - 1] == '\n') { diff --git a/lib-remoteconfig/src/shell/shellcmd.cpp b/lib-remoteconfig/src/shell/shellcmd.cpp index f82b55cd3..457fcbe53 100755 --- a/lib-remoteconfig/src/shell/shellcmd.cpp +++ b/lib-remoteconfig/src/shell/shellcmd.cpp @@ -423,7 +423,7 @@ void Shell::CmdHwClock() { #if defined (DEBUG_I2C) void Shell::CmdI2cDetect() { - I2cDetect i2cdetect; + i2c_detect(); } #endif diff --git a/lib-remoteconfig/src/tftp/remoteconfig.cpp b/lib-remoteconfig/src/tftp/remoteconfig.cpp index eee8894f8..01a61dd6f 100644 --- a/lib-remoteconfig/src/tftp/remoteconfig.cpp +++ b/lib-remoteconfig/src/tftp/remoteconfig.cpp @@ -2,7 +2,7 @@ * @file remoteconfig.cpp * */ -/* Copyright (C) 2022-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,6 +24,9 @@ */ #if defined(ENABLE_TFTP_SERVER) +# if defined (DEBUG_TFTP) +# undef NDEBUG +# endif #if !defined(__clang__) // Needed for compiling on MacOS # pragma GCC push_options @@ -83,5 +86,4 @@ void RemoteConfig::PlatformHandleTftpGet() { DEBUG_EXIT } - #endif diff --git a/lib-remoteconfig/src/tftp/tftpfileserver.cpp b/lib-remoteconfig/src/tftp/tftpfileserver.cpp index ccc094471..88592e403 100644 --- a/lib-remoteconfig/src/tftp/tftpfileserver.cpp +++ b/lib-remoteconfig/src/tftp/tftpfileserver.cpp @@ -2,7 +2,7 @@ * @file tftpfileserver.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_TFTP) +# undef NDEBUG +#endif + #include #include #include From b9118f2a33c0ff48b4aaf9f58f8cd264e4a4f395 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:08:52 +0200 Subject: [PATCH 07/36] RDMNet LLRP fixed issue with GetDefaultRoute --- lib-rdm/include/llrp/llrpdevice.h | 43 +++++++++++++++++++++---------- lib-rdm/src/llrp/llrpdevice.cpp | 15 +++++------ lib-rdm/src/rdm_message_print.cpp | 4 +-- lib-rdm/src/rdmhandler.cpp | 2 +- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/lib-rdm/include/llrp/llrpdevice.h b/lib-rdm/include/llrp/llrpdevice.h index 53dafb7ae..1ae718e23 100755 --- a/lib-rdm/include/llrp/llrpdevice.h +++ b/lib-rdm/include/llrp/llrpdevice.h @@ -2,7 +2,7 @@ * @file llrpdevice.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,8 +51,10 @@ class LLRPDevice { public: LLRPDevice() { DEBUG_ENTRY + assert(s_pThis == nullptr); + s_pThis = this; - s_nHandleLLRP = Network::Get()->Begin(llrp::device::LLRP_PORT); + s_nHandleLLRP = Network::Get()->Begin(llrp::device::LLRP_PORT, LLRPDevice::staticCallbackFunction); assert(s_nHandleLLRP != -1); Network::Get()->JoinGroup(s_nHandleLLRP, llrp::device::IPV4_LLRP_REQUEST); @@ -65,16 +67,15 @@ class LLRPDevice { Network::Get()->LeaveGroup(s_nHandleLLRP, llrp::device::IPV4_LLRP_REQUEST); Network::Get()->End(llrp::device::LLRP_PORT); + s_pThis = nullptr; + DEBUG_EXIT } - void Run() { - uint16_t nForeignPort; - - const auto nBytesReceived = Network::Get()->RecvFrom(s_nHandleLLRP, const_cast(reinterpret_cast(&s_pLLRP)), &s_nIpAddressFrom, &nForeignPort) ; - - if (__builtin_expect((nBytesReceived < sizeof(struct TLLRPCommonPacket)), 1)) { - return; + void Input(const uint8_t *pBuffer, [[maybe_unused]] uint32_t nSize, uint32_t nFromIp, [[maybe_unused]] uint16_t nFromPort) { + if (pBuffer != 0) { + s_pLLRP = const_cast(pBuffer); + s_nIpAddressFrom = nFromIp; } #ifndef NDEBUG @@ -107,6 +108,18 @@ class LLRPDevice { } } + void Run() { + uint16_t nForeignPort; + + const auto nBytesReceived = Network::Get()->RecvFrom(s_nHandleLLRP, const_cast(reinterpret_cast(&s_pLLRP)), &s_nIpAddressFrom, &nForeignPort) ; + + if (__builtin_expect((nBytesReceived < sizeof(struct TLLRPCommonPacket)), 1)) { + return; + } + + Input(nullptr, 0, 0, 0); + } + void Print() { printf("LLRP Device\n"); printf(" Port UDP : %d\n", llrp::device::LLRP_PORT); @@ -127,13 +140,17 @@ class LLRPDevice { void DumpLLRP(); void DumpRdmMessageInNoSc(); + void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + s_pThis->Input(pBuffer, nSize, nFromIp, nFromPort); + } private: RDMHandler m_RDMHandler { false }; - static int32_t s_nHandleLLRP; - static uint32_t s_nIpAddressFrom; - static uint8_t *s_pLLRP; - static TRdmMessage s_RdmCommand; + static inline int32_t s_nHandleLLRP; + static inline uint32_t s_nIpAddressFrom; + static inline uint8_t *s_pLLRP; + static inline TRdmMessage s_RdmCommand; + static inline LLRPDevice *s_pThis; }; #endif /* LLRPDEVICE_H_ */ diff --git a/lib-rdm/src/llrp/llrpdevice.cpp b/lib-rdm/src/llrp/llrpdevice.cpp index e63664fb7..b2f1c4b98 100755 --- a/lib-rdm/src/llrp/llrpdevice.cpp +++ b/lib-rdm/src/llrp/llrpdevice.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_RDM_LLRPDEVICE) +# undef NDEBUG +#endif + #include #include #include @@ -43,14 +47,9 @@ #if defined(__linux__) || defined (__APPLE__) # define SHOW_LLRP_MESSAGE -# define SHOW_RDM_MESSAGE +# define DEBUG_RDM_SHOW_MESSAGE #endif -int32_t LLRPDevice::s_nHandleLLRP ; -uint32_t LLRPDevice::s_nIpAddressFrom; -uint8_t *LLRPDevice::s_pLLRP; -TRdmMessage LLRPDevice::s_RdmCommand; - void LLRPDevice::HandleRequestMessage() { DEBUG_ENTRY @@ -118,7 +117,7 @@ void LLRPDevice::HandleRdmCommand() { auto *pRDMCommand = reinterpret_cast(s_pLLRP); -#ifdef SHOW_RDM_MESSAGE +#ifdef DEBUG_RDM_SHOW_MESSAGE const auto *pRdmDataInNoSc = const_cast(pRDMCommand->RDMCommandPDU.RDMData); rdm::message_print_no_sc(pRdmDataInNoSc); #endif @@ -150,7 +149,7 @@ void LLRPDevice::HandleRdmCommand() { Network::Get()->SendTo(s_nHandleLLRP, pRDMCommand, nLength , llrp::device::IPV4_LLRP_RESPONSE, llrp::device::LLRP_PORT); -#ifdef SHOW_RDM_MESSAGE +#ifdef DEBUG_RDM_SHOW_MESSAGE rdm::message_print(pReply); #endif diff --git a/lib-rdm/src/rdm_message_print.cpp b/lib-rdm/src/rdm_message_print.cpp index a2071dc59..6faa63559 100644 --- a/lib-rdm/src/rdm_message_print.cpp +++ b/lib-rdm/src/rdm_message_print.cpp @@ -60,13 +60,13 @@ void message_print(const uint8_t *pRdmData) { printf("GET_COMMAND"); break; case E120_GET_COMMAND_RESPONSE: - printf("GET_COMMAND_RESPONSE"); + printf("GET_COMMAND_RESPONSE %u", pRdmMessage->slot16.response_type); break; case E120_SET_COMMAND: printf("SET_COMMAND"); break; case E120_SET_COMMAND_RESPONSE: - printf("SET_COMMAND_RESPONSE"); + printf("SET_COMMAND_RESPONSE %u", pRdmMessage->slot16.response_type); break; default: printf("CC {%.2x}", pRdmMessage->command_class); diff --git a/lib-rdm/src/rdmhandler.cpp b/lib-rdm/src/rdmhandler.cpp index 8fafa51e2..0bddfcdb1 100644 --- a/lib-rdm/src/rdmhandler.cpp +++ b/lib-rdm/src/rdmhandler.cpp @@ -115,7 +115,7 @@ const RDMHandler::PidDefinition RDMHandler::PID_DEFINITIONS[] { {E137_2_IPV4_STATIC_ADDRESS, &RDMHandler::GetStaticAddress, &RDMHandler::SetStaticAddress, 4, false, false, true }, {E137_2_INTERFACE_APPLY_CONFIGURATION,nullptr, &RDMHandler::ApplyConfiguration, 4, false, false, true }, {E137_2_DNS_IPV4_NAME_SERVER, &RDMHandler::GetNameServers, nullptr, 1, false, false, true }, - {E137_2_IPV4_DEFAULT_ROUTE, &RDMHandler::GetDefaultRoute, &RDMHandler::SetDefaultRoute, 4, false, false, true }, + {E137_2_IPV4_DEFAULT_ROUTE, &RDMHandler::GetDefaultRoute, &RDMHandler::SetDefaultRoute, 0, false, false, true }, {E137_2_DNS_HOSTNAME, &RDMHandler::GetHostName, &RDMHandler::SetHostName, 0, false, false, true }, {E137_2_DNS_DOMAIN_NAME, &RDMHandler::GetDomainName, &RDMHandler::SetDomainName, 0, false, false, true } #endif From c87f41a644f971d4c26397f8ca02be160aa3ac55 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:10:00 +0200 Subject: [PATCH 08/36] Minor code cleanup --- lib-artnet/src/controller/artnetpolltable.cpp | 6 +- lib-configstore/.cproject | 188 +++++++++++++++--- .../.settings/language.settings.xml | 6 +- lib-configstore/include/envparams.h | 7 +- lib-configstore/src/envparams.cpp | 7 - lib-e131/include/e131bridge.h | 3 - lib-flash/.settings/language.settings.xml | 2 +- lib-flash/src/spi/gd32/spi_flash.cpp | 2 +- lib-osc/Rules.mk | 2 +- lib-osc/include/oscblob.h | 15 +- lib-osc/include/oscclient.h | 115 +++++++++-- lib-osc/include/oscserver.h | 81 ++++++-- lib-osc/include/oscsimplemessage.h | 30 +-- lib-osc/include/oscstring.h | 11 +- lib-osc/src/client/oscclient.cpp | 95 +-------- lib-osc/src/oscsimplemessage.cpp | 22 +- lib-osc/src/server/oscserver.cpp | 73 ++----- lib-showfile/src/osc/showfileosc.cpp | 47 ++--- lib-ws28xx/src/pixeltype.cpp | 4 +- 19 files changed, 413 insertions(+), 303 deletions(-) diff --git a/lib-artnet/src/controller/artnetpolltable.cpp b/lib-artnet/src/controller/artnetpolltable.cpp index 2bcb665be..b855adafa 100644 --- a/lib-artnet/src/controller/artnetpolltable.cpp +++ b/lib-artnet/src/controller/artnetpolltable.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -72,8 +72,8 @@ ArtNetPollTable::ArtNetPollTable() { m_PollTableClean.nUniverseIndex = 0; m_PollTableClean.bOffLine = true; - DEBUG_PRINTF("NodeEntry[%d] = %u bytes [%u Kb]", artnet::POLL_TABLE_SIZE_ENRIES, (sizeof(artnet::NodeEntry[artnet::POLL_TABLE_SIZE_ENRIES])), (sizeof(artnet::NodeEntry[artnet::POLL_TABLE_SIZE_ENRIES])) / 1024U); - DEBUG_PRINTF("PollTableUniverses[%d] = %u bytes [%u Kb]", artnet::POLL_TABLE_SIZE_UNIVERSES, (sizeof(artnet::PollTableUniverses[artnet::POLL_TABLE_SIZE_UNIVERSES])), (sizeof(artnet::PollTableUniverses[artnet::POLL_TABLE_SIZE_UNIVERSES])) / 1024U); + DEBUG_PRINTF("NodeEntry[%d] = %u bytes [%u Kb]", artnet::POLL_TABLE_SIZE_ENRIES, static_cast(sizeof(artnet::NodeEntry[artnet::POLL_TABLE_SIZE_ENRIES])), static_cast(sizeof(artnet::NodeEntry[artnet::POLL_TABLE_SIZE_ENRIES])) / 1024U); + DEBUG_PRINTF("PollTableUniverses[%d] = %u bytes [%u Kb]", artnet::POLL_TABLE_SIZE_UNIVERSES, static_cast(sizeof(artnet::PollTableUniverses[artnet::POLL_TABLE_SIZE_UNIVERSES])), static_cast(sizeof(artnet::PollTableUniverses[artnet::POLL_TABLE_SIZE_UNIVERSES])) / 1024U); DEBUG_EXIT } diff --git a/lib-configstore/.cproject b/lib-configstore/.cproject index d2468e80b..7c78af3c1 100755 --- a/lib-configstore/.cproject +++ b/lib-configstore/.cproject @@ -1,10 +1,11 @@ - - + + + @@ -13,53 +14,174 @@ - - - - + + + + + + + @@ -101,5 +230,4 @@ - \ No newline at end of file diff --git a/lib-configstore/.settings/language.settings.xml b/lib-configstore/.settings/language.settings.xml index ec4f6fc73..22849cdff 100755 --- a/lib-configstore/.settings/language.settings.xml +++ b/lib-configstore/.settings/language.settings.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/lib-configstore/include/envparams.h b/lib-configstore/include/envparams.h index 633338900..282552b1c 100755 --- a/lib-configstore/include/envparams.h +++ b/lib-configstore/include/envparams.h @@ -27,6 +27,7 @@ #define ENVPARAMS_H_ #include +#include class EnvParams { public: @@ -38,7 +39,11 @@ class EnvParams { void Builder(char *pBuffer, uint32_t nLength, uint32_t& nSize); public: - static void staticCallbackFunction(void *p, const char *s); + static void staticCallbackFunction(void *p, const char *s) { + assert(p != nullptr); + assert(s != nullptr); + (static_cast(p))->callbackFunction(s); + } private: void Dump(); diff --git a/lib-configstore/src/envparams.cpp b/lib-configstore/src/envparams.cpp index cead222f6..c6e18dd94 100755 --- a/lib-configstore/src/envparams.cpp +++ b/lib-configstore/src/envparams.cpp @@ -96,13 +96,6 @@ void EnvParams::callbackFunction(const char *pLine) { } } -void EnvParams::staticCallbackFunction(void *p, const char *s) { - assert(p != nullptr); - assert(s != nullptr); - - (static_cast(p))->callbackFunction(s); -} - void EnvParams::Builder(char *pBuffer, uint32_t nLength, uint32_t& nSize) { DEBUG_ENTRY diff --git a/lib-e131/include/e131bridge.h b/lib-e131/include/e131bridge.h index bac902a8f..575ee17ad 100755 --- a/lib-e131/include/e131bridge.h +++ b/lib-e131/include/e131bridge.h @@ -350,9 +350,6 @@ class E131Bridge { #endif } } -#endif -#if defined (DMXCONFIGUDP_H) - m_DmxConfigUdp.Run(); #endif } diff --git a/lib-flash/.settings/language.settings.xml b/lib-flash/.settings/language.settings.xml index b5de257f2..1c186e8c5 100755 --- a/lib-flash/.settings/language.settings.xml +++ b/lib-flash/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-flash/src/spi/gd32/spi_flash.cpp b/lib-flash/src/spi/gd32/spi_flash.cpp index a719e284d..e4cbbf6a5 100644 --- a/lib-flash/src/spi/gd32/spi_flash.cpp +++ b/lib-flash/src/spi/gd32/spi_flash.cpp @@ -55,7 +55,7 @@ int spi_init() { return 0; } -inline static void spi_transfern(char *pBuffer, uint32_t nLength) { +inline static void spi_transfern(char *pBuffer, const uint32_t nLength) { gd32_spi_transfernb(pBuffer, pBuffer, nLength); } diff --git a/lib-osc/Rules.mk b/lib-osc/Rules.mk index 20152ce32..2c117785e 100755 --- a/lib-osc/Rules.mk +++ b/lib-osc/Rules.mk @@ -1,7 +1,7 @@ $(info [${CURDIR}]) $(info $$MAKE_FLAGS [${MAKE_FLAGS}]) -EXTRA_INCLUDES+=../lib-display/include ../lib-properties/include ../lib-network/include +EXTRA_INCLUDES+=../lib-display/include ../lib-properties/include ../lib-lightset/include ../lib-network/include ifneq ($(MAKE_FLAGS),) ifneq (,$(findstring NODE_OSC_CLIENT,$(MAKE_FLAGS))) diff --git a/lib-osc/include/oscblob.h b/lib-osc/include/oscblob.h index fe0346ea4..5496a81ee 100644 --- a/lib-osc/include/oscblob.h +++ b/lib-osc/include/oscblob.h @@ -2,7 +2,7 @@ * @file oscblob.h * */ -/* Copyright (C) 2016-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -36,17 +36,14 @@ class OSCBlob { public: - OSCBlob(const uint8_t *pData, uint32_t nSize) : - m_pData(const_cast(pData)), m_nSize(nSize) { - } - ~OSCBlob() { + OSCBlob(const uint8_t *pData, uint32_t nSize) : m_pData(pData), m_nSize(nSize) { } - uint32_t GetDataSize() { + uint32_t GetDataSize() const { return m_nSize; } - const uint8_t* GetDataPtr() { + const uint8_t* GetDataPtr() const { return m_pData; } @@ -55,7 +52,7 @@ class OSCBlob { return (4 * ((nBlobSize + 3) / 4)); } - uint8_t GetByte(uint32_t nIndex) { + uint8_t GetByte(const uint32_t nIndex) { if (nIndex < m_nSize) { return m_pData[nIndex]; } @@ -63,7 +60,7 @@ class OSCBlob { } private: - uint8_t *m_pData; + const uint8_t *m_pData; uint32_t m_nSize; }; diff --git a/lib-osc/include/oscclient.h b/lib-osc/include/oscclient.h index de81dc8ad..25e63a7ff 100755 --- a/lib-osc/include/oscclient.h +++ b/lib-osc/include/oscclient.h @@ -2,7 +2,7 @@ * @file oscclient.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,8 +29,16 @@ #include #include +#include "osc.h" +#include "oscsimplesend.h" #include "oscclientled.h" +#include "hardware.h" +#include "network.h" +#include "display.h" + +#include "debug.h" + namespace oscclient { static constexpr auto STORE = 944; ///< Configuration store in bytes namespace defaults { @@ -54,15 +62,92 @@ static constexpr uint32_t LED = oscclient::max::LED_COUNT * oscclient::max::LED_ class OscClient { public: - OscClient(); - ~OscClient() { - Stop(); + OscClient() : + m_nPortOutgoing(oscclient::defaults::PORT_OUTGOING), + m_nPortIncoming(oscclient::defaults::PORT_INCOMING), + m_nPingDelayMillis(oscclient::defaults::PING_DELAY_SECONDS * 1000) + { + DEBUG_ENTRY + + DEBUG_EXIT + } + + void Start() { + DEBUG_ENTRY + + assert(m_nHandle == -1); + m_nHandle = Network::Get()->Begin(m_nPortIncoming); + assert(m_nHandle != -1); + + DEBUG_EXIT + } + + void Stop() { + DEBUG_ENTRY + + assert(m_nHandle != -1); + Network::Get()->End(m_nPortIncoming); + m_nHandle = -1; + + DEBUG_EXIT } - void Start(); - void Stop(); + void Run() { + if (!m_bPingDisable) { + m_nCurrenMillis = Hardware::Get()->Millis(); + + if ((m_nCurrenMillis - m_nPreviousMillis) >= m_nPingDelayMillis) { + OscSimpleSend MsgSend(m_nHandle, m_nServerIP, m_nPortOutgoing, "/ping", nullptr); + m_bPingSent = true; + m_nPreviousMillis = m_nCurrenMillis; + m_nPingTimeMillis = m_nCurrenMillis; + DEBUG_PUTS("Ping sent"); + } + } + + uint32_t nRemoteIp; + uint16_t nRemotePort; - void Run(); + const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, reinterpret_cast(&m_pBuffer), &nRemoteIp, &nRemotePort); + + if (__builtin_expect((nBytesReceived == 0), 1)) { + if (m_bPingSent && ((m_nCurrenMillis - m_nPingTimeMillis) >= 1000)) { + if (m_bPongReceived) { + m_bPongReceived = false; + Display::Get()->TextStatus("No /Pong"); + DEBUG_PUTS("No /Pong"); + } + } + return; + } + + if (nRemoteIp != m_nServerIP) { + DEBUG_PRINTF("Data not received from server " IPSTR , IP2STR(nRemoteIp)); + return; + } + + if ((m_pOscClientLed != nullptr) && (HandleLedMessage(nBytesReceived))) { + DEBUG_EXIT + return; + } + + + if (!m_bPingDisable) { + if (!osc::is_match(m_pBuffer, "/pong")) { + DEBUG_PUTS(m_pBuffer); + return; + } + + + if (!m_bPongReceived) { + Display::Get()->TextStatus("Ping-Pong"); + DEBUG_PUTS("Ping-Pong"); + } + + m_bPongReceived = true; + m_bPingSent = false; + } + } void Send(const char *pPath); void SendCmd(uint32_t nCmd); @@ -125,23 +210,23 @@ class OscClient { bool HandleLedMessage(const uint16_t nBytesReceived); private: - uint32_t m_nServerIP { 0 }; uint16_t m_nPortOutgoing; uint16_t m_nPortIncoming; - int32_t m_nHandle { -1 }; - bool m_bPingDisable { false }; uint32_t m_nPingDelayMillis; - bool m_bPingSent { false }; - bool m_bPongReceived { false }; - char *m_pBuffer { nullptr }; + uint32_t m_nServerIP { 0 }; + int32_t m_nHandle { -1 }; uint32_t m_nCurrenMillis { 0 }; uint32_t m_nPreviousMillis { 0 }; uint32_t m_nPingTimeMillis { 0 }; + const char *m_pBuffer { nullptr }; + bool m_bPingDisable { false }; + bool m_bPingSent { false }; + bool m_bPongReceived { false }; OscClientLed *m_pOscClientLed { nullptr }; - static char m_pCmds[oscclient::buffer::size::CMD]; - static char m_pLeds[oscclient::buffer::size::LED]; + static inline char m_pCmds[oscclient::buffer::size::CMD]; + static inline char m_pLeds[oscclient::buffer::size::LED]; }; #endif /* OSCCLIENT_H_ */ diff --git a/lib-osc/include/oscserver.h b/lib-osc/include/oscserver.h index 2f73c6662..60162792f 100755 --- a/lib-osc/include/oscserver.h +++ b/lib-osc/include/oscserver.h @@ -2,7 +2,7 @@ * @file oscserver.h * */ -/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,10 +27,18 @@ #define OSCSERVER_H_ #include +#include #include +#include "oscsimplesend.h" + +#include "hardware.h" +#include "network.h" + #include "lightset.h" +#include "debug.h" + namespace osc { namespace server { struct DefaultPort { @@ -55,7 +63,45 @@ class OscServerHandler { class OscServer { public: OscServer(); - ~OscServer(); + + void Start() { + DEBUG_ENTRY + + assert(m_nHandle == -1); + m_nHandle = Network::Get()->Begin(m_nPortIncoming); + assert(m_nHandle != -1); + + OscSimpleSend MsgSend(m_nHandle, Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), m_nPortIncoming, "/ping", nullptr); + + Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); + + DEBUG_EXIT + } + + void Stop() { + DEBUG_ENTRY + + if (m_pLightSet != nullptr) { + m_pLightSet->Stop(0); + } + + assert(m_nHandle != -1); + Network::Get()->End(m_nPortIncoming); + m_nHandle = -1; + + DEBUG_EXIT + } + + void Print() { + puts("OSC Server"); + printf(" Incoming Port : %d\n", m_nPortIncoming); + printf(" Outgoing Port : %d\n", m_nPortOutgoing); + printf(" DMX Path : [%s][%s]\n", s_aPath, s_aPathSecond); + printf(" Blackout Path : [%s]\n", s_aPathBlackOut); + printf(" Partial Transmission : %s\n", m_bPartialTransmission ? "Yes" : "No"); + } + + void Run(); void SetOutput(LightSet *pLightSet) { assert(pLightSet != nullptr); @@ -67,7 +113,7 @@ class OscServer { m_pOscServerHandler = pOscServerHandler; } - void SetPortIncoming(uint16_t nPortIncoming = osc::server::DefaultPort::INCOMING) { + void SetPortIncoming(const uint16_t nPortIncoming = osc::server::DefaultPort::INCOMING) { assert(nPortIncoming > 1023); m_nPortIncoming = nPortIncoming; } @@ -76,7 +122,7 @@ class OscServer { return m_nPortIncoming; } - void SetPortOutgoing(uint16_t nPortOutgoing) { + void SetPortOutgoing(const uint16_t nPortOutgoing) { assert(nPortOutgoing > 1023); m_nPortOutgoing = nPortOutgoing; } @@ -118,14 +164,7 @@ class OscServer { return m_bEnableNoChangeUpdate; } - void Print(); - - void Start(); - void Stop(); - - void Run(); - - static OscServer* Get() { + static OscServer *Get() { return s_pThis; } @@ -137,7 +176,7 @@ class OscServer { uint16_t m_nPortIncoming { osc::server::DefaultPort::INCOMING }; uint16_t m_nPortOutgoing { osc::server::DefaultPort::OUTGOING }; int32_t m_nHandle { -1 }; - uint16_t m_nLastChannel { 0 }; + uint32_t m_nLastChannel { 0 }; bool m_bPartialTransmission { false }; bool m_bEnableNoChangeUpdate { false }; @@ -150,16 +189,16 @@ class OscServer { const char *m_pModel; const char *m_pSoC; - static char s_aPath[osc::server::Max::PATH_LENGTH]; - static char s_aPathSecond[osc::server::Max::PATH_LENGTH]; - static char s_aPathInfo[osc::server::Max::PATH_LENGTH]; - static char s_aPathBlackOut[osc::server::Max::PATH_LENGTH]; + static inline char s_aPath[osc::server::Max::PATH_LENGTH]; + static inline char s_aPathSecond[osc::server::Max::PATH_LENGTH]; + static inline char s_aPathInfo[osc::server::Max::PATH_LENGTH]; + static inline char s_aPathBlackOut[osc::server::Max::PATH_LENGTH]; - static uint8_t s_pData[lightset::dmx::UNIVERSE_SIZE]; - static uint8_t s_pOsc[lightset::dmx::UNIVERSE_SIZE]; + static inline uint8_t s_pData[lightset::dmx::UNIVERSE_SIZE]; + static inline uint8_t s_pOsc[lightset::dmx::UNIVERSE_SIZE]; - static char *s_pUdpBuffer; - static OscServer *s_pThis; + static inline const uint8_t *s_pUdpBuffer; + static inline OscServer *s_pThis; }; #endif /* OSCSERVER_H_ */ diff --git a/lib-osc/include/oscsimplemessage.h b/lib-osc/include/oscsimplemessage.h index fa15a01af..e60b00b72 100644 --- a/lib-osc/include/oscsimplemessage.h +++ b/lib-osc/include/oscsimplemessage.h @@ -2,7 +2,7 @@ * @file oscsimplemessage.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,13 +33,13 @@ class OscSimpleMessage { public: - OscSimpleMessage(void *pData, unsigned nLength); + OscSimpleMessage(const uint8_t *pOscMessage, uint32_t nLength); - bool IsValid() { + bool IsValid() const { return m_bIsValid; } - int GetArgc() { + int GetArgc() const { if (m_bIsValid) { return static_cast(m_nArgc); } @@ -47,7 +47,7 @@ class OscSimpleMessage { return -1; } - char GetType(unsigned argc) { + char GetType(unsigned argc) const { if (argc < m_nArgc) { return static_cast(m_pArg[argc]); } @@ -55,19 +55,19 @@ class OscSimpleMessage { return osc::type::UNKNOWN; } - float GetFloat(unsigned argc); - int GetInt(unsigned argc); - char* GetString(unsigned argc); - OSCBlob GetBlob(unsigned argc); + float GetFloat(const unsigned argc); + int GetInt(const unsigned argc); + const char *GetString(const unsigned argc); + OSCBlob GetBlob(const unsigned argc); private: - uint8_t *m_pOscMessage; + const uint8_t *m_pOscMessage; uint32_t m_nLength; - bool m_bIsValid = false; - uint8_t *m_pArg; - uint32_t m_nArgc = 0; - uint8_t *m_pOscMessageData = nullptr; - uint32_t m_nOscMessageDataLength = 0; + const uint8_t *m_pArg; + uint32_t m_nArgc { 0 }; + const uint8_t *m_pOscMessageData { nullptr }; + uint32_t m_nOscMessageDataLength { 0 }; + bool m_bIsValid { false }; }; #endif /* OSCSIMPLEMESSAGE_H_ */ diff --git a/lib-osc/include/oscstring.h b/lib-osc/include/oscstring.h index 5658cf38e..3ac010a5c 100644 --- a/lib-osc/include/oscstring.h +++ b/lib-osc/include/oscstring.h @@ -2,7 +2,7 @@ * @file oscstring.h * */ -/* Copyright (C) 2016-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,6 +27,7 @@ #define OSCSTRING_H_ #include +#include #include "osc.h" @@ -37,11 +38,11 @@ */ namespace osc { -inline static int string_validate(void *pData, unsigned nSize) { - unsigned nLength = 0; - char *pSrc = reinterpret_cast(pData); +inline static int string_validate(const void *pData, uint32_t nSize) { + uint32_t nLength = 0; + auto *pSrc = reinterpret_cast(pData); - unsigned i = 0; + uint32_t i = 0; for (i = 0; i < nSize; ++i) { if (pSrc[i] == '\0') { diff --git a/lib-osc/src/client/oscclient.cpp b/lib-osc/src/client/oscclient.cpp index 11e203836..9bf570f54 100755 --- a/lib-osc/src/client/oscclient.cpp +++ b/lib-osc/src/client/oscclient.cpp @@ -2,7 +2,7 @@ * @file oscclient.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_OSCCLIENT) +# undef NDEBUG +#endif + #include #include #include @@ -34,95 +38,8 @@ #include "oscsimplemessage.h" #include "osc.h" -#include "hardware.h" -#include "network.h" -#include "display.h" - #include "debug.h" -char OscClient::m_pCmds[oscclient::buffer::size::CMD]; -char OscClient::m_pLeds[oscclient::buffer::size::LED]; - -OscClient::OscClient() : - m_nPortOutgoing(oscclient::defaults::PORT_OUTGOING), - m_nPortIncoming(oscclient::defaults::PORT_INCOMING), - m_nPingDelayMillis(oscclient::defaults::PING_DELAY_SECONDS * 1000) -{ - DEBUG_ENTRY - - DEBUG_EXIT -} - -void OscClient::Start() { - DEBUG_ENTRY - - m_nHandle = Network::Get()->Begin(m_nPortIncoming); - assert(m_nHandle != -1); - - DEBUG_EXIT -} - -void OscClient::Stop() { - m_nHandle = Network::Get()->End(m_nPortIncoming); -} - -void OscClient::Run() { - if (!m_bPingDisable) { - m_nCurrenMillis = Hardware::Get()->Millis(); - - if ((m_nCurrenMillis - m_nPreviousMillis) >= m_nPingDelayMillis) { - OscSimpleSend MsgSend(m_nHandle, m_nServerIP, m_nPortOutgoing, "/ping", nullptr); - m_bPingSent = true; - m_nPreviousMillis = m_nCurrenMillis; - m_nPingTimeMillis = m_nCurrenMillis; - DEBUG_PUTS("Ping sent"); - } - } - - uint32_t nRemoteIp; - uint16_t nRemotePort; - - const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&m_pBuffer)), &nRemoteIp, &nRemotePort); - - if (__builtin_expect((nBytesReceived == 0), 1)) { - if (m_bPingSent && ((m_nCurrenMillis - m_nPingTimeMillis) >= 1000)) { - if (m_bPongReceived) { - m_bPongReceived = false; - Display::Get()->TextStatus("No /Pong"); - DEBUG_PUTS("No /Pong"); - } - } - return; - } - - if (nRemoteIp != m_nServerIP) { - DEBUG_PRINTF("Data not received from server " IPSTR , IP2STR(nRemoteIp)); - return; - } - - if ((m_pOscClientLed != nullptr) && (HandleLedMessage(nBytesReceived))) { - DEBUG_EXIT - return; - } - - - if (!m_bPingDisable) { - if (!osc::is_match(m_pBuffer, "/pong")) { - DEBUG_PUTS(m_pBuffer); - return; - } - - - if (!m_bPongReceived) { - Display::Get()->TextStatus("Ping-Pong"); - DEBUG_PUTS("Ping-Pong"); - } - - m_bPongReceived = true; - m_bPingSent = false; - } -} - void OscClient::CopyCmds(const char *pCmds, uint32_t nCount, uint32_t nLength) { assert(pCmds != nullptr); @@ -161,7 +78,7 @@ bool OscClient::HandleLedMessage(const uint16_t nBytesReceived) { return false; } - OscSimpleMessage Msg(m_pBuffer, nBytesReceived); + OscSimpleMessage Msg(reinterpret_cast(m_pBuffer), nBytesReceived); const int nArgc = Msg.GetArgc(); diff --git a/lib-osc/src/oscsimplemessage.cpp b/lib-osc/src/oscsimplemessage.cpp index 49737001f..9b67ba780 100644 --- a/lib-osc/src/oscsimplemessage.cpp +++ b/lib-osc/src/oscsimplemessage.cpp @@ -2,7 +2,7 @@ * @file oscsimplemessage.cpp * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ #include "oscsimplemessage.h" #include "osc.h" -OscSimpleMessage::OscSimpleMessage(void *pData, unsigned nLength) : m_pOscMessage(reinterpret_cast(pData)), m_nLength(nLength) { +OscSimpleMessage::OscSimpleMessage(const uint8_t *pOscMessage, uint32_t nLength) : m_pOscMessage(pOscMessage), m_nLength(nLength) { auto nResult = osc::string_validate(m_pOscMessage, m_nLength); if (nResult < 0) { @@ -68,34 +68,34 @@ float OscSimpleMessage::GetFloat(unsigned argc) { } osc_pcast32; if ((m_nOscMessageDataLength >= 4 * (1 + argc)) && (m_pArg[argc] == osc::type::FLOAT)) { - osc_pcast32.i = static_cast(__builtin_bswap32(*reinterpret_cast((4 * argc) + m_pOscMessageData))); + osc_pcast32.i = static_cast(__builtin_bswap32(*reinterpret_cast((4 * argc) + m_pOscMessageData))); return osc_pcast32.f; } return 0; } -int OscSimpleMessage::GetInt(unsigned argc) { +int OscSimpleMessage::GetInt(const unsigned argc) { if ((m_nOscMessageDataLength >= 4 * (1 + argc)) && (m_pArg[argc] == osc::type::INT32)) { - return static_cast(__builtin_bswap32(*reinterpret_cast((4 * argc) + m_pOscMessageData))); + return static_cast(__builtin_bswap32(*reinterpret_cast((4 * argc) + m_pOscMessageData))); } return 0; } -char* OscSimpleMessage::GetString(__attribute__ ((unused)) unsigned argc) { - if ((m_pArg[0] == osc::type::STRING) && (m_nOscMessageDataLength == osc::string_size(reinterpret_cast(m_pOscMessageData)))) { - return reinterpret_cast(m_pOscMessageData); +const char *OscSimpleMessage::GetString([[maybe_unused]] const unsigned argc) { + if ((m_pArg[0] == osc::type::STRING) && (m_nOscMessageDataLength == osc::string_size(reinterpret_cast(m_pOscMessageData)))) { + return reinterpret_cast(m_pOscMessageData); } return nullptr; } -OSCBlob OscSimpleMessage::GetBlob(__attribute__ ((unused)) unsigned argc) { +OSCBlob OscSimpleMessage::GetBlob([[maybe_unused]] const unsigned argc) { if (m_pArg[0] == osc::type::BLOB) { - const uint32_t nSize = __builtin_bswap32(*reinterpret_cast(m_pOscMessageData)); - const uint8_t *pData = reinterpret_cast(m_pOscMessageData) + 4; + auto nSize = __builtin_bswap32(*reinterpret_cast(m_pOscMessageData)); + auto *pData = m_pOscMessageData + 4; if ((nSize + 4) <= m_nOscMessageDataLength) { return OSCBlob(pData, nSize); diff --git a/lib-osc/src/server/oscserver.cpp b/lib-osc/src/server/oscserver.cpp index e52041d46..8faf2ae8e 100755 --- a/lib-osc/src/server/oscserver.cpp +++ b/lib-osc/src/server/oscserver.cpp @@ -2,7 +2,7 @@ * @file oscserver.cpp * */ -/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_OSCSERVER) +# undef NDEBUG +#endif + #include #include #include @@ -35,7 +39,6 @@ #include "oscblob.h" #include "lightset.h" -#include "network.h" #include "hardware.h" @@ -48,19 +51,9 @@ #define SOFTWARE_VERSION "1.0" -char OscServer::s_aPath[osc::server::Max::PATH_LENGTH]; -char OscServer::s_aPathSecond[osc::server::Max::PATH_LENGTH]; -char OscServer::s_aPathInfo[osc::server::Max::PATH_LENGTH]; -char OscServer::s_aPathBlackOut[osc::server::Max::PATH_LENGTH]; - -char *OscServer::s_pUdpBuffer; -uint8_t OscServer::s_pData[lightset::dmx::UNIVERSE_SIZE]; -uint8_t OscServer::s_pOsc[lightset::dmx::UNIVERSE_SIZE]; - -OscServer *OscServer::s_pThis; - OscServer::OscServer() { DEBUG_ENTRY + assert(s_pThis == nullptr); s_pThis = this; @@ -89,31 +82,6 @@ OscServer::OscServer() { DEBUG_EXIT } -OscServer::~OscServer() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void OscServer::Start() { - DEBUG_ENTRY - - m_nHandle = Network::Get()->Begin(m_nPortIncoming); - assert(m_nHandle != -1); - - OscSimpleSend MsgSend(m_nHandle, Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), m_nPortIncoming, "/ping", nullptr); - - Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); - - DEBUG_EXIT -} - -void OscServer::Stop() { - if (m_pLightSet != nullptr) { - m_pLightSet->Stop(0); - } -} - void OscServer::SetPath(const char* pPath) { if (*pPath == '/') { auto nLength = sizeof(s_aPath) - 3; // We need space for '\0' and "/*" @@ -222,7 +190,7 @@ void OscServer::Run() { uint32_t nRemoteIp; uint16_t nRemotePort; - const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &nRemoteIp, &nRemotePort); + const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, reinterpret_cast(&s_pUdpBuffer), &nRemoteIp, &nRemotePort); if (__builtin_expect((nBytesReceived == 0), 1)) { return; @@ -234,9 +202,11 @@ void OscServer::Run() { debug_dump(s_pUdpBuffer, nBytesReceived); - DEBUG_PRINTF("[%d] path : %s", nBytesReceived, osc::get_path(s_pUdpBuffer, nBytesReceived)); + auto *pUdpBuffer = reinterpret_cast(s_pUdpBuffer); - if (osc::is_match(s_pUdpBuffer, s_aPath)) { + DEBUG_PRINTF("[%d] path : %s", nBytesReceived, osc::get_path(pUdpBuffer, nBytesReceived)); + + if (osc::is_match(pUdpBuffer, s_aPath)) { const auto nArgc = Msg.GetArgc(); if ((nArgc == 1) && (Msg.GetType(0) == osc::type::BLOB)) { @@ -254,7 +224,7 @@ void OscServer::Run() { if ((!m_bPartialTransmission) || (size == lightset::dmx::UNIVERSE_SIZE)) { m_pLightSet->SetData(0, s_pData, lightset::dmx::UNIVERSE_SIZE); } else { - m_nLastChannel = static_cast(size > m_nLastChannel ? size : m_nLastChannel); + m_nLastChannel = (size > m_nLastChannel ? size : m_nLastChannel); m_pLightSet->SetData(0, s_pData, m_nLastChannel); } @@ -309,7 +279,7 @@ void OscServer::Run() { return; } - if ((m_pOscServerHandler != nullptr) && (osc::is_match(s_pUdpBuffer, s_aPathBlackOut))) { + if ((m_pOscServerHandler != nullptr) && (osc::is_match(pUdpBuffer, s_aPathBlackOut))) { OscSimpleMessage Msg(s_pUdpBuffer, nBytesReceived); if (Msg.GetType(0) != osc::type::FLOAT) { @@ -328,11 +298,11 @@ void OscServer::Run() { return; } - if (osc::is_match(s_pUdpBuffer, s_aPathSecond)) { + if (osc::is_match(pUdpBuffer, s_aPathSecond)) { const auto nArgc = Msg.GetArgc(); if (nArgc == 1) { // /path/N 'i' or 'f' - const auto nChannel = static_cast(GetChannel(s_pUdpBuffer)); + const auto nChannel = static_cast(GetChannel(pUdpBuffer)); if (nChannel >= 1 && nChannel <= lightset::dmx::UNIVERSE_SIZE) { uint8_t nData; @@ -370,14 +340,14 @@ void OscServer::Run() { return; } - if (osc::is_match(s_pUdpBuffer, "/ping")) { + if (osc::is_match(pUdpBuffer, "/ping")) { DEBUG_PUTS("ping received"); OscSimpleSend MsgSend(m_nHandle, nRemoteIp, m_nPortOutgoing, "/pong", nullptr); return; } - if (osc::is_match(s_pUdpBuffer, s_aPathInfo)) { + if (osc::is_match(pUdpBuffer, s_aPathInfo)) { OscSimpleSend MsgSendInfo(m_nHandle, nRemoteIp, m_nPortOutgoing, "/info/os", "s", m_Os); OscSimpleSend MsgSendModel(m_nHandle, nRemoteIp, m_nPortOutgoing, "/info/model", "s", m_pModel); OscSimpleSend MsgSendSoc(m_nHandle, nRemoteIp, m_nPortOutgoing, "/info/soc", "s", m_pSoC); @@ -389,12 +359,3 @@ void OscServer::Run() { return; } } - -void OscServer::Print() { - puts("OSC Server"); - printf(" Incoming Port : %d\n", m_nPortIncoming); - printf(" Outgoing Port : %d\n", m_nPortOutgoing); - printf(" DMX Path : [%s][%s]\n", s_aPath, s_aPathSecond); - printf(" Blackout Path : [%s]\n", s_aPathBlackOut); - printf(" Partial Transmission : %s\n", m_bPartialTransmission ? "Yes" : "No"); -} diff --git a/lib-showfile/src/osc/showfileosc.cpp b/lib-showfile/src/osc/showfileosc.cpp index 4e597bbc3..ece8e6124 100644 --- a/lib-showfile/src/osc/showfileosc.cpp +++ b/lib-showfile/src/osc/showfileosc.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_SHOWFILEOSC) +# undef NDEBUG +#endif + #include #include #include @@ -73,48 +77,31 @@ namespace length { static constexpr uint32_t INDEX = sizeof(cmd::INDEX) - 1; } -ShowFileOSC::ShowFileOSC(uint16_t nPortIncoming, uint16_t nPortOutgoing) : m_nPortIncoming(nPortIncoming), m_nPortOutgoing(nPortOutgoing) { - DEBUG_ENTRY - - m_nHandle = Network::Get()->Begin(m_nPortIncoming); - assert(m_nHandle != -1); - - DEBUG_EXIT -} - -ShowFileOSC::~ShowFileOSC() { - DEBUG_ENTRY - - Network::Get()->End(m_nPortIncoming); - - DEBUG_EXIT -} - void ShowFileOSC::Process() { - DEBUG_PRINTF("[%s] %d,%d %s", m_pBuffer, static_cast(strlen(m_pBuffer)), static_cast(length::PATH), &m_pBuffer[length::PATH]); + DEBUG_PRINTF("[%s] %d,%d %s", m_pBuffer, static_cast(strlen(m_pBuffer)), static_cast(showfileosc::PATH_LENGTH), &m_pBuffer[showfileosc::PATH_LENGTH]); - if (memcmp(&m_pBuffer[length::PATH], cmd::START, length::START) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::START, length::START) == 0) { ShowFile::Get()->Play(); SendStatus(); DEBUG_PUTS("ActionStart"); return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::STOP, length::STOP) == 0){ + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::STOP, length::STOP) == 0){ ShowFile::Get()->Stop(); SendStatus(); DEBUG_PUTS("ActionStop"); return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::RESUME, length::RESUME) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::RESUME, length::RESUME) == 0) { ShowFile::Get()->Resume(); SendStatus(); DEBUG_PUTS("ActionResume"); return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::SHOW, length::SHOW) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::SHOW, length::SHOW) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); const auto nValue = static_cast(Msg.GetInt(0)); @@ -128,7 +115,7 @@ void ShowFileOSC::Process() { return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::LOOP, length::LOOP) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::LOOP, length::LOOP) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); int nValue; @@ -149,7 +136,7 @@ void ShowFileOSC::Process() { return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::BO, length::BO) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::BO, length::BO) == 0) { ShowFile::Get()->BlackOut(); SendStatus(); DEBUG_PUTS("Blackout"); @@ -157,7 +144,7 @@ void ShowFileOSC::Process() { } #if defined (CONFIG_SHOWFILE_ENABLE_MASTER) - if (memcmp(&m_pBuffer[length::PATH], cmd::MASTER, length::MASTER) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::MASTER, length::MASTER) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); int nValue; @@ -179,7 +166,7 @@ void ShowFileOSC::Process() { } #endif - if (memcmp(&m_pBuffer[length::PATH], cmd::TFTP, length::TFTP) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::TFTP, length::TFTP) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); int nValue; @@ -200,7 +187,7 @@ void ShowFileOSC::Process() { } - if (memcmp(&m_pBuffer[length::PATH], cmd::DELETE, length::DELETE) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::DELETE, length::DELETE) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); uint32_t nValue = 255; @@ -231,7 +218,7 @@ void ShowFileOSC::Process() { return; } - if (memcmp(&m_pBuffer[length::PATH], cmd::INDEX, length::INDEX) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::INDEX, length::INDEX) == 0) { OscSimpleMessage Msg(m_pBuffer, m_nBytesReceived); if (Msg.GetType(0) != osc::type::FLOAT){ @@ -257,7 +244,7 @@ void ShowFileOSC::Process() { } // TouchOSC - if (memcmp(&m_pBuffer[length::PATH], cmd::RELOAD, length::RELOAD) == 0) { + if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::RELOAD, length::RELOAD) == 0) { ShowFiles(); DEBUG_PUTS("Reload"); return; @@ -287,7 +274,7 @@ void ShowFileOSC::ShowFiles() { OscSimpleSend MsgStatus(m_nHandle, m_nRemoteIp, m_nPortOutgoing, aPath, "s", aValue); } - for (; i < ShowFileOSCMax::FILES_ENTRIES; i++) { + for (; i < showfileosc::MAX_FILES_ENTRIES; i++) { snprintf(aPath, sizeof(aPath) - 1, "/showfile/%u/show", static_cast(i)); OscSimpleSend MsgStatus(m_nHandle, m_nRemoteIp, m_nPortOutgoing, aPath, "s", " "); } diff --git a/lib-ws28xx/src/pixeltype.cpp b/lib-ws28xx/src/pixeltype.cpp index a43511511..bcb10b1ea 100644 --- a/lib-ws28xx/src/pixeltype.cpp +++ b/lib-ws28xx/src/pixeltype.cpp @@ -36,7 +36,7 @@ #include "pixeltype.h" namespace pixel { -const char TYPES[static_cast(pixel::Type::UNDEFINED)][pixel::TYPES_MAX_NAME_LENGTH] = +static constexpr char TYPES[static_cast(pixel::Type::UNDEFINED)][pixel::TYPES_MAX_NAME_LENGTH] = { "WS2801\0", // 1 "WS2811\0", "WS2812\0", "WS2812B", "WS2813\0", "WS2815\0", // 5 "SK6812\0", "SK6812W", // 2 @@ -46,7 +46,7 @@ const char TYPES[static_cast(pixel::Type::UNDEFINED)][pixel::TYPES_MAX "P9813", // 1 }; // = 14 -const char MAPS[static_cast(pixel::Map::UNDEFINED)][4] = { "RGB", "RBG", "GRB", "GBR", "BRG", "BGR"}; +static constexpr char MAPS[static_cast(pixel::Map::UNDEFINED)][4] = { "RGB", "RBG", "GRB", "GBR", "BRG", "BGR"}; const char *pixel_get_type(pixel::Type type) { if (type < pixel::Type::UNDEFINED) { From a82f112bd28841e4963e5941182090e8925014ab Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:14:52 +0200 Subject: [PATCH 09/36] Updates for previous commits - Removed MDNS mDns - mDns.Print() -> mdns_print(); - Removed mDns.Run() - mDns.ServiceRecordAdd -> mdns_service_record_add --- linux_artnet/.settings/language.settings.xml | 2 +- linux_artnet/src/main.cpp | 6 +- linux_ddp/.settings/language.settings.xml | 2 +- linux_ddp/src/main.cpp | 8 +- linux_e131/.settings/language.settings.xml | 2 +- linux_e131/run.sh | 4 +- linux_e131/src/main.cpp | 8 +- linux_osc/.settings/language.settings.xml | 2 +- linux_osc/src/main.cpp | 10 +- linux_pp/.settings/language.settings.xml | 2 +- linux_pp/src/main.cpp | 8 +- .../.settings/language.settings.xml | 4 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_dmx/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_dmx_multi/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_monitor/firmware/main.cpp | 5 +- opi_emac_artnet_pixel/firmware/main.cpp | 7 +- opi_emac_artnet_pixel_dmx/firmware/main.cpp | 7 +- .../firmware/main.cpp | 7 +- opi_emac_artnet_pixel_multi/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_rdm_l6470/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_rdm_pca9685/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_serial/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- .../firmware/main.cpp | 9 +- .../.settings/language.settings.xml | 2 +- opi_emac_ddp_pixel_multi/firmware/main.cpp | 9 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_artnet/firmware/main.cpp | 5 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_dmx/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_dmx_multi/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_monitor/firmware/main.cpp | 5 +- opi_emac_e131_pixel/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_pixel_dmx/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- .../firmware/main.cpp | 7 +- opi_emac_e131_pixel_multi/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_llrp_tftpd/Makefile.H3 | 15 ++- opi_emac_llrp_tftpd/firmware/main.cpp | 11 +- .../.settings/language.settings.xml | 4 +- opi_emac_ltc_smpte/Makefile.H3 | 20 ++- opi_emac_ltc_smpte/firmware/main.cpp | 39 +++--- opi_emac_ltc_smpte/include/ltcoscserver.h | 59 ++++++--- opi_emac_ltc_smpte/lib/ltcoscserver.cpp | 123 +++++++++--------- opi_emac_ltc_smpte/lib/mcpbuttons.cpp | 6 +- .../.settings/language.settings.xml | 2 +- opi_emac_osc_client/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_osc_dmx/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_osc_monitor/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_osc_pixel/firmware/main.cpp | 7 +- .../.settings/language.settings.xml | 2 +- opi_emac_pp_pixel_multi/firmware/main.cpp | 9 +- .../.settings/language.settings.xml | 2 +- opi_emac_showfile_artnet/Makefile.H3 | 1 + opi_emac_showfile_artnet/firmware/main.cpp | 15 +-- .../.settings/language.settings.xml | 2 +- opi_emac_showfile_e131/firmware/main.cpp | 15 +-- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- opi_rdm_responder/firmware/main.cpp | 3 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 4 +- rpi_wifi_artnet_dmx/Makefile.H3 | 6 +- .../.settings/language.settings.xml | 4 +- rpi_wifi_e131_dmx/Makefile.H3 | 15 ++- .../.settings/language.settings.xml | 4 +- rpi_wifi_e131_pixel/Makefile.H3 | 13 +- 81 files changed, 304 insertions(+), 328 deletions(-) diff --git a/linux_artnet/.settings/language.settings.xml b/linux_artnet/.settings/language.settings.xml index 6564e402d..7f4f7220e 100644 --- a/linux_artnet/.settings/language.settings.xml +++ b/linux_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_artnet/src/main.cpp b/linux_artnet/src/main.cpp index 57636c424..2f1dd24c0 100644 --- a/linux_artnet/src/main.cpp +++ b/linux_artnet/src/main.cpp @@ -93,7 +93,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); - MDNS mDns; +// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -180,7 +180,7 @@ int main(int argc, char **argv) { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); node.Start(); while (keepRunning) { @@ -188,7 +188,7 @@ int main(int argc, char **argv) { #if defined (NODE_SHOWFILE) showFile.Run(); #endif - mDns.Run(); + mdns_run(); // mDns.Run(); remoteConfig.Run(); configStore.Flash(); } diff --git a/linux_ddp/.settings/language.settings.xml b/linux_ddp/.settings/language.settings.xml index 286dc1005..7f4f7220e 100755 --- a/linux_ddp/.settings/language.settings.xml +++ b/linux_ddp/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_ddp/src/main.cpp b/linux_ddp/src/main.cpp index 773cd5e45..d2866f95b 100644 --- a/linux_ddp/src/main.cpp +++ b/linux_ddp/src/main.cpp @@ -71,7 +71,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); - MDNS mDns; +// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -116,7 +116,7 @@ int main(int argc, char **argv) { llrpOnlyDevice.Print(); - mDns.ServiceRecordAdd(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); + mdns_service_record_add(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); ddpDisplay.Print(); @@ -129,12 +129,12 @@ int main(int argc, char **argv) { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); ddpDisplay.Start(); while (keepRunning) { ddpDisplay.Run(); - mDns.Run(); + mdns_run(); // mDns.Run(); remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); diff --git a/linux_e131/.settings/language.settings.xml b/linux_e131/.settings/language.settings.xml index 6564e402d..7f4f7220e 100644 --- a/linux_e131/.settings/language.settings.xml +++ b/linux_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_e131/run.sh b/linux_e131/run.sh index d6d2facb1..3a2797ba0 100755 --- a/linux_e131/run.sh +++ b/linux_e131/run.sh @@ -1,7 +1,5 @@ #!/bin/bash -rm -rf build_linux - make retVal=$? if [ $retVal -ne 0 ]; then @@ -9,4 +7,4 @@ if [ $retVal -ne 0 ]; then exit $retVal fi -sudo valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -v ./linux_e131 eno1 +sudo valgrind --track-origins=yes -v ./linux_e131 bond0 diff --git a/linux_e131/src/main.cpp b/linux_e131/src/main.cpp index 935aa5b61..e6444e261 100644 --- a/linux_e131/src/main.cpp +++ b/linux_e131/src/main.cpp @@ -93,7 +93,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); - MDNS mDns; +// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -160,7 +160,7 @@ int main(int argc, char **argv) { llrpOnlyDevice.Print(); - mDns.ServiceRecordAdd(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); + mdns_service_record_add(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); bridge.Print(); @@ -187,7 +187,7 @@ int main(int argc, char **argv) { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); bridge.Start(); while (keepRunning) { @@ -195,7 +195,7 @@ int main(int argc, char **argv) { #if defined (NODE_SHOWFILE) showFile.Run(); #endif - mDns.Run(); + mdns_run(); // mDns.Run(); remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); diff --git a/linux_osc/.settings/language.settings.xml b/linux_osc/.settings/language.settings.xml index 6564e402d..7f4f7220e 100644 --- a/linux_osc/.settings/language.settings.xml +++ b/linux_osc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_osc/src/main.cpp b/linux_osc/src/main.cpp index 01f2617ca..70af2b4b1 100644 --- a/linux_osc/src/main.cpp +++ b/linux_osc/src/main.cpp @@ -74,7 +74,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); - MDNS mDns; +// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -118,8 +118,8 @@ int main(int argc, char **argv) { llrpOnlyDevice.Print(); - mDns.ServiceRecordAdd(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); - mDns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=monitor", server.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=monitor", server.GetPortIncoming()); server.Print(); @@ -132,12 +132,12 @@ int main(int argc, char **argv) { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); server.Start(); while (keepRunning) { server.Run(); - mDns.Run(); + mdns_run(); // mDns.Run(); remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); diff --git a/linux_pp/.settings/language.settings.xml b/linux_pp/.settings/language.settings.xml index 286dc1005..7f4f7220e 100755 --- a/linux_pp/.settings/language.settings.xml +++ b/linux_pp/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_pp/src/main.cpp b/linux_pp/src/main.cpp index 35080458e..ec4b884f3 100644 --- a/linux_pp/src/main.cpp +++ b/linux_pp/src/main.cpp @@ -71,7 +71,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); - MDNS mDns; +// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -114,7 +114,7 @@ int main(int argc, char **argv) { llrpOnlyDevice.Print(); - mDns.ServiceRecordAdd(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); + mdns_service_record_add(nullptr, mdns::Services::RDMNET_LLRP, "node=RDMNet LLRP Only"); pp.Print(); @@ -127,12 +127,12 @@ int main(int argc, char **argv) { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); pp.Start(); while (keepRunning) { pp.Run(); - mDns.Run(); + mdns_run(); // mDns.Run(); remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); diff --git a/opi_dmx_monitor/.settings/language.settings.xml b/opi_dmx_monitor/.settings/language.settings.xml index 306e80499..dd816c72a 100644 --- a/opi_dmx_monitor/.settings/language.settings.xml +++ b/opi_dmx_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/opi_dmx_usb_pro/.settings/language.settings.xml b/opi_dmx_usb_pro/.settings/language.settings.xml index 5c6fbf2bc..525366eef 100644 --- a/opi_dmx_usb_pro/.settings/language.settings.xml +++ b/opi_dmx_usb_pro/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx/.settings/language.settings.xml b/opi_emac_artnet_dmx/.settings/language.settings.xml index 7c600e764..3da5307f1 100644 --- a/opi_emac_artnet_dmx/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx/firmware/main.cpp b/opi_emac_artnet_dmx/firmware/main.cpp index f93550412..c38e8c932 100644 --- a/opi_emac_artnet_dmx/firmware/main.cpp +++ b/opi_emac_artnet_dmx/firmware/main.cpp @@ -77,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -158,7 +157,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -177,7 +176,7 @@ int main() { #endif remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml index 7c600e764..3da5307f1 100644 --- a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx_multi/firmware/main.cpp b/opi_emac_artnet_dmx_multi/firmware/main.cpp index adc57fad8..4e47cc95e 100644 --- a/opi_emac_artnet_dmx_multi/firmware/main.cpp +++ b/opi_emac_artnet_dmx_multi/firmware/main.cpp @@ -77,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -162,7 +161,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -181,7 +180,7 @@ int main() { #endif remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_monitor/.settings/language.settings.xml b/opi_emac_artnet_monitor/.settings/language.settings.xml index 7c600e764..3da5307f1 100644 --- a/opi_emac_artnet_monitor/.settings/language.settings.xml +++ b/opi_emac_artnet_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_monitor/firmware/main.cpp b/opi_emac_artnet_monitor/firmware/main.cpp index 8ec74a7b3..31a3d4e97 100644 --- a/opi_emac_artnet_monitor/firmware/main.cpp +++ b/opi_emac_artnet_monitor/firmware/main.cpp @@ -77,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -154,7 +153,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -175,7 +174,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_pixel/firmware/main.cpp b/opi_emac_artnet_pixel/firmware/main.cpp index ec79c114e..f86fe48dd 100644 --- a/opi_emac_artnet_pixel/firmware/main.cpp +++ b/opi_emac_artnet_pixel/firmware/main.cpp @@ -87,7 +87,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -210,7 +209,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -228,12 +227,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_pixel_dmx/firmware/main.cpp b/opi_emac_artnet_pixel_dmx/firmware/main.cpp index 707f85ff4..e9f3ec805 100644 --- a/opi_emac_artnet_pixel_dmx/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx/firmware/main.cpp @@ -93,7 +93,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -239,7 +238,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -257,12 +256,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp index 21e2520d5..c4f304756 100644 --- a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp @@ -97,7 +97,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -260,7 +259,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -278,12 +277,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_pixel_multi/firmware/main.cpp b/opi_emac_artnet_pixel_multi/firmware/main.cpp index 4ea7b3cbc..fdd18bb20 100644 --- a/opi_emac_artnet_pixel_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_multi/firmware/main.cpp @@ -89,7 +89,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -216,7 +215,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -234,12 +233,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml index 7c600e764..3da5307f1 100644 --- a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_l6470/firmware/main.cpp b/opi_emac_artnet_rdm_l6470/firmware/main.cpp index 0a0af52a2..179bb9ee5 100644 --- a/opi_emac_artnet_rdm_l6470/firmware/main.cpp +++ b/opi_emac_artnet_rdm_l6470/firmware/main.cpp @@ -93,7 +93,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -227,7 +226,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -247,7 +246,7 @@ int main() { ntpClient.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml index ef70920ed..4571fcf97 100755 --- a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_pca9685/firmware/main.cpp b/opi_emac_artnet_rdm_pca9685/firmware/main.cpp index aa1d01992..08ff9b126 100755 --- a/opi_emac_artnet_rdm_pca9685/firmware/main.cpp +++ b/opi_emac_artnet_rdm_pca9685/firmware/main.cpp @@ -88,7 +88,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -184,7 +183,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -204,7 +203,7 @@ int main() { ntpClient.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_serial/.settings/language.settings.xml b/opi_emac_artnet_serial/.settings/language.settings.xml index 7c600e764..3da5307f1 100644 --- a/opi_emac_artnet_serial/.settings/language.settings.xml +++ b/opi_emac_artnet_serial/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_serial/firmware/main.cpp b/opi_emac_artnet_serial/firmware/main.cpp index 920ff2467..7b16afbc6 100644 --- a/opi_emac_artnet_serial/firmware/main.cpp +++ b/opi_emac_artnet_serial/firmware/main.cpp @@ -78,7 +78,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -166,7 +165,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -187,7 +186,7 @@ int main() { llrpOnlyDevice.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml index 87b3665eb..0b9454b33 100755 --- a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp index 44d3a838d..ec51f4713 100644 --- a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp @@ -83,14 +83,13 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("DDP Pixel controller 8x 4U with 2x DMX"); - mDns.ServiceRecordAdd(nullptr, mdns::Services::DDP, "type=display"); + mdns_service_record_add(nullptr, mdns::Services::DDP, "type=display"); // LightSet A - Pixel - 32 Universes @@ -189,7 +188,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus("DDP Display Start", CONSOLE_YELLOW); @@ -206,10 +205,6 @@ int main() { remoteConfig.Run(); configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif display.Run(); hw.Run(); } diff --git a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml index 87b3665eb..0b9454b33 100755 --- a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_multi/firmware/main.cpp b/opi_emac_ddp_pixel_multi/firmware/main.cpp index a00d0d438..4b2b626bc 100644 --- a/opi_emac_ddp_pixel_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_multi/firmware/main.cpp @@ -78,14 +78,13 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("DDP Pixel controller 8x 4U"); - mDns.ServiceRecordAdd(nullptr, mdns::Services::DDP, "type=display"); + mdns_service_record_add(nullptr, mdns::Services::DDP, "type=display"); PixelDmxConfiguration pixelDmxConfiguration; @@ -166,7 +165,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus("DDP Display Start", CONSOLE_YELLOW); @@ -183,10 +182,6 @@ int main() { remoteConfig.Run(); configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif display.Run(); hw.Run(); } diff --git a/opi_emac_e131_artnet/.settings/language.settings.xml b/opi_emac_e131_artnet/.settings/language.settings.xml index 7c7115c05..83f44d039 100644 --- a/opi_emac_e131_artnet/.settings/language.settings.xml +++ b/opi_emac_e131_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_artnet/firmware/main.cpp b/opi_emac_e131_artnet/firmware/main.cpp index f734cfa7c..079e08eb6 100644 --- a/opi_emac_e131_artnet/firmware/main.cpp +++ b/opi_emac_e131_artnet/firmware/main.cpp @@ -74,7 +74,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -163,7 +162,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -182,7 +181,7 @@ int main() { remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_dmx/.settings/language.settings.xml b/opi_emac_e131_dmx/.settings/language.settings.xml index 7c7115c05..83f44d039 100644 --- a/opi_emac_e131_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx/firmware/main.cpp b/opi_emac_e131_dmx/firmware/main.cpp index b9b6dd8f3..c9741c238 100644 --- a/opi_emac_e131_dmx/firmware/main.cpp +++ b/opi_emac_e131_dmx/firmware/main.cpp @@ -84,7 +84,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -183,7 +182,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -201,11 +200,7 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_dmx_multi/.settings/language.settings.xml index 7c7115c05..83f44d039 100644 --- a/opi_emac_e131_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx_multi/firmware/main.cpp b/opi_emac_e131_dmx_multi/firmware/main.cpp index dde627958..61149bac4 100644 --- a/opi_emac_e131_dmx_multi/firmware/main.cpp +++ b/opi_emac_e131_dmx_multi/firmware/main.cpp @@ -84,7 +84,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -189,7 +188,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -207,11 +206,7 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_monitor/.settings/language.settings.xml b/opi_emac_e131_monitor/.settings/language.settings.xml index 7c7115c05..83f44d039 100644 --- a/opi_emac_e131_monitor/.settings/language.settings.xml +++ b/opi_emac_e131_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_monitor/firmware/main.cpp b/opi_emac_e131_monitor/firmware/main.cpp index b552f7ef3..3c93fc065 100644 --- a/opi_emac_e131_monitor/firmware/main.cpp +++ b/opi_emac_e131_monitor/firmware/main.cpp @@ -82,7 +82,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -179,7 +178,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -201,7 +200,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_pixel/firmware/main.cpp b/opi_emac_e131_pixel/firmware/main.cpp index 5c7106b24..d2e494acc 100644 --- a/opi_emac_e131_pixel/firmware/main.cpp +++ b/opi_emac_e131_pixel/firmware/main.cpp @@ -86,7 +86,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -202,7 +201,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -220,12 +219,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml index 88a8fba28..bcb9693a8 100755 --- a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx/firmware/main.cpp b/opi_emac_e131_pixel_dmx/firmware/main.cpp index c0cc5c087..708eb3d45 100644 --- a/opi_emac_e131_pixel_dmx/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx/firmware/main.cpp @@ -92,7 +92,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -237,7 +236,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -255,12 +254,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml index ae7937559..5424b9fd4 100755 --- a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp index 12f2c50b8..243c0d39b 100644 --- a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp @@ -96,7 +96,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -261,7 +260,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -279,12 +278,8 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_e131_pixel_multi/firmware/main.cpp b/opi_emac_e131_pixel_multi/firmware/main.cpp index 497b13f17..4d35c1ede 100644 --- a/opi_emac_e131_pixel_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_multi/firmware/main.cpp @@ -89,7 +89,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -212,7 +211,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(E131MsgConst::START, CONSOLE_YELLOW); @@ -230,14 +229,10 @@ int main() { showFile.Run(); #endif remoteConfig.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif configStore.Flash(); if (__builtin_expect((pPixelTestPattern != nullptr), 0)) { pPixelTestPattern->Run(); } - mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_llrp_tftpd/.settings/language.settings.xml b/opi_emac_llrp_tftpd/.settings/language.settings.xml index d326e0cbc..4e0f5c115 100644 --- a/opi_emac_llrp_tftpd/.settings/language.settings.xml +++ b/opi_emac_llrp_tftpd/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_llrp_tftpd/Makefile.H3 b/opi_emac_llrp_tftpd/Makefile.H3 index 0278e9e5d..9dac20bfb 100644 --- a/opi_emac_llrp_tftpd/Makefile.H3 +++ b/opi_emac_llrp_tftpd/Makefile.H3 @@ -12,18 +12,27 @@ DEFINES+=ENET_LINK_CHECK_REG_POLL DEFINES+=DEBUG_STACK DEFINES+=DEBUG_HEAP +#DEFINES+=DEBUG_EMAC #DEFINES+=DEBUG_NET_IP #DEFINES+=DEBUG_NET_UDP #DEFINES+=DEBUG_NET_TCP #DEFINES+=DEBUG_NET_ARP #DEFINES+=DEBUG_NET_ACD #DEFINES+=DEBUG_NET_DHCP -#DEFINES+=DEBUG_NET_NETIF +#DEFINES+=DEBUG_NET_IGMP +DEFINES+=DEBUG_NET_NETIF #DEFINES+=DEBUG_NET_NET -#DEFINES+=DEBUG_NET_APPS_MDNS -#DEFINES+=DEBUG_NETWORK +DEFINES+=DEBUG_NETWORK #DEFINES+=DEBUG_HTTPD +#DEFINES+=DEBUG_NET_APPS_MDNS + +#DEFINES+=DEBUG_NET_APPS_TFTP +#DEFINES+=DEBUG_TFTP + +#DEFINES+=DEBUG_RDM_LLRPDEVICE +#DEFINES+=DEBUG_RDM_SHOW_MESSAGE + DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_llrp_tftpd/firmware/main.cpp b/opi_emac_llrp_tftpd/firmware/main.cpp index ed8c615bc..88475ca50 100755 --- a/opi_emac_llrp_tftpd/firmware/main.cpp +++ b/opi_emac_llrp_tftpd/firmware/main.cpp @@ -70,7 +70,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -93,12 +92,10 @@ int main() { remoteConfigParams.Load(); remoteConfigParams.Set(&remoteConfig); - DEBUG_PUTS(""); - while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); display.SetTitle("LLRP Only - TFTP"); display.Set(2, displayudf::Labels::HOSTNAME); @@ -121,14 +118,8 @@ int main() { struct tm tmHwClock; memset(&tmHwClock, 0, sizeof(struct tm)); - DEBUG_PUTS(""); - for (;;) { nw.Run(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - device.Run(); -#endif remoteConfig.Run(); ntpClient.Run(); configStore.Flash(); diff --git a/opi_emac_ltc_smpte/.settings/language.settings.xml b/opi_emac_ltc_smpte/.settings/language.settings.xml index 5c6fbf2bc..8312ebc82 100644 --- a/opi_emac_ltc_smpte/.settings/language.settings.xml +++ b/opi_emac_ltc_smpte/.settings/language.settings.xml @@ -4,8 +4,8 @@ - - + + diff --git a/opi_emac_ltc_smpte/Makefile.H3 b/opi_emac_ltc_smpte/Makefile.H3 index 46ff7a37d..e0a0d70db 100644 --- a/opi_emac_ltc_smpte/Makefile.H3 +++ b/opi_emac_ltc_smpte/Makefile.H3 @@ -12,7 +12,25 @@ DEFINES+=ENABLE_HTTPD ENABLE_CONTENT #DEFINES+=ENABLE_SHELL UART0_ECHO LTC_READER -DEFINES+=NDEBUG +DEFINES+=DEBUG_STACK +#DEFINES+=DEBUG_HEAP + +#DEFINES+=DEBUG_EMAC +#DEFINES+=DEBUG_NET_IP +#DEFINES+=DEBUG_NET_UDP +#DEFINES+=DEBUG_NET_TCP +#DEFINES+=DEBUG_NET_ARP +#DEFINES+=DEBUG_NET_ACD +#DEFINES+=DEBUG_NET_DHCP +#DEFINES+=DEBUG_NET_NETIF +#DEFINES+=DEBUG_NET_NET +#DEFINES+=DEBUG_NET_APPS_MDNS +#DEFINES+=DEBUG_NETWORK +#DEFINES+=DEBUG_HTTPD + +#DEFINES+=DEBUG_DISPLAY + +DEFINES+=DEBUG_LTCOSCSERVER LIBS= diff --git a/opi_emac_ltc_smpte/firmware/main.cpp b/opi_emac_ltc_smpte/firmware/main.cpp index 29c6ba726..2d3cb16d2 100644 --- a/opi_emac_ltc_smpte/firmware/main.cpp +++ b/opi_emac_ltc_smpte/firmware/main.cpp @@ -39,7 +39,6 @@ #include "ltcdisplayparams.h" #include "ltcdisplayrgb.h" #include "ltcdisplaymax7219.h" -#include "ltcmidisystemrealtime.h" #include "ltcetc.h" #include "ltcetcparams.h" @@ -62,21 +61,22 @@ #include "ntpserver.h" #include "mcpbuttons.h" -#include "ltcoscserver.h" +#include "ltcoscserver.h" #include "ltcsourceconst.h" #include "ltcsource.h" - -#include "artnetreader.h" -#include "ltcreader.h" #include "ltcsender.h" -#include "midireader.h" -#include "tcnetreader.h" -#include "ltcgenerator.h" -#include "rtpmidireader.h" -#include "systimereader.h" -#include "ltcetcreader.h" -#include "ltcoutputs.h" + +#include "arm/artnetreader.h" +#include "arm/ltcreader.h" +#include "arm/midireader.h" +#include "arm/systimereader.h" +#include "arm/tcnetreader.h" +#include "arm/ltcgenerator.h" +#include "arm/ltcmidisystemrealtime.h" +#include "arm/rtpmidireader.h" +#include "arm/ltcetcreader.h" +#include "arm/ltcoutputs.h" #include "flashcodeinstall.h" @@ -161,7 +161,7 @@ int main() { display.ClearLine(1); display.ClearLine(2); - MDNS mdns; +// MDNS mdns; NtpClient ntpClient; ntpClient.Start(); @@ -390,7 +390,8 @@ int main() { oscServer.Start(); oscServer.Print(); - mdns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=server", oscServer.GetPortIncoming()); +// mdns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=server", oscServer.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=server", oscServer.GetPortIncoming()); } /** @@ -431,8 +432,8 @@ int main() { ntpServer.Start(); ntpServer.Print(); - mdns.ServiceRecordAdd(nullptr, mdns::Services::NTP, "type=server"); - +// mdns.ServiceRecordAdd(nullptr, mdns::Services::NTP, "type=server"); + mdns_service_record_add(nullptr, mdns::Services::NTP, "type=server"); } /** @@ -490,7 +491,7 @@ int main() { break; } - mdns.Print(); + mdns_print(); RemoteConfig remoteConfig(remoteconfig::Node::LTC, remoteconfig::Output::TIMECODE, 1U + static_cast(ltcSource)); @@ -609,14 +610,10 @@ int main() { sourceSelect.Run(); } -#if defined (NODE_RDMNET_LLRP_ONLY) - rdmNetLLRPOnly.Run(); -#endif remoteConfig.Run(); configStore.Flash(); #if defined(ENABLE_SHELL) shell.Run(); #endif - mdns.Run(); } } diff --git a/opi_emac_ltc_smpte/include/ltcoscserver.h b/opi_emac_ltc_smpte/include/ltcoscserver.h index dd9862d1d..41f658ea7 100644 --- a/opi_emac_ltc_smpte/include/ltcoscserver.h +++ b/opi_emac_ltc_smpte/include/ltcoscserver.h @@ -2,7 +2,7 @@ * @file ltcoscserver.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,27 +23,52 @@ * THE SOFTWARE. */ -#ifndef OSCSERVER_H_ -#define OSCSERVER_H_ +#ifndef LTCOSCSERVER_H_ +#define LTCOSCSERVER_H_ -#include +#include +#include + +#if !(defined(CONFIG_LTC_DISABLE_RGB_PANEL) && defined (CONFIG_LTC_DISABLE_WS28XX)) +# include "ltcdisplayrgb.h" +#else +# define LTC_NO_DISPLAY_RGB +#endif + +#include "osc.h" -#include "ltcdisplayrgb.h" #include "network.h" +#include "debug.h" + namespace ltcoscserver { static constexpr auto PATH_LENGTH_MAX =128; } // namespace ltcoscserver class LtcOscServer { public: - LtcOscServer(); + LtcOscServer(): m_nPortIncoming(osc::port::DEFAULT_INCOMING) { + DEBUG_ENTRY - void Start(); - void Stop(); - void Print(); + m_nPathLength = static_cast(snprintf(m_aPath, sizeof(m_aPath) - 1, "/%s/tc/*", Network::Get()->GetHostName()) - 1); - void SetPortIncoming(uint16_t nPortIncoming) { + DEBUG_PRINTF("%d [%s]", m_nPathLength, m_aPath); + DEBUG_EXIT + } + + void Start() { + assert(m_nHandle == -1); + m_nHandle = Network::Get()->Begin(m_nPortIncoming); + assert(m_nHandle != -1); + } + + void Print() { + puts("OSC Server"); + printf(" Port : %u\n", m_nPortIncoming); + printf(" Path : [%s]\n", m_aPath); + } + + void SetPortIncoming(const uint16_t nPortIncoming) { m_nPortIncoming = nPortIncoming; } @@ -52,7 +77,7 @@ class LtcOscServer { } void Run() { - const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&m_pBuffer)), &m_nRemoteIp, &m_nRemotePort); + const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, reinterpret_cast(&m_pBuffer), &m_nRemoteIp, &m_nRemotePort); if (__builtin_expect((nBytesReceived <= 4), 1)) { return; @@ -62,17 +87,19 @@ class LtcOscServer { } private: - void HandleOscRequest(const uint16_t nBytesReceived); - void SetWS28xxRGB(uint32_t nSize, ltcdisplayrgb::ColourIndex tIndex); + void HandleOscRequest(const uint32_t nBytesReceived); +#if !defined(LTC_NO_DISPLAY_RGB) + void SetWS28xxRGB(uint32_t nSize, ltcdisplayrgb::ColourIndex index); +#endif private: uint16_t m_nPortIncoming; + uint16_t m_nRemotePort { 0 }; int32_t m_nHandle { -1 }; uint32_t m_nRemoteIp { 0 }; - uint16_t m_nRemotePort { 0 }; char m_aPath[ltcoscserver::PATH_LENGTH_MAX]; uint32_t m_nPathLength { 0 }; - char *m_pBuffer; + const uint8_t *m_pBuffer { nullptr }; }; -#endif /* OSCSERVER_H_ */ +#endif /* LTCOSCSERVER_H_ */ diff --git a/opi_emac_ltc_smpte/lib/ltcoscserver.cpp b/opi_emac_ltc_smpte/lib/ltcoscserver.cpp index 410d399ac..eff7f3c53 100644 --- a/opi_emac_ltc_smpte/lib/ltcoscserver.cpp +++ b/opi_emac_ltc_smpte/lib/ltcoscserver.cpp @@ -2,7 +2,7 @@ * @file oscserver.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,35 +23,36 @@ * THE SOFTWARE. */ +#if defined (DEBUG_LTCOSCSERVER) +# undef NDEBUG +#endif + #include #include #include #include -#include "ltcdisplayrgb.h" #include "ltcoscserver.h" -#include "ltcmidisystemrealtime.h" +#if !defined (LTC_NO_DISPLAY_RGB) +# include "ltcdisplayrgb.h" +#endif + +#include "arm/ltcmidisystemrealtime.h" +#include "arm/ltcgenerator.h" +#include "arm/ltcoutputs.h" +#include "arm/systimereader.h" #include "tcnetdisplay.h" +#include "tcnet.h" +#include "midi.h" #include "osc.h" #include "oscsimplemessage.h" #include "network.h" -#include "ltcgenerator.h" -#include "systimereader.h" -#include "ltcoutputs.h" - -#include "tcnet.h" -#include "midi.h" - #include "debug.h" -namespace udp { -static constexpr auto MAX_BUFFER = 1024; -} // namespace udp - namespace cmd { static constexpr char START[] = "start"; static constexpr char STOP[] = "stop"; @@ -147,25 +148,13 @@ static constexpr auto INFO = sizeof(cmd::INFO) - 1; static constexpr auto VALUE_LENGTH = 11; static constexpr auto FPS_VALUE_LENGTH = 2; -LtcOscServer::LtcOscServer(): m_nPortIncoming(osc::port::DEFAULT_INCOMING) { - m_nPathLength = static_cast(snprintf(m_aPath, sizeof(m_aPath) - 1, "/%s/tc/*", Network::Get()->GetHostName()) - 1); - - DEBUG_PRINTF("%d [%s]", m_nPathLength, m_aPath); -} - -void LtcOscServer::Start() { - m_nHandle = Network::Get()->Begin(m_nPortIncoming); - assert(m_nHandle != -1); -} - -void LtcOscServer::Stop() { -} +void LtcOscServer::HandleOscRequest(const uint32_t nBytesReceived) { + auto *pBuffer = reinterpret_cast(m_pBuffer); -void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { - if (osc::is_match(m_pBuffer, m_aPath)) { - const auto nCommandLength = strlen(m_pBuffer); + if (osc::is_match(pBuffer, m_aPath)) { + const auto nCommandLength = strlen(pBuffer); - DEBUG_PRINTF("[%s]:%d %d:|%s|", m_pBuffer, static_cast(nCommandLength), m_nPathLength, &m_pBuffer[m_nPathLength]); + DEBUG_PRINTF("[%s]:%d %d:|%s|", pBuffer, static_cast(nCommandLength), m_nPathLength, &m_pBuffer[m_nPathLength]); // */pitch f if (memcmp(&m_pBuffer[m_nPathLength], cmd::PITCH, length::PITCH) == 0) { @@ -195,26 +184,34 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { } else if ((nCommandLength == (m_nPathLength + length::START + 1 + VALUE_LENGTH))) { if (m_pBuffer[m_nPathLength + length::START] == '/') { const auto nOffset = m_nPathLength + length::START + 1; - m_pBuffer[nOffset + 2] = ':'; - m_pBuffer[nOffset + 5] = ':'; - m_pBuffer[nOffset + 8] = '.'; - LtcGenerator::Get()->ActionSetStart(&m_pBuffer[nOffset]); + char timeCode[VALUE_LENGTH]; + memcpy(timeCode, &m_pBuffer[nOffset], VALUE_LENGTH); + + timeCode[2] = ':'; + timeCode[5] = ':'; + timeCode[8] = '.'; + + LtcGenerator::Get()->ActionSetStart(timeCode); LtcGenerator::Get()->ActionStop(); LtcGenerator::Get()->ActionStart(); - DEBUG_PUTS(&m_pBuffer[nOffset]); + DEBUG_PUTS(timeCode); } } else if ((nCommandLength == (m_nPathLength + length::START + length::SET + VALUE_LENGTH))) { if (memcmp(&m_pBuffer[m_nPathLength + length::START], cmd::SET, length::SET) == 0) { const auto nOffset = m_nPathLength + length::START + length::SET; - m_pBuffer[nOffset + 2] = ':'; - m_pBuffer[nOffset + 5] = ':'; - m_pBuffer[nOffset + 8] = '.'; - LtcGenerator::Get()->ActionSetStart(&m_pBuffer[nOffset]); + char timeCode[VALUE_LENGTH]; + memcpy(timeCode, &m_pBuffer[nOffset], VALUE_LENGTH); + + timeCode[2] = ':'; + timeCode[5] = ':'; + timeCode[8] = '.'; - DEBUG_PUTS(&m_pBuffer[nOffset]); + LtcGenerator::Get()->ActionSetStart(timeCode); + + DEBUG_PUTS(timeCode); } } return; @@ -230,13 +227,17 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { } else if ((nCommandLength == (m_nPathLength + length::STOP + length::SET + VALUE_LENGTH))) { if (memcmp(&m_pBuffer[m_nPathLength + length::STOP], cmd::SET, length::SET) == 0) { const auto nOffset = m_nPathLength + length::STOP + length::SET; - m_pBuffer[nOffset + 2] = ':'; - m_pBuffer[nOffset + 5] = ':'; - m_pBuffer[nOffset + 8] = '.'; - LtcGenerator::Get()->ActionSetStop(&m_pBuffer[nOffset]); + char timeCode[VALUE_LENGTH]; + memcpy(timeCode, &m_pBuffer[nOffset], VALUE_LENGTH); + + timeCode[2] = ':'; + timeCode[5] = ':'; + timeCode[8] = '.'; + + LtcGenerator::Get()->ActionSetStop(timeCode); - DEBUG_PUTS(&m_pBuffer[nOffset]); + DEBUG_PUTS(timeCode); } } @@ -279,7 +280,7 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { if (memcmp(&m_pBuffer[m_nPathLength + length::RATE], cmd::SET, length::SET) == 0) { const auto nOffset = m_nPathLength + length::RATE + length::SET; - LtcGenerator::Get()->ActionSetRate(&m_pBuffer[nOffset]); + LtcGenerator::Get()->ActionSetRate(&pBuffer[nOffset]); DEBUG_PUTS(&m_pBuffer[nOffset]); return; @@ -296,13 +297,17 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { if ((nCommandLength == (m_nPathLength + length::GOTO + 1 + VALUE_LENGTH)) && (memcmp(&m_pBuffer[m_nPathLength], cmd::GOTO, length::GOTO) == 0)) { if (m_pBuffer[m_nPathLength + length::GOTO] == '/') { const auto nOffset = m_nPathLength + length::GOTO + 1; - m_pBuffer[nOffset + 2] = ':'; - m_pBuffer[nOffset + 5] = ':'; - m_pBuffer[nOffset + 8] = '.'; - LtcGenerator::Get()->ActionGoto(&m_pBuffer[nOffset]); + char timeCode[VALUE_LENGTH]; + memcpy(timeCode, &m_pBuffer[nOffset], VALUE_LENGTH); - DEBUG_PUTS(&m_pBuffer[nOffset]); + timeCode[2] = ':'; + timeCode[5] = ':'; + timeCode[8] = '.'; + + LtcGenerator::Get()->ActionGoto(timeCode); + + DEBUG_PUTS(timeCode); return; } } @@ -310,7 +315,7 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { if ((nCommandLength <= (m_nPathLength + length::DIRECTION + 1 + 8)) && (memcmp(&m_pBuffer[m_nPathLength], cmd::DIRECTION, length::DIRECTION) == 0)) { if (m_pBuffer[m_nPathLength + length::DIRECTION] == '/') { const uint32_t nOffset = m_nPathLength + length::DIRECTION + 1; - LtcGenerator::Get()->ActionSetDirection(&m_pBuffer[nOffset]); + LtcGenerator::Get()->ActionSetDirection(&pBuffer[nOffset]); DEBUG_PUTS(&m_pBuffer[nOffset]); return; @@ -434,7 +439,7 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { return; } } - +#if !defined(LTC_NO_DISPLAY_RGB) // */ws28xx/ if (memcmp(&m_pBuffer[m_nPathLength], ws28xx::cmd::PATH, ws28xx::length::PATH) == 0) { // ws28xx/master i @@ -532,9 +537,12 @@ void LtcOscServer::HandleOscRequest(const uint16_t nBytesReceived) { } } } +#endif } } + +#if !defined(LTC_NO_DISPLAY_RGB) void LtcOscServer::SetWS28xxRGB(uint32_t nSize, ltcdisplayrgb::ColourIndex tIndex) { OscSimpleMessage Msg(m_pBuffer, nSize); @@ -550,9 +558,4 @@ void LtcOscServer::SetWS28xxRGB(uint32_t nSize, ltcdisplayrgb::ColourIndex tInde DEBUG_PUTS("Invalid ws28xx/rgb/*"); } } - -void LtcOscServer::Print() { - printf("OSC Server\n"); - printf(" Port : %d\n", m_nPortIncoming); - printf(" Path : [%s]\n", m_aPath); -} +#endif diff --git a/opi_emac_ltc_smpte/lib/mcpbuttons.cpp b/opi_emac_ltc_smpte/lib/mcpbuttons.cpp index 4072cca8f..56b93fcd3 100644 --- a/opi_emac_ltc_smpte/lib/mcpbuttons.cpp +++ b/opi_emac_ltc_smpte/lib/mcpbuttons.cpp @@ -2,7 +2,7 @@ * @file mcpbuttons.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,8 +51,8 @@ #include "ltcsource.h" #include "ltcstore.h" -#include "ltcgenerator.h" -#include "systimereader.h" +#include "arm/ltcgenerator.h" +#include "arm/systimereader.h" // Interrupt #include "board/h3_opi_zero.h" diff --git a/opi_emac_osc_client/.settings/language.settings.xml b/opi_emac_osc_client/.settings/language.settings.xml index abe3b163e..fe62819bb 100644 --- a/opi_emac_osc_client/.settings/language.settings.xml +++ b/opi_emac_osc_client/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_client/firmware/main.cpp b/opi_emac_osc_client/firmware/main.cpp index a855f0d26..3229b218a 100644 --- a/opi_emac_osc_client/firmware/main.cpp +++ b/opi_emac_osc_client/firmware/main.cpp @@ -62,7 +62,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -76,7 +75,7 @@ int main() { params.Load(); params.Set(&client); - mDns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=client", client.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=client", client.GetPortIncoming()); display.TextStatus(OscClientMsgConst::PARAMS, CONSOLE_YELLOW); @@ -111,7 +110,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); for (uint32_t i = 1; i < 7 ; i++) { display.ClearLine(i); @@ -140,7 +139,7 @@ int main() { pButtonsSet->Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_osc_dmx/.settings/language.settings.xml b/opi_emac_osc_dmx/.settings/language.settings.xml index abe3b163e..fe62819bb 100644 --- a/opi_emac_osc_dmx/.settings/language.settings.xml +++ b/opi_emac_osc_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_dmx/firmware/main.cpp b/opi_emac_osc_dmx/firmware/main.cpp index 9de088735..8822c040d 100644 --- a/opi_emac_osc_dmx/firmware/main.cpp +++ b/opi_emac_osc_dmx/firmware/main.cpp @@ -63,7 +63,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -77,7 +76,7 @@ int main() { params.Load(); params.Set(&server); - mDns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=server", server.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=server", server.GetPortIncoming()); display.TextStatus(OscServerMsgConst::PARAMS, CONSOLE_YELLOW); @@ -120,7 +119,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); hw.WatchdogInit(); @@ -130,7 +129,7 @@ int main() { server.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_osc_monitor/.settings/language.settings.xml b/opi_emac_osc_monitor/.settings/language.settings.xml index abe3b163e..fe62819bb 100644 --- a/opi_emac_osc_monitor/.settings/language.settings.xml +++ b/opi_emac_osc_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_monitor/firmware/main.cpp b/opi_emac_osc_monitor/firmware/main.cpp index 20bf856c0..ca2218ebc 100644 --- a/opi_emac_osc_monitor/firmware/main.cpp +++ b/opi_emac_osc_monitor/firmware/main.cpp @@ -66,7 +66,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -93,7 +92,7 @@ int main() { params.Load(); params.Set(&server); - mDns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=monitor", server.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=monitor", server.GetPortIncoming()); NtpClient ntpClient; ntpClient.Start(); @@ -125,7 +124,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(OscServerMsgConst::START, CONSOLE_YELLOW); @@ -143,7 +142,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_osc_pixel/.settings/language.settings.xml b/opi_emac_osc_pixel/.settings/language.settings.xml index abe3b163e..fe62819bb 100644 --- a/opi_emac_osc_pixel/.settings/language.settings.xml +++ b/opi_emac_osc_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_pixel/firmware/main.cpp b/opi_emac_osc_pixel/firmware/main.cpp index 432eeaaa7..ca8d2363e 100644 --- a/opi_emac_osc_pixel/firmware/main.cpp +++ b/opi_emac_osc_pixel/firmware/main.cpp @@ -65,7 +65,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -78,7 +77,7 @@ int main() { params.Load(); params.Set(&server); - mDns.ServiceRecordAdd(nullptr, mdns::Services::OSC, "type=server", server.GetPortIncoming()); + mdns_service_record_add(nullptr, mdns::Services::OSC, "type=server", server.GetPortIncoming()); display.TextStatus(OscServerMsgConst::PARAMS, CONSOLE_YELLOW); @@ -122,7 +121,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus(OscServerMsgConst::START, CONSOLE_YELLOW); @@ -139,7 +138,7 @@ int main() { remoteConfig.Run(); configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_pp_pixel_multi/.settings/language.settings.xml b/opi_emac_pp_pixel_multi/.settings/language.settings.xml index 87b3665eb..0b9454b33 100755 --- a/opi_emac_pp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_pp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_pp_pixel_multi/firmware/main.cpp b/opi_emac_pp_pixel_multi/firmware/main.cpp index b56ce84e4..33665f76d 100644 --- a/opi_emac_pp_pixel_multi/firmware/main.cpp +++ b/opi_emac_pp_pixel_multi/firmware/main.cpp @@ -77,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -85,7 +84,7 @@ int main() { fw.Print("PixelPusher controller 8x 4U"); - mDns.ServiceRecordAdd(nullptr, mdns::Services::PP, "type=PixelPusher"); + mdns_service_record_add(nullptr, mdns::Services::PP, "type=PixelPusher"); PixelDmxConfiguration pixelDmxConfiguration; @@ -167,7 +166,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.TextStatus("PixelPusher Start", CONSOLE_YELLOW); @@ -184,10 +183,6 @@ int main() { remoteConfig.Run(); configStore.Flash(); pixelTestPattern.Run(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - llrpOnlyDevice.Run(); -#endif display.Run(); hw.Run(); } diff --git a/opi_emac_showfile_artnet/.settings/language.settings.xml b/opi_emac_showfile_artnet/.settings/language.settings.xml index db804150c..7b1b74060 100755 --- a/opi_emac_showfile_artnet/.settings/language.settings.xml +++ b/opi_emac_showfile_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_artnet/Makefile.H3 b/opi_emac_showfile_artnet/Makefile.H3 index 950cbb131..114cad434 100755 --- a/opi_emac_showfile_artnet/Makefile.H3 +++ b/opi_emac_showfile_artnet/Makefile.H3 @@ -21,6 +21,7 @@ DEFINES+=CONFIG_FS_ENABLE_WRITE SD_EXFAT_SUPPORT DEFINES+=ENABLE_HTTPD ENABLE_CONTENT #DEFINES+=DEBUG_POSIX +#DEFINES+=DEBUG_HTTPD DEFINES+=NDEBUG diff --git a/opi_emac_showfile_artnet/firmware/main.cpp b/opi_emac_showfile_artnet/firmware/main.cpp index e53ee8a71..7a71b680d 100755 --- a/opi_emac_showfile_artnet/firmware/main.cpp +++ b/opi_emac_showfile_artnet/firmware/main.cpp @@ -40,9 +40,11 @@ #include "showfiledisplay.h" #include "showfileparams.h" -#include "rdmnetllrponly.h" -#include "rdm_e120.h" -#include "factorydefaults.h" +#if defined (NODE_RDMNET_LLRP_ONLY) +# include "rdmnetllrponly.h" +# include "rdm_e120.h" +# include "factorydefaults.h" +#endif #include "remoteconfig.h" #include "remoteconfigparams.h" @@ -75,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -111,7 +112,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.SetTitle("Showfile player"); display.Set(2, displayudf::Labels::HOSTNAME); @@ -148,10 +149,6 @@ int main() { showFile.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - rdmNetLLRPOnly.Run(); -#endif display.Run(); hw.Run(); } diff --git a/opi_emac_showfile_e131/.settings/language.settings.xml b/opi_emac_showfile_e131/.settings/language.settings.xml index db804150c..7b1b74060 100755 --- a/opi_emac_showfile_e131/.settings/language.settings.xml +++ b/opi_emac_showfile_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_e131/firmware/main.cpp b/opi_emac_showfile_e131/firmware/main.cpp index e8cf3bd01..0bf5ac772 100755 --- a/opi_emac_showfile_e131/firmware/main.cpp +++ b/opi_emac_showfile_e131/firmware/main.cpp @@ -40,9 +40,11 @@ #include "showfiledisplay.h" #include "showfileparams.h" -#include "rdmnetllrponly.h" -#include "rdm_e120.h" -#include "factorydefaults.h" +#if defined (NODE_RDMNET_LLRP_ONLY) +# include "rdmnetllrponly.h" +# include "rdm_e120.h" +# include "factorydefaults.h" +#endif #include "remoteconfig.h" #include "remoteconfigparams.h" @@ -75,7 +77,6 @@ int main() { ConfigStore configStore; display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -111,7 +112,7 @@ int main() { while (configStore.Flash()) ; - mDns.Print(); + mdns_print(); // mDns.Print(); display.SetTitle("Showfile player"); display.Set(2, displayudf::Labels::HOSTNAME); @@ -142,10 +143,6 @@ int main() { showFile.Run(); remoteConfig.Run(); configStore.Flash(); - mDns.Run(); -#if defined (NODE_RDMNET_LLRP_ONLY) - rdmNetLLRPOnly.Run(); -#endif display.Run(); hw.Run(); } diff --git a/opi_midi_monitor/.settings/language.settings.xml b/opi_midi_monitor/.settings/language.settings.xml index a2ad16154..9eb454bb9 100644 --- a/opi_midi_monitor/.settings/language.settings.xml +++ b/opi_midi_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder/.settings/language.settings.xml b/opi_rdm_responder/.settings/language.settings.xml index 68abc5df5..86f525b63 100644 --- a/opi_rdm_responder/.settings/language.settings.xml +++ b/opi_rdm_responder/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder/firmware/main.cpp b/opi_rdm_responder/firmware/main.cpp index 7ba062611..337c7ceac 100644 --- a/opi_rdm_responder/firmware/main.cpp +++ b/opi_rdm_responder/firmware/main.cpp @@ -77,7 +77,6 @@ int main() { #if !defined(NO_EMAC) display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - MDNS mDns; display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); #else Network nw; @@ -204,7 +203,7 @@ int main() { #if !defined(NO_EMAC) nw.Run(); remoteConfig.Run(); - mDns.Run(); +// mdns_run(); // mDns.Run(); // mDns.Run(); #endif pixelTestPattern.Run(); display.Run(); diff --git a/opi_rdm_responder_l6470/.settings/language.settings.xml b/opi_rdm_responder_l6470/.settings/language.settings.xml index e145996bc..61f01aa2a 100644 --- a/opi_rdm_responder_l6470/.settings/language.settings.xml +++ b/opi_rdm_responder_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/rpi_wifi_artnet_dmx/.settings/language.settings.xml b/rpi_wifi_artnet_dmx/.settings/language.settings.xml index 6c72f2e54..ed79de28f 100644 --- a/rpi_wifi_artnet_dmx/.settings/language.settings.xml +++ b/rpi_wifi_artnet_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/rpi_wifi_artnet_dmx/Makefile.H3 b/rpi_wifi_artnet_dmx/Makefile.H3 index c20d09ad4..d2cfaf697 100644 --- a/rpi_wifi_artnet_dmx/Makefile.H3 +++ b/rpi_wifi_artnet_dmx/Makefile.H3 @@ -1,13 +1,15 @@ PLATFORM=ORANGE_PI -DEFINES =NO_EMAC ESP8266 +DEFINES =NO_EMAC ESP8266 DEFINES+=NODE_ARTNET ARTNET_VERSION=3 LIGHTSET_PORTS=4 +DEFINES+=ARTNET_DISABLE_DMX_CONFIG_UDP + DEFINES+=OUTPUT_DMX_SEND DEFINES+=RDM_CONTROLLER -DEFINES+=DO_NOT_USE_EXTERNAL_LED +DEFINES+=DO_NOT_USE_EXTERNAL_LED DEFINES+=DISABLE_RTC diff --git a/rpi_wifi_e131_dmx/.settings/language.settings.xml b/rpi_wifi_e131_dmx/.settings/language.settings.xml index 3616d19cd..46a0ad733 100644 --- a/rpi_wifi_e131_dmx/.settings/language.settings.xml +++ b/rpi_wifi_e131_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/rpi_wifi_e131_dmx/Makefile.H3 b/rpi_wifi_e131_dmx/Makefile.H3 index 214eee330..1d9d529c3 100644 --- a/rpi_wifi_e131_dmx/Makefile.H3 +++ b/rpi_wifi_e131_dmx/Makefile.H3 @@ -1,10 +1,17 @@ PLATFORM=ORANGE_PI -DEFINES =NO_EMAC ESP8266 +DEFINES =NO_EMAC ESP8266 + DEFINES+=NODE_E131 LIGHTSET_PORTS=4 -DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 -DEFINES+=OUTPUT_DMX_SEND OUTPUT_DMX_PIXEL -DEFINES+=DO_NOT_USE_EXTERNAL_LED DISABLE_RTC NDEBUG +DEFINES+=E131_DISABLE_DMX_CONFIG_UDP + +DEFINES+=OUTPUT_DMX_SEND + +DEFINES+=DO_NOT_USE_EXTERNAL_LED + +DEFINES+=DISABLE_RTC + +DEFINES+=NDEBUG LIBS= diff --git a/rpi_wifi_e131_pixel/.settings/language.settings.xml b/rpi_wifi_e131_pixel/.settings/language.settings.xml index fe1262b2b..46a0ad733 100755 --- a/rpi_wifi_e131_pixel/.settings/language.settings.xml +++ b/rpi_wifi_e131_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/rpi_wifi_e131_pixel/Makefile.H3 b/rpi_wifi_e131_pixel/Makefile.H3 index 214eee330..84c1183ab 100755 --- a/rpi_wifi_e131_pixel/Makefile.H3 +++ b/rpi_wifi_e131_pixel/Makefile.H3 @@ -1,10 +1,17 @@ PLATFORM=ORANGE_PI -DEFINES =NO_EMAC ESP8266 +DEFINES =NO_EMAC ESP8266 + DEFINES+=NODE_E131 LIGHTSET_PORTS=4 DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 -DEFINES+=OUTPUT_DMX_SEND OUTPUT_DMX_PIXEL -DEFINES+=DO_NOT_USE_EXTERNAL_LED DISABLE_RTC NDEBUG + +DEFINES+=OUTPUT_DMX_PIXEL + +DEFINES+=DO_NOT_USE_EXTERNAL_LED + +DEFINES+=DISABLE_RTC + +DEFINES+=NDEBUG LIBS= From b59bf807850ff202d2e5aa9f7f7a803902f2c3b0 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:21:57 +0200 Subject: [PATCH 10/36] Fix for GD32 --- lib-ltc/include/timecodeconst.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib-ltc/include/timecodeconst.h b/lib-ltc/include/timecodeconst.h index fdd9f540e..74acdefdc 100755 --- a/lib-ltc/include/timecodeconst.h +++ b/lib-ltc/include/timecodeconst.h @@ -27,6 +27,13 @@ #include +#if defined (GD32) +# include "gd32.h" +# define MASTER_TIMER_CLOCK (APB2_CLOCK_FREQ * 2) +# define TIMER_PRESCALER (199) +# define FREQUENCY_EFFECTIVE (MASTER_TIMER_CLOCK / (TIMER_PRESCALER + 1)) +#endif + struct TimeCodeConst { static constexpr uint8_t FPS[4] = { 24, 25, 30, 30 }; #if defined (H3) @@ -35,14 +42,6 @@ struct TimeCodeConst { static constexpr uint32_t TMR_INTV[4] = {(FREQUENCY_EFFECTIVE / 24), (FREQUENCY_EFFECTIVE / 25) - 1, (FREQUENCY_EFFECTIVE / 30) - 1, (FREQUENCY_EFFECTIVE / 30) - 1}; static_assert((FREQUENCY_EFFECTIVE / 24) <= UINT16_MAX); #endif - }; -#if defined (GD32) -# include "gd32.h" -# define MASTER_TIMER_CLOCK (APB2_CLOCK_FREQ * 2) -# define TIMER_PRESCALER (199) -# define FREQUENCY_EFFECTIVE (MASTER_TIMER_CLOCK / (TIMER_PRESCALER + 1)) -#endif - #endif /* TIMECODECONST_H_ */ From 40f414982392246c84665cd03dcfb5077ec82de3 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 19 Oct 2024 15:22:19 +0200 Subject: [PATCH 11/36] Fix for workflow run --- lib-showfile/include/showfileosc.h | 76 +++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/lib-showfile/include/showfileosc.h b/lib-showfile/include/showfileosc.h index 660563945..d658e3a59 100644 --- a/lib-showfile/include/showfileosc.h +++ b/lib-showfile/include/showfileosc.h @@ -33,49 +33,76 @@ #include #include #include +#include #include "showfiledisplay.h" #include "osc.h" #include "network.h" -namespace cmd { -static constexpr char PATH[] = "/showfile/"; -} -namespace length { -static constexpr uint32_t PATH = sizeof(cmd::PATH) - 1; -} // namespace length +#include "debug.h" -struct ShowFileOSCMax { - static constexpr auto CMD_LENGTH = 128; - static constexpr auto FILES_ENTRIES = 10; -}; +namespace showfileosc { +static constexpr char CMD_PATH[] = "/showfile/"; +static constexpr uint32_t PATH_LENGTH = sizeof(CMD_PATH) - 1; +static constexpr uint32_t MAX_CMD_LENGTH = 128; +static constexpr uint32_t MAX_FILES_ENTRIES = 10; +} // namespace showfileosc class ShowFileOSC { public: - ShowFileOSC(uint16_t nPortIncoming = osc::port::DEFAULT_INCOMING, uint16_t nPortOutgoing = osc::port::DEFAULT_OUTGOING); - ~ShowFileOSC(); + ShowFileOSC(uint16_t nPortIncoming = osc::port::DEFAULT_INCOMING, uint16_t nPortOutgoing = osc::port::DEFAULT_OUTGOING) : m_nPortIncoming(nPortIncoming), m_nPortOutgoing(nPortOutgoing) { + DEBUG_ENTRY - void Run() { - m_nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&m_pBuffer)), &m_nRemoteIp, &m_nRemotePort); + assert(s_pThis == nullptr); + s_pThis = this; - if (__builtin_expect((m_nBytesReceived <= length::PATH), 1)) { - return; + m_nHandle = Network::Get()->Begin(m_nPortIncoming); + assert(m_nHandle != -1); + + DEBUG_EXIT + } + + ~ShowFileOSC() { + DEBUG_ENTRY + + Network::Get()->End(m_nPortIncoming); + + DEBUG_EXIT + } + + void Input(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + if (pBuffer != nullptr) { + m_pBuffer = pBuffer; + m_nRemoteIp = nFromIp; + m_nBytesReceived = nSize; + m_nRemotePort = nFromPort; } - if (memcmp(m_pBuffer, cmd::PATH, length::PATH) == 0) { + if (memcmp(m_pBuffer, showfileosc::CMD_PATH, showfileosc::PATH_LENGTH) == 0) { Process(); } } + void Run() { + m_nBytesReceived = Network::Get()->RecvFrom(m_nHandle, reinterpret_cast(&m_pBuffer), &m_nRemoteIp, &m_nRemotePort); + + if (__builtin_expect((m_nBytesReceived <= showfileosc::PATH_LENGTH), 1)) { + return; + } + + Input(nullptr, 0, 0, 0); + } + void Print() { puts("OSC Server"); - printf(" Path : [%s]\n", cmd::PATH); + printf(" Path : [%s]\n", showfileosc::CMD_PATH); printf(" Incoming port : %u\n", m_nPortIncoming); printf(" Outgoing port : %u\n", m_nPortOutgoing); } void SetPortIncoming(const uint16_t nPortIncoming) { + assert(m_nHandle == -1); m_nPortIncoming = nPortIncoming; } uint16_t GetPortIncoming() const { @@ -95,14 +122,19 @@ class ShowFileOSC { void SendStatus(); void ShowFiles(); + void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { + s_pThis->Input(pBuffer, nSize, nFromIp, nFromPort); + } + private: + uint16_t m_nPortIncoming; + uint16_t m_nPortOutgoing; int32_t m_nHandle { -1 }; - char *m_pBuffer { nullptr }; + const uint8_t *m_pBuffer { nullptr }; uint32_t m_nRemoteIp { 0 }; - uint32_t m_nBytesReceived; + uint32_t m_nBytesReceived { 0 }; uint16_t m_nRemotePort { 0 }; - uint16_t m_nPortIncoming; - uint16_t m_nPortOutgoing; + static inline ShowFileOSC *s_pThis; }; #endif /* SHOWFILEOSC_H_ */ From 1645a65496a7c103f17b8d70b3851e7a992edbdb Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sun, 20 Oct 2024 19:15:16 +0200 Subject: [PATCH 12/36] Improved ArtNetNode::SendPollReply --- lib-artnet/.settings/language.settings.xml | 6 +- lib-artnet/include/artnetnode.h | 4 +- lib-artnet/src/node/artnetnode.cpp | 6 +- .../src/node/artnetnodehandleaddress.cpp | 2 +- lib-artnet/src/node/artnetnodehandledmx.cpp | 3 +- .../src/node/artnetnodehandleipprog.cpp | 2 +- lib-artnet/src/node/artnetnodehandlepoll.cpp | 152 +++++++++++++----- lib-artnet/src/node/dmxin/handleinput.cpp | 2 +- 8 files changed, 127 insertions(+), 50 deletions(-) diff --git a/lib-artnet/.settings/language.settings.xml b/lib-artnet/.settings/language.settings.xml index 636c59c2c..176e0c1fe 100644 --- a/lib-artnet/.settings/language.settings.xml +++ b/lib-artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-artnet/include/artnetnode.h b/lib-artnet/include/artnetnode.h index 6a780bddb..c2d1dd234 100755 --- a/lib-artnet/include/artnetnode.h +++ b/lib-artnet/include/artnetnode.h @@ -622,8 +622,8 @@ class ArtNetNode { void UpdateMergeStatus(const uint32_t nPortIndex); void CheckMergeTimeouts(const uint32_t nPortIndex); - void ProcessPollRelply(const uint32_t nPortIndex, uint32_t& NumPortsInput, uint32_t& NumPortsOutput); - void SendPollRelply(const uint32_t nBindIndex, const uint32_t nDestinationIp, artnet::ArtPollQueue *pQueue = nullptr); + void ProcessPollReply(const uint32_t nPortIndex, uint32_t& NumPortsInput, uint32_t& NumPortsOutput); + void SendPollReply(const uint32_t nBindIndex, const uint32_t nDestinationIp, artnet::ArtPollQueue *pQueue = nullptr); void SendTod(uint32_t nPortIndex); void SendTodRequest(uint32_t nPortIndex); diff --git a/lib-artnet/src/node/artnetnode.cpp b/lib-artnet/src/node/artnetnode.cpp index 13f841249..faba18713 100755 --- a/lib-artnet/src/node/artnetnode.cpp +++ b/lib-artnet/src/node/artnetnode.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -490,7 +490,7 @@ void ArtNetNode::Process(const uint32_t nBytesReceived) { if (entry.ArtPollMillis != 0) { if ((m_nCurrentPacketMillis - entry.ArtPollMillis) > m_State.ArtPollReplyDelayMillis) { entry.ArtPollMillis = 0; - SendPollRelply(0, entry.ArtPollReplyIpAddress, &entry); + SendPollReply(0, entry.ArtPollReplyIpAddress, &entry); } } } @@ -640,7 +640,7 @@ void ArtNetNode::Process(const uint32_t nBytesReceived) { if (entry.ArtPollMillis != 0) { if ((m_nCurrentPacketMillis - entry.ArtPollMillis) > m_State.ArtPollReplyDelayMillis) { entry.ArtPollMillis = 0; - SendPollRelply(0, entry.ArtPollReplyIpAddress, &entry); + SendPollReply(0, entry.ArtPollReplyIpAddress, &entry); } } } diff --git a/lib-artnet/src/node/artnetnodehandleaddress.cpp b/lib-artnet/src/node/artnetnodehandleaddress.cpp index 24d983268..014b45fb1 100644 --- a/lib-artnet/src/node/artnetnodehandleaddress.cpp +++ b/lib-artnet/src/node/artnetnodehandleaddress.cpp @@ -485,5 +485,5 @@ void ArtNetNode::HandleAddress() { break; } - SendPollRelply(pArtAddress->BindIndex, m_nIpAddressFrom); + SendPollReply(pArtAddress->BindIndex, m_nIpAddressFrom); } diff --git a/lib-artnet/src/node/artnetnodehandledmx.cpp b/lib-artnet/src/node/artnetnodehandledmx.cpp index c15479178..418314caa 100755 --- a/lib-artnet/src/node/artnetnodehandledmx.cpp +++ b/lib-artnet/src/node/artnetnodehandledmx.cpp @@ -26,10 +26,11 @@ * THE SOFTWARE. */ -#if !defined(__clang__) +#ifdef __GNUC__ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include diff --git a/lib-artnet/src/node/artnetnodehandleipprog.cpp b/lib-artnet/src/node/artnetnodehandleipprog.cpp index 2fe3d566c..bdd75801b 100644 --- a/lib-artnet/src/node/artnetnodehandleipprog.cpp +++ b/lib-artnet/src/node/artnetnodehandleipprog.cpp @@ -114,7 +114,7 @@ void ArtNetNode::HandleIpProg() { memcpy(m_ArtPollReply.BindIp, &pArtIpProgReply->ProgIpHi, artnet::IP_SIZE); #endif if (m_State.SendArtPollReplyOnChange) { - SendPollRelply(0, m_nIpAddressFrom); + SendPollReply(0, m_nIpAddressFrom); } #ifndef NDEBUG diff --git a/lib-artnet/src/node/artnetnodehandlepoll.cpp b/lib-artnet/src/node/artnetnodehandlepoll.cpp index 28360a1cc..f2608540f 100644 --- a/lib-artnet/src/node/artnetnodehandlepoll.cpp +++ b/lib-artnet/src/node/artnetnodehandlepoll.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,6 +26,17 @@ * THE SOFTWARE. */ +#if defined(DEBUG_ARTNET_POLL) +# undef NDEBUG +#endif + +#ifdef __GNUC__ +# pragma GCC push_options +# pragma GCC optimize ("O2") +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") +#endif + #include #include #include @@ -43,23 +54,94 @@ #include "debug.h" +template +static inline void uitoa(uint32_t v, uint8_t *p) { + static_assert(N >= 1); + auto *o = p + (N - 1); + do { + *o-- = static_cast('0' + (v % 10U)); + v /= 10U; + } while ((o >= p) && (v > 0)); + + // If there are remaining digits, fill with zeros + while (o >= p) { + *o-- = '0'; + } +} + +using namespace artnet; + +/* + * Table 3 – NodeReport Codes + */ +static const char *get_report_code_string(const ReportCode code) { + switch (code) { + case ReportCode::RCDEBUG: return "Booted in debug mode (Only used in development)"; + case ReportCode::RCPOWEROK: return "Power On Tests successful"; + case ReportCode::RCPOWERFAIL: return "Hardware tests failed at Power On"; + case ReportCode::RCSOCKETWR1: return "Last UDP from Node failed due to truncated length"; + case ReportCode::RCPARSEFAIL: return "Unable to identify last UDP transmission."; + case ReportCode::RCUDPFAIL: return "Unable to open Udp Socket in last transmission"; + case ReportCode::RCSHNAMEOK: return "Short Name programming [ArtAddress] was successful."; + case ReportCode::RCLONAMEOK: return "Long Name programming [ArtAddress] was successful."; + case ReportCode::RCDMXERROR: return "DMX512 receive errors detected."; + case ReportCode::RCDMXUDPFULL: return "Ran out of internal DMX transmit buffers."; + case ReportCode::RCDMXRXFULL: return "Ran out of internal DMX Rx buffers."; + case ReportCode::RCSWITCHERR: return "Rx Universe switches conflict."; + case ReportCode::RCCONFIGERR: return "Product configuration does not match firmware."; + case ReportCode::RCDMXSHORT: return "DMX output short detected. See GoodOutput field."; + case ReportCode::RCFIRMWAREFAIL: return "Last attempt to upload new firmware failed."; + case ReportCode::RCUSERFAIL: return "User changed switch settings when address locked."; + default: return "Unknown Report Code"; + } +} + +/* + * NodeReport [64] + * + * The array is a textual report of the Node’s operating status or operational errors. It is + * primarily intended for ‘engineering’ data rather than ‘end user’ data. The field is formatted as: + * “#xxxx [yyyy..] zzzzz…” + * xxxx is a hex status code as defined in Table 3. + * yyyy is a decimal counter that increments every time the Node sends an ArtPollResponse. + */ +static void create_node_report(uint8_t *pNodeReport, const ReportCode code, const uint32_t nCounter) { + [[maybe_unused]] const auto *pBegin = pNodeReport; + + *pNodeReport++ = '#'; + uitoa<4>(static_cast(code), pNodeReport); + pNodeReport += 4; + *pNodeReport++ = ' '; + *pNodeReport++ = '['; + uitoa<4>(nCounter, pNodeReport); + pNodeReport += 4; + *pNodeReport++ = ']'; + *pNodeReport++ = ' '; + + assert((REPORT_LENGTH - (pNodeReport - pBegin) - 1) == 50); + constexpr auto nRemainingSize = 50; // REPORT_LENGTH - (pNodeReport - pBegin) - 1; + const auto *preportStr = get_report_code_string(code); + + strncpy(reinterpret_cast(pNodeReport), preportStr, nRemainingSize); +} + union uip { uint32_t u32; uint8_t u8[4]; } static ip; -void ArtNetNode::ProcessPollRelply(const uint32_t nPortIndex, [[maybe_unused]] uint32_t& NumPortsInput, uint32_t& NumPortsOutput) { +void ArtNetNode::ProcessPollReply(const uint32_t nPortIndex, [[maybe_unused]] uint32_t& NumPortsInput, uint32_t& NumPortsOutput) { if (m_Node.Port[nPortIndex].direction == lightset::PortDir::OUTPUT) { #if (ARTNET_VERSION >= 4) - if (m_Node.Port[nPortIndex].protocol == artnet::PortProtocol::SACN) { - constexpr auto MASK = artnet::GoodOutput::OUTPUT_IS_MERGING | artnet::GoodOutput::DATA_IS_BEING_TRANSMITTED | artnet::GoodOutput::OUTPUT_IS_SACN; + if (m_Node.Port[nPortIndex].protocol == PortProtocol::SACN) { + constexpr auto MASK = GoodOutput::OUTPUT_IS_MERGING | GoodOutput::DATA_IS_BEING_TRANSMITTED | GoodOutput::OUTPUT_IS_SACN; auto GoodOutput = m_OutputPort[nPortIndex].GoodOutput; GoodOutput &= static_cast(~MASK); GoodOutput = static_cast(GoodOutput | (GetGoodOutput4(nPortIndex) & MASK)); m_OutputPort[nPortIndex].GoodOutput = GoodOutput; } #endif - m_ArtPollReply.PortTypes[0] |= artnet::PortType::OUTPUT_ARTNET; + m_ArtPollReply.PortTypes[0] |= PortType::OUTPUT_ARTNET; m_ArtPollReply.GoodOutput[0] = m_OutputPort[nPortIndex].GoodOutput; m_ArtPollReply.GoodOutputB[0] = m_OutputPort[nPortIndex].GoodOutputB; m_ArtPollReply.GoodInput[0] = 0; @@ -72,22 +154,30 @@ void ArtNetNode::ProcessPollRelply(const uint32_t nPortIndex, [[maybe_unused]] u #if defined (ARTNET_HAVE_DMXIN) if (m_Node.Port[nPortIndex].direction == lightset::PortDir::INPUT) { #if (ARTNET_VERSION >= 4) - if (m_Node.Port[nPortIndex].protocol == artnet::PortProtocol::SACN) { + if (m_Node.Port[nPortIndex].protocol == PortProtocol::SACN) { } #endif - m_ArtPollReply.PortTypes[0] |= artnet::PortType::INPUT_ARTNET; + m_ArtPollReply.PortTypes[0] |= PortType::INPUT_ARTNET; m_ArtPollReply.GoodOutput[0] = 0; m_ArtPollReply.GoodOutputB[0] = 0; m_ArtPollReply.GoodInput[0] = m_InputPort[nPortIndex].GoodInput; m_ArtPollReply.SwOut[0] = 0; m_ArtPollReply.SwIn[0] = m_Node.Port[nPortIndex].DefaultAddress; NumPortsInput++; + return; } #endif + + m_ArtPollReply.PortTypes[0] = 0; + m_ArtPollReply.GoodOutput[0] = 0; + m_ArtPollReply.GoodOutputB[0] = 0; + m_ArtPollReply.GoodInput[0] = 0; + m_ArtPollReply.SwOut[0] = 0; + m_ArtPollReply.SwIn[0] = 0; } -void ArtNetNode::SendPollRelply(const uint32_t nBindIndex, const uint32_t nDestinationIp, artnet::ArtPollQueue *pQueue) { +void ArtNetNode::SendPollReply(const uint32_t nBindIndex, const uint32_t nDestinationIp, ArtPollQueue *pQueue) { DEBUG_PRINTF("nBindIndex=%u", nBindIndex); ip.u32 = Network::Get()->GetIp(); @@ -101,19 +191,6 @@ void ArtNetNode::SendPollRelply(const uint32_t nBindIndex, const uint32_t nDesti continue; } - for (uint32_t nArtNetPortIndex = 0; nArtNetPortIndex < artnet::PORTS; nArtNetPortIndex++) { - m_ArtPollReply.PortTypes[nArtNetPortIndex] = 0; - m_ArtPollReply.SwIn[nArtNetPortIndex] = 0; - m_ArtPollReply.SwOut[nArtNetPortIndex] = 0; - } - - m_ArtPollReply.NetSwitch = m_Node.Port[nPortIndex].NetSwitch; - m_ArtPollReply.SubSwitch = m_Node.Port[nPortIndex].SubSwitch; - m_ArtPollReply.BindIndex = static_cast(nPortIndex + 1); - - uint32_t nPortsOutput = 0; - uint32_t nPortsInput = 0; - if ((nBindIndex == 0) && (pQueue != nullptr)) { if (!((m_Node.Port[nPortIndex].PortAddress >= pQueue->ArtPollReply.TargetPortAddressBottom) && (m_Node.Port[nPortIndex].PortAddress <= pQueue->ArtPollReply.TargetPortAddressTop))) { @@ -126,9 +203,11 @@ void ArtNetNode::SendPollRelply(const uint32_t nBindIndex, const uint32_t nDesti } } - memcpy(m_ArtPollReply.ShortName, m_Node.Port[nPortIndex].ShortName, artnet::SHORT_NAME_LENGTH); + m_ArtPollReply.NetSwitch = m_Node.Port[nPortIndex].NetSwitch; + m_ArtPollReply.SubSwitch = m_Node.Port[nPortIndex].SubSwitch; + m_ArtPollReply.BindIndex = static_cast(nPortIndex + 1); - ProcessPollRelply(nPortIndex, nPortsInput, nPortsOutput); + memcpy(m_ArtPollReply.ShortName, m_Node.Port[nPortIndex].ShortName, SHORT_NAME_LENGTH); if (__builtin_expect((m_pLightSet != nullptr), 1)) { const auto nRefreshRate = m_pLightSet->GetRefreshRate(); @@ -136,31 +215,28 @@ void ArtNetNode::SendPollRelply(const uint32_t nBindIndex, const uint32_t nDesti m_ArtPollReply.RefreshRateHi = static_cast(nRefreshRate >> 8); } - m_ArtPollReply.NumPortsLo = static_cast(std::max(nPortsInput, nPortsOutput)); - m_State.ArtPollReplyCount++; + create_node_report(m_ArtPollReply.NodeReport, m_State.reportCode, m_State.ArtPollReplyCount); - uint8_t nSysNameLenght; - const auto *pSysName = Hardware::Get()->GetSysName(nSysNameLenght); - snprintf(reinterpret_cast(m_ArtPollReply.NodeReport), artnet::REPORT_LENGTH, "#%04x [%04d] %.*s AvV", static_cast(m_State.reportCode), static_cast(m_State.ArtPollReplyCount), nSysNameLenght, pSysName); + uint32_t nPortsOutput = 0; + uint32_t nPortsInput = 0; + ProcessPollReply(nPortIndex, nPortsInput, nPortsOutput); - Network::Get()->SendTo(m_nHandle, &m_ArtPollReply, sizeof(artnet::ArtPollReply), nDestinationIp, artnet::UDP_PORT); + m_ArtPollReply.NumPortsLo = static_cast(std::max(nPortsInput, nPortsOutput)); + + Network::Get()->SendTo(m_nHandle, &m_ArtPollReply, sizeof(ArtPollReply), nDestinationIp, UDP_PORT); } m_State.IsChanged = false; } void ArtNetNode::HandlePoll() { - const auto *const pArtPoll = reinterpret_cast(m_pReceiveBuffer); + const auto *const pArtPoll = reinterpret_cast(m_pReceiveBuffer); - if (pArtPoll->Flags & artnet::Flags::SEND_ARTP_ON_CHANGE) { - m_State.SendArtPollReplyOnChange = true; - } else { - m_State.SendArtPollReplyOnChange = false; - } + m_State.SendArtPollReplyOnChange = ((pArtPoll->Flags & Flags::SEND_ARTP_ON_CHANGE) == Flags::SEND_ARTP_ON_CHANGE); // If any controller requests diagnostics, the node will send diagnostics. (ArtPoll->Flags->2). - if (pArtPoll->Flags & artnet::Flags::SEND_DIAG_MESSAGES) { + if (pArtPoll->Flags & Flags::SEND_DIAG_MESSAGES) { m_State.SendArtDiagData = true; if (m_State.ArtPollIpAddress == 0) { @@ -179,7 +255,7 @@ void ArtNetNode::HandlePoll() { } // If there are multiple controllers requesting diagnostics, diagnostics shall be broadcast. (Ignore ArtPoll->Flags->3). - if (!m_State.IsMultipleControllersReqDiag && (pArtPoll->Flags & artnet::Flags::SEND_DIAG_UNICAST)) { + if (!m_State.IsMultipleControllersReqDiag && (pArtPoll->Flags & Flags::SEND_DIAG_UNICAST)) { m_State.ArtDiagIpAddress = m_nIpAddressFrom; } else { m_State.ArtDiagIpAddress = Network::Get()->GetBroadcastIp(); @@ -192,7 +268,7 @@ void ArtNetNode::HandlePoll() { uint16_t TargetPortAddressTop = 32767; //TODO uint16_t TargetPortAddressBottom = 0; - if (pArtPoll->Flags & artnet::Flags::USE_TARGET_PORT_ADDRESS) { + if (pArtPoll->Flags & Flags::USE_TARGET_PORT_ADDRESS) { TargetPortAddressTop = static_cast((static_cast(pArtPoll->TargetPortAddressTopHi) >> 8) | pArtPoll->TargetPortAddressTopLo); TargetPortAddressBottom = static_cast((static_cast(pArtPoll->TargetPortAddressBottomHi) >> 8) | pArtPoll->TargetPortAddressBottomLo); } diff --git a/lib-artnet/src/node/dmxin/handleinput.cpp b/lib-artnet/src/node/dmxin/handleinput.cpp index b9072b6bf..928af7852 100755 --- a/lib-artnet/src/node/dmxin/handleinput.cpp +++ b/lib-artnet/src/node/dmxin/handleinput.cpp @@ -65,7 +65,7 @@ void ArtNetNode::HandleInput() { } if (m_State.SendArtPollReplyOnChange) { - SendPollRelply(0, m_nIpAddressFrom); + SendPollReply(0, m_nIpAddressFrom); } DEBUG_EXIT From 57cfb8f379ea03a60ac169c82446e4a90b47b9b4 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 17:47:19 +0100 Subject: [PATCH 13/36] Added support for SPI LCD driver ST7735S --- lib-display/.cproject | 12 ++ lib-display/.settings/language.settings.xml | 6 +- lib-display/include/i2c/display.h | 22 +- lib-display/include/spi/config.h | 24 ++- lib-display/include/spi/display.h | 137 +++++++++--- lib-display/include/spi/ili9341.h | 162 +++++++++++++-- lib-display/include/spi/lcd_font.h | 17 +- lib-display/include/spi/paint.h | 218 +++++++++++++++++-- lib-display/include/spi/spi_lcd.h | 116 ----------- lib-display/include/spi/spilcd.h | 148 +++++++++++++ lib-display/include/spi/st7735s.h | 168 +++++++++++++++ lib-display/include/spi/st7789.h | 141 ++++++++++--- lib-display/include/spi/st77xx.h | 104 +++++++--- lib-display/src/i2c/display.cpp | 2 - lib-display/src/sleep/display.cpp | 6 +- lib-display/src/spi/display.cpp | 114 ---------- lib-display/src/spi/ili9341.cpp | 193 ----------------- lib-display/src/spi/paint.cpp | 219 -------------------- lib-display/src/spi/st7789.cpp | 137 ------------ lib-display/src/spi/st7xx.cpp | 83 -------- 20 files changed, 1018 insertions(+), 1011 deletions(-) delete mode 100644 lib-display/include/spi/spi_lcd.h create mode 100644 lib-display/include/spi/spilcd.h create mode 100755 lib-display/include/spi/st7735s.h delete mode 100644 lib-display/src/spi/display.cpp delete mode 100644 lib-display/src/spi/ili9341.cpp delete mode 100644 lib-display/src/spi/paint.cpp delete mode 100644 lib-display/src/spi/st7789.cpp delete mode 100644 lib-display/src/spi/st7xx.cpp diff --git a/lib-display/.cproject b/lib-display/.cproject index 7bbb68379..bbe7b2020 100755 --- a/lib-display/.cproject +++ b/lib-display/.cproject @@ -31,6 +31,7 @@ + @@ -46,6 +47,7 @@ + @@ -110,6 +112,7 @@ + @@ -124,6 +127,7 @@ + @@ -264,11 +268,13 @@ + @@ -280,11 +286,13 @@ + @@ -296,6 +304,10 @@ + + + + - + diff --git a/lib-display/include/i2c/display.h b/lib-display/include/i2c/display.h index 65a90fbb8..0a1c463cd 100644 --- a/lib-display/include/i2c/display.h +++ b/lib-display/include/i2c/display.h @@ -30,6 +30,17 @@ # error #endif +#if defined (CONFIG_I2C_LCD_OPTIMIZE_O2) || defined (CONFIG_I2C_LCD_OPTIMIZE_O3) +# pragma GCC push_options +# if defined (CONFIG_I2C_LCD_OPTIMIZE_O2) +# pragma GCC optimize ("O2") +# else +# pragma GCC optimize ("O3") +# endif +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") +#endif + #include #include #include @@ -267,8 +278,8 @@ class Display { static constexpr char SYMBOLS[] = { '/' , '-', '\\' , '|' }; static uint32_t nSymbolsIndex; - Display::Get()->SetCursorPos(Display::Get()->GetColumns() - 1U, Display::Get()->GetRows() - 1U); - Display::Get()->PutChar(SYMBOLS[nSymbolsIndex++]); + SetCursorPos(GetColumns() - 1U, GetRows() - 1U); + PutChar(SYMBOLS[nSymbolsIndex++]); if (nSymbolsIndex >= sizeof(SYMBOLS)) { nSymbolsIndex = 0; @@ -309,7 +320,7 @@ class Display { if (m_bIsSleep) { #if defined (DISPLAYTIMEOUT_GPIO) - if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == LOW)), 0)) { + if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == 0)), 0)) { SetSleep(false); } #endif @@ -338,7 +349,10 @@ class Display { #endif DisplaySet *m_LcdDisplay { nullptr }; - static Display *s_pThis; + static inline Display *s_pThis; }; +#if defined (CONFIG_I2C_LCD_OPTIMIZE) +# pragma GCC pop_options +#endif #endif /* I2C_DISPLAY_H_ */ diff --git a/lib-display/include/spi/config.h b/lib-display/include/spi/config.h index c0b9a0560..7b226c472 100755 --- a/lib-display/include/spi/config.h +++ b/lib-display/include/spi/config.h @@ -2,7 +2,7 @@ * @file config.h * */ -/* Copyright (C) 2022-2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,18 +23,24 @@ * THE SOFTWARE. */ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef SPI_CONFIG_H +#define SPI_CONFIG_H #include namespace config { #if defined (SPI_LCD_240X240) -static constexpr uint32_t WIDTH = 240; -static constexpr uint32_t HEIGHT = 240; + static constexpr uint32_t WIDTH = 240; + static constexpr uint32_t HEIGHT = 240; #elif defined (SPI_LCD_240X320) -static constexpr uint32_t WIDTH = 240; -static constexpr uint32_t HEIGHT = 320; + static constexpr uint32_t WIDTH = 240; + static constexpr uint32_t HEIGHT = 320; +#elif defined (SPI_LCD_128X128) + static constexpr uint32_t WIDTH = 128; + static constexpr uint32_t HEIGHT = 128; +#elif defined (SPI_LCD_160X80) + static constexpr uint32_t WIDTH = 80; + static constexpr uint32_t HEIGHT = 160; #else # error lib-display spi config #endif @@ -47,7 +53,7 @@ static constexpr uint32_t HEIGHT = 320; # if defined(SPI_LCD_HAVE_CS_GPIO) # define SPI_LCD_CS_GPIO GPIO_EXT_24 // GPIO13 / SPI CS0 # endif -#elif defined (GD32) //See board file +#elif defined (GD32) // See board file #else # include "bcm2835.h" # define SPI_LCD_RST_GPIO RPI_V2_GPIO_P1_07 // GPIO4 @@ -58,4 +64,4 @@ static constexpr uint32_t HEIGHT = 320; # endif #endif -#endif /* CONFIG_H */ +#endif /* SPI_CONFIG_H */ diff --git a/lib-display/include/spi/display.h b/lib-display/include/spi/display.h index 9d4080875..ce1337308 100644 --- a/lib-display/include/spi/display.h +++ b/lib-display/include/spi/display.h @@ -30,6 +30,17 @@ # error #endif +#if defined (CONFIG_SPI_LCD_OPTIMIZE_O2) || defined (CONFIG_SPI_LCD_OPTIMIZE_O3) +# pragma GCC push_options +# if defined (CONFIG_SPI_LCD_OPTIMIZE_O2) +# pragma GCC optimize ("O2") +# else +# pragma GCC optimize ("O3") +# endif +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") +#endif + #include #include #include @@ -37,23 +48,55 @@ #if defined (CONFIG_USE_ILI9341) # include "spi/ili9341.h" + typedef ILI9341 LcdDriver; +#elif defined (CONFIG_USE_ST7735S) +# include "spi/st7735s.h" + typedef ST7735S LcdDriver; #else # include "spi/st7789.h" + typedef ST7789 LcdDriver; #endif +#include "spi/lcd_font.h" +#include "spi/spilcd.h" + #if defined (DISPLAYTIMEOUT_GPIO) # include "hal_gpio.h" #endif -#include "hardware.h" +#if defined(SPI_LCD_HAVE_CS_GPIO) + static constexpr uint32_t CS_GPIO = SPI_LCD_CS_GPIO; +#else + static constexpr uint32_t CS_GPIO = 0; +#endif -class Display { +#include "debug.h" + +class Display : public LcdDriver { public: - Display(); - ~Display() { - s_pThis = nullptr; + Display(uint32_t nCS = CS_GPIO) : LcdDriver(nCS) { + DEBUG_ENTRY + + s_pThis = this; + + SetBackLight(1); + SetFlipVertically(false); + FillColour(COLOR_BACKGROUND); + + m_nCols = (GetWidth() / s_pFONT->Width); + m_nRows = (GetHeight() / s_pFONT->Height); + +#if defined (DISPLAYTIMEOUT_GPIO) + FUNC_PREFIX(gpio_fsel(DISPLAYTIMEOUT_GPIO, GPIO_FSEL_INPUT)); + FUNC_PREFIX(gpio_set_pud(DISPLAYTIMEOUT_GPIO, GPIO_PULL_UP)); +#endif + + PrintInfo(); + DEBUG_EXIT } + ~Display() {} + bool isDetected() const { return true; } @@ -61,15 +104,38 @@ class Display { void PrintInfo() { #if defined (CONFIG_USE_ILI9341) printf("ILI9341 "); +#elif defined (CONFIG_USE_ST7735S) + printf("ST7735S "); #else printf("ST7789 "); #endif printf("(%d,%d)\n", m_nRows, m_nCols); } - void Cls(); - void SetCursorPos(uint32_t nCol, uint32_t nRow); - void PutChar(int c); + void Cls() { + FillColour(COLOR_BACKGROUND); + } + + void SetCursorPos(const uint32_t nCol, const uint32_t nRow) { + m_nCursorX = nCol * s_pFONT->Width; + m_nCursorY = nRow * s_pFONT->Height; + } + + void PutChar(const int c) { + DrawChar(m_nCursorX, m_nCursorY, static_cast(c), s_pFONT, COLOR_BACKGROUND, COLOR_FOREGROUND); + + m_nCursorX += s_pFONT->Width; + + if (m_nCursorX >= GetWidth()) { + m_nCursorX = 0; + + m_nCursorY += s_pFONT->Height; + + if (m_nCursorY >= GetHeight()) { + m_nCursorY = 0; + } + } + } void PutString(const char *p) { for (uint32_t i = 0; *p != '\0'; i++) { @@ -78,7 +144,7 @@ class Display { } } - void ClearLine(uint32_t nLine) { + void ClearLine(const uint32_t nLine) { if (__builtin_expect((!(nLine <= m_nRows)), 0)) { return; } @@ -92,7 +158,7 @@ class Display { SetCursorPos(0, (nLine - 1U)); } - void TextLine(uint32_t nLine, const char *pText, uint32_t nLength) { + void TextLine(const uint32_t nLine, const char *pText, const uint32_t nLength) { if (__builtin_expect((!(nLine <= m_nRows)), 0)) { return; } @@ -115,7 +181,7 @@ class Display { } } - int Write(uint32_t nLine, const char *pText) { + int Write(const uint32_t nLine, const char *pText) { const auto *p = pText; int nCount = 0; @@ -130,7 +196,7 @@ class Display { return nCount; } - int Printf(uint8_t nLine, const char *format, ...) { + int Printf(const uint8_t nLine, const char *format, ...) { char buffer[32]; va_list arp; @@ -149,7 +215,7 @@ class Display { void TextStatus(const char *pText) { SetCursorPos(0, static_cast(m_nRows - 1)); - for (uint32_t i = 0; i < static_cast(m_nCols - 1); i++) { + for (uint32_t i = 0; i < (m_nCols - 1); i++) { PutChar(' '); } @@ -172,22 +238,22 @@ class Display { static constexpr char SYMBOLS[] = { '/' , '-', '\\' , '|' }; static uint32_t nSymbolsIndex; - Display::Get()->SetCursorPos(Display::Get()->GetColumns() - 1U, Display::Get()->GetRows() - 1U); - Display::Get()->PutChar(SYMBOLS[nSymbolsIndex++]); + SetCursorPos(GetColumns() - 1U, GetRows() - 1U); + PutChar(SYMBOLS[nSymbolsIndex++]); if (nSymbolsIndex >= sizeof(SYMBOLS)) { nSymbolsIndex = 0; } } - void SetContrast(uint8_t nContrast) { - SpiLcd.SetBackLight(nContrast); + void SetContrast(const uint8_t nContrast) { + SetBackLight(nContrast); } - void SetSleep(bool bSleep) { + void SetSleep(const bool bSleep) { m_bIsSleep = bSleep; - SpiLcd.EnableSleep(bSleep); + EnableSleep(bSleep); if (!bSleep) { SetSleepTimer(m_nSleepTimeout != 0); @@ -208,7 +274,7 @@ class Display { } void SetFlipVertically(bool doFlipVertically) { - SpiLcd.SetRotation(doFlipVertically ? 3 : 1); + SetRotation(doFlipVertically ? 3 : 1); } uint32_t GetColumns() const { @@ -234,7 +300,7 @@ class Display { if (m_bIsSleep) { #if defined (DISPLAYTIMEOUT_GPIO) - if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == LOW)), 0)) { + if (__builtin_expect(((FUNC_PREFIX(gpio_lev(DISPLAYTIMEOUT_GPIO)) == 0)), 0)) { SetSleep(false); } #endif @@ -249,25 +315,34 @@ class Display { void SetSleepTimer(const bool bActive); private: -#if defined (CONFIG_USE_ILI9341) - ILI9341 SpiLcd; -#else - ST7789 SpiLcd; -#endif uint32_t m_nCols; uint32_t m_nRows; uint32_t m_nSleepTimeout { 1000U * 60U * display::Defaults::SLEEP_TIMEOUT }; + uint32_t m_nCursorX { 0 }; + uint32_t m_nCursorY { 0 }; + + uint8_t m_nContrast { 0x7F }; bool m_bIsFlippedVertically { false }; bool m_bIsSleep { false }; bool m_bClearEndOfLine { false }; - uint16_t m_nCursorX { 0 }; - uint16_t m_nCursorY { 0 }; - - uint8_t m_nContrast { 0x7F }; + static inline Display *s_pThis; - static Display *s_pThis; +#if defined (SPI_LCD_240X320) + static constexpr sFONT *s_pFONT = &Font16x24; +#elif defined (SPI_LCD_128X128) + static constexpr sFONT *s_pFONT = &Font8x8; +#elif defined (SPI_LCD_160X80) + static constexpr sFONT *s_pFONT = &Font8x8; +#else + static constexpr sFONT *s_pFONT = &Font12x12; +#endif + static constexpr uint16_t COLOR_BACKGROUND = 0x001F; + static constexpr uint16_t COLOR_FOREGROUND = 0xFFE0; }; +#if defined (CONFIG_SPI_LCD_OPTIMIZE) +# pragma GCC pop_options +#endif #endif /* SPI_DISPLAY_H_ */ diff --git a/lib-display/include/spi/ili9341.h b/lib-display/include/spi/ili9341.h index ea0eccca1..78ae0c6d5 100644 --- a/lib-display/include/spi/ili9341.h +++ b/lib-display/include/spi/ili9341.h @@ -23,12 +23,14 @@ * THE SOFTWARE. */ -#ifndef ILI9341_H_ -#define ILI9341_H_ +#ifndef SPI_ILI9341_H_ +#define SPI_ILI9341_H_ #include +#include #include "spi/config.h" +#include "spi/spilcd.h" namespace ili9341 { namespace cmd { @@ -86,24 +88,160 @@ static constexpr uint16_t YELLOW = 0xFFE0; class ILI9341 : public Paint { public: - ILI9341(); - ~ILI9341() override; + ILI9341(uint32_t nCS) : Paint(nCS) { + DEBUG_ENTRY - void Init(); +#if defined(SPI_LCD_RST_GPIO) + HardwareReset(); +#endif - void SetRotation(uint32_t nRotation); - void SetBackLight(uint32_t nValue); + WriteCommand(0xC0); //Power control + WriteDataByte(0x23); //VRH[5:0] - void EnableDisplay(bool bEnable); - void EnableSleep(bool bEnable); - void EnableColourInversion(bool bEnable); + WriteCommand(0xC1); //Power control + WriteDataByte(0x10); //SAP[2:0];BT[3:0] + + WriteCommand(0xC5); //VCM control + WriteDataByte(0x3e); // + WriteDataByte(0x28); + + WriteCommand(0xC7); //VCM control2 + WriteDataByte(0x86); //-- + + WriteCommand(0x3A); + WriteDataByte(0x55); + + WriteCommand(0xB1); + WriteDataByte(0x00); + WriteDataByte(0x18); + + WriteCommand(0xB6); // Display Function Control + WriteDataByte(0x08); + WriteDataByte(0xA2); + WriteDataByte(0x27); + + WriteCommand(0xF2); // 3Gamma Function Disable + WriteDataByte(0x00); + + WriteCommand(0x26); //Gamma curve selected + WriteDataByte(0x01); + + WriteCommand(0xE0); //Set Gamma + WriteDataByte(0x0F); + WriteDataByte(0x31); + WriteDataByte(0x2B); + WriteDataByte(0x0C); + WriteDataByte(0x0E); + WriteDataByte(0x08); + WriteDataByte(0x4E); + WriteDataByte(0xF1); + WriteDataByte(0x37); + WriteDataByte(0x07); + WriteDataByte(0x10); + WriteDataByte(0x03); + WriteDataByte(0x0E); + WriteDataByte(0x09); + WriteDataByte(0x00); + + WriteCommand(0XE1); //Set Gamma + WriteDataByte(0x00); + WriteDataByte(0x0E); + WriteDataByte(0x14); + WriteDataByte(0x03); + WriteDataByte(0x11); + WriteDataByte(0x07); + WriteDataByte(0x31); + WriteDataByte(0xC1); + WriteDataByte(0x48); + WriteDataByte(0x08); + WriteDataByte(0x0F); + WriteDataByte(0x0C); + WriteDataByte(0x31); + WriteDataByte(0x36); + WriteDataByte(0x0F); + + SetRotation(0); + + WriteCommand(0x11); //Exit Sleep + WriteCommand(0x29); //Display on + + DEBUG_EXIT + } + + ~ILI9341() override { + DEBUG_ENTRY + DEBUG_EXIT + } + + void SetRotation(const uint32_t nRotation) { + WriteCommand(ili9341::cmd::MADCTL); + + switch (nRotation) { + case 0: + WriteDataByte(ili9341::data::MADCTL_BGR); + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 1: + WriteDataByte(ili9341::data::MADCTL_MX | ili9341::data::MADCTL_MV | ili9341::data::MADCTL_BGR); + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + case 2: + WriteDataByte(ili9341::data::MADCTL_MX | ili9341::data::MADCTL_MY | ili9341::data::MADCTL_BGR); + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 3: + WriteDataByte(ili9341::data::MADCTL_MY | ili9341::data::MADCTL_MV | ili9341::data::MADCTL_BGR); + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + default: + assert(0); + __builtin_unreachable(); + break; + } + + m_nRotate = nRotation; + } + + void SetBackLight(uint32_t nValue) { + FUNC_PREFIX(gpio_write(SPI_LCD_BL_GPIO, nValue == 0 ? LOW : HIGH)); + } + + void EnableDisplay(bool bEnable) { + WriteCommand(bEnable ? ili9341::cmd::DISPON : ili9341::cmd::DISPOFF); + } + + void EnableSleep(bool bEnable) { + WriteCommand(bEnable ? ili9341::cmd::SLPIN : ili9341::cmd::SLPOUT); + } + + void EnableColourInversion(bool bEnable) { + WriteCommand(bEnable ? ili9341::cmd::INVON : ili9341::cmd::INVOFF); + } private: - void SetAddressWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) override; + void SetAddressWindow(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1) override { + WriteCommand(ili9341::cmd::CASET); + { + uint8_t data[] = { static_cast(x0 >> 8), static_cast(x0), static_cast(x1 >> 8), static_cast(x1) }; + write_data(data, sizeof(data)); + } + + WriteCommand(ili9341::cmd::RASET); + { + uint8_t data[] = { static_cast(y0 >> 8), static_cast(y0), static_cast(y1 >> 8), static_cast(y1) }; + write_data(data, sizeof(data)); + } + + WriteCommand(ili9341::cmd::RAMWR); + } protected: uint32_t m_nShiftX { 0 }; uint32_t m_nShiftY { 0 }; }; -#endif /* ILI9341_H_ */ +#endif /* SPI_ILI9341_H_ */ diff --git a/lib-display/include/spi/lcd_font.h b/lib-display/include/spi/lcd_font.h index bf5ff4829..be4ff6d78 100644 --- a/lib-display/include/spi/lcd_font.h +++ b/lib-display/include/spi/lcd_font.h @@ -35,16 +35,15 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI OF SUCH DAMAGE. */ -#ifndef LCD_FONT_H -#define LCD_FONT_H +#ifndef SPI_LCD_FONT_H +#define SPI_LCD_FONT_H -#include +#include -typedef struct _tFont -{ - const uint16_t *table; - uint16_t Width; - uint16_t Height; +typedef struct _tFont { + const uint16_t *table; + const uint16_t Width; + const uint16_t Height; } sFONT; extern sFONT Font16x24; @@ -55,5 +54,5 @@ extern sFONT Font8x8; #define LINE(x) ((x) * (((sFONT *)lcd_font_get())->Height)) -#endif /* LCD_FONT_H */ +#endif /* SPI_LCD_FONT_H */ diff --git a/lib-display/include/spi/paint.h b/lib-display/include/spi/paint.h index ed1a28d58..bcfae9308 100644 --- a/lib-display/include/spi/paint.h +++ b/lib-display/include/spi/paint.h @@ -2,7 +2,7 @@ * @file paint.h * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,44 +23,224 @@ * THE SOFTWARE. */ -#ifndef PAINT_H -#define PAINT_H +#ifndef SPI_PAINT_H +#define SPI_PAINT_H + +#include +#include #include "spi/lcd_font.h" +#include "spi/spilcd.h" + #include "spi/config.h" -class Paint { +#include "debug.h" + +class Paint : public SpiLcd { public: - Paint(); - virtual ~Paint(); + Paint(uint32_t nCS) : SpiLcd(nCS) { + DEBUG_ENTRY + DEBUG_EXIT + } + virtual ~Paint() {}; - uint16_t GetWidth() const { + uint32_t GetWidth() const { return m_nWidth; } - uint16_t GetHeight() const { + uint32_t GetHeight() const { return m_nHeight; } - void FillColour(uint16_t nColor); - void Fill(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t nColour); + void FillColour(const uint16_t nColour) { + DEBUG_PRINTF("nColour=0x%x", nColour); + + SetAddressWindow(0, 0, m_nWidth - 1, m_nHeight - 1); + + FillFramebuffer(nColour); + + ClearCS(); + SetDC(); + + for (uint32_t i = 0; i < config::HEIGHT / FRAME_BUFFER_ROWS; i++) { + WriteDataContinue(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); + } + + SetCS(); + } + + void Fill(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint16_t nColour) { + if (!(x0 < m_nWidth && (y0 < m_nHeight) && (x1 < m_nWidth) && (y1 < m_nHeight))) { +// DEBUG_PRINTF("[%u:%u] %u:%u-%u:%u", m_nWidth, m_nHeight, x0, y0, x1, y1); + return; + } + + assert(x1 > x0); + assert(y1 > y0); + + SetAddressWindow(x0, y0, x1, y1); + + FillFramebuffer(nColour); + + auto nPixels = (1 + (y1 - y0)) * (1 + (x1 - x0)); + const auto nBufferSize = sizeof(s_FrameBuffer) / sizeof(s_FrameBuffer[0]); + + if (nPixels > nBufferSize) { + WriteDataStart(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); + + nPixels = nPixels - nBufferSize; + + while (nPixels > nBufferSize) { + WriteDataContinue(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); + nPixels = nPixels - nBufferSize; + } + + if (nPixels > 0) { + WriteDataEnd(reinterpret_cast(s_FrameBuffer), nPixels * 2); + } else { + SetCS(); + } + } else { + WriteData(reinterpret_cast(s_FrameBuffer), nPixels * 2); + } + } + + void DrawPixel(const uint32_t x, const uint32_t y, const uint16_t nColour) { + SetAddressWindow(x, y, x, y); + WriteDataWord(nColour); + } + + void DrawChar(uint32_t x0, uint32_t y0, const char nChar, sFONT *pFont, uint16_t nColourBackground, uint16_t nColourForeGround) { + const auto x1 = x0 + pFont->Width - 1; + const auto y1 = y0 + pFont->Height - 1; + + SetAddressWindow(x0, y0, x1, y1); + + nColourForeGround = __builtin_bswap16(nColourForeGround); + nColourBackground = __builtin_bswap16(nColourBackground); - void DrawPixel(uint16_t x, uint16_t y, uint16_t nColour); - void DrawChar(uint16_t x0, uint16_t y0, const char c, sFONT* pFont, uint16_t nColourBackground, uint16_t nColourForeground); - void DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t nColour); + const auto nCharOffset = (nChar - ' ') * pFont->Height; + const auto *ptr = &pFont->table[nCharOffset]; + +// DEBUG_PRINTF("w=%u, h=%u, nCharOffset=%u", pFont->Width , pFont->Height, nCharOffset); + + uint32_t nIndex = 0; + + if (pFont->Width == 8) { + for (auto nPage = 0; nPage < pFont->Height; nPage++) { + auto line = *ptr++; + + for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { + if ((line & 0x80) != 0) { + s_FrameBuffer[nIndex++] = nColourForeGround; + } else { + s_FrameBuffer[nIndex++] = nColourBackground; + } + + line = line << 1; + } + } + } else if (pFont->Width < 16) { + for (auto nPage = 0; nPage < pFont->Height; nPage++) { + auto line = *ptr++; + + for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { + if ((line & 0x8000) != 0) { + s_FrameBuffer[nIndex++] = nColourForeGround; + } else { + s_FrameBuffer[nIndex++] = nColourBackground; + } + + line = line << 1; + } + } + } else { + for (auto nPage = 0; nPage < pFont->Height; nPage++) { + auto line = *ptr++; + + for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { + if ((line & 0x1) != 0) { + s_FrameBuffer[nIndex++] = nColourForeGround; + } else { + s_FrameBuffer[nIndex++] = nColourBackground; + } + + line = line >> 1; + } + } + } + + WriteData(reinterpret_cast(s_FrameBuffer), nIndex * 2); + } + + /** + * Bresenham + */ + //TODO Can be optimized for horizontal and vertical lines + void DrawLine(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint16_t nColour) { + const auto dx = abs(x1 - x0); + const auto dy = -abs(y1 - y0); + + const auto sx = x0 < x1 ? 1 : -1; + const auto sy = y0 < y1 ? 1 : -1; + + auto error = dx + dy; + + while (true) { + DrawPixel(x0, y0, nColour); + + if ((x0 == x1) && (y0 == y1)) { + break; + } + + auto e2 = 2 * error; + + if (e2 >= dy) { + if (x0 == x1) { + break; + } + error = error + dy; + x0 = x0 + sx; + } + + if (e2 <= dx) { + if (y0 == y1) { + break; + } + error = error + dx; + y0 = y0 + sy; + } + } + } private: - virtual void SetAddressWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)=0; + virtual void SetAddressWindow(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)=0; private: - void SetCursor(uint16_t x, uint16_t y) { + void SetCursor(const uint32_t x, const uint32_t y) { SetAddressWindow(x, y, x, y); } + void FillFramebuffer(uint16_t nColour) { + nColour = __builtin_bswap16(nColour); + + for (uint32_t i = 0; i < sizeof(s_FrameBuffer) / sizeof(s_FrameBuffer[0]); i++) { + s_FrameBuffer[i] = nColour; + } + } + protected: - uint16_t m_nWidth; - uint16_t m_nHeight; - uint16_t m_nRotate { 0 }; + uint32_t m_nWidth { config::WIDTH }; + uint32_t m_nHeight { config::HEIGHT }; + uint32_t m_nRotate { 0 }; + +#if !defined(SPI_LCD_FRAME_BUFFER_ROWS) + static constexpr uint32_t FRAME_BUFFER_ROWS = 5; +#else + static constexpr uint32_t FRAME_BUFFER_ROWS = SPI_LCD_FRAME_BUFFER_ROWS; +#endif + + static inline uint16_t s_FrameBuffer[config::WIDTH * FRAME_BUFFER_ROWS]; }; -#endif /* PAINT_H */ +#endif /* SPI_PAINT_H */ diff --git a/lib-display/include/spi/spi_lcd.h b/lib-display/include/spi/spi_lcd.h deleted file mode 100644 index 9e3791481..000000000 --- a/lib-display/include/spi/spi_lcd.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file spi_lcd.h - * - */ -/* Copyright (C) 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. - */ - -#ifndef SPI_LCD_H_ -#define SPI_LCD_H_ - -#include "spi/config.h" - -#include "hal_spi.h" - -namespace spi { -namespace lcd { - -inline static void ms_delay(const uint32_t ms) { - udelay(1000 * ms); -} - -inline static void CS_Set() { -#if defined(SPI_LCD_HAVE_CS_GPIO) - FUNC_PREFIX(gpio_set(SPI_LCD_CS_GPIO)); -#endif -} - -inline static void CS_Clear() { -#if defined(SPI_LCD_HAVE_CS_GPIO) - FUNC_PREFIX(gpio_clr(SPI_LCD_CS_GPIO)); -#endif -} - -inline static void DC_Set() { - FUNC_PREFIX(gpio_set(SPI_LCD_DC_GPIO)); -} - -inline static void DC_Clear() { - FUNC_PREFIX(gpio_clr(SPI_LCD_DC_GPIO)); -} - -inline static void HW_Reset() { -#if defined (SPI_LCD_RST_GPIO) - ms_delay(200); - FUNC_PREFIX(gpio_clr(SPI_LCD_RST_GPIO)); - ms_delay(200); - FUNC_PREFIX(gpio_set(SPI_LCD_RST_GPIO)); - ms_delay(200); -#endif -} - -inline static void Write_Command(uint8_t data) { - CS_Clear(); - DC_Clear(); - FUNC_PREFIX(spi_writenb(reinterpret_cast(&data), 1)); - CS_Set(); -} - -inline static void WriteData_Byte(uint8_t data) { - CS_Clear(); - DC_Set(); - FUNC_PREFIX(spi_writenb(reinterpret_cast(&data), 1)); - CS_Set(); -} - -inline static void WriteData_Word(uint16_t data) { - CS_Clear(); - DC_Set(); - FUNC_PREFIX(spi_write(data)); - CS_Set(); -} - -inline static void WriteData(uint8_t *pData, uint32_t nLength) { - CS_Clear(); - DC_Set(); - FUNC_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); - CS_Set(); -} - -inline static void WriteDataStart(uint8_t *pData, uint32_t nLength) { - CS_Clear(); - DC_Set(); - FUNC_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); -} - -inline static void WriteDataContinue(uint8_t *pData, uint32_t nLength) { - FUNC_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); -} - -inline static void WriteDataEnd(uint8_t *pData, uint32_t nLength) { - FUNC_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); - CS_Set(); -} - -} // namespace lcd -} // namespace spi - -#endif /* SPI_LCD_H_ */ diff --git a/lib-display/include/spi/spilcd.h b/lib-display/include/spi/spilcd.h new file mode 100644 index 000000000..bc006c00f --- /dev/null +++ b/lib-display/include/spi/spilcd.h @@ -0,0 +1,148 @@ +/** + * @file spilcd.h + * + */ +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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. + */ + +#ifndef SPI_SPILCD_H_ +#define SPI_SPILCD_H_ + +#include "spi/config.h" + +#include "hal_spi.h" + +#include "debug.h" + +#if defined CONFIG_LCD_SPI_BITBANG +# define SPI_PREFIX(x) FUNC_PREFIX(bitbang_##x); +#else +# define SPI_PREFIX(x) FUNC_PREFIX(x); +#endif + +class SpiLcd { +public: + SpiLcd(uint32_t nCS = 0) : m_nCS(nCS) { + DEBUG_ENTRY + DEBUG_PRINTF("nCS=%u", nCS); + + SPI_PREFIX(spi_begin()); + SPI_PREFIX(spi_chipSelect(SPI_CS_NONE)); + SPI_PREFIX(spi_set_speed_hz(20000000)); + SPI_PREFIX(spi_setDataMode(SPI_MODE0)); + +#if defined (SPI_LCD_RST_GPIO) + FUNC_PREFIX(gpio_fsel(SPI_LCD_RST_GPIO, GPIO_FSEL_OUTPUT)); +#endif + FUNC_PREFIX(gpio_fsel(SPI_LCD_DC_GPIO, GPIO_FSEL_OUTPUT)); + FUNC_PREFIX(gpio_fsel(SPI_LCD_BL_GPIO, GPIO_FSEL_OUTPUT)); +#if defined(SPI_LCD_HAVE_CS_GPIO) + FUNC_PREFIX(gpio_fsel(m_nCS, GPIO_FSEL_OUTPUT)); +#endif + + DEBUG_EXIT + } + + void HardwareReset() { +#if defined (SPI_LCD_RST_GPIO) + udelay(1000 * 200); + FUNC_PREFIX(gpio_clr(SPI_LCD_RST_GPIO)); + udelay(1000 * 200); + FUNC_PREFIX(gpio_set(SPI_LCD_RST_GPIO)); + udelay(1000 * 200); +#endif + } + + void SetCS() { +#if defined(SPI_LCD_HAVE_CS_GPIO) + FUNC_PREFIX(gpio_set(m_nCS)); +#endif + } + + void ClearCS() { +#if defined(SPI_LCD_HAVE_CS_GPIO) + FUNC_PREFIX(gpio_clr(m_nCS)); +#endif + } + + void SetDC() { + FUNC_PREFIX(gpio_set(SPI_LCD_DC_GPIO)); + } + + void ClearDC() { + FUNC_PREFIX(gpio_clr(SPI_LCD_DC_GPIO)); + } + + void WriteCommand(uint8_t nData) { + ClearCS(); + ClearDC(); + SPI_PREFIX(spi_writenb(reinterpret_cast(&nData), 1)); + SetCS(); + } + + void WriteData(const uint8_t *pData, const uint32_t nLength) { + ClearCS(); + SetDC(); + SPI_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); + SetCS(); + } + + void WriteCommand(const uint8_t *pData, const uint32_t nLength) { + auto *p = pData; + WriteCommand(p++[0]); + if (nLength != 0) + WriteData(p, nLength); + } + + void WriteDataByte(uint8_t nData) { + ClearCS(); + SetDC(); + SPI_PREFIX(spi_writenb(reinterpret_cast(&nData), 1)); + SetCS(); + } + + void WriteDataWord(uint16_t nData) { + ClearCS(); + SetDC(); + SPI_PREFIX(spi_write(nData)); + SetCS(); + } + + void WriteDataStart(uint8_t *pData, const uint32_t nLength) { + ClearCS(); + SetDC(); + SPI_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); + } + + void WriteDataContinue(uint8_t *pData, const uint32_t nLength) { + SPI_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); + } + + void WriteDataEnd(uint8_t *pData, const uint32_t nLength) { + SPI_PREFIX(spi_writenb(reinterpret_cast(pData), nLength)); + SetCS(); + } + +private: + uint32_t m_nCS; +}; + +#endif /* SPI_SPILCD_H_ */ diff --git a/lib-display/include/spi/st7735s.h b/lib-display/include/spi/st7735s.h new file mode 100755 index 000000000..dd659dd4e --- /dev/null +++ b/lib-display/include/spi/st7735s.h @@ -0,0 +1,168 @@ +/** + * @file st7735s.h + * + */ +/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org + * + * 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. + */ + +/** + * ST7735S + * 132RGB x 162dot 262K Color with Frame Memory + * Single-Chip TFT Controller/Driver + * Datasheet + * Version 1.1 + * 2011/11 + */ + +#ifndef SPI_ST7735S_H_ +#define SPI_ST7735S_H_ + +#include +#include + +#include "spi/config.h" +#include "spi/st77xx.h" + +#include "debug.h" + +namespace st7735s { +namespace cmd { +static constexpr uint8_t INVCTR = 0xB4; ///< Display Inversion Control +static constexpr uint8_t PWCTR1 = 0xC0; ///< Power Control 1 +static constexpr uint8_t PWCTR2 = 0xC1; ///< Power Control 2 +static constexpr uint8_t PWCTR3 = 0xC2; ///< Power Control 3 in normal mode, full colors +static constexpr uint8_t PWCTR4 = 0xC3; ///< Power Control 4 in idle mode 8colors +static constexpr uint8_t PWCTR5 = 0xC4; ///< Power Control 5 in partial mode, full colors +static constexpr uint8_t GMCTRP1 = 0xE0; ///< Gamma (‘+’polarity) Correction Characteristics Setting +static constexpr uint8_t GMCTRN1 = 0xE1; ///< Gamma ‘-’polarity Correction Characteristics Setting +} // namespace cmd +#if defined (SPI_LCD_128X128) + static constexpr uint32_t ROTATION_0_SHIFT_X = 0; + static constexpr uint32_t ROTATION_0_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_1_SHIFT_X = 3; + static constexpr uint32_t ROTATION_1_SHIFT_Y = 2; + static constexpr uint32_t ROTATION_2_SHIFT_X = 0; + static constexpr uint32_t ROTATION_2_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_3_SHIFT_X = 1; + static constexpr uint32_t ROTATION_3_SHIFT_Y = 1; +#elif defined (SPI_LCD_160X80) + static constexpr uint32_t ROTATION_0_SHIFT_X = 0; + static constexpr uint32_t ROTATION_0_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_1_SHIFT_X = 0; + static constexpr uint32_t ROTATION_1_SHIFT_Y = 24; + static constexpr uint32_t ROTATION_2_SHIFT_X = 0; + static constexpr uint32_t ROTATION_2_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_3_SHIFT_X = 0; + static constexpr uint32_t ROTATION_3_SHIFT_Y = 24; +#endif +} // namespace st7735s + +class ST7735S : public ST77XX { +public: + ST7735S(uint32_t nCS) : ST77XX(nCS) { + DEBUG_ENTRY + +#if defined(SPI_LCD_RST_GPIO) + HardwareReset(); +#endif + + WriteCommand(st77xx::cmd::SWRESET); + udelay(1000 * 150); + + static constexpr uint8_t config[] = { + 1, st77xx::cmd::COLMOD, 0x05, ///< Page 150, 5 -> 16-bit/pixel + 1, st77xx::cmd::GAMSET, 0x08, ///< Page 125, 8 -> Gamma Curve 4 + 1, st7735s::cmd::INVCTR, 0x01, ///< Page 162, Display Inversion mode control -> 3-bit, 0=Dot, 1=Column + 16, st7735s::cmd::GMCTRP1,0x02, 0x1c, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2c, + 0x29, 0x25, 0x2b, 0x39, 0x00, 0x01, 0x03, 0x10, + 16, st7735s::cmd::GMCTRN1,0x03, 0x1d, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2c, + 0x2e, 0x2e, 0x37, 0x3f, 0x00, 0x00, 0x02, 0x10, + 0, st77xx::cmd::INVOFF, ///< Page 124, Enter into display inversion mode + 0, st77xx::cmd::IDMOFF, ///< Page 147, Recover from Idle mode on + 0, st77xx::cmd::NORON ///< Page 122, Normal Display mode on + }; + + uint32_t nArgLength = 0; + + for (uint32_t i = 0; i < sizeof(config); i+=(nArgLength + 2)) { + nArgLength = config[i]; + DEBUG_PRINTF("i=%u, nArgLength=%u", i, nArgLength); + WriteCommand(&config[i + 1], nArgLength); + } + + SetRotation(0); + + WriteCommand(st77xx::cmd::SLPOUT); ///< Sleep Out + WriteCommand(st77xx::cmd::DISPON); ///< Display On + + DEBUG_EXIT + } + + ~ST7735S() override {}; + + void SetRotation(const uint32_t nRotation) { + DEBUG_ENTRY + DEBUG_PRINTF("nRotation=%u", nRotation); + + WriteCommand(st77xx::cmd::MADCTL); + + switch (nRotation) { + case 0: + WriteDataByte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MY | st77xx::data::MADCTL_BGR); + m_nShiftX = st7735s::ROTATION_0_SHIFT_X; + m_nShiftY = st7735s::ROTATION_0_SHIFT_Y; + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 1: + WriteDataByte(st77xx::data::MADCTL_MY | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_BGR); + m_nShiftX = st7735s::ROTATION_1_SHIFT_X; + m_nShiftY = st7735s::ROTATION_1_SHIFT_Y; + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + case 2: + WriteDataByte(st77xx::data::MADCTL_BGR); + m_nShiftX = st7735s::ROTATION_2_SHIFT_X; + m_nShiftY = st7735s::ROTATION_2_SHIFT_Y; + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 3: + WriteDataByte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_BGR); + m_nShiftX = st7735s::ROTATION_3_SHIFT_X; + m_nShiftY = st7735s::ROTATION_3_SHIFT_Y; + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + default: + assert(0); + __builtin_unreachable(); + break; + } + + m_nRotate = nRotation; + + DEBUG_EXIT + } +}; + +#endif /* SPI_ST7735S_H_ */ diff --git a/lib-display/include/spi/st7789.h b/lib-display/include/spi/st7789.h index 3dea3de0d..e4252437e 100644 --- a/lib-display/include/spi/st7789.h +++ b/lib-display/include/spi/st7789.h @@ -2,7 +2,7 @@ * @file st7789.h * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,44 +23,137 @@ * THE SOFTWARE. */ -#ifndef ST7789_H -#define ST7789_H +#ifndef SPI_ST7789_H +#define SPI_ST7789_H #include +#include #include "spi/config.h" #include "spi/st77xx.h" +#include "debug.h" + namespace st7789 { +namespace cmd { +static constexpr uint8_t GCTRL = 0xB7; ///< Gate Control +static constexpr uint8_t VCOMS = 0xBB; ///< VCOM Setting +static constexpr uint8_t LCMCTRL = 0xC0; ///< LCM Control +static constexpr uint8_t VDVVRHEN = 0xC2; ///< VDV and VRH Command Enable +static constexpr uint8_t VRHS = 0xC3; ///< VRH Set +static constexpr uint8_t VDVS = 0xC4; ///< VDV Set +static constexpr uint8_t FRCTRL2 = 0xC6; ///< Frame Rate Control in Normal Mode +static constexpr uint8_t PWCTRL1 = 0xD0; ///< Power Control 1 +} // namespace cmd #if defined (SPI_LCD_240X240) -static constexpr auto ROTATION_0_SHIFT_X = 0; -static constexpr auto ROTATION_0_SHIFT_Y = 80; -static constexpr auto ROTATION_1_SHIFT_X = 80; -static constexpr auto ROTATION_1_SHIFT_Y = 0; -static constexpr auto ROTATION_2_SHIFT_X = 0; -static constexpr auto ROTATION_2_SHIFT_Y = 0; -static constexpr auto ROTATION_3_SHIFT_X = 0; -static constexpr auto ROTATION_3_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_0_SHIFT_X = 0; + static constexpr uint32_t ROTATION_0_SHIFT_Y = 80; + static constexpr uint32_t ROTATION_1_SHIFT_X = 80; + static constexpr uint32_t ROTATION_1_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_2_SHIFT_X = 0; + static constexpr uint32_t ROTATION_2_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_3_SHIFT_X = 0; + static constexpr uint32_t ROTATION_3_SHIFT_Y = 0; #elif defined (SPI_LCD_240X320) -static constexpr auto ROTATION_0_SHIFT_X = 0; -static constexpr auto ROTATION_0_SHIFT_Y = 0; -static constexpr auto ROTATION_1_SHIFT_X = 0; -static constexpr auto ROTATION_1_SHIFT_Y = 0; -static constexpr auto ROTATION_2_SHIFT_X = 0; -static constexpr auto ROTATION_2_SHIFT_Y = 0; -static constexpr auto ROTATION_3_SHIFT_X = 0; -static constexpr auto ROTATION_3_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_0_SHIFT_X = 0; + static constexpr uint32_t ROTATION_0_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_1_SHIFT_X = 0; + static constexpr uint32_t ROTATION_1_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_2_SHIFT_X = 0; + static constexpr uint32_t ROTATION_2_SHIFT_Y = 0; + static constexpr uint32_t ROTATION_3_SHIFT_X = 0; + static constexpr uint32_t ROTATION_3_SHIFT_Y = 0; #endif } // namespace st7789 class ST7789 : public ST77XX { public: - ST7789(); - ~ST7789() override; + ST7789(uint32_t nCS) : ST77XX(nCS) { + DEBUG_ENTRY + +#if defined(SPI_LCD_RST_GPIO) + HardwareReset(); +#endif + + WriteCommand(st77xx::cmd::SWRESET); + udelay(1000 * 150); + + static constexpr uint8_t config[] = { + 1, st77xx::cmd::COLMOD, 0x55, + 1, st7789::cmd::GCTRL, 0x35, + 1, st7789::cmd::VCOMS, 0x19, + 1, st7789::cmd::LCMCTRL, 0x2C, + 1, st7789::cmd::VDVVRHEN, 0x01, + 1, st7789::cmd::VRHS, 0x12, + 1, st7789::cmd::VDVS, 0x20, + 1, st7789::cmd::FRCTRL2, 0x0F, + 2, st7789::cmd::PWCTRL1, 0xA4, 0xA1, + 0, st77xx::cmd::NORON, + 0, st77xx::cmd::INVON + }; + + uint32_t nArgLength = 0; + + for (uint32_t i = 0; i < sizeof(config); i+=(nArgLength + 2)) { + nArgLength = config[i]; + DEBUG_PRINTF("i=%u, nArgLength=%u", i, nArgLength); + WriteCommand(&config[i + 1], nArgLength); + } + + SetRotation(0); + + WriteCommand(st77xx::cmd::SLPOUT); ///< Sleep Out + WriteCommand(st77xx::cmd::DISPON); ///< Display On + + DEBUG_EXIT + + } + + ~ST7789() override { + DEBUG_ENTRY + DEBUG_EXIT + }; + + void SetRotation(const uint32_t nRotation) { + WriteCommand(st77xx::cmd::MADCTL); - void Init(); + switch (nRotation) { + case 0: + WriteDataByte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MY | st77xx::data::MADCTL_RGB); + m_nShiftX = st7789::ROTATION_0_SHIFT_X; + m_nShiftY = st7789::ROTATION_0_SHIFT_Y; + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 1: + WriteDataByte(st77xx::data::MADCTL_MY | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_RGB); + m_nShiftX = st7789::ROTATION_1_SHIFT_X; + m_nShiftY = st7789::ROTATION_1_SHIFT_Y; + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + case 2: + WriteDataByte(st77xx::data::MADCTL_RGB); + m_nShiftX = st7789::ROTATION_2_SHIFT_X; + m_nShiftY = st7789::ROTATION_2_SHIFT_Y; + m_nWidth = config::WIDTH; + m_nHeight = config::HEIGHT; + break; + case 3: + WriteDataByte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_RGB); + m_nShiftX = st7789::ROTATION_3_SHIFT_X; + m_nShiftY = st7789::ROTATION_3_SHIFT_Y; + m_nWidth = config::HEIGHT; + m_nHeight = config::WIDTH; + break; + default: + assert(0); + __builtin_unreachable(); + break; + } - void SetRotation(uint32_t nRotation); + m_nRotate = nRotation; + } }; -#endif /* ST7789_H */ +#endif /* SPI_ST7789_H */ diff --git a/lib-display/include/spi/st77xx.h b/lib-display/include/spi/st77xx.h index af61b9b7e..7b855b14e 100644 --- a/lib-display/include/spi/st77xx.h +++ b/lib-display/include/spi/st77xx.h @@ -23,38 +23,43 @@ * THE SOFTWARE. */ -#ifndef ST77XX_H_ -#define ST77XX_H_ +#ifndef SPI_ST77XX_H_ +#define SPI_ST77XX_H_ #include #include "spi/paint.h" +#include "spi/spilcd.h" + +#include "hal_gpio.h" #include "debug.h" namespace st77xx { namespace cmd { -static constexpr uint8_t NOP = 0x00; -static constexpr uint8_t SWRESET = 0x01; -static constexpr uint8_t RDDID = 0x04; -static constexpr uint8_t RDDST = 0x09; -static constexpr uint8_t SLPIN = 0x10; -static constexpr uint8_t SLPOUT = 0x11; -static constexpr uint8_t PTLON = 0x12; -static constexpr uint8_t NORON = 0x13; -static constexpr uint8_t INVOFF = 0x20; -static constexpr uint8_t INVON = 0x21; -static constexpr uint8_t DISPOFF = 0x28; -static constexpr uint8_t DISPON = 0x29; -static constexpr uint8_t CASET = 0x2A; -static constexpr uint8_t RASET = 0x2B; -static constexpr uint8_t RAMWR = 0x2C; -static constexpr uint8_t RAMRD = 0x2E; -static constexpr uint8_t PTLAR = 0x30; -static constexpr uint8_t TEOFF = 0x34; -static constexpr uint8_t TEON = 0x35; -static constexpr uint8_t MADCTL = 0x36; -static constexpr uint8_t COLMOD = 0x3A; +static constexpr uint8_t NOP = 0x00; +static constexpr uint8_t SWRESET = 0x01; ///< Software Reset +static constexpr uint8_t RDDID = 0x04; ///< Read Display ID +static constexpr uint8_t RDDST = 0x09; ///< Read Display Status +static constexpr uint8_t SLPIN = 0x10; ///< Sleep In +static constexpr uint8_t SLPOUT = 0x11; ///< Sleep Out +static constexpr uint8_t PTLON = 0x12; ///< Partial Display Mode On +static constexpr uint8_t NORON = 0x13; ///< Normal Display Mode On +static constexpr uint8_t INVOFF = 0x20; ///< Display Inversion Off +static constexpr uint8_t INVON = 0x21; ///< Display Inversion On +static constexpr uint8_t GAMSET = 0x26; ///< Gamma Set +static constexpr uint8_t DISPOFF = 0x28; ///< Display Offs +static constexpr uint8_t DISPON = 0x29; ///< Display On +static constexpr uint8_t CASET = 0x2A; ///< Column Address Set +static constexpr uint8_t RASET = 0x2B; ///< Row Address Set +static constexpr uint8_t RAMWR = 0x2C; ///< Memory Write +static constexpr uint8_t RAMRD = 0x2E; ///< Memory Read +static constexpr uint8_t PTLAR = 0x30; ///< Partial Area +static constexpr uint8_t TEOFF = 0x34; ///< Tearing Effect Line OFF +static constexpr uint8_t TEON = 0x35; ///< Tearing Effect Line ON . +static constexpr uint8_t MADCTL = 0x36; ///< Memory Data Access Control. +static constexpr uint8_t IDMOFF = 0x38; ///< Idle Mode Off . +static constexpr uint8_t COLMOD = 0x3A; ///< Interface Pixel Format } // namespace cmd namespace data { /** @@ -73,6 +78,7 @@ static constexpr uint8_t MADCTL_MV = 0x20; static constexpr uint8_t MADCTL_ML = 0x10; /* RGB/BGR Order ('0' = RGB, '1' = BGR) */ static constexpr uint8_t MADCTL_RGB = 0x00; +static constexpr uint8_t MADCTL_BGR = 0x08; } // namespace data namespace colour { @@ -93,20 +99,52 @@ static constexpr uint16_t YELLOW = 0xFFE0; class ST77XX : public Paint { public: - ST77XX(); - ~ST77XX() override; + ST77XX(uint32_t nCS) : Paint(nCS) { + DEBUG_ENTRY + DEBUG_EXIT + } + + ~ST77XX() override { + DEBUG_ENTRY + DEBUG_EXIT + } + + void EnableDisplay(const bool bEnable) { + WriteCommand(bEnable ? st77xx::cmd::DISPON : st77xx::cmd::DISPOFF); + } + + void EnableSleep(const bool bEnable) { + WriteCommand(bEnable ? st77xx::cmd::SLPIN : st77xx::cmd::SLPOUT); + } + + void SetBackLight(uint32_t nValue) { + FUNC_PREFIX(gpio_write(SPI_LCD_BL_GPIO, nValue == 0 ? 0 : 1)); + } + + void SetAddressWindow(const uint32_t x0, const uint32_t y0, const uint32_t x1, const uint32_t y1) override { + const auto nStartX = x0 + m_nShiftX; + const auto nEndX = x1 + m_nShiftX; + const auto nStartY = y0 + m_nShiftY; + const auto nEndY = y1 + m_nShiftY; - void SetBackLight(uint32_t nValue); + WriteCommand(st77xx::cmd::CASET); + { + uint8_t data[] = { static_cast(nStartX >> 8), static_cast(nStartX), static_cast(nEndX >> 8), static_cast(nEndX) }; + WriteData(data, sizeof(data)); + } - void EnableDisplay(bool bEnable); - void EnableSleep(bool bEnable); + WriteCommand(st77xx::cmd::RASET); + { + uint8_t data[] = { static_cast(nStartY >> 8), static_cast(nStartY), static_cast(nEndY >> 8), static_cast(nEndY) }; + WriteData(data, sizeof(data)); + } -private: - void SetAddressWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) override; + WriteCommand(st77xx::cmd::RAMWR); + } protected: - uint16_t m_nShiftX { 0 }; - uint16_t m_nShiftY { 0 }; + uint32_t m_nShiftX { 0 }; + uint32_t m_nShiftY { 0 }; }; -#endif /* ST77XX_H_ */ +#endif /* SPI_ST77XX_H_ */ diff --git a/lib-display/src/i2c/display.cpp b/lib-display/src/i2c/display.cpp index aa3325841..b5429608a 100644 --- a/lib-display/src/i2c/display.cpp +++ b/lib-display/src/i2c/display.cpp @@ -55,8 +55,6 @@ static void gpio_init() { } } // namespace display::timeout -Display *Display::s_pThis; - Display::Display() : m_I2C(display::segment7::I2C_ADDRESS) { assert(s_pThis == nullptr); s_pThis = this; diff --git a/lib-display/src/sleep/display.cpp b/lib-display/src/sleep/display.cpp index 80db81472..4b4a6df59 100755 --- a/lib-display/src/sleep/display.cpp +++ b/lib-display/src/sleep/display.cpp @@ -32,11 +32,11 @@ #include "display.h" -#include "timers.h" +#include "softwaretimers.h" #include "debug.h" -static int32_t s_nTimerId = -1; +static TimerHandle_t s_nTimerId = TIMER_ID_NONE; static void sleep_timer([[maybe_unused]] TimerHandle_t nHandle) { Display::Get()->SetSleep(true); @@ -52,7 +52,7 @@ void Display::SetSleepTimer(const bool bActive) { return; } - if (s_nTimerId < 0) { + if (s_nTimerId != TIMER_ID_NONE) { s_nTimerId = SoftwareTimerAdd(m_nSleepTimeout, sleep_timer); DEBUG_EXIT return; diff --git a/lib-display/src/spi/display.cpp b/lib-display/src/spi/display.cpp deleted file mode 100644 index 3fd3fd9c4..000000000 --- a/lib-display/src/spi/display.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @file display.cpp - * - */ -/* Copyright (C) 2022-2024 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 (DEBUG_DISPLAY) -# undef NDEBUG -#endif - -#include -#include - -#include "display.h" -#include "hardware.h" - -#include "hal_spi.h" -#include "hal_gpio.h" - -#include "spi/lcd_font.h" - -#include "debug.h" - -#if defined (SPI_LCD_240X320) -static constexpr sFONT *s_pFONT = &Font16x24; -#else -static constexpr sFONT *s_pFONT = &Font12x12; -#endif - -static constexpr auto COLOR_BACKGROUND = 0x001F; -static constexpr auto COLOR_FOREGROUND = 0xFFE0; - -Display *Display::s_pThis; - -Display::Display() { - DEBUG_ENTRY - - assert(s_pThis == nullptr); - s_pThis = this; - - FUNC_PREFIX(spi_begin()); - FUNC_PREFIX(spi_chipSelect(SPI_CS_NONE)); - FUNC_PREFIX(spi_set_speed_hz(20000000)); - FUNC_PREFIX(spi_setDataMode(SPI_MODE0)); - -#if defined (SPI_LCD_RST_GPIO) - FUNC_PREFIX(gpio_fsel(SPI_LCD_RST_GPIO, GPIO_FSEL_OUTPUT)); -#endif - FUNC_PREFIX(gpio_fsel(SPI_LCD_DC_GPIO, GPIO_FSEL_OUTPUT)); - FUNC_PREFIX(gpio_fsel(SPI_LCD_BL_GPIO, GPIO_FSEL_OUTPUT)); -#if defined(SPI_LCD_HAVE_CS_GPIO) - FUNC_PREFIX(gpio_fsel(SPI_LCD_CS_GPIO, GPIO_FSEL_OUTPUT)); -#endif - - SpiLcd.SetBackLight(1); - SpiLcd.Init(); - SetFlipVertically(false); - SpiLcd.FillColour(COLOR_BACKGROUND); - - m_nCols = static_cast(SpiLcd.GetWidth() / s_pFONT->Width); - m_nRows = static_cast(SpiLcd.GetHeight() / s_pFONT->Height); - -#if defined (DISPLAYTIMEOUT_GPIO) - FUNC_PREFIX(gpio_fsel(DISPLAYTIMEOUT_GPIO, GPIO_FSEL_INPUT)); - FUNC_PREFIX(gpio_set_pud(DISPLAYTIMEOUT_GPIO, GPIO_PULL_UP)); -#endif - - PrintInfo(); - DEBUG_EXIT -} - -void Display::Cls() { - SpiLcd.FillColour(COLOR_BACKGROUND); -} - -void Display::SetCursorPos(uint32_t nCol, uint32_t nRow) { - m_nCursorX = static_cast(nCol * s_pFONT->Width); - m_nCursorY = static_cast(nRow * s_pFONT->Height); -} - -void Display::PutChar(int c) { - SpiLcd.DrawChar(m_nCursorX, m_nCursorY, static_cast(c), s_pFONT, COLOR_BACKGROUND, COLOR_FOREGROUND); - - m_nCursorX += s_pFONT->Width; - - if (m_nCursorX >= SpiLcd.GetWidth()) { - m_nCursorX = 0; - - m_nCursorY += s_pFONT->Height; - - if (m_nCursorY >= SpiLcd.GetHeight()) { - m_nCursorY = 0; - } - } -} diff --git a/lib-display/src/spi/ili9341.cpp b/lib-display/src/spi/ili9341.cpp deleted file mode 100644 index 2a9b40f17..000000000 --- a/lib-display/src/spi/ili9341.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @file ili9341.cpp - * - */ -/* Copyright (C) 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. - */ - -#include -#include - -#include "spi/ili9341.h" -#include "spi/spi_lcd.h" - -#include "hal_gpio.h" - -#include "debug.h" - -using namespace spi::lcd; - -ILI9341::ILI9341() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -ILI9341::~ILI9341() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void ILI9341::Init() { - DEBUG_ENTRY - -#if defined(SPI_LCD_RST_GPIO) - HW_Reset(); -#endif - - Write_Command(0xC0); //Power control - WriteData_Byte(0x23); //VRH[5:0] - - Write_Command(0xC1); //Power control - WriteData_Byte(0x10); //SAP[2:0];BT[3:0] - - Write_Command(0xC5); //VCM control - WriteData_Byte(0x3e); // - WriteData_Byte(0x28); - - Write_Command(0xC7); //VCM control2 - WriteData_Byte(0x86); //-- - - Write_Command(0x3A); - WriteData_Byte(0x55); - - Write_Command(0xB1); - WriteData_Byte(0x00); - WriteData_Byte(0x18); - - Write_Command(0xB6); // Display Function Control - WriteData_Byte(0x08); - WriteData_Byte(0xA2); - WriteData_Byte(0x27); - - Write_Command(0xF2); // 3Gamma Function Disable - WriteData_Byte(0x00); - - Write_Command(0x26); //Gamma curve selected - WriteData_Byte(0x01); - - Write_Command(0xE0); //Set Gamma - WriteData_Byte(0x0F); - WriteData_Byte(0x31); - WriteData_Byte(0x2B); - WriteData_Byte(0x0C); - WriteData_Byte(0x0E); - WriteData_Byte(0x08); - WriteData_Byte(0x4E); - WriteData_Byte(0xF1); - WriteData_Byte(0x37); - WriteData_Byte(0x07); - WriteData_Byte(0x10); - WriteData_Byte(0x03); - WriteData_Byte(0x0E); - WriteData_Byte(0x09); - WriteData_Byte(0x00); - - Write_Command(0XE1); //Set Gamma - WriteData_Byte(0x00); - WriteData_Byte(0x0E); - WriteData_Byte(0x14); - WriteData_Byte(0x03); - WriteData_Byte(0x11); - WriteData_Byte(0x07); - WriteData_Byte(0x31); - WriteData_Byte(0xC1); - WriteData_Byte(0x48); - WriteData_Byte(0x08); - WriteData_Byte(0x0F); - WriteData_Byte(0x0C); - WriteData_Byte(0x31); - WriteData_Byte(0x36); - WriteData_Byte(0x0F); - - SetRotation(0); - - Write_Command(0x11); //Exit Sleep - Write_Command(0x29); //Display on - - DEBUG_EXIT -} - -void ILI9341::SetRotation(uint32_t nRotation) { - Write_Command(ili9341::cmd::MADCTL); - - switch (nRotation) { - case 0: - WriteData_Byte(ili9341::data::MADCTL_BGR); - m_nWidth = config::WIDTH; - m_nHeight = config::HEIGHT; - break; - case 1: - WriteData_Byte(ili9341::data::MADCTL_MX | ili9341::data::MADCTL_MV | ili9341::data::MADCTL_BGR); - m_nWidth = config::HEIGHT; - m_nHeight = config::WIDTH; - break; - case 2: - WriteData_Byte(ili9341::data::MADCTL_MX | ili9341::data::MADCTL_MY | ili9341::data::MADCTL_BGR); - m_nWidth = config::WIDTH; - m_nHeight = config::HEIGHT; - break; - case 3: - WriteData_Byte(ili9341::data::MADCTL_MY | ili9341::data::MADCTL_MV | ili9341::data::MADCTL_BGR); - m_nWidth = config::HEIGHT; - m_nHeight = config::WIDTH; - break; - default: - assert(0); - __builtin_unreachable(); - break; - } - - m_nRotate = nRotation; -} - -void ILI9341::SetBackLight(uint32_t nValue) { - FUNC_PREFIX(gpio_write(SPI_LCD_BL_GPIO, nValue == 0 ? LOW : HIGH)); -} - -void ILI9341::EnableDisplay(bool bEnable) { - Write_Command(bEnable ? ili9341::cmd::DISPON : ili9341::cmd::DISPOFF); -} - -void ILI9341::EnableSleep(bool bEnable) { - Write_Command(bEnable ? ili9341::cmd::SLPIN : ili9341::cmd::SLPOUT); -} - -void ILI9341::EnableColourInversion(bool bEnable) { - Write_Command(bEnable ? ili9341::cmd::INVON : ili9341::cmd::INVOFF); -} - -void ILI9341::SetAddressWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - Write_Command(ili9341::cmd::CASET); - { - uint8_t data[] = { static_cast(x0 >> 8), static_cast(x0), static_cast(x1 >> 8), static_cast(x1) }; - WriteData(data, sizeof(data)); - } - - Write_Command(ili9341::cmd::RASET); - { - uint8_t data[] = { static_cast(y0 >> 8), static_cast(y0), static_cast(y1 >> 8), static_cast(y1) }; - WriteData(data, sizeof(data)); - } - - Write_Command(ili9341::cmd::RAMWR); -} diff --git a/lib-display/src/spi/paint.cpp b/lib-display/src/spi/paint.cpp deleted file mode 100644 index be8212a14..000000000 --- a/lib-display/src/spi/paint.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/** - * @file paint.cpp - * - */ -/* Copyright (C) 2022-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. - */ - -#include -#include -#include -#include -#include - -#include "spi/paint.h" -#include "spi/spi_lcd.h" - -#include "debug.h" - -#if !defined(SPI_LCD_FRAME_BUFFER_ROWS) - static constexpr uint32_t FRAME_BUFFER_ROWS = 5; -#else - static constexpr uint32_t FRAME_BUFFER_ROWS = SPI_LCD_FRAME_BUFFER_ROWS; -#endif - -static uint16_t s_FrameBuffer[config::WIDTH * FRAME_BUFFER_ROWS]; - -using namespace spi::lcd; - -static void fill_framebuffer(uint16_t nColour) { - nColour = __builtin_bswap16(nColour); - - for (size_t i = 0; i < sizeof(s_FrameBuffer) / sizeof(s_FrameBuffer[0]); i++) { - s_FrameBuffer[i] = nColour; - } -} - -Paint::Paint() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -Paint::~Paint() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void Paint::FillColour(uint16_t nColour) { - SetAddressWindow(0, 0, m_nWidth - 1, m_nHeight - 1); - - fill_framebuffer(nColour); - - for (uint32_t i = 0; i < config::HEIGHT / FRAME_BUFFER_ROWS; i++) { - WriteData(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); - } -} - -void Paint::Fill(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t nColour) { - if (!(x0 < m_nWidth && (y0 < m_nHeight) && (x1 < m_nWidth) && (y1 < m_nHeight))) { - DEBUG_PRINTF("[%u:%u] %u:%u-%u:%u", m_nWidth, m_nHeight, x0, y0, x1, y1); - return; - } - - assert(x1 > x0); - assert(y1 > y0); - - SetAddressWindow(x0, y0, x1, y1); - - fill_framebuffer(nColour); - - auto nPixels = static_cast((1 + (y1 - y0)) * (1 + (x1 - x0))); - const auto nBufferSize = sizeof(s_FrameBuffer) / sizeof(s_FrameBuffer[0]); - - if (nPixels > nBufferSize) { - WriteDataStart(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); - - nPixels = nPixels - nBufferSize; - - while (nPixels > nBufferSize) { - WriteDataContinue(reinterpret_cast(s_FrameBuffer), sizeof(s_FrameBuffer)); - nPixels = nPixels - nBufferSize; - } - - if (nPixels > 0) { - WriteDataEnd(reinterpret_cast(s_FrameBuffer), nPixels * 2); - } else { - CS_Set(); - } - } else { - WriteData(reinterpret_cast(s_FrameBuffer), nPixels * 2); - } -} - -void Paint::DrawChar(uint16_t x0, uint16_t y0, const char nChar, sFONT *pFont, uint16_t nColourBackground, uint16_t nColourForeGround) { - const auto x1 = static_cast(x0 + pFont->Width - 1); - const auto y1 = static_cast(y0 + pFont->Height - 1); - - SetAddressWindow(x0, y0, x1, y1); - - nColourForeGround = __builtin_bswap16(nColourForeGround); - nColourBackground = __builtin_bswap16(nColourBackground); - - const auto nCharOffset = (nChar - ' ') * pFont->Height; - const auto *ptr = &pFont->table[nCharOffset]; - - DEBUG_PRINTF("w=%u, h=%u, nCharOffset=%u", pFont->Width , pFont->Height, nCharOffset); - - uint32_t nIndex = 0; - - if (pFont->Width == 8) { - for (auto nPage = 0; nPage < pFont->Height; nPage++) { - auto line = *ptr++; - - for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { - if ((line & 0x80) != 0) { - s_FrameBuffer[nIndex++] = nColourForeGround; - } else { - s_FrameBuffer[nIndex++] = nColourBackground; - } - - line = line << 1; - } - } - } else if (pFont->Width < 16) { - for (auto nPage = 0; nPage < pFont->Height; nPage++) { - auto line = *ptr++; - - for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { - if ((line & 0x8000) != 0) { - s_FrameBuffer[nIndex++] = nColourForeGround; - } else { - s_FrameBuffer[nIndex++] = nColourBackground; - } - - line = line << 1; - } - } - } else { - for (auto nPage = 0; nPage < pFont->Height; nPage++) { - auto line = *ptr++; - - for (auto nColumn = 0; nColumn < pFont->Width; nColumn++) { - if ((line & 0x1) != 0) { - s_FrameBuffer[nIndex++] = nColourForeGround; - } else { - s_FrameBuffer[nIndex++] = nColourBackground; - } - - line = line >> 1; - } - } - } - - WriteData(reinterpret_cast(s_FrameBuffer), nIndex * 2); -} - -void Paint::DrawPixel(uint16_t x, uint16_t y, uint16_t nColour) { - SetAddressWindow(x, y, x, y); - WriteData_Word(nColour); -} - -/** - * Bresenham - */ -//TODO Can be optimized for horizontal and vertical lines -void Paint::DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t nColour) { - const auto dx = abs(x1 - x0); - const auto dy = -abs(y1 - y0); - - const auto sx = x0 < x1 ? 1 : -1; - const auto sy = y0 < y1 ? 1 : -1; - - auto error = dx + dy; - - while (true) { - DrawPixel(x0, y0, nColour); - - if ((x0 == x1) && (y0 == y1)) { - break; - } - - auto e2 = 2 * error; - - if (e2 >= dy) { - if (x0 == x1) { - break; - } - error = error + dy; - x0 = x0 + sx; - } - - if (e2 <= dx) { - if (y0 == y1) { - break; - } - error = error + dx; - y0 = y0 + sy; - } - } -} diff --git a/lib-display/src/spi/st7789.cpp b/lib-display/src/spi/st7789.cpp deleted file mode 100644 index 1efcaf5a6..000000000 --- a/lib-display/src/spi/st7789.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file st7789.cpp - * - */ -/* Copyright (C) 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. - */ - -#include -#include - -#include "spi/st7789.h" -#include "spi/st77xx.h" -#include "spi/spi_lcd.h" - -#include "hal_gpio.h" - -#include "debug.h" - -using namespace spi::lcd; - -ST7789::ST7789() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -ST7789::~ST7789() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void ST7789::Init() { - DEBUG_ENTRY - -#if defined(SPI_LCD_RST_GPIO) - HW_Reset(); -#endif - - Write_Command(st77xx::cmd::SWRESET); - ms_delay(150); - - Write_Command(st77xx::cmd::COLMOD); - WriteData_Byte(0x55); - - Write_Command(0xB7); - WriteData_Byte(0x35); - - Write_Command(0xBB); - WriteData_Byte(0x19); - - Write_Command(0xC0); - WriteData_Byte(0x2C); - - Write_Command(0xC2); - WriteData_Byte(0x01); - - Write_Command(0xC3); - WriteData_Byte(0x12); - - Write_Command(0xC4); - WriteData_Byte(0x20); - - Write_Command(0xC6); - WriteData_Byte(0x0F); - - Write_Command(0xD0); - WriteData_Byte(0xA4); - WriteData_Byte(0xA1); - - SetRotation(0); - - Write_Command(st77xx::cmd::INVON); - Write_Command(st77xx::cmd::SLPOUT); - Write_Command(st77xx::cmd::DISPON); - - DEBUG_EXIT -} - -void ST7789::SetRotation(uint32_t nRotation) { - Write_Command(st77xx::cmd::MADCTL); - - switch (nRotation) { - case 0: - WriteData_Byte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MY | st77xx::data::MADCTL_RGB); - m_nShiftX = st7789::ROTATION_0_SHIFT_X; - m_nShiftY = st7789::ROTATION_0_SHIFT_Y; - m_nWidth = config::WIDTH; - m_nHeight = config::HEIGHT; - break; - case 1: - WriteData_Byte(st77xx::data::MADCTL_MY | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_RGB); - m_nShiftX = st7789::ROTATION_1_SHIFT_X; - m_nShiftY = st7789::ROTATION_1_SHIFT_Y; - m_nWidth = config::HEIGHT; - m_nHeight = config::WIDTH; - break; - case 2: - WriteData_Byte(st77xx::data::MADCTL_RGB); - m_nShiftX = st7789::ROTATION_2_SHIFT_X; - m_nShiftY = st7789::ROTATION_2_SHIFT_Y; - m_nWidth = config::WIDTH; - m_nHeight = config::HEIGHT; - break; - case 3: - WriteData_Byte(st77xx::data::MADCTL_MX | st77xx::data::MADCTL_MV | st77xx::data::MADCTL_RGB); - m_nShiftX = st7789::ROTATION_3_SHIFT_X; - m_nShiftY = st7789::ROTATION_3_SHIFT_Y; - m_nWidth = config::HEIGHT; - m_nHeight = config::WIDTH; - break; - default: - assert(0); - __builtin_unreachable(); - break; - } - - m_nRotate = static_cast(nRotation); -} diff --git a/lib-display/src/spi/st7xx.cpp b/lib-display/src/spi/st7xx.cpp deleted file mode 100644 index cf613c972..000000000 --- a/lib-display/src/spi/st7xx.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file st77xx.cpp - * - */ -/* Copyright (C) 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. - */ - -#include -#include - -#include "spi/st77xx.h" -#include "spi/spi_lcd.h" - -#include "hal_gpio.h" -#include "hal_spi.h" - -#include "debug.h" - -using namespace spi::lcd; - -ST77XX::ST77XX() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -ST77XX::~ST77XX() { - DEBUG_ENTRY - - DEBUG_EXIT -} - -void ST77XX::EnableDisplay(bool bEnable) { - Write_Command(bEnable ? st77xx::cmd::DISPON : st77xx::cmd::DISPOFF); -} - -void ST77XX::EnableSleep(bool bEnable) { - Write_Command(bEnable ? st77xx::cmd::SLPIN : st77xx::cmd::SLPOUT); -} - -//TODO This should be a PWM pin -void ST77XX::SetBackLight(uint32_t nValue) { - FUNC_PREFIX(gpio_write(SPI_LCD_BL_GPIO, nValue == 0 ? LOW : HIGH)); -} - -void ST77XX::SetAddressWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - const auto x_start = x0 + m_nShiftX; - const auto x_end = x1 + m_nShiftX; - const auto y_start = y0 + m_nShiftY; - const auto y_end = y1 + m_nShiftY; - - Write_Command(st77xx::cmd::CASET); - { - uint8_t data[] = { static_cast(x_start >> 8), static_cast(x_start), static_cast(x_end >> 8), static_cast(x_end) }; - WriteData(data, sizeof(data)); - } - - Write_Command(st77xx::cmd::RASET); - { - uint8_t data[] = { static_cast(y_start >> 8), static_cast(y_start), static_cast(y_end >> 8), static_cast(y_end) }; - WriteData(data, sizeof(data)); - } - - Write_Command(st77xx::cmd::RAMWR); -} From f5e8148f534e6003df48de09f56649756b5adcbd Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 21:55:16 +0100 Subject: [PATCH 14/36] Updated Eclipse project settings --- .gitignore | 4 + lib-arm/.settings/language.settings.xml | 4 +- lib-artnet/.cproject | 50 +-- lib-artnet/.settings/language.settings.xml | 6 +- lib-bcm2835/.settings/language.settings.xml | 2 +- lib-clib/.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- lib-ddp/.cproject | 252 ++++++++++----- lib-ddp/.settings/language.settings.xml | 10 +- lib-device/.settings/language.settings.xml | 4 +- lib-display/.settings/language.settings.xml | 6 +- lib-displayudf/.cproject | 6 +- .../.settings/language.settings.xml | 4 +- lib-dmx/.cproject | 20 ++ lib-dmx/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 6 +- lib-dmxserial/.cproject | 290 ++++++++++++------ lib-dmxserial/.settings/language.settings.xml | 10 +- lib-e131/.cproject | 272 +++++++++------- lib-e131/.settings/language.settings.xml | 8 +- lib-flash/.cproject | 192 +++++++++--- lib-flash/.settings/language.settings.xml | 6 +- lib-flashcode/.cproject | 196 +++++++++--- lib-flashcode/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 2 +- lib-gps/.settings/language.settings.xml | 2 +- lib-hal/.settings/language.settings.xml | 6 +- lib-jamstapl/.cproject | 2 +- lib-jamstapl/.settings/language.settings.xml | 2 +- lib-l6470/.settings/language.settings.xml | 6 +- lib-l6470dmx/.settings/language.settings.xml | 6 +- lib-lightset/.cproject | 3 + lib-lightset/.settings/language.settings.xml | 6 +- lib-midi/.settings/language.settings.xml | 4 +- lib-network/.settings/language.settings.xml | 6 +- lib-osc/.settings/language.settings.xml | 6 +- lib-pca9685/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 6 +- lib-pp/.settings/language.settings.xml | 4 +- .../.settings/language.settings.xml | 6 +- lib-rdm/.settings/language.settings.xml | 6 +- lib-rdmsensor/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 6 +- lib-remoteconfig/.cproject | 12 + .../.settings/language.settings.xml | 4 +- lib-tcnet/.settings/language.settings.xml | 4 +- lib-tlc59711/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 6 +- lib-usb/.settings/language.settings.xml | 4 +- lib-widget/.settings/language.settings.xml | 4 +- lib-ws28xx/.settings/language.settings.xml | 6 +- .../.settings/language.settings.xml | 2 +- lib-ws28xxdmx/.settings/language.settings.xml | 6 +- linux_artnet/.settings/language.settings.xml | 2 +- linux_e131/.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 4 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- 88 files changed, 1060 insertions(+), 521 deletions(-) diff --git a/.gitignore b/.gitignore index 4445cdff0..89305110d 100644 --- a/.gitignore +++ b/.gitignore @@ -113,3 +113,7 @@ software_version_id.h /lib-node /lib-showfile/Doxygen /opi_emac_eve_example +*._h +*._cpp +/opi_emac_debug_lcd_udp +/lib-dmxnode diff --git a/lib-arm/.settings/language.settings.xml b/lib-arm/.settings/language.settings.xml index 552b63f18..ae71ff5d5 100644 --- a/lib-arm/.settings/language.settings.xml +++ b/lib-arm/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-artnet/.cproject b/lib-artnet/.cproject index afabd1c05..5f8c22d59 100644 --- a/lib-artnet/.cproject +++ b/lib-artnet/.cproject @@ -50,6 +50,8 @@ + + @@ -83,6 +85,8 @@ + + @@ -177,6 +181,8 @@ + + @@ -209,6 +215,8 @@ + + @@ -361,18 +369,13 @@ + + + + + - + - + diff --git a/lib-artnet/.settings/language.settings.xml b/lib-artnet/.settings/language.settings.xml index 176e0c1fe..bb7181ede 100644 --- a/lib-artnet/.settings/language.settings.xml +++ b/lib-artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-bcm2835/.settings/language.settings.xml b/lib-bcm2835/.settings/language.settings.xml index 9ac84d157..0844c86df 100644 --- a/lib-bcm2835/.settings/language.settings.xml +++ b/lib-bcm2835/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-clib/.settings/language.settings.xml b/lib-clib/.settings/language.settings.xml index fc14cbd1f..fcfe65cf0 100755 --- a/lib-clib/.settings/language.settings.xml +++ b/lib-clib/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-configstore/.settings/language.settings.xml b/lib-configstore/.settings/language.settings.xml index 22849cdff..6ba10a604 100755 --- a/lib-configstore/.settings/language.settings.xml +++ b/lib-configstore/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-ddp/.cproject b/lib-ddp/.cproject index 72f81c5ab..685229980 100755 --- a/lib-ddp/.cproject +++ b/lib-ddp/.cproject @@ -1,70 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -77,14 +13,14 @@ - + - - - - @@ -141,6 +77,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib-ddp/.settings/language.settings.xml b/lib-ddp/.settings/language.settings.xml index 6eba6edbe..88719f44a 100755 --- a/lib-ddp/.settings/language.settings.xml +++ b/lib-ddp/.settings/language.settings.xml @@ -1,23 +1,23 @@ - + - + - + - - + + diff --git a/lib-device/.settings/language.settings.xml b/lib-device/.settings/language.settings.xml index c5fbb2573..237715cdc 100644 --- a/lib-device/.settings/language.settings.xml +++ b/lib-device/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-display/.settings/language.settings.xml b/lib-display/.settings/language.settings.xml index a709a0258..05bdcbba5 100755 --- a/lib-display/.settings/language.settings.xml +++ b/lib-display/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-displayudf/.cproject b/lib-displayudf/.cproject index cf0457ecf..22b72519d 100644 --- a/lib-displayudf/.cproject +++ b/lib-displayudf/.cproject @@ -257,6 +257,8 @@ + + @@ -286,11 +288,7 @@ - - - - diff --git a/lib-displayudf/.settings/language.settings.xml b/lib-displayudf/.settings/language.settings.xml index c160f6635..6e99ed3f7 100644 --- a/lib-displayudf/.settings/language.settings.xml +++ b/lib-displayudf/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-dmx/.cproject b/lib-dmx/.cproject index 0337cc859..bb90960cf 100644 --- a/lib-dmx/.cproject +++ b/lib-dmx/.cproject @@ -31,9 +31,11 @@ + @@ -48,9 +50,11 @@ + @@ -73,6 +77,7 @@ + @@ -113,6 +118,10 @@ + + + @@ -124,6 +133,10 @@ + + + @@ -142,6 +155,7 @@ + @@ -261,6 +275,7 @@ + @@ -281,6 +297,7 @@ + @@ -301,6 +319,7 @@ + diff --git a/lib-dmx/.settings/language.settings.xml b/lib-dmx/.settings/language.settings.xml index 69ed61838..6a1097c7c 100644 --- a/lib-dmx/.settings/language.settings.xml +++ b/lib-dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-dmxmonitor/.settings/language.settings.xml b/lib-dmxmonitor/.settings/language.settings.xml index 3008ff609..702281c9f 100644 --- a/lib-dmxmonitor/.settings/language.settings.xml +++ b/lib-dmxmonitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-dmxserial/.cproject b/lib-dmxserial/.cproject index 39ebe7bb0..01595308d 100644 --- a/lib-dmxserial/.cproject +++ b/lib-dmxserial/.cproject @@ -1,8 +1,8 @@ - - + + @@ -13,69 +13,63 @@ - - - - - - + + + @@ -99,69 +94,166 @@ - - - - @@ -189,38 +281,50 @@ + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - \ No newline at end of file diff --git a/lib-dmxserial/.settings/language.settings.xml b/lib-dmxserial/.settings/language.settings.xml index 0e1c5fb28..cbd9c1afd 100644 --- a/lib-dmxserial/.settings/language.settings.xml +++ b/lib-dmxserial/.settings/language.settings.xml @@ -1,23 +1,23 @@ - + - + - + - - + + diff --git a/lib-e131/.cproject b/lib-e131/.cproject index c42abcd02..2aeb00a1d 100644 --- a/lib-e131/.cproject +++ b/lib-e131/.cproject @@ -30,6 +30,9 @@ + + + @@ -124,6 +133,9 @@ + + + @@ -187,8 +205,8 @@ - - + + @@ -200,153 +218,169 @@ - - - - + + + + + + + + - - - - - + + + \ No newline at end of file diff --git a/lib-flash/.settings/language.settings.xml b/lib-flash/.settings/language.settings.xml index 1c186e8c5..43fda3c11 100755 --- a/lib-flash/.settings/language.settings.xml +++ b/lib-flash/.settings/language.settings.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/lib-flashcode/.cproject b/lib-flashcode/.cproject index 6a877f0a2..9023f5725 100755 --- a/lib-flashcode/.cproject +++ b/lib-flashcode/.cproject @@ -1,11 +1,11 @@ - - + + - + @@ -14,53 +14,167 @@ - - - - + + + + + + + + + - + + + + - - - - - - \ No newline at end of file diff --git a/lib-flashcode/.settings/language.settings.xml b/lib-flashcode/.settings/language.settings.xml index 1315b9bfd..6a955d626 100755 --- a/lib-flashcode/.settings/language.settings.xml +++ b/lib-flashcode/.settings/language.settings.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/lib-flashcodeinstall/.settings/language.settings.xml b/lib-flashcodeinstall/.settings/language.settings.xml index 2217524fa..5242dcdec 100755 --- a/lib-flashcodeinstall/.settings/language.settings.xml +++ b/lib-flashcodeinstall/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-gps/.settings/language.settings.xml b/lib-gps/.settings/language.settings.xml index cf04b2ce4..0383e302c 100644 --- a/lib-gps/.settings/language.settings.xml +++ b/lib-gps/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-hal/.settings/language.settings.xml b/lib-hal/.settings/language.settings.xml index d7152ae63..4e2b877f8 100644 --- a/lib-hal/.settings/language.settings.xml +++ b/lib-hal/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-jamstapl/.cproject b/lib-jamstapl/.cproject index a7178e84c..04588df6b 100644 --- a/lib-jamstapl/.cproject +++ b/lib-jamstapl/.cproject @@ -5,7 +5,6 @@ - @@ -63,6 +62,7 @@ + diff --git a/lib-jamstapl/.settings/language.settings.xml b/lib-jamstapl/.settings/language.settings.xml index 1feceea34..4237821d6 100644 --- a/lib-jamstapl/.settings/language.settings.xml +++ b/lib-jamstapl/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-l6470/.settings/language.settings.xml b/lib-l6470/.settings/language.settings.xml index a295dcfd1..1d0795c57 100644 --- a/lib-l6470/.settings/language.settings.xml +++ b/lib-l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-l6470dmx/.settings/language.settings.xml b/lib-l6470dmx/.settings/language.settings.xml index 3a5c58361..49839c725 100644 --- a/lib-l6470dmx/.settings/language.settings.xml +++ b/lib-l6470dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-lightset/.cproject b/lib-lightset/.cproject index 01871b567..1cd183bb1 100644 --- a/lib-lightset/.cproject +++ b/lib-lightset/.cproject @@ -244,6 +244,7 @@ + - + diff --git a/lib-midi/.settings/language.settings.xml b/lib-midi/.settings/language.settings.xml index d8dc0e7ef..5d974a48e 100644 --- a/lib-midi/.settings/language.settings.xml +++ b/lib-midi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-network/.settings/language.settings.xml b/lib-network/.settings/language.settings.xml index 35b522821..035999e6e 100644 --- a/lib-network/.settings/language.settings.xml +++ b/lib-network/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-osc/.settings/language.settings.xml b/lib-osc/.settings/language.settings.xml index eea99bb3f..f4407090e 100644 --- a/lib-osc/.settings/language.settings.xml +++ b/lib-osc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685/.settings/language.settings.xml b/lib-pca9685/.settings/language.settings.xml index 9ea522c4d..86915f751 100644 --- a/lib-pca9685/.settings/language.settings.xml +++ b/lib-pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685dmx/.settings/language.settings.xml b/lib-pca9685dmx/.settings/language.settings.xml index 0f9b63df2..abbde0319 100644 --- a/lib-pca9685dmx/.settings/language.settings.xml +++ b/lib-pca9685dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pp/.settings/language.settings.xml b/lib-pp/.settings/language.settings.xml index 276ec9b20..e46dd855d 100755 --- a/lib-pp/.settings/language.settings.xml +++ b/lib-pp/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-properties/.settings/language.settings.xml b/lib-properties/.settings/language.settings.xml index 48d2a9d00..3bb45a834 100644 --- a/lib-properties/.settings/language.settings.xml +++ b/lib-properties/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-rdm/.settings/language.settings.xml b/lib-rdm/.settings/language.settings.xml index bb7455857..0e921bef9 100644 --- a/lib-rdm/.settings/language.settings.xml +++ b/lib-rdm/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-rdmsensor/.settings/language.settings.xml b/lib-rdmsensor/.settings/language.settings.xml index b5685e76a..99099c1cd 100644 --- a/lib-rdmsensor/.settings/language.settings.xml +++ b/lib-rdmsensor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-rdmsubdevice/.settings/language.settings.xml b/lib-rdmsubdevice/.settings/language.settings.xml index c07f896a9..be358008d 100644 --- a/lib-rdmsubdevice/.settings/language.settings.xml +++ b/lib-rdmsubdevice/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-remoteconfig/.cproject b/lib-remoteconfig/.cproject index b5a7a9ddd..4ded30592 100644 --- a/lib-remoteconfig/.cproject +++ b/lib-remoteconfig/.cproject @@ -329,6 +329,10 @@ + + + + - + diff --git a/lib-tcnet/.settings/language.settings.xml b/lib-tcnet/.settings/language.settings.xml index ca44c5014..60bf10e76 100644 --- a/lib-tcnet/.settings/language.settings.xml +++ b/lib-tcnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-tlc59711/.settings/language.settings.xml b/lib-tlc59711/.settings/language.settings.xml index 9f972a06b..4b21ae3de 100644 --- a/lib-tlc59711/.settings/language.settings.xml +++ b/lib-tlc59711/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-tlc59711dmx/.settings/language.settings.xml b/lib-tlc59711dmx/.settings/language.settings.xml index 2d8d2c6c2..0355f656a 100644 --- a/lib-tlc59711dmx/.settings/language.settings.xml +++ b/lib-tlc59711dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-usb/.settings/language.settings.xml b/lib-usb/.settings/language.settings.xml index f8829e8ba..2d4ba3e86 100644 --- a/lib-usb/.settings/language.settings.xml +++ b/lib-usb/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-widget/.settings/language.settings.xml b/lib-widget/.settings/language.settings.xml index f8829e8ba..2d4ba3e86 100644 --- a/lib-widget/.settings/language.settings.xml +++ b/lib-widget/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-ws28xx/.settings/language.settings.xml b/lib-ws28xx/.settings/language.settings.xml index 886e78980..02ddd41b6 100644 --- a/lib-ws28xx/.settings/language.settings.xml +++ b/lib-ws28xx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-ws28xxdisplay/.settings/language.settings.xml b/lib-ws28xxdisplay/.settings/language.settings.xml index 845dcad8c..01eb8eeac 100644 --- a/lib-ws28xxdisplay/.settings/language.settings.xml +++ b/lib-ws28xxdisplay/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-ws28xxdmx/.settings/language.settings.xml b/lib-ws28xxdmx/.settings/language.settings.xml index 7bfbed531..4054cf5e2 100644 --- a/lib-ws28xxdmx/.settings/language.settings.xml +++ b/lib-ws28xxdmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/linux_artnet/.settings/language.settings.xml b/linux_artnet/.settings/language.settings.xml index 7f4f7220e..c8d35c1a6 100644 --- a/linux_artnet/.settings/language.settings.xml +++ b/linux_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_e131/.settings/language.settings.xml b/linux_e131/.settings/language.settings.xml index 7f4f7220e..c8d35c1a6 100644 --- a/linux_e131/.settings/language.settings.xml +++ b/linux_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_dmx_monitor/.settings/language.settings.xml b/opi_dmx_monitor/.settings/language.settings.xml index dd816c72a..db6d729be 100644 --- a/opi_dmx_monitor/.settings/language.settings.xml +++ b/opi_dmx_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/opi_dmx_usb_pro/.settings/language.settings.xml b/opi_dmx_usb_pro/.settings/language.settings.xml index 525366eef..ff1d802c2 100644 --- a/opi_dmx_usb_pro/.settings/language.settings.xml +++ b/opi_dmx_usb_pro/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx/.settings/language.settings.xml b/opi_emac_artnet_dmx/.settings/language.settings.xml index 3da5307f1..ba76aabdd 100644 --- a/opi_emac_artnet_dmx/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml index 3da5307f1..ba76aabdd 100644 --- a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_monitor/.settings/language.settings.xml b/opi_emac_artnet_monitor/.settings/language.settings.xml index 3da5307f1..ba76aabdd 100644 --- a/opi_emac_artnet_monitor/.settings/language.settings.xml +++ b/opi_emac_artnet_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel/.settings/language.settings.xml b/opi_emac_artnet_pixel/.settings/language.settings.xml index 0ca9813fe..658094508 100644 --- a/opi_emac_artnet_pixel/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml b/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml index f506b2d4b..9d4d66f91 100755 --- a/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml index 66ad31a18..2d41b0370 100755 --- a/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_multi/.settings/language.settings.xml b/opi_emac_artnet_pixel_multi/.settings/language.settings.xml index 388ff4ff2..dfda8b455 100644 --- a/opi_emac_artnet_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml index 3da5307f1..ba76aabdd 100644 --- a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml index 4571fcf97..385aac416 100755 --- a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_serial/.settings/language.settings.xml b/opi_emac_artnet_serial/.settings/language.settings.xml index 3da5307f1..ba76aabdd 100644 --- a/opi_emac_artnet_serial/.settings/language.settings.xml +++ b/opi_emac_artnet_serial/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml index 0b9454b33..c6f613b69 100755 --- a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml index 0b9454b33..c6f613b69 100755 --- a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_artnet/.settings/language.settings.xml b/opi_emac_e131_artnet/.settings/language.settings.xml index 83f44d039..769a1a60c 100644 --- a/opi_emac_e131_artnet/.settings/language.settings.xml +++ b/opi_emac_e131_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx/.settings/language.settings.xml b/opi_emac_e131_dmx/.settings/language.settings.xml index 83f44d039..769a1a60c 100644 --- a/opi_emac_e131_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_dmx_multi/.settings/language.settings.xml index 83f44d039..769a1a60c 100644 --- a/opi_emac_e131_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_monitor/.settings/language.settings.xml b/opi_emac_e131_monitor/.settings/language.settings.xml index 83f44d039..769a1a60c 100644 --- a/opi_emac_e131_monitor/.settings/language.settings.xml +++ b/opi_emac_e131_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel/.settings/language.settings.xml b/opi_emac_e131_pixel/.settings/language.settings.xml index eff48f0b7..a340f3b95 100644 --- a/opi_emac_e131_pixel/.settings/language.settings.xml +++ b/opi_emac_e131_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml index bcb9693a8..fb15fb409 100755 --- a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml index 5424b9fd4..b72e68cc1 100755 --- a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_multi/.settings/language.settings.xml b/opi_emac_e131_pixel_multi/.settings/language.settings.xml index e8869aef1..ee9e9a6e0 100644 --- a/opi_emac_e131_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_llrp_tftpd/.settings/language.settings.xml b/opi_emac_llrp_tftpd/.settings/language.settings.xml index 4e0f5c115..a469be822 100644 --- a/opi_emac_llrp_tftpd/.settings/language.settings.xml +++ b/opi_emac_llrp_tftpd/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ltc_smpte/.settings/language.settings.xml b/opi_emac_ltc_smpte/.settings/language.settings.xml index 8312ebc82..d091405d6 100644 --- a/opi_emac_ltc_smpte/.settings/language.settings.xml +++ b/opi_emac_ltc_smpte/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_client/.settings/language.settings.xml b/opi_emac_osc_client/.settings/language.settings.xml index fe62819bb..d3662cbde 100644 --- a/opi_emac_osc_client/.settings/language.settings.xml +++ b/opi_emac_osc_client/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_dmx/.settings/language.settings.xml b/opi_emac_osc_dmx/.settings/language.settings.xml index fe62819bb..d3662cbde 100644 --- a/opi_emac_osc_dmx/.settings/language.settings.xml +++ b/opi_emac_osc_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_monitor/.settings/language.settings.xml b/opi_emac_osc_monitor/.settings/language.settings.xml index fe62819bb..d3662cbde 100644 --- a/opi_emac_osc_monitor/.settings/language.settings.xml +++ b/opi_emac_osc_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_pixel/.settings/language.settings.xml b/opi_emac_osc_pixel/.settings/language.settings.xml index fe62819bb..d3662cbde 100644 --- a/opi_emac_osc_pixel/.settings/language.settings.xml +++ b/opi_emac_osc_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_pp_pixel_multi/.settings/language.settings.xml b/opi_emac_pp_pixel_multi/.settings/language.settings.xml index 0b9454b33..c6f613b69 100755 --- a/opi_emac_pp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_pp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_artnet/.settings/language.settings.xml b/opi_emac_showfile_artnet/.settings/language.settings.xml index 7b1b74060..61fa4107c 100755 --- a/opi_emac_showfile_artnet/.settings/language.settings.xml +++ b/opi_emac_showfile_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_e131/.settings/language.settings.xml b/opi_emac_showfile_e131/.settings/language.settings.xml index 7b1b74060..61fa4107c 100755 --- a/opi_emac_showfile_e131/.settings/language.settings.xml +++ b/opi_emac_showfile_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder/.settings/language.settings.xml b/opi_rdm_responder/.settings/language.settings.xml index 86f525b63..c6771bbef 100644 --- a/opi_rdm_responder/.settings/language.settings.xml +++ b/opi_rdm_responder/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder_l6470/.settings/language.settings.xml b/opi_rdm_responder_l6470/.settings/language.settings.xml index 61f01aa2a..07584218b 100644 --- a/opi_rdm_responder_l6470/.settings/language.settings.xml +++ b/opi_rdm_responder_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + From b744eb4cf192614cdde01dca1d0de81ee26f8f3e Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 22:02:48 +0100 Subject: [PATCH 15/36] Added optimize ("-fprefetch-loop-arrays") --- lib-network/src/net/arp.cpp | 22 ++++-- lib-network/src/net/icmp.cpp | 1 + lib-network/src/net/igmp.cpp | 5 +- lib-network/src/net/ip.cpp | 1 + lib-network/src/net/net.cpp | 1 + lib-network/src/net/net_chksum.cpp | 1 + lib-network/src/net/tcp.cpp | 11 ++- lib-network/src/net/udp.cpp | 117 +++++++++++++++++------------ 8 files changed, 98 insertions(+), 61 deletions(-) diff --git a/lib-network/src/net/arp.cpp b/lib-network/src/net/arp.cpp index 043491dae..9d34bd3e0 100755 --- a/lib-network/src/net/arp.cpp +++ b/lib-network/src/net/arp.cpp @@ -37,6 +37,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include @@ -55,7 +56,7 @@ #include "net/protocol/udp.h" #include "netif.h" -#include "timers.h" +#include "softwaretimers.h" #include "debug.h" @@ -98,9 +99,8 @@ struct Record { } // namespace arp static net::arp::Record s_ArpRecords[MAX_RECORDS] SECTION_NETWORK ALIGNED; - -static struct t_arp s_arp_request ALIGNED ; -static struct t_arp s_arp_reply ALIGNED; +static struct t_arp s_arp_request SECTION_NETWORK ALIGNED ; +static struct t_arp s_arp_reply SECTION_NETWORK ALIGNED; #ifndef NDEBUG static constexpr char STATE[4][12] = { "EMPTY", "PROBE", "REACHABLE", "STALE", }; @@ -430,6 +430,14 @@ static void arp_send_implementation(struct t_udp *pPacket, const uint32_t nSize, DEBUG_ENTRY DEBUG_PRINTF(IPSTR, IP2STR(nRemoteIp)); + const auto &netif = net::globals::netif_default; + + DEBUG_PRINTF(IPSTR, IP2STR(netif.ip.addr)); + + if (__builtin_expect((netif.ip.addr == 0), 0)) { + return; + } + net::memcpy_ip(pPacket->ip4.dst, nRemoteIp); pPacket->ip4.chksum = 0; #if !defined (CHECKSUM_BY_HARDWARE) @@ -444,7 +452,7 @@ static void arp_send_implementation(struct t_udp *pPacket, const uint32_t nSize, on the same physical link. The host MUST NOT send the packet to any router for forwarding". */ if (!network::is_linklocal_ip(nRemoteIp)) { - nDestinationIp = net::globals::netif_default.gw.addr; + nDestinationIp = netif.gw.addr; DEBUG_PUTS(""); } } @@ -454,11 +462,11 @@ static void arp_send_implementation(struct t_udp *pPacket, const uint32_t nSize, if (record.nIp == nDestinationIp) { std::memcpy(pPacket->ether.dst, record.mac_address, ETH_ADDR_LEN); - if (S == net::arp::EthSend::IS_NORMAL) { + if constexpr (S == net::arp::EthSend::IS_NORMAL) { emac_eth_send(reinterpret_cast(pPacket), nSize); } #if defined CONFIG_ENET_ENABLE_PTP - else if (S == net::arp::EthSend::IS_TIMESTAMP) { + else if constexpr (S == net::arp::EthSend::IS_TIMESTAMP) { emac_eth_send_timestamp(reinterpret_cast(pPacket), nSize); } #endif diff --git a/lib-network/src/net/icmp.cpp b/lib-network/src/net/icmp.cpp index 51d8b2355..7940d046c 100755 --- a/lib-network/src/net/icmp.cpp +++ b/lib-network/src/net/icmp.cpp @@ -31,6 +31,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include diff --git a/lib-network/src/net/igmp.cpp b/lib-network/src/net/igmp.cpp index 6ac3ec32a..0986cd83e 100644 --- a/lib-network/src/net/igmp.cpp +++ b/lib-network/src/net/igmp.cpp @@ -31,6 +31,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include @@ -48,7 +49,7 @@ #include "net_memcpy.h" #include "net_private.h" -#include "timers.h" +#include "softwaretimers.h" #include "debug.h" @@ -81,7 +82,7 @@ static struct t_igmp s_leave SECTION_NETWORK ALIGNED; static uint8_t s_multicast_mac[ETH_ADDR_LEN] SECTION_NETWORK ALIGNED; static struct t_group_info s_groups[IGMP_MAX_JOINS_ALLOWED] SECTION_NETWORK ALIGNED; static uint16_t s_id SECTION_NETWORK ALIGNED; -static int32_t nTimerId; +static TimerHandle_t nTimerId; void igmp_set_ip() { net::memcpy_ip(s_report.ip4.src, net::globals::netif_default.ip.addr); diff --git a/lib-network/src/net/ip.cpp b/lib-network/src/net/ip.cpp index 5c6faebff..9eeea7c0c 100644 --- a/lib-network/src/net/ip.cpp +++ b/lib-network/src/net/ip.cpp @@ -31,6 +31,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include diff --git a/lib-network/src/net/net.cpp b/lib-network/src/net/net.cpp index 5809a6aac..8cc04e6cc 100755 --- a/lib-network/src/net/net.cpp +++ b/lib-network/src/net/net.cpp @@ -33,6 +33,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include diff --git a/lib-network/src/net/net_chksum.cpp b/lib-network/src/net/net_chksum.cpp index 05ad77008..b56c124ba 100644 --- a/lib-network/src/net/net_chksum.cpp +++ b/lib-network/src/net/net_chksum.cpp @@ -27,6 +27,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include diff --git a/lib-network/src/net/tcp.cpp b/lib-network/src/net/tcp.cpp index d20d0d584..0f1c6a58e 100644 --- a/lib-network/src/net/tcp.cpp +++ b/lib-network/src/net/tcp.cpp @@ -41,6 +41,7 @@ #pragma GCC push_options #pragma GCC optimize ("O2") #pragma GCC optimize ("no-tree-loop-distribute-patterns") +#pragma GCC optimize ("-fprefetch-loop-arrays") #include #include @@ -1132,10 +1133,10 @@ __attribute__((hot)) void tcp_handle(struct t_tcp *pTcp) { // --> Public API's -int tcp_begin(const uint16_t nLocalPort) { +int32_t tcp_begin(const uint16_t nLocalPort) { DEBUG_PRINTF("nLocalPort=%u", nLocalPort); - for (int i = 0; i < TCP_MAX_PORTS_ALLOWED; i++) { + for (int32_t i = 0; i < TCP_MAX_PORTS_ALLOWED; i++) { if (s_Port[i].nLocalPort == nLocalPort) { return i; } @@ -1163,7 +1164,11 @@ int tcp_begin(const uint16_t nLocalPort) { } -uint16_t tcp_read(const int32_t nHandleListen, const uint8_t **pData, uint32_t &nHandleConnection) { +int32_t tcp_end([[maybe_unused]] const int32_t nHandle) { + return 0; +} + +uint32_t tcp_read(const int32_t nHandleListen, const uint8_t **pData, uint32_t &nHandleConnection) { assert(nHandleListen >= 0); assert(nHandleListen < TCP_MAX_PORTS_ALLOWED); diff --git a/lib-network/src/net/udp.cpp b/lib-network/src/net/udp.cpp index 1aa90a58a..adeb7a2f9 100644 --- a/lib-network/src/net/udp.cpp +++ b/lib-network/src/net/udp.cpp @@ -31,6 +31,7 @@ # pragma GCC push_options # pragma GCC optimize ("O2") # pragma GCC optimize ("no-tree-loop-distribute-patterns") +# pragma GCC optimize ("-fprefetch-loop-arrays") #endif #include @@ -58,15 +59,19 @@ struct PortInfo { uint16_t nPort; }; -struct data_entry { - uint32_t from_ip; - uint32_t size; - uint16_t from_port; +struct Data { + uint32_t nFromIp; + uint32_t nSize; uint8_t data[UDP_DATA_SIZE]; + uint16_t nFromPort; +}; + +struct Port { + PortInfo info; + Data data ALIGNED; } ALIGNED; -static PortInfo s_PortInfo[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; -static data_entry s_data[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; +static Port s_Ports[UDP_MAX_PORTS_ALLOWED] SECTION_NETWORK ALIGNED; static t_udp s_send_packet SECTION_NETWORK ALIGNED; static uint16_t s_id SECTION_NETWORK ALIGNED; static uint8_t s_multicast_mac[ETH_ADDR_LEN] SECTION_NETWORK ALIGNED; @@ -104,26 +109,27 @@ __attribute__((hot)) void udp_handle(struct t_udp *pUdp) { const auto nDestinationPort = __builtin_bswap16(pUdp->udp.destination_port); for (uint32_t nPortIndex = 0; nPortIndex < UDP_MAX_PORTS_ALLOWED; nPortIndex++) { - if (s_PortInfo[nPortIndex].nPort == nDestinationPort) { - if (__builtin_expect ((s_data[nPortIndex].size != 0), 0)) { + const auto& portInfo = s_Ports[nPortIndex].info; + auto& data = s_Ports[nPortIndex].data; + + if (portInfo.nPort == nDestinationPort) { + if (__builtin_expect ((data.nSize != 0), 0)) { DEBUG_PRINTF(IPSTR ":%d[%x]", pUdp->ip4.src[0],pUdp->ip4.src[1],pUdp->ip4.src[2],pUdp->ip4.src[3], nDestinationPort, nDestinationPort); } - auto *p_queue_entry = &s_data[nPortIndex]; - - const auto nDataLength = static_cast(__builtin_bswap16(pUdp->udp.len) - UDP_HEADER_SIZE); - const auto i = std::min(static_cast(UDP_DATA_SIZE), nDataLength); + const auto nDataLength = static_cast(__builtin_bswap16(pUdp->udp.len) - UDP_HEADER_SIZE); + const auto i = std::min(static_cast(UDP_DATA_SIZE), nDataLength); - net::memcpy(p_queue_entry->data, pUdp->udp.data, i); + net::memcpy(data.data, pUdp->udp.data, i); - p_queue_entry->from_ip = net::memcpy_ip(pUdp->ip4.src); - p_queue_entry->from_port = __builtin_bswap16(pUdp->udp.source_port); - p_queue_entry->size = static_cast(i); + data.nFromIp = net::memcpy_ip(pUdp->ip4.src); + data.nFromPort = __builtin_bswap16(pUdp->udp.source_port); + data.nSize = i; emac_free_pkt(); - if (s_PortInfo[nPortIndex].callback != nullptr) { - s_PortInfo[nPortIndex].callback(p_queue_entry->data, nDataLength, p_queue_entry->from_ip, p_queue_entry->from_port); + if (portInfo.callback != nullptr) { + portInfo.callback(data.data, nDataLength, data.nFromIp, data.nFromPort); } return; @@ -139,7 +145,7 @@ template static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { assert(nIndex >= 0); assert(nIndex < UDP_MAX_PORTS_ALLOWED); - assert(s_PortInfo[nIndex].nPort != 0); + assert(s_Ports[nIndex].info.nPort != 0); //IPv4 s_send_packet.ip4.id = s_id++; @@ -147,7 +153,7 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n s_send_packet.ip4.chksum = 0; //UDP - s_send_packet.udp.source_port = __builtin_bswap16( s_PortInfo[nIndex].nPort); + s_send_packet.udp.source_port = __builtin_bswap16(s_Ports[nIndex].info.nPort); s_send_packet.udp.destination_port = __builtin_bswap16(nRemotePort); s_send_packet.udp.len = __builtin_bswap16(static_cast(nSize + UDP_HEADER_SIZE)); @@ -206,17 +212,19 @@ static void udp_send_implementation(int nIndex, const uint8_t *pData, uint32_t n // --> -int udp_begin(uint16_t nLocalPort, UdpCallbackFunctionPtr callback) { +int32_t udp_begin(uint16_t nLocalPort, UdpCallbackFunctionPtr callback) { DEBUG_PRINTF("nLocalPort=%u", nLocalPort); - for (int i = 0; i < UDP_MAX_PORTS_ALLOWED; i++) { - if (s_PortInfo[i].nPort == nLocalPort) { + for (auto i = 0; i < UDP_MAX_PORTS_ALLOWED; i++) { + auto& portInfo = s_Ports[i].info; + + if (portInfo.nPort == nLocalPort) { return i; } - if (s_PortInfo[i].nPort == 0) { - s_PortInfo[i].callback = callback; - s_PortInfo[i].nPort = nLocalPort; + if (portInfo.nPort == 0) { + portInfo.callback = callback; + portInfo.nPort = nLocalPort; DEBUG_PRINTF("i=%d, local_port=%d[%x], callback=%p", i, nLocalPort, nLocalPort, callback); return i; @@ -229,14 +237,18 @@ int udp_begin(uint16_t nLocalPort, UdpCallbackFunctionPtr callback) { return -1; } -int udp_end(uint16_t nLocalPort) { +int32_t udp_end(uint16_t nLocalPort) { DEBUG_PRINTF("nLocalPort=%u[%x]", nLocalPort, nLocalPort); for (auto i = 0; i < UDP_MAX_PORTS_ALLOWED; i++) { - if (s_PortInfo[i].nPort == nLocalPort) { - s_PortInfo[i].callback = nullptr; - s_PortInfo[i].nPort = 0; - s_data[i].size = 0; + auto& portInfo = s_Ports[i].info; + + if (portInfo.nPort == nLocalPort) { + portInfo.callback = nullptr; + portInfo.nPort = 0; + + auto& data = s_Ports[i].data; + data.nSize = 0; return 0; } } @@ -245,54 +257,61 @@ int udp_end(uint16_t nLocalPort) { return -1; } -uint32_t udp_recv1(int nIndex, uint8_t *pData, uint32_t nSize, uint32_t *pFromIp, uint16_t *FromPort) { +uint32_t udp_recv1(const int32_t nIndex, uint8_t *pData, uint32_t nSize, uint32_t *pFromIp, uint16_t *FromPort) { assert(nIndex >= 0); assert(nIndex < UDP_MAX_PORTS_ALLOWED); - if (__builtin_expect((s_data[nIndex].size == 0), 1)) { + auto& data = s_Ports[nIndex].data; + + if (__builtin_expect((data.nSize == 0), 1)) { return 0; } - auto *p_data = &s_data[nIndex]; - const auto i = std::min(nSize, p_data->size); + const auto i = std::min(nSize, data.nSize); - net::memcpy(pData, p_data->data, i); + net::memcpy(pData, data.data, i); - *pFromIp = p_data->from_ip; - *FromPort = p_data->from_port; + *pFromIp = data.nFromIp; + *FromPort = data.nFromPort; - p_data->size = 0; + data.nSize = 0; return i; } -uint32_t udp_recv2(int nIndex, const uint8_t **pData, uint32_t *pFromIp, uint16_t *pFromPort) { +uint32_t udp_recv2(const int32_t nIndex, const uint8_t **pData, uint32_t *pFromIp, uint16_t *pFromPort) { assert(nIndex >= 0); assert(nIndex < UDP_MAX_PORTS_ALLOWED); - auto &p_data = s_data[nIndex]; + const auto& portInfo = s_Ports[nIndex].info; + + if (__builtin_expect(portInfo.callback != nullptr, 0)) { + return 0; + } + + auto& data = s_Ports[nIndex].data; - if (__builtin_expect((p_data.size == 0), 1)) { + if (__builtin_expect((data.nSize == 0), 1)) { return 0; } - *pData = p_data.data; - *pFromIp = p_data.from_ip; - *pFromPort = p_data.from_port; + *pData = data.data; + *pFromIp = data.nFromIp; + *pFromPort = data.nFromPort; - const auto nSize = p_data.size; + const auto nSize = data.nSize; - p_data.size = 0; + data.nSize = 0; return nSize; } -void udp_send(int nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { +void udp_send(const int32_t nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { udp_send_implementation(nIndex, pData, nSize, nRemoteIp, nRemotePort); } #if defined CONFIG_ENET_ENABLE_PTP -void udp_send_timestamp(int nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { +void udp_send_timestamp(const int32_t nIndex, const uint8_t *pData, uint32_t nSize, uint32_t nRemoteIp, uint16_t nRemotePort) { udp_send_implementation(nIndex, pData, nSize, nRemoteIp, nRemotePort); } #endif From cded66a022682a000ea2f646b6ea8e3ffbdc073a Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 22:05:33 +0100 Subject: [PATCH 16/36] Added defines DEBUG_EMAC and DEBUG_NET_PHY --- lib-network/src/emac/gd32/emac.cpp | 4 ++++ lib-network/src/emac/gd32/net_phy.cpp | 21 +++++++++++++++++---- lib-network/src/emac/phy/net_phy.cpp | 4 ++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib-network/src/emac/gd32/emac.cpp b/lib-network/src/emac/gd32/emac.cpp index e482d3349..8d45e0590 100644 --- a/lib-network/src/emac/gd32/emac.cpp +++ b/lib-network/src/emac/gd32/emac.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_EMAC) +# undef NDEBUG +#endif + #include #include diff --git a/lib-network/src/emac/gd32/net_phy.cpp b/lib-network/src/emac/gd32/net_phy.cpp index 693aa290c..59db950b0 100644 --- a/lib-network/src/emac/gd32/net_phy.cpp +++ b/lib-network/src/emac/gd32/net_phy.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_NET_PHY) +# undef NDEBUG +#endif + #include #include "emac/phy.h" @@ -58,13 +62,13 @@ bool phy_config(const uint32_t nAddress) { DEBUG_ENTRY #if defined (GD32H7XX) - uint32_t reg = ENET_MAC_PHY_CTL(ENETx); + auto reg = ENET_MAC_PHY_CTL(ENETx); #else - uint32_t reg = ENET_MAC_PHY_CTL; + auto reg = ENET_MAC_PHY_CTL; #endif reg &= ~ENET_MAC_PHY_CTL_CLR; - const uint32_t ahbclk = rcu_clock_freq_get(CK_AHB); + const auto ahbclk = rcu_clock_freq_get(CK_AHB); DEBUG_PRINTF("ahbclk=%u", ahbclk); @@ -78,6 +82,7 @@ bool phy_config(const uint32_t nAddress) { } else if ((ENET_RANGE(ahbclk, 90000000U, 108000000U)) || (108000000U == ahbclk)) { reg |= ENET_MDC_HCLK_DIV62; } else { + DEBUG_EXIT return false; } #elif defined GD32F20X @@ -90,6 +95,7 @@ bool phy_config(const uint32_t nAddress) { } else if ((ENET_RANGE(ahbclk, 100000000U, 120000000U)) || (120000000U == ahbclk)) { reg |= ENET_MDC_HCLK_DIV62; } else { + DEBUG_EXIT return false; } #elif defined GD32F4XX @@ -104,6 +110,7 @@ bool phy_config(const uint32_t nAddress) { } else if ((ENET_RANGE(ahbclk, 150000000U, 240000000U)) || (240000000U == ahbclk)) { reg |= ENET_MDC_HCLK_DIV102; } else { + DEBUG_EXIT return false; } #elif defined GD32H7XX @@ -124,8 +131,11 @@ bool phy_config(const uint32_t nAddress) { } else if ((ENET_RANGE(ahbclk, 350000000U, 400000000U)) || (400000000U == ahbclk)) { reg |= ENET_MDC_HCLK_DIV162; } else { + DEBUG_EXIT return false; } +#else +# error #endif #if defined (GD32H7XX) @@ -136,6 +146,7 @@ bool phy_config(const uint32_t nAddress) { if (!phy_write(nAddress, mmi::REG_BMCR, mmi::BMCR_RESET)) { DEBUG_PUTS("PHY reset failed"); + DEBUG_EXIT return false; } @@ -148,9 +159,10 @@ bool phy_config(const uint32_t nAddress) { const auto nMillis = Hardware::Get()->Millis(); uint16_t nValue; - while (Hardware::Get()->Millis() - nMillis < 500) { + while (Hardware::Get()->Millis() - nMillis < 500U) { if (!phy_read(nAddress, mmi::REG_BMCR, nValue)) { DEBUG_PUTS("PHY status read failed"); + DEBUG_EXIT return false; } @@ -163,6 +175,7 @@ bool phy_config(const uint32_t nAddress) { if (nValue & mmi::BMCR_RESET) { DEBUG_PUTS("PHY reset timed out"); + DEBUG_EXIT return false; } diff --git a/lib-network/src/emac/phy/net_phy.cpp b/lib-network/src/emac/phy/net_phy.cpp index 821901818..fbd6ecc88 100755 --- a/lib-network/src/emac/phy/net_phy.cpp +++ b/lib-network/src/emac/phy/net_phy.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_NET_PHY) +# undef NDEBUG +#endif + #include #include #include From 69a9dd8cb5e1382bba9ce32d927ce0a11f4b7fb8 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 22:10:15 +0100 Subject: [PATCH 17/36] Moved timers.h to softwaretimers.h Fixed issue with FreeRTOS includes --- lib-hal/include/gd32/hal_gpio.h | 7 +--- lib-hal/include/gd32/hardware.h | 10 +++--- lib-hal/include/h3/hardware.h | 2 +- lib-hal/include/linux/hardware.h | 2 +- .../include/{timers.h => softwaretimers.h} | 36 ++++++++++++++++--- .../superloop/{timers.h => softwaretimers.h} | 2 +- .../{timers.cpp => softwaretimers.cpp} | 4 +-- lib-network/src/net/acd.cpp | 10 +++--- lib-network/src/net/dhcp.cpp | 4 +-- 9 files changed, 49 insertions(+), 28 deletions(-) rename lib-hal/include/{timers.h => softwaretimers.h} (52%) rename lib-hal/include/superloop/{timers.h => softwaretimers.h} (98%) rename lib-hal/superloop/{timers.cpp => softwaretimers.cpp} (98%) diff --git a/lib-hal/include/gd32/hal_gpio.h b/lib-hal/include/gd32/hal_gpio.h index 95acb0fb3..ea9a341f5 100644 --- a/lib-hal/include/gd32/hal_gpio.h +++ b/lib-hal/include/gd32/hal_gpio.h @@ -2,7 +2,7 @@ * @file hal_gpio.h * */ -/* Copyright (C) 2021 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,4 @@ #include "gd32_gpio.h" #include "gd32_board.h" -#if !defined(LOW) -# define LOW 0 -# define HIGH (!LOW) -#endif - #endif /* GD32_HAL_GPIO_H_ */ diff --git a/lib-hal/include/gd32/hardware.h b/lib-hal/include/gd32/hardware.h index 7a34deb0f..1fe49a204 100644 --- a/lib-hal/include/gd32/hardware.h +++ b/lib-hal/include/gd32/hardware.h @@ -62,9 +62,7 @@ extern "C" { extern "C" void console_error(const char *); #endif -#if !defined(USE_FREE_RTOS) -# include "superloop/timers.h" -#endif +#include "softwaretimers.h" #include "panel_led.h" @@ -86,6 +84,8 @@ class Hardware { #if defined (CONFIG_HAL_USE_SYSTICK) extern volatile uint32_t gv_nSysTickMillis; return gv_nSysTickMillis; +#elif defined (USE_FREE_RTOS) + return xTaskGetTickCount(); #else extern uint32_t timer6_get_elapsed_milliseconds(); return timer6_get_elapsed_milliseconds(); @@ -255,7 +255,7 @@ class Hardware { DEBUG_ENTRY DEBUG_PRINTF("m_nTimerId=%d, nFreqHz=%u", m_nTimerId, nFreqHz); - if (m_nTimerId < 0) { + if (m_nTimerId == TIMER_ID_NONE) { m_nTimerId = SoftwareTimerAdd((1000U / nFreqHz), ledblink); DEBUG_EXIT return; @@ -308,7 +308,7 @@ class Hardware { bool m_bIsWatchdog { false }; hardware::ledblink::Mode m_Mode { hardware::ledblink::Mode::UNKNOWN }; bool m_doLock { false }; - int32_t m_nTimerId { -1 }; + TimerHandle_t m_nTimerId { TIMER_ID_NONE }; #if !defined(HAL_HAVE_PORT_BIT_TOGGLE) static inline int32_t m_nToggleLed { 1 }; diff --git a/lib-hal/include/h3/hardware.h b/lib-hal/include/h3/hardware.h index d748e42c3..04549977c 100644 --- a/lib-hal/include/h3/hardware.h +++ b/lib-hal/include/h3/hardware.h @@ -39,7 +39,7 @@ #include "h3_watchdog.h" #include "h3_thermal.h" -#include "superloop/timers.h" +#include "superloop/softwaretimers.h" #include "debug.h" diff --git a/lib-hal/include/linux/hardware.h b/lib-hal/include/linux/hardware.h index 2f9aa6a70..31f76b2f4 100644 --- a/lib-hal/include/linux/hardware.h +++ b/lib-hal/include/linux/hardware.h @@ -44,7 +44,7 @@ #include "linux/hal_api.h" -#include "superloop/timers.h" +#include "superloop/softwaretimers.h" namespace hardware { enum class LedStatus { diff --git a/lib-hal/include/timers.h b/lib-hal/include/softwaretimers.h similarity index 52% rename from lib-hal/include/timers.h rename to lib-hal/include/softwaretimers.h index 15809052f..b910a8626 100755 --- a/lib-hal/include/timers.h +++ b/lib-hal/include/softwaretimers.h @@ -1,5 +1,5 @@ /** - * @file timers.h + * @file softwaretimers.h * */ /* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org @@ -23,13 +23,39 @@ * THE SOFTWARE. */ -#ifndef HAL_TIMERS_H_ -#define HAL_TIMERS_H_ +#ifndef HAL_SOFTWARETIMERS_H_ +#define HAL_SOFTWARETIMERS_H_ #if defined(USE_FREE_RTOS) +# ifdef __cplusplus +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wold-style-cast" +# endif +# include "../FreeRTOS/FreeRTOS-Kernel/include/FreeRTOS.h" # include "../FreeRTOS/FreeRTOS-Kernel/include/timers.h" +# define TIMER_ID_NONE nullptr +inline TimerHandle_t SoftwareTimerAdd(const uint32_t nIntervalMillis, const TimerCallbackFunction_t pCallbackFunction) { + const auto xTimer = xTimerCreate("", nIntervalMillis / portTICK_PERIOD_MS, pdTRUE, nullptr, pCallbackFunction); + if (xTimer != nullptr) xTimerStart( xTimer, 0); + return xTimer; +} + +inline bool SoftwareTimerDelete(TimerHandle_t& nId) { + TimerHandle_t t = nId; + const auto b = (xTimerDelete(t, 0) != pdFAIL); + if (b) nId = TIMER_ID_NONE; + return b; +} + +inline bool SoftwareTimerChange(const TimerHandle_t nId, const uint32_t nIntervalMillis) { + return xTimerChangePeriod(nId, nIntervalMillis / portTICK_PERIOD_MS, 0) != pdFAIL; +} +# ifdef __cplusplus +# pragma GCC diagnostic pop +# endif #else -# include "superloop/timers.h" +# include "superloop/softwaretimers.h" +static constexpr TimerHandle_t TIMER_ID_NONE = -1; #endif -#endif /* HAL_TIMERS_H_ */ +#endif /* HAL_SOFTWARETIMERS_H_ */ diff --git a/lib-hal/include/superloop/timers.h b/lib-hal/include/superloop/softwaretimers.h similarity index 98% rename from lib-hal/include/superloop/timers.h rename to lib-hal/include/superloop/softwaretimers.h index 76b473bc8..718942621 100755 --- a/lib-hal/include/superloop/timers.h +++ b/lib-hal/include/superloop/softwaretimers.h @@ -1,5 +1,5 @@ /** - * @file timers.h + * @file softwaretimers.h * */ /* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org diff --git a/lib-hal/superloop/timers.cpp b/lib-hal/superloop/softwaretimers.cpp similarity index 98% rename from lib-hal/superloop/timers.cpp rename to lib-hal/superloop/softwaretimers.cpp index 29ebcd70b..fb3e57e58 100755 --- a/lib-hal/superloop/timers.cpp +++ b/lib-hal/superloop/softwaretimers.cpp @@ -1,5 +1,5 @@ /** - * @file timers.cpp + * @file softwaretimers.cpp * */ /* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org @@ -34,7 +34,7 @@ #include -#include "superloop/timers.h" +#include "superloop/softwaretimers.h" #include "hardware.h" extern "C" void console_error(const char *); diff --git a/lib-network/src/net/acd.cpp b/lib-network/src/net/acd.cpp index 61469e891..456a4bff7 100755 --- a/lib-network/src/net/acd.cpp +++ b/lib-network/src/net/acd.cpp @@ -49,7 +49,7 @@ #include "net/protocol/arp.h" #include "net_memcpy.h" -#include "timers.h" +#include "softwaretimers.h" #include "debug.h" namespace net { @@ -58,7 +58,7 @@ static constexpr uint32_t ACD_TMR_INTERVAL = 100; static constexpr uint32_t ACD_TICKS_PER_SECOND = (1000U / ACD_TMR_INTERVAL); } // namespace acd -static int32_t nTimerId; +static TimerHandle_t nTimerId; static void acd_timer([[maybe_unused]] TimerHandle_t nHandle) { auto *acd = reinterpret_cast(globals::netif_default.acd); @@ -209,7 +209,7 @@ void acd_start(struct acd::Acd *acd, const ip4_addr_t ipaddr) { acd->ttw = static_cast(static_cast(random()) % (PROBE_WAIT * acd::ACD_TICKS_PER_SECOND)); nTimerId = SoftwareTimerAdd(acd::ACD_TMR_INTERVAL, acd_timer); - assert(nTimerId >= 0); + assert( != TIMER_ID_NONE); DEBUG_EXIT } @@ -220,9 +220,9 @@ void acd_stop(struct acd::Acd *acd) { acd->state = acd::State::ACD_STATE_OFF; - assert(nTimerId >= 0); + assert(nTimerId != TIMER_ID_NONE); SoftwareTimerDelete(nTimerId); - nTimerId = -1; + nTimerId = TIMER_ID_NONE; DEBUG_EXIT } diff --git a/lib-network/src/net/dhcp.cpp b/lib-network/src/net/dhcp.cpp index fdbd715d1..8cc84b6b0 100755 --- a/lib-network/src/net/dhcp.cpp +++ b/lib-network/src/net/dhcp.cpp @@ -40,7 +40,7 @@ #include "net_memcpy.h" #include "net_private.h" -#include "timers.h" +#include "softwaretimers.h" #include "network.h" #include "../../config/net_config.h" @@ -54,7 +54,7 @@ #define REBOOT_TRIES 2 -static int32_t nTimerId; +static TimerHandle_t nTimerId; // https://tools.ietf.org/html/rfc1541 namespace net { From e833856af784fd1fe8b54de47d07d1c9f246f4d8 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 22:12:24 +0100 Subject: [PATCH 18/36] Minor code cleanup - Refactoring --- lib-dmx/src/h3/multi/dmx.cpp | 5 +-- lib-dmxmonitor/src/h3/showsystime.cpp | 22 ++++++------- lib-dmxserial/include/dmxserial.h | 3 +- lib-dmxserial/src/dmxserial.cpp | 2 -- lib-dmxserial/src/dmxserialhandleudp.cpp | 41 ++++++++++++------------ lib-jamstapl/src/jbistub.cpp | 9 +++--- lib-ltc/.settings/language.settings.xml | 2 +- lib-ltc/include/arm/ltcgenerator.h | 22 +++++++------ lib-ltc/src/arm/ltcgenerator.cpp | 28 ++++++++-------- lib-ltc/src/ltc.cpp | 22 ++++++------- lib-osc/include/oscparamsconst.h | 6 ++-- lib-osc/src/oscparamsconst.cpp | 29 ----------------- lib-osc/src/server/oscserver.cpp | 2 +- lib-properties/include/properties.h | 0 lib-properties/src/properties.cpp | 0 15 files changed, 82 insertions(+), 111 deletions(-) delete mode 100644 lib-osc/src/oscparamsconst.cpp mode change 100644 => 100755 lib-properties/include/properties.h mode change 100644 => 100755 lib-properties/src/properties.cpp diff --git a/lib-dmx/src/h3/multi/dmx.cpp b/lib-dmx/src/h3/multi/dmx.cpp index 8033306f9..810d2d69c 100644 --- a/lib-dmx/src/h3/multi/dmx.cpp +++ b/lib-dmx/src/h3/multi/dmx.cpp @@ -824,13 +824,12 @@ void Dmx::SetDmxMabTime(uint32_t nMabTime) { void Dmx::SetDmxPeriodTime(uint32_t nPeriod) { DEBUG_ENTRY - DEBUG_PRINTF("nPeriod=%u", nPeriod); m_nDmxTransmitPeriodRequested = nPeriod; auto nLengthMax = m_nDmxTransmissionLength[0]; - DEBUG_PRINTF("nLengthMax=%u", nLengthMax); + DEBUG_PRINTF("nPeriod=%u, nLengthMax=%u", nPeriod, nLengthMax); for (uint32_t i = 1; i < config::max::PORTS; i++) { if (m_nDmxTransmissionLength[i] > nLengthMax) { @@ -838,6 +837,8 @@ void Dmx::SetDmxPeriodTime(uint32_t nPeriod) { } } + DEBUG_PRINTF("nLengthMax=%u", nLengthMax); + const auto nPackageLengthMicroSeconds = m_nDmxTransmitBreakTime + m_nDmxTransmitMabTime + (nLengthMax * 44) + 44; if (nPeriod != 0) { diff --git a/lib-dmxmonitor/src/h3/showsystime.cpp b/lib-dmxmonitor/src/h3/showsystime.cpp index 3f9264f44..de1021be0 100644 --- a/lib-dmxmonitor/src/h3/showsystime.cpp +++ b/lib-dmxmonitor/src/h3/showsystime.cpp @@ -2,7 +2,7 @@ * @file showsystime.cpp * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,17 +35,17 @@ static constexpr auto COLUMN = 80; static char systime[] __attribute__ ((aligned (4))) = "--:--:-- --/--/--"; -static void itoa_base10(int nArg, char *pBuffer) { +static void itoa(const int nValue, char *pBuffer) { auto *p = pBuffer; - if (nArg == 0) { + if (nValue == 0) { *p++ = '0'; *p = '0'; return; } - *p++ = static_cast('0' + (nArg / 10)); - *p = static_cast('0' + static_cast(nArg % 10)); + *p++ = static_cast('0' + (nValue / 10)); + *p = static_cast('0' + static_cast(nValue % 10)); } void ShowSystime::Run() { @@ -58,13 +58,13 @@ void ShowSystime::Run() { m_nSecondsPrevious = pLocalTime->tm_sec; - itoa_base10(pLocalTime->tm_hour, &systime[0]); - itoa_base10(pLocalTime->tm_min, &systime[3]); - itoa_base10(pLocalTime->tm_sec, &systime[6]); + itoa(pLocalTime->tm_hour, &systime[0]); + itoa(pLocalTime->tm_min, &systime[3]); + itoa(pLocalTime->tm_sec, &systime[6]); - itoa_base10(pLocalTime->tm_year - 100, &systime[9]); - itoa_base10(pLocalTime->tm_mon + 1, &systime[12]); - itoa_base10(pLocalTime->tm_mday, &systime[15]); + itoa(pLocalTime->tm_year - 100, &systime[9]); + itoa(pLocalTime->tm_mon + 1, &systime[12]); + itoa(pLocalTime->tm_mday, &systime[15]); console_save_cursor(); console_set_cursor(COLUMN, ROW); diff --git a/lib-dmxserial/include/dmxserial.h b/lib-dmxserial/include/dmxserial.h index 89f6f180e..08c11c179 100644 --- a/lib-dmxserial/include/dmxserial.h +++ b/lib-dmxserial/include/dmxserial.h @@ -103,6 +103,7 @@ class DmxSerial: public LightSet { uint32_t m_nFilesCount { 0 }; int32_t m_aFileIndex[DmxSerialFile::MAX_NUMBER]; int32_t m_nHandle { -1 }; + uint8_t *m_pReceiveBuffer { nullptr }; DmxSerialChannelData *m_pDmxSerialChannelData[DmxSerialFile::MAX_NUMBER]; uint16_t m_nDmxLastSlot { lightset::dmx::UNIVERSE_SIZE }; uint8_t m_DmxData[lightset::dmx::UNIVERSE_SIZE]; @@ -114,7 +115,7 @@ class DmxSerial: public LightSet { bool m_bEnableTFTP { false }; DmxSerialTFTP *m_pDmxSerialTFTP { nullptr }; - static DmxSerial *s_pThis; + static inline DmxSerial *s_pThis; }; #endif /* DMXSERIAL_H_ */ diff --git a/lib-dmxserial/src/dmxserial.cpp b/lib-dmxserial/src/dmxserial.cpp index f1d2c0a4f..645dd0a82 100644 --- a/lib-dmxserial/src/dmxserial.cpp +++ b/lib-dmxserial/src/dmxserial.cpp @@ -40,8 +40,6 @@ #include "debug.h" -DmxSerial *DmxSerial::s_pThis = nullptr; - DmxSerial::DmxSerial() { assert(s_pThis == nullptr); s_pThis = this; diff --git a/lib-dmxserial/src/dmxserialhandleudp.cpp b/lib-dmxserial/src/dmxserialhandleudp.cpp index f26f5e279..291548fc6 100644 --- a/lib-dmxserial/src/dmxserialhandleudp.cpp +++ b/lib-dmxserial/src/dmxserialhandleudp.cpp @@ -2,7 +2,7 @@ * @file dmxserialhandleudp.cpp * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,6 +33,7 @@ #include "hardware.h" #include "network.h" +#include "net/protocol/udp.h" #include "debug.h" @@ -52,68 +53,66 @@ namespace length { static constexpr auto REQUEST_DELETE = sizeof(cmd::REQUEST_DELETE) - 1; } -static char s_UdpBuffer[UDP::BUFFER_SIZE] __attribute__ ((aligned (4))); - void DmxSerial::HandleUdp() { uint16_t nForeignPort; uint32_t nIPAddressFrom; - auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, s_UdpBuffer, UDP::BUFFER_SIZE, &nIPAddressFrom, &nForeignPort); + auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&m_pReceiveBuffer)), &nIPAddressFrom, &nForeignPort); if (__builtin_expect((nBytesReceived < 6), 1)) { return; } - if (s_UdpBuffer[nBytesReceived - 1] == '\n') { + if (m_pReceiveBuffer[nBytesReceived - 1] == '\n') { nBytesReceived--; } #ifndef NDEBUG - debug_dump(s_UdpBuffer, nBytesReceived); + debug_dump(m_pReceiveBuffer, nBytesReceived); #endif - if (memcmp(s_UdpBuffer, cmd::REQUEST_FILES, length::REQUEST_FILES) == 0) { + if (memcmp(m_pReceiveBuffer, cmd::REQUEST_FILES, length::REQUEST_FILES) == 0) { for (uint32_t i = 0; i < m_nFilesCount; i++) { - const auto nLength = snprintf(s_UdpBuffer, sizeof(s_UdpBuffer) - 1, DMXSERIAL_FILE_PREFIX "%.3d" DMXSERIAL_FILE_SUFFIX "\n", m_aFileIndex[i]); - Network::Get()->SendTo(m_nHandle, s_UdpBuffer, nLength, nIPAddressFrom, UDP::PORT); + const auto nLength = snprintf(reinterpret_cast(m_pReceiveBuffer), UDP_DATA_SIZE - 1, DMXSERIAL_FILE_PREFIX "%.3d" DMXSERIAL_FILE_SUFFIX "\n", m_aFileIndex[i]); + Network::Get()->SendTo(m_nHandle, m_pReceiveBuffer, nLength, nIPAddressFrom, UDP::PORT); } return; } - if ((nBytesReceived >= length::GET_TFTP) && (memcmp(s_UdpBuffer, cmd::GET_TFTP, length::GET_TFTP) == 0)) { + if ((nBytesReceived >= length::GET_TFTP) && (memcmp(m_pReceiveBuffer, cmd::GET_TFTP, length::GET_TFTP) == 0)) { if (nBytesReceived == length::GET_TFTP) { - const auto nLength = snprintf(s_UdpBuffer, UDP::BUFFER_SIZE - 1, "tftp:%s\n", m_bEnableTFTP ? "On" : "Off"); - Network::Get()->SendTo(m_nHandle, s_UdpBuffer,nLength, nIPAddressFrom, UDP::PORT); + const auto nLength = snprintf(reinterpret_cast(m_pReceiveBuffer), UDP_DATA_SIZE - 1, "tftp:%s\n", m_bEnableTFTP ? "On" : "Off"); + Network::Get()->SendTo(m_nHandle, m_pReceiveBuffer,nLength, nIPAddressFrom, UDP::PORT); return; } if (nBytesReceived == length::GET_TFTP + 3) { - if (memcmp(&s_UdpBuffer[length::GET_TFTP], "bin", 3) == 0) { + if (memcmp(&m_pReceiveBuffer[length::GET_TFTP], "bin", 3) == 0) { Network::Get()->SendTo(m_nHandle, &m_bEnableTFTP, sizeof(bool) , nIPAddressFrom, UDP::PORT); return; } } } - if ((nBytesReceived == length::SET_TFTP + 1) && (memcmp(s_UdpBuffer, cmd::SET_TFTP, length::SET_TFTP) == 0)) { - EnableTFTP(s_UdpBuffer[length::SET_TFTP] != '0'); + if ((nBytesReceived == length::SET_TFTP + 1) && (memcmp(m_pReceiveBuffer, cmd::SET_TFTP, length::SET_TFTP) == 0)) { + EnableTFTP(m_pReceiveBuffer[length::SET_TFTP] != '0'); return; } - if (memcmp(s_UdpBuffer, cmd::REQUEST_RELOAD, length::REQUEST_RELOAD) == 0) { + if (memcmp(m_pReceiveBuffer, cmd::REQUEST_RELOAD, length::REQUEST_RELOAD) == 0) { Hardware::Get()->Reboot(); return; } - if ((nBytesReceived == length::REQUEST_DELETE + 3) && (memcmp(s_UdpBuffer, cmd::REQUEST_DELETE, length::REQUEST_DELETE) == 0)) { - s_UdpBuffer[length::REQUEST_DELETE + 3] = '\0'; + if ((nBytesReceived == length::REQUEST_DELETE + 3) && (memcmp(m_pReceiveBuffer, cmd::REQUEST_DELETE, length::REQUEST_DELETE) == 0)) { + m_pReceiveBuffer[length::REQUEST_DELETE + 3] = '\0'; - if (DmxSerial::Get()->DeleteFile(&s_UdpBuffer[length::REQUEST_DELETE])) { + if (DmxSerial::Get()->DeleteFile(reinterpret_cast(&m_pReceiveBuffer[length::REQUEST_DELETE]))) { Network::Get()->SendTo(m_nHandle, "Success\n", 8, nIPAddressFrom, UDP::PORT); } else { const auto *pError = strerror(errno); - const auto nLength = snprintf(s_UdpBuffer, UDP::BUFFER_SIZE - 1, "%s\n", pError); - Network::Get()->SendTo(m_nHandle, s_UdpBuffer, nLength, nIPAddressFrom, UDP::PORT); + const auto nLength = snprintf(reinterpret_cast(m_pReceiveBuffer), UDP_DATA_SIZE - 1, "%s\n", pError); + Network::Get()->SendTo(m_nHandle, m_pReceiveBuffer, nLength, nIPAddressFrom, UDP::PORT); } return; } diff --git a/lib-jamstapl/src/jbistub.cpp b/lib-jamstapl/src/jbistub.cpp index 8804902a1..c3c029bc0 100644 --- a/lib-jamstapl/src/jbistub.cpp +++ b/lib-jamstapl/src/jbistub.cpp @@ -2,7 +2,7 @@ * @file jbistub.cpp * */ -/* Copyright (C) 2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 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 @@ -31,14 +31,13 @@ #include "hal_gpio.h" -#if defined (H3) extern "C" { void uart0_puts(const char *s); int uart0_printf(const char* fmt, ...); } -# define puts uart0_puts -# define printf uart0_printf -#endif + +#define puts uart0_puts +#define printf uart0_printf #define GPIO_TDO GPIO_EXT_7 // GPIO_EXT_12 #define GPIO_TDI GPIO_EXT_10 // GPIO_EXT_16 diff --git a/lib-ltc/.settings/language.settings.xml b/lib-ltc/.settings/language.settings.xml index 26e0b6364..6e648161e 100644 --- a/lib-ltc/.settings/language.settings.xml +++ b/lib-ltc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-ltc/include/arm/ltcgenerator.h b/lib-ltc/include/arm/ltcgenerator.h index 31e82c898..7bb79ca69 100755 --- a/lib-ltc/include/arm/ltcgenerator.h +++ b/lib-ltc/include/arm/ltcgenerator.h @@ -2,7 +2,7 @@ * @file ltcgenerator.h * */ -/* Copyright (C) 2019-2020 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,13 +32,15 @@ #include "hardware.h" -enum TLtcGeneratorDirection { - LTC_GENERATOR_FORWARD, LTC_GENERATOR_BACKWARD +namespace ltcgenerator { +enum class Direction { + DIRECTION_FORWARD, DIRECTION_BACKWARD }; -enum TLtcGeneratorPitch { - LTC_GENERATOR_NORMAL, LTC_GENERATOR_FASTER, LTC_GENERATOR_SLOWER +enum class Pitch { + PITCH_NORMAL, PITCH_FASTER, PITCH_SLOWER }; +} // namespace ltcgenerator class LtcGenerator { public: @@ -93,14 +95,14 @@ class LtcGenerator { void Decrement(); bool PitchControl(); void SetPitch(const char *pTimeCodePitch, uint32_t nSize); - void SetSkip(const char *pSeconds, uint32_t nSize, TLtcGeneratorDirection tDirection); + void SetSkip(const char *pSeconds, uint32_t nSize, const ltcgenerator::Direction direction); void SetTimeCode(int32_t nSeconds); int32_t GetSeconds(const struct ltc::TimeCode& timecode) { int32_t nSeconds = timecode.nHours; - nSeconds *= 60; + nSeconds *= 60U; nSeconds += timecode.nMinutes; - nSeconds *= 60; + nSeconds *= 60U; nSeconds += timecode.nSeconds; return nSeconds; @@ -113,11 +115,11 @@ class LtcGenerator { int32_t m_nStartSeconds; int32_t m_nStopSeconds; uint8_t m_nFps { 0 }; - TLtcGeneratorDirection m_tDirection { LTC_GENERATOR_FORWARD }; + ltcgenerator::Direction m_tDirection { ltcgenerator::Direction::DIRECTION_FORWARD }; float m_fPitchControl { 0 }; uint32_t m_nPitchTicker { 1 }; uint32_t m_nPitchPrevious { 0 }; - TLtcGeneratorPitch m_tPitch { LTC_GENERATOR_FASTER }; + ltcgenerator::Pitch m_tPitch { ltcgenerator::Pitch::PITCH_FASTER }; uint32_t m_nButtons { 0 }; int m_nHandle { -1 }; uint32_t m_nBytesReceived { 0 }; diff --git a/lib-ltc/src/arm/ltcgenerator.cpp b/lib-ltc/src/arm/ltcgenerator.cpp index eff01ce7e..d0e732735 100755 --- a/lib-ltc/src/arm/ltcgenerator.cpp +++ b/lib-ltc/src/arm/ltcgenerator.cpp @@ -303,9 +303,9 @@ void LtcGenerator::ActionSetDirection(const char *pTimeCodeDirection) { DEBUG_ENTRY if (memcmp("forward", pTimeCodeDirection, 7) == 0) { - m_tDirection = LTC_GENERATOR_FORWARD; + m_tDirection = ltcgenerator::Direction::DIRECTION_FORWARD; } else if (memcmp("backward", pTimeCodeDirection, 8) == 0) { - m_tDirection = LTC_GENERATOR_BACKWARD; + m_tDirection = ltcgenerator::Direction::DIRECTION_BACKWARD; } DEBUG_PRINTF("m_tDirection=%d", m_tDirection); @@ -321,13 +321,13 @@ void LtcGenerator::ActionSetPitch(float fTimeCodePitch) { } if (fTimeCodePitch < 0) { - m_tPitch = LTC_GENERATOR_SLOWER; + m_tPitch = ltcgenerator::Pitch::PITCH_SLOWER; m_fPitchControl = -fTimeCodePitch; } else if (fTimeCodePitch == 0) { - m_tPitch = LTC_GENERATOR_NORMAL; + m_tPitch = ltcgenerator::Pitch::PITCH_NORMAL; return; } else { - m_tPitch = LTC_GENERATOR_FASTER; + m_tPitch = ltcgenerator::Pitch::PITCH_FASTER; m_fPitchControl = fTimeCodePitch; } @@ -465,7 +465,7 @@ void LtcGenerator::SetPitch(const char *pTimeCodePitch, uint32_t nSize) { DEBUG_EXIT } -void LtcGenerator::SetSkip(const char *pSeconds, uint32_t nSize, TLtcGeneratorDirection tDirection) { +void LtcGenerator::SetSkip(const char *pSeconds, uint32_t nSize, ltcgenerator::Direction direction) { DEBUG_ENTRY debug_dump(const_cast(pSeconds), static_cast(nSize)); @@ -473,7 +473,7 @@ void LtcGenerator::SetSkip(const char *pSeconds, uint32_t nSize, TLtcGeneratorDi DEBUG_PRINTF("nSeconds=%d", nSeconds); - if (tDirection == LTC_GENERATOR_FORWARD) { + if (direction == ltcgenerator::Direction::DIRECTION_FORWARD) { ActionForward(nSeconds); } else { ActionBackward(nSeconds); @@ -572,14 +572,14 @@ void LtcGenerator::HandleRequest(char *pBuffer, uint16_t nBufferLength) { if (m_nBytesReceived <= (4 + FORWARD_LENGTH + 2)) { if (memcmp(&s_pUdpBuffer[4], CMD_FORWARD, FORWARD_LENGTH) == 0) { - SetSkip(&s_pUdpBuffer[(4 + FORWARD_LENGTH)], m_nBytesReceived - (4 + FORWARD_LENGTH), LTC_GENERATOR_FORWARD); + SetSkip(&s_pUdpBuffer[(4 + FORWARD_LENGTH)], m_nBytesReceived - (4 + FORWARD_LENGTH), ltcgenerator::Direction::DIRECTION_FORWARD); return; } } if (m_nBytesReceived <= (4 + BACKWARD_LENGTH + 2)) { if (memcmp(&s_pUdpBuffer[4], CMD_BACKWARD, BACKWARD_LENGTH) == 0) { - SetSkip(&s_pUdpBuffer[(4 + BACKWARD_LENGTH)], m_nBytesReceived - (4 + BACKWARD_LENGTH), LTC_GENERATOR_BACKWARD); + SetSkip(&s_pUdpBuffer[(4 + BACKWARD_LENGTH)], m_nBytesReceived - (4 + BACKWARD_LENGTH), ltcgenerator::Direction::DIRECTION_BACKWARD); return; } } @@ -757,11 +757,11 @@ void LtcGenerator::Update() { LtcOutputs::Get()->Update(static_cast(&g_ltc_LtcTimeCode)); - if (__builtin_expect((m_tDirection == LTC_GENERATOR_FORWARD), 1)) { - if (__builtin_expect((m_tPitch == LTC_GENERATOR_NORMAL), 1)) { + if (__builtin_expect((m_tDirection == ltcgenerator::Direction::DIRECTION_FORWARD), 1)) { + if (__builtin_expect((m_tPitch == ltcgenerator::Pitch::PITCH_NORMAL), 1)) { Increment(); } else { - if (m_tPitch == LTC_GENERATOR_FASTER) { + if (m_tPitch == ltcgenerator::Pitch::PITCH_FASTER) { Increment(); if (PitchControl()) { Increment(); @@ -773,10 +773,10 @@ void LtcGenerator::Update() { } } } else { // LTC_GENERATOR_BACKWARD - if (__builtin_expect((m_tPitch == LTC_GENERATOR_NORMAL), 1)) { + if (__builtin_expect((m_tPitch == ltcgenerator::Pitch::PITCH_NORMAL), 1)) { Decrement(); } else { - if (m_tPitch == LTC_GENERATOR_FASTER) { + if (m_tPitch == ltcgenerator::Pitch::PITCH_FASTER) { Decrement(); if (PitchControl()) { Decrement(); diff --git a/lib-ltc/src/ltc.cpp b/lib-ltc/src/ltc.cpp index 019cda060..4c80369f0 100755 --- a/lib-ltc/src/ltc.cpp +++ b/lib-ltc/src/ltc.cpp @@ -98,36 +98,36 @@ void init_systemtime(char *pSystemTime) { pSystemTime[ltc::systemtime::index::COLON_2] = ':'; } -static void itoa_base10(int arg, char *pBuffer) { +static void itoa(const uint32_t nValue, char *pBuffer) { auto *p = pBuffer; - if (arg == 0) { + if (nValue == 0) { *p++ = '0'; *p = '0'; return; } - *p++ = static_cast('0' + (arg / 10)); - *p = static_cast('0' + (arg % 10)); + *p++ = static_cast('0' + (nValue / 10U)); + *p = static_cast('0' + (nValue % 10U)); } void itoa_base10(const struct ltc::TimeCode *ptLtcTimeCode, char *pTimeCode) { assert(ptLtcTimeCode != nullptr); assert(pTimeCode != nullptr); - itoa_base10(ptLtcTimeCode->nHours, &pTimeCode[ltc::timecode::index::HOURS]); - itoa_base10(ptLtcTimeCode->nMinutes, &pTimeCode[ltc::timecode::index::MINUTES]); - itoa_base10(ptLtcTimeCode->nSeconds, &pTimeCode[ltc::timecode::index::SECONDS]); - itoa_base10(ptLtcTimeCode->nFrames, &pTimeCode[ltc::timecode::index::FRAMES]); + itoa(ptLtcTimeCode->nHours, &pTimeCode[ltc::timecode::index::HOURS]); + itoa(ptLtcTimeCode->nMinutes, &pTimeCode[ltc::timecode::index::MINUTES]); + itoa(ptLtcTimeCode->nSeconds, &pTimeCode[ltc::timecode::index::SECONDS]); + itoa(ptLtcTimeCode->nFrames, &pTimeCode[ltc::timecode::index::FRAMES]); } void itoa_base10(const struct tm *pLocalTime, char *pSystemTime) { assert(pLocalTime != nullptr); assert(pSystemTime != nullptr); - itoa_base10(pLocalTime->tm_hour, &pSystemTime[ltc::systemtime::index::HOURS]); - itoa_base10(pLocalTime->tm_min, &pSystemTime[ltc::systemtime::index::MINUTES]); - itoa_base10(pLocalTime->tm_sec, &pSystemTime[ltc::systemtime::index::SECONDS]); + itoa(pLocalTime->tm_hour, &pSystemTime[ltc::systemtime::index::HOURS]); + itoa(pLocalTime->tm_min, &pSystemTime[ltc::systemtime::index::MINUTES]); + itoa(pLocalTime->tm_sec, &pSystemTime[ltc::systemtime::index::SECONDS]); } #define DIGIT(x) ((x) - '0') diff --git a/lib-osc/include/oscparamsconst.h b/lib-osc/include/oscparamsconst.h index 521ae0c6f..9dbb77eec 100644 --- a/lib-osc/include/oscparamsconst.h +++ b/lib-osc/include/oscparamsconst.h @@ -2,7 +2,7 @@ * @file oscconst.h * */ -/* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,8 +27,8 @@ #define OSCPARAMSCONST_H_ struct OscParamsConst { - static const char INCOMING_PORT[]; - static const char OUTGOING_PORT[]; + static inline const char INCOMING_PORT[] = "incoming_port"; + static inline const char OUTGOING_PORT[] = "outgoing_port"; }; #endif /* OSCPARAMSCONST_H_ */ diff --git a/lib-osc/src/oscparamsconst.cpp b/lib-osc/src/oscparamsconst.cpp deleted file mode 100644 index cb5db092b..000000000 --- a/lib-osc/src/oscparamsconst.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file oscconst.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. - */ - -#include "oscparamsconst.h" - -const char OscParamsConst::INCOMING_PORT[] = "incoming_port"; -const char OscParamsConst::OUTGOING_PORT[] = "outgoing_port"; diff --git a/lib-osc/src/server/oscserver.cpp b/lib-osc/src/server/oscserver.cpp index 8faf2ae8e..db5c15c1c 100755 --- a/lib-osc/src/server/oscserver.cpp +++ b/lib-osc/src/server/oscserver.cpp @@ -204,7 +204,7 @@ void OscServer::Run() { auto *pUdpBuffer = reinterpret_cast(s_pUdpBuffer); - DEBUG_PRINTF("[%d] path : %s", nBytesReceived, osc::get_path(pUdpBuffer, nBytesReceived)); + DEBUG_PRINTF("[%d] path : %s", nBytesReceived, osc::get_path(const_cast(pUdpBuffer), nBytesReceived)); if (osc::is_match(pUdpBuffer, s_aPath)) { const auto nArgc = Msg.GetArgc(); diff --git a/lib-properties/include/properties.h b/lib-properties/include/properties.h old mode 100644 new mode 100755 diff --git a/lib-properties/src/properties.cpp b/lib-properties/src/properties.cpp old mode 100644 new mode 100755 From 04a7d22fffbc2f5f6fdf301b8f52044a3bd49ad5 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Fri, 8 Nov 2024 22:12:53 +0100 Subject: [PATCH 19/36] Added atexit.cpp --- lib-clib/src/atexit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 lib-clib/src/atexit.cpp diff --git a/lib-clib/src/atexit.cpp b/lib-clib/src/atexit.cpp new file mode 100755 index 000000000..0902dc246 --- /dev/null +++ b/lib-clib/src/atexit.cpp @@ -0,0 +1,7 @@ +/* + * atexit.cpp + */ + +extern "C" int atexit([[maybe_unused]] void (*func)(void)) { + return 0; // No-op +} From 7c8d48c28b9311fbe5ba20404251914f62b02f2a Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sun, 10 Nov 2024 18:37:09 +0100 Subject: [PATCH 20/36] Changed compiler setting -O2 to -Os - Only code that needs -O2 has its own setting --- .gitignore | 1 + firmware-template-h3/lib/Rules.mk | 4 ++-- firmware-template-linux/Rules.mk | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 89305110d..18258af6c 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,4 @@ software_version_id.h *._cpp /opi_emac_debug_lcd_udp /lib-dmxnode +opi_emac_llrp_tftpd/do-tftp-bad.sh diff --git a/firmware-template-h3/lib/Rules.mk b/firmware-template-h3/lib/Rules.mk index 693748562..2474f6666 100644 --- a/firmware-template-h3/lib/Rules.mk +++ b/firmware-template-h3/lib/Rules.mk @@ -63,8 +63,8 @@ $(info $$MAKE_FLAGS [${MAKE_FLAGS}]) COPS=-DBARE_METAL -DH3 $(DEFINES) $(MAKE_FLAGS) $(INCLUDES) COPS+=-mfpu=neon-vfpv4 -mcpu=cortex-a7 -mfloat-abi=hard -mhard-float -COPS+=-nostartfiles -ffreestanding -nostdlib -fprefetch-loop-arrays -COPS+=-O2 -Wall -Werror -Wextra -Wpedantic -Wunused -Wsign-conversion -Wconversion +COPS+=-nostartfiles -ffreestanding -nostdlib +COPS+=-Os -Wall -Werror -Wextra -Wpedantic -Wunused -Wsign-conversion -Wconversion COPS+=-Wduplicated-cond -Wlogical-op -Wduplicated-branches COPS+=-ffunction-sections -fdata-sections diff --git a/firmware-template-linux/Rules.mk b/firmware-template-linux/Rules.mk index c6e3434c1..394a5fdd6 100755 --- a/firmware-template-linux/Rules.mk +++ b/firmware-template-linux/Rules.mk @@ -43,6 +43,10 @@ ifeq ($(findstring ARTNET_VERSION=4,$(DEFINES)),ARTNET_VERSION=4) endif endif +ifneq ($(findstring _TIME_STAMP_YEAR_,$(DEFINES)), _TIME_STAMP_YEAR_) + DEFINES+=-D_TIME_STAMP_YEAR_=$(shell date +"%Y") -D_TIME_STAMP_MONTH_=$(shell date +"%-m") -D_TIME_STAMP_DAY_=$(shell date +"%-d") +endif + # The variable for the firmware include directories INCDIRS=$(wildcard ./lib) $(wildcard ./include) $(wildcard ./*/include) ../firmware-template-linux/include INCDIRS:=$(addprefix -I,$(INCDIRS)) -I../lib-display/include From 9e540e87d37fd61a8f23b7615216dae6db13802a Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sun, 10 Nov 2024 18:40:49 +0100 Subject: [PATCH 21/36] Updated Eclipse project settings --- lib-arm/.settings/language.settings.xml | 2 +- lib-artnet/.settings/language.settings.xml | 6 +++--- lib-bcm2835/.settings/language.settings.xml | 2 +- lib-clib/.settings/language.settings.xml | 2 +- lib-configstore/.cproject | 6 ------ lib-configstore/.settings/language.settings.xml | 2 +- lib-ddp/.settings/language.settings.xml | 4 ++-- lib-device/.settings/language.settings.xml | 4 ++-- lib-display/.settings/language.settings.xml | 6 +++--- lib-displayudf/.settings/language.settings.xml | 4 ++-- lib-dmxmonitor/.settings/language.settings.xml | 6 +++--- lib-dmxserial/.settings/language.settings.xml | 4 ++-- lib-e131/.settings/language.settings.xml | 6 +++--- lib-flash/.settings/language.settings.xml | 2 +- lib-flashcode/.settings/language.settings.xml | 2 +- lib-flashcodeinstall/.settings/language.settings.xml | 2 +- lib-gps/.settings/language.settings.xml | 2 +- lib-h3/.settings/language.settings.xml | 2 +- lib-hal/.settings/language.settings.xml | 6 +++--- lib-input/.settings/language.settings.xml | 6 +++--- lib-jamstapl/.settings/language.settings.xml | 2 +- lib-l6470/.settings/language.settings.xml | 6 +++--- lib-l6470dmx/.settings/language.settings.xml | 6 +++--- lib-lightset/.settings/language.settings.xml | 6 +++--- lib-ltc/.settings/language.settings.xml | 2 +- lib-midi/.settings/language.settings.xml | 4 ++-- lib-network/.settings/language.settings.xml | 6 +++--- lib-osc/.settings/language.settings.xml | 6 +++--- lib-pca9685/.settings/language.settings.xml | 6 +++--- lib-pca9685dmx/.settings/language.settings.xml | 6 +++--- lib-pp/.settings/language.settings.xml | 4 ++-- lib-properties/.settings/language.settings.xml | 6 +++--- lib-rdm/.settings/language.settings.xml | 6 +++--- lib-rdmsensor/.settings/language.settings.xml | 6 +++--- lib-rdmsubdevice/.settings/language.settings.xml | 6 +++--- lib-remoteconfig/.settings/language.settings.xml | 4 ++-- lib-rgbpanel/.settings/language.settings.xml | 2 +- lib-showfile/.settings/language.settings.xml | 4 ++-- lib-tcnet/.settings/language.settings.xml | 4 ++-- lib-tlc59711/.settings/language.settings.xml | 6 +++--- lib-tlc59711dmx/.settings/language.settings.xml | 6 +++--- lib-usb/.settings/language.settings.xml | 4 ++-- lib-widget/.settings/language.settings.xml | 4 ++-- lib-ws28xx/.settings/language.settings.xml | 6 +++--- lib-ws28xxdisplay/.settings/language.settings.xml | 2 +- lib-ws28xxdmx/.settings/language.settings.xml | 6 +++--- linux_artnet/.settings/language.settings.xml | 2 +- linux_e131/.settings/language.settings.xml | 2 +- opi_dmx_monitor/.settings/language.settings.xml | 4 ++-- opi_dmx_usb_pro/.settings/language.settings.xml | 2 +- opi_emac_artnet_dmx/.settings/language.settings.xml | 2 +- opi_emac_artnet_dmx_multi/.settings/language.settings.xml | 2 +- opi_emac_artnet_monitor/.settings/language.settings.xml | 2 +- opi_emac_artnet_pixel/.settings/language.settings.xml | 2 +- opi_emac_artnet_pixel_dmx/.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- opi_emac_artnet_pixel_multi/.settings/language.settings.xml | 2 +- opi_emac_artnet_rdm_l6470/.settings/language.settings.xml | 2 +- opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml | 2 +- opi_emac_artnet_serial/.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- opi_emac_ddp_pixel_multi/.settings/language.settings.xml | 2 +- opi_emac_e131_artnet/.settings/language.settings.xml | 2 +- opi_emac_e131_dmx/.settings/language.settings.xml | 2 +- opi_emac_e131_dmx_multi/.settings/language.settings.xml | 2 +- opi_emac_e131_monitor/.settings/language.settings.xml | 2 +- opi_emac_e131_pixel/.settings/language.settings.xml | 2 +- opi_emac_e131_pixel_dmx/.settings/language.settings.xml | 2 +- .../.settings/language.settings.xml | 2 +- opi_emac_e131_pixel_multi/.settings/language.settings.xml | 2 +- opi_emac_llrp_tftpd/.settings/language.settings.xml | 2 +- opi_emac_ltc_smpte/.settings/language.settings.xml | 2 +- opi_emac_osc_client/.settings/language.settings.xml | 2 +- opi_emac_osc_dmx/.settings/language.settings.xml | 2 +- opi_emac_osc_monitor/.settings/language.settings.xml | 2 +- opi_emac_osc_pixel/.settings/language.settings.xml | 2 +- opi_emac_pp_pixel_multi/.settings/language.settings.xml | 2 +- opi_emac_showfile_artnet/.settings/language.settings.xml | 2 +- opi_emac_showfile_e131/.settings/language.settings.xml | 2 +- opi_midi_monitor/.settings/language.settings.xml | 2 +- opi_rdm_responder/.settings/language.settings.xml | 2 +- opi_rdm_responder_l6470/.settings/language.settings.xml | 2 +- 82 files changed, 135 insertions(+), 141 deletions(-) diff --git a/lib-arm/.settings/language.settings.xml b/lib-arm/.settings/language.settings.xml index ae71ff5d5..62a625c5b 100644 --- a/lib-arm/.settings/language.settings.xml +++ b/lib-arm/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-artnet/.settings/language.settings.xml b/lib-artnet/.settings/language.settings.xml index bb7181ede..9e2fed309 100644 --- a/lib-artnet/.settings/language.settings.xml +++ b/lib-artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-bcm2835/.settings/language.settings.xml b/lib-bcm2835/.settings/language.settings.xml index 0844c86df..ace184b37 100644 --- a/lib-bcm2835/.settings/language.settings.xml +++ b/lib-bcm2835/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-clib/.settings/language.settings.xml b/lib-clib/.settings/language.settings.xml index fcfe65cf0..bb2dba1e4 100755 --- a/lib-clib/.settings/language.settings.xml +++ b/lib-clib/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-configstore/.cproject b/lib-configstore/.cproject index 7c78af3c1..30de09155 100755 --- a/lib-configstore/.cproject +++ b/lib-configstore/.cproject @@ -109,8 +109,6 @@ @@ -127,8 +125,6 @@ @@ -145,8 +141,6 @@ diff --git a/lib-configstore/.settings/language.settings.xml b/lib-configstore/.settings/language.settings.xml index 6ba10a604..63ed6763c 100755 --- a/lib-configstore/.settings/language.settings.xml +++ b/lib-configstore/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-ddp/.settings/language.settings.xml b/lib-ddp/.settings/language.settings.xml index 88719f44a..11e9c38ea 100755 --- a/lib-ddp/.settings/language.settings.xml +++ b/lib-ddp/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-device/.settings/language.settings.xml b/lib-device/.settings/language.settings.xml index 237715cdc..dc7c9654e 100644 --- a/lib-device/.settings/language.settings.xml +++ b/lib-device/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-display/.settings/language.settings.xml b/lib-display/.settings/language.settings.xml index 05bdcbba5..a709a0258 100755 --- a/lib-display/.settings/language.settings.xml +++ b/lib-display/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-displayudf/.settings/language.settings.xml b/lib-displayudf/.settings/language.settings.xml index 6e99ed3f7..b630667cc 100644 --- a/lib-displayudf/.settings/language.settings.xml +++ b/lib-displayudf/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-dmxmonitor/.settings/language.settings.xml b/lib-dmxmonitor/.settings/language.settings.xml index 702281c9f..104b623a6 100644 --- a/lib-dmxmonitor/.settings/language.settings.xml +++ b/lib-dmxmonitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-dmxserial/.settings/language.settings.xml b/lib-dmxserial/.settings/language.settings.xml index cbd9c1afd..cab42945d 100644 --- a/lib-dmxserial/.settings/language.settings.xml +++ b/lib-dmxserial/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-e131/.settings/language.settings.xml b/lib-e131/.settings/language.settings.xml index c0b9c9a75..3f7bba418 100644 --- a/lib-e131/.settings/language.settings.xml +++ b/lib-e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-flash/.settings/language.settings.xml b/lib-flash/.settings/language.settings.xml index 43fda3c11..01315f3d4 100755 --- a/lib-flash/.settings/language.settings.xml +++ b/lib-flash/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-flashcode/.settings/language.settings.xml b/lib-flashcode/.settings/language.settings.xml index 6a955d626..bddc192d5 100755 --- a/lib-flashcode/.settings/language.settings.xml +++ b/lib-flashcode/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-flashcodeinstall/.settings/language.settings.xml b/lib-flashcodeinstall/.settings/language.settings.xml index 5242dcdec..4b5e4f32e 100755 --- a/lib-flashcodeinstall/.settings/language.settings.xml +++ b/lib-flashcodeinstall/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-gps/.settings/language.settings.xml b/lib-gps/.settings/language.settings.xml index 0383e302c..f735e0ba6 100644 --- a/lib-gps/.settings/language.settings.xml +++ b/lib-gps/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-h3/.settings/language.settings.xml b/lib-h3/.settings/language.settings.xml index 4c1fd3f6a..e4e250dbc 100644 --- a/lib-h3/.settings/language.settings.xml +++ b/lib-h3/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-hal/.settings/language.settings.xml b/lib-hal/.settings/language.settings.xml index 4e2b877f8..f08c127de 100644 --- a/lib-hal/.settings/language.settings.xml +++ b/lib-hal/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-input/.settings/language.settings.xml b/lib-input/.settings/language.settings.xml index b761a2025..46d2ae124 100644 --- a/lib-input/.settings/language.settings.xml +++ b/lib-input/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-jamstapl/.settings/language.settings.xml b/lib-jamstapl/.settings/language.settings.xml index 4237821d6..6f2749d65 100644 --- a/lib-jamstapl/.settings/language.settings.xml +++ b/lib-jamstapl/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-l6470/.settings/language.settings.xml b/lib-l6470/.settings/language.settings.xml index 1d0795c57..6221db960 100644 --- a/lib-l6470/.settings/language.settings.xml +++ b/lib-l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-l6470dmx/.settings/language.settings.xml b/lib-l6470dmx/.settings/language.settings.xml index 49839c725..a7af71722 100644 --- a/lib-l6470dmx/.settings/language.settings.xml +++ b/lib-l6470dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-lightset/.settings/language.settings.xml b/lib-lightset/.settings/language.settings.xml index 7e0fa5ec5..f36035296 100644 --- a/lib-lightset/.settings/language.settings.xml +++ b/lib-lightset/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-ltc/.settings/language.settings.xml b/lib-ltc/.settings/language.settings.xml index 6e648161e..434265c38 100644 --- a/lib-ltc/.settings/language.settings.xml +++ b/lib-ltc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-midi/.settings/language.settings.xml b/lib-midi/.settings/language.settings.xml index 5d974a48e..c76347182 100644 --- a/lib-midi/.settings/language.settings.xml +++ b/lib-midi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-network/.settings/language.settings.xml b/lib-network/.settings/language.settings.xml index 035999e6e..334cbef4a 100644 --- a/lib-network/.settings/language.settings.xml +++ b/lib-network/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-osc/.settings/language.settings.xml b/lib-osc/.settings/language.settings.xml index f4407090e..b16f9ae8f 100644 --- a/lib-osc/.settings/language.settings.xml +++ b/lib-osc/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685/.settings/language.settings.xml b/lib-pca9685/.settings/language.settings.xml index 86915f751..4e2f77c5a 100644 --- a/lib-pca9685/.settings/language.settings.xml +++ b/lib-pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pca9685dmx/.settings/language.settings.xml b/lib-pca9685dmx/.settings/language.settings.xml index abbde0319..0170abb75 100644 --- a/lib-pca9685dmx/.settings/language.settings.xml +++ b/lib-pca9685dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-pp/.settings/language.settings.xml b/lib-pp/.settings/language.settings.xml index e46dd855d..d41324fac 100755 --- a/lib-pp/.settings/language.settings.xml +++ b/lib-pp/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-properties/.settings/language.settings.xml b/lib-properties/.settings/language.settings.xml index 3bb45a834..7658d84a0 100644 --- a/lib-properties/.settings/language.settings.xml +++ b/lib-properties/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-rdm/.settings/language.settings.xml b/lib-rdm/.settings/language.settings.xml index 0e921bef9..0f948f1ee 100644 --- a/lib-rdm/.settings/language.settings.xml +++ b/lib-rdm/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-rdmsensor/.settings/language.settings.xml b/lib-rdmsensor/.settings/language.settings.xml index 99099c1cd..6496859bf 100644 --- a/lib-rdmsensor/.settings/language.settings.xml +++ b/lib-rdmsensor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-rdmsubdevice/.settings/language.settings.xml b/lib-rdmsubdevice/.settings/language.settings.xml index be358008d..8eb3ec0d0 100644 --- a/lib-rdmsubdevice/.settings/language.settings.xml +++ b/lib-rdmsubdevice/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-remoteconfig/.settings/language.settings.xml b/lib-remoteconfig/.settings/language.settings.xml index b048b1995..fa00af8dc 100644 --- a/lib-remoteconfig/.settings/language.settings.xml +++ b/lib-remoteconfig/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/lib-rgbpanel/.settings/language.settings.xml b/lib-rgbpanel/.settings/language.settings.xml index 14b487345..9c1f3b432 100644 --- a/lib-rgbpanel/.settings/language.settings.xml +++ b/lib-rgbpanel/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/lib-showfile/.settings/language.settings.xml b/lib-showfile/.settings/language.settings.xml index 723344307..8e7626f2c 100644 --- a/lib-showfile/.settings/language.settings.xml +++ b/lib-showfile/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-tcnet/.settings/language.settings.xml b/lib-tcnet/.settings/language.settings.xml index 60bf10e76..80affc35a 100644 --- a/lib-tcnet/.settings/language.settings.xml +++ b/lib-tcnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-tlc59711/.settings/language.settings.xml b/lib-tlc59711/.settings/language.settings.xml index 4b21ae3de..ed9e97d96 100644 --- a/lib-tlc59711/.settings/language.settings.xml +++ b/lib-tlc59711/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-tlc59711dmx/.settings/language.settings.xml b/lib-tlc59711dmx/.settings/language.settings.xml index 0355f656a..170880612 100644 --- a/lib-tlc59711dmx/.settings/language.settings.xml +++ b/lib-tlc59711dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-usb/.settings/language.settings.xml b/lib-usb/.settings/language.settings.xml index 2d4ba3e86..a0f2c2be0 100644 --- a/lib-usb/.settings/language.settings.xml +++ b/lib-usb/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-widget/.settings/language.settings.xml b/lib-widget/.settings/language.settings.xml index 2d4ba3e86..a0f2c2be0 100644 --- a/lib-widget/.settings/language.settings.xml +++ b/lib-widget/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/lib-ws28xx/.settings/language.settings.xml b/lib-ws28xx/.settings/language.settings.xml index 02ddd41b6..e7cc1378c 100644 --- a/lib-ws28xx/.settings/language.settings.xml +++ b/lib-ws28xx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/lib-ws28xxdisplay/.settings/language.settings.xml b/lib-ws28xxdisplay/.settings/language.settings.xml index 01eb8eeac..cad088404 100644 --- a/lib-ws28xxdisplay/.settings/language.settings.xml +++ b/lib-ws28xxdisplay/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/lib-ws28xxdmx/.settings/language.settings.xml b/lib-ws28xxdmx/.settings/language.settings.xml index 4054cf5e2..4817037c8 100644 --- a/lib-ws28xxdmx/.settings/language.settings.xml +++ b/lib-ws28xxdmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/linux_artnet/.settings/language.settings.xml b/linux_artnet/.settings/language.settings.xml index c8d35c1a6..d02a6b236 100644 --- a/linux_artnet/.settings/language.settings.xml +++ b/linux_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/linux_e131/.settings/language.settings.xml b/linux_e131/.settings/language.settings.xml index c8d35c1a6..d02a6b236 100644 --- a/linux_e131/.settings/language.settings.xml +++ b/linux_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_dmx_monitor/.settings/language.settings.xml b/opi_dmx_monitor/.settings/language.settings.xml index db6d729be..d362b3f07 100644 --- a/opi_dmx_monitor/.settings/language.settings.xml +++ b/opi_dmx_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/opi_dmx_usb_pro/.settings/language.settings.xml b/opi_dmx_usb_pro/.settings/language.settings.xml index ff1d802c2..ed73cb376 100644 --- a/opi_dmx_usb_pro/.settings/language.settings.xml +++ b/opi_dmx_usb_pro/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx/.settings/language.settings.xml b/opi_emac_artnet_dmx/.settings/language.settings.xml index ba76aabdd..7f05fa9d5 100644 --- a/opi_emac_artnet_dmx/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml index ba76aabdd..7f05fa9d5 100644 --- a/opi_emac_artnet_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_monitor/.settings/language.settings.xml b/opi_emac_artnet_monitor/.settings/language.settings.xml index ba76aabdd..7f05fa9d5 100644 --- a/opi_emac_artnet_monitor/.settings/language.settings.xml +++ b/opi_emac_artnet_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel/.settings/language.settings.xml b/opi_emac_artnet_pixel/.settings/language.settings.xml index 658094508..cc9de2114 100644 --- a/opi_emac_artnet_pixel/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml b/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml index 9d4d66f91..95f9a735c 100755 --- a/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml index 2d41b0370..b90761430 100755 --- a/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_pixel_multi/.settings/language.settings.xml b/opi_emac_artnet_pixel_multi/.settings/language.settings.xml index dfda8b455..9b81f976e 100644 --- a/opi_emac_artnet_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_artnet_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml index ba76aabdd..7f05fa9d5 100644 --- a/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml index 385aac416..1d9348793 100755 --- a/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml +++ b/opi_emac_artnet_rdm_pca9685/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_artnet_serial/.settings/language.settings.xml b/opi_emac_artnet_serial/.settings/language.settings.xml index ba76aabdd..7f05fa9d5 100644 --- a/opi_emac_artnet_serial/.settings/language.settings.xml +++ b/opi_emac_artnet_serial/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml index c6f613b69..ff12927dd 100755 --- a/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml index c6f613b69..ff12927dd 100755 --- a/opi_emac_ddp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_ddp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_artnet/.settings/language.settings.xml b/opi_emac_e131_artnet/.settings/language.settings.xml index 769a1a60c..2d44a3b8e 100644 --- a/opi_emac_e131_artnet/.settings/language.settings.xml +++ b/opi_emac_e131_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx/.settings/language.settings.xml b/opi_emac_e131_dmx/.settings/language.settings.xml index 769a1a60c..2d44a3b8e 100644 --- a/opi_emac_e131_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_dmx_multi/.settings/language.settings.xml index 769a1a60c..2d44a3b8e 100644 --- a/opi_emac_e131_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_monitor/.settings/language.settings.xml b/opi_emac_e131_monitor/.settings/language.settings.xml index 769a1a60c..2d44a3b8e 100644 --- a/opi_emac_e131_monitor/.settings/language.settings.xml +++ b/opi_emac_e131_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel/.settings/language.settings.xml b/opi_emac_e131_pixel/.settings/language.settings.xml index a340f3b95..fa5af951e 100644 --- a/opi_emac_e131_pixel/.settings/language.settings.xml +++ b/opi_emac_e131_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml index fb15fb409..9c8f695a2 100755 --- a/opi_emac_e131_pixel_dmx/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml index b72e68cc1..dd1556344 100755 --- a/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_dmx_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_e131_pixel_multi/.settings/language.settings.xml b/opi_emac_e131_pixel_multi/.settings/language.settings.xml index ee9e9a6e0..d84f1f011 100644 --- a/opi_emac_e131_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_e131_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_llrp_tftpd/.settings/language.settings.xml b/opi_emac_llrp_tftpd/.settings/language.settings.xml index a469be822..9b90ef46c 100644 --- a/opi_emac_llrp_tftpd/.settings/language.settings.xml +++ b/opi_emac_llrp_tftpd/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_ltc_smpte/.settings/language.settings.xml b/opi_emac_ltc_smpte/.settings/language.settings.xml index d091405d6..276dceda0 100644 --- a/opi_emac_ltc_smpte/.settings/language.settings.xml +++ b/opi_emac_ltc_smpte/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_client/.settings/language.settings.xml b/opi_emac_osc_client/.settings/language.settings.xml index d3662cbde..b3a048eff 100644 --- a/opi_emac_osc_client/.settings/language.settings.xml +++ b/opi_emac_osc_client/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_dmx/.settings/language.settings.xml b/opi_emac_osc_dmx/.settings/language.settings.xml index d3662cbde..b3a048eff 100644 --- a/opi_emac_osc_dmx/.settings/language.settings.xml +++ b/opi_emac_osc_dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_monitor/.settings/language.settings.xml b/opi_emac_osc_monitor/.settings/language.settings.xml index d3662cbde..b3a048eff 100644 --- a/opi_emac_osc_monitor/.settings/language.settings.xml +++ b/opi_emac_osc_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_osc_pixel/.settings/language.settings.xml b/opi_emac_osc_pixel/.settings/language.settings.xml index d3662cbde..b3a048eff 100644 --- a/opi_emac_osc_pixel/.settings/language.settings.xml +++ b/opi_emac_osc_pixel/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_pp_pixel_multi/.settings/language.settings.xml b/opi_emac_pp_pixel_multi/.settings/language.settings.xml index c6f613b69..ff12927dd 100755 --- a/opi_emac_pp_pixel_multi/.settings/language.settings.xml +++ b/opi_emac_pp_pixel_multi/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_artnet/.settings/language.settings.xml b/opi_emac_showfile_artnet/.settings/language.settings.xml index 61fa4107c..5f1aa48c5 100755 --- a/opi_emac_showfile_artnet/.settings/language.settings.xml +++ b/opi_emac_showfile_artnet/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_emac_showfile_e131/.settings/language.settings.xml b/opi_emac_showfile_e131/.settings/language.settings.xml index 61fa4107c..5f1aa48c5 100755 --- a/opi_emac_showfile_e131/.settings/language.settings.xml +++ b/opi_emac_showfile_e131/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_midi_monitor/.settings/language.settings.xml b/opi_midi_monitor/.settings/language.settings.xml index 9eb454bb9..75d6e781c 100644 --- a/opi_midi_monitor/.settings/language.settings.xml +++ b/opi_midi_monitor/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder/.settings/language.settings.xml b/opi_rdm_responder/.settings/language.settings.xml index c6771bbef..a6eec1a8c 100644 --- a/opi_rdm_responder/.settings/language.settings.xml +++ b/opi_rdm_responder/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/opi_rdm_responder_l6470/.settings/language.settings.xml b/opi_rdm_responder_l6470/.settings/language.settings.xml index 07584218b..188799a8b 100644 --- a/opi_rdm_responder_l6470/.settings/language.settings.xml +++ b/opi_rdm_responder_l6470/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + From 7cfcc638266f9ecbe9144743d76460f3683a5b19 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 11:10:52 +0100 Subject: [PATCH 22/36] Major cleanup spi_flash.cpp --- lib-artnet/src/node/failsafe/spi/failsafe.cpp | 10 +- lib-configstore/device/spi/storedevice.cpp | 13 +- lib-flash/include/spi/spi_flash.h | 23 +- lib-flash/src/spi/gd32/spi_flash.cpp | 9 +- lib-flash/src/spi/gigadevice.cpp | 22 +- lib-flash/src/spi/h3/spi_flash.cpp | 31 +- lib-flash/src/spi/macronix.cpp | 16 +- lib-flash/src/spi/spi_flash.cpp | 352 +++++++----------- lib-flash/src/spi/spi_flash_internal.h | 23 +- lib-flash/src/spi/winbond.cpp | 66 +--- lib-flashcode/src/h3/flashcode.cpp | 13 +- 11 files changed, 222 insertions(+), 356 deletions(-) diff --git a/lib-artnet/src/node/failsafe/spi/failsafe.cpp b/lib-artnet/src/node/failsafe/spi/failsafe.cpp index 407813b61..30a3e3d16 100644 --- a/lib-artnet/src/node/failsafe/spi/failsafe.cpp +++ b/lib-artnet/src/node/failsafe/spi/failsafe.cpp @@ -2,7 +2,7 @@ * @file failsafe.cpp * */ -/* Copyright (C) 2022 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,7 +43,7 @@ static bool check_have_flash() { DEBUG_PRINTF("s_hasFlash=%d", s_hasFlash); if (!s_hasFlash) { - if ((spi_flash_probe(0, 0, 0) < 0)) { + if (!spi_flash_probe()) { DEBUG_EXIT return false; } @@ -74,11 +74,9 @@ void failsafe_write_start() { return; } - const auto nReturn = spi_flash_cmd_erase(nOffsetBase, spi_flash_get_sector_size()); + s_hasFlash = spi_flash_cmd_erase(nOffsetBase, spi_flash_get_sector_size()); - s_hasFlash = !(nReturn < 0) ; - - DEBUG_PRINTF("nReturn=%d, s_hasFlash=%d", nReturn, s_hasFlash); + DEBUG_PRINTF("s_hasFlash=%d", s_hasFlash); DEBUG_EXIT } diff --git a/lib-configstore/device/spi/storedevice.cpp b/lib-configstore/device/spi/storedevice.cpp index 1c77549f1..78b66c535 100755 --- a/lib-configstore/device/spi/storedevice.cpp +++ b/lib-configstore/device/spi/storedevice.cpp @@ -2,7 +2,7 @@ * @file storedevice.cpp * */ -/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,7 +34,7 @@ StoreDevice::StoreDevice() { DEBUG_ENTRY - if (spi_flash_probe(0, 0, 0) < 0) { + if (!spi_flash_probe()) { DEBUG_PUTS("No SPI flash chip"); } else { printf("StoreDevice: %s sector size %u total %u bytes [%u kB]\n", @@ -65,8 +65,7 @@ uint32_t StoreDevice::GetSectorSize() const { bool StoreDevice::Read(uint32_t nOffset, uint32_t nLength, uint8_t *pBuffer, storedevice::result& nResult) { DEBUG_ENTRY - const auto nReturn = spi_flash_cmd_read_fast(nOffset, nLength, pBuffer); - nResult = (nReturn < 0) ? storedevice::result::ERROR : storedevice::result::OK; + nResult = spi_flash_cmd_read_fast(nOffset, nLength, pBuffer) ? storedevice::result::OK : storedevice::result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT @@ -76,8 +75,7 @@ bool StoreDevice::Read(uint32_t nOffset, uint32_t nLength, uint8_t *pBuffer, sto bool StoreDevice::Erase(uint32_t nOffset, uint32_t nLength, storedevice::result& nResult) { DEBUG_ENTRY - const auto nReturn = spi_flash_cmd_erase(nOffset, nLength); - nResult = (nReturn < 0) ? storedevice::result::ERROR : storedevice::result::OK; + nResult = spi_flash_cmd_erase(nOffset, nLength) ? storedevice::result::OK : storedevice::result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT @@ -87,8 +85,7 @@ bool StoreDevice::Erase(uint32_t nOffset, uint32_t nLength, storedevice::result& bool StoreDevice::Write(uint32_t nOffset, uint32_t nLength, const uint8_t *pBuffer, storedevice::result& nResult) { DEBUG_ENTRY - const auto nReturn = spi_flash_cmd_write_multi(nOffset, nLength, pBuffer); - nResult = (nReturn < 0) ? storedevice::result::ERROR : storedevice::result::OK; + nResult = spi_flash_cmd_write_multi(nOffset, nLength, pBuffer) ? storedevice::result::OK : storedevice::result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT diff --git a/lib-flash/include/spi/spi_flash.h b/lib-flash/include/spi/spi_flash.h index 729a61f68..a4e0238ab 100644 --- a/lib-flash/include/spi/spi_flash.h +++ b/lib-flash/include/spi/spi_flash.h @@ -2,7 +2,7 @@ * @file spi_flash.h * */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,17 +27,24 @@ #define SPI_FLASH_H_ #include -#include -int spi_flash_probe(unsigned int cs, unsigned int max_hz, unsigned int spi_mode); +namespace spi_flash { +static constexpr uint32_t PAGE_SIZE = 256; +static constexpr uint32_t SECTOR_SIZE = 4096; +} // namespace spi_flash + +bool spi_flash_probe(); const char *spi_flash_get_name(); uint32_t spi_flash_get_size(); -uint32_t spi_flash_get_sector_size(); -int spi_flash_cmd_read_fast(uint32_t offset, size_t len, uint8_t *data); -int spi_flash_cmd_write_multi(uint32_t offset, size_t len, const uint8_t *buf); -int spi_flash_cmd_erase(uint32_t offset, size_t len); -int spi_flash_cmd_write_status(uint8_t sr); +inline uint32_t spi_flash_get_sector_size() { + return spi_flash::SECTOR_SIZE; +} + +bool spi_flash_cmd_read_fast(uint32_t nOffset, uint32_t nLength, uint8_t *data); +bool spi_flash_cmd_write_multi(uint32_t nOffset, uint32_t nLength, const uint8_t *buf); +bool spi_flash_cmd_erase(uint32_t nOffset, uint32_t nLength); +bool spi_flash_cmd_write_status(uint8_t sr); #endif /* SPI_FLASH_H_ */ diff --git a/lib-flash/src/spi/gd32/spi_flash.cpp b/lib-flash/src/spi/gd32/spi_flash.cpp index e4cbbf6a5..ff6c851d1 100644 --- a/lib-flash/src/spi/gd32/spi_flash.cpp +++ b/lib-flash/src/spi/gd32/spi_flash.cpp @@ -33,7 +33,7 @@ #include "debug.h" -int spi_init() { +void spi_init() { gd32_spi_begin(); gd32_spi_chipSelect(GD32_SPI_CS_NONE); gd32_spi_set_speed_hz(SPI_XFER_SPEED_HZ); @@ -51,16 +51,13 @@ int spi_init() { gpio_fsel(SPI_GPIOx, SPI_FLASH_HOLD_GPIO_PINx, GPIO_FSEL_OUTPUT); gpio_bit_set(SPI_GPIOx, SPI_FLASH_HOLD_GPIO_PINx); #endif - - return 0; } inline static void spi_transfern(char *pBuffer, const uint32_t nLength) { gd32_spi_transfernb(pBuffer, pBuffer, nLength); } -int spi_xfer(uint32_t nLength, const uint8_t *pOut, uint8_t *pIn, uint32_t nFlags) { - +void spi_xfer(uint32_t nLength, const uint8_t *pOut, uint8_t *pIn, uint32_t nFlags) { if (nFlags & SPI_XFER_BEGIN) { gpio_bit_reset(SPI_FLASH_CS_GPIOx, SPI_FLASH_CS_GPIO_PINx); } @@ -78,6 +75,4 @@ int spi_xfer(uint32_t nLength, const uint8_t *pOut, uint8_t *pIn, uint32_t nFlag if (nFlags & SPI_XFER_END) { gpio_bit_set(SPI_FLASH_CS_GPIOx, SPI_FLASH_CS_GPIO_PINx); } - - return 0; } diff --git a/lib-flash/src/spi/gigadevice.cpp b/lib-flash/src/spi/gigadevice.cpp index 9c72f30af..5b88f2627 100755 --- a/lib-flash/src/spi/gigadevice.cpp +++ b/lib-flash/src/spi/gigadevice.cpp @@ -12,7 +12,7 @@ /* * Original code : https://github.com/martinezjavier/u-boot/blob/master/drivers/mtd/spi/gigadevice.c */ -/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,13 +35,15 @@ #include -#include "debug.h" +#include "spi/spi_flash.h" #include "spi_flash_internal.h" +#include "debug.h" + struct gigadevice_spi_flash_params { - uint16_t id; - uint16_t nr_blocks; - const char *name; + const uint16_t id; + const uint16_t nr_blocks; + const char *name; }; static constexpr struct gigadevice_spi_flash_params gigadevice_spi_flash_table[] = { @@ -62,7 +64,7 @@ static constexpr struct gigadevice_spi_flash_params gigadevice_spi_flash_table[] }, }; -int spi_flash_probe_gigadevice(struct spi_flash *flash, uint8_t *idcode) { +bool spi_flash_probe_gigadevice(struct SpiFlashInfo *flash, uint8_t *idcode) { const struct gigadevice_spi_flash_params *params; unsigned int i; @@ -74,13 +76,11 @@ int spi_flash_probe_gigadevice(struct spi_flash *flash, uint8_t *idcode) { if (i == ARRAY_SIZE(gigadevice_spi_flash_table)) { DEBUG_PRINTF("SF: Unsupported GigaDevice ID %02x%02x", idcode[1], idcode[2]); - return -1; + return false; } flash->name = params->name; - flash->page_size = 256; - flash->sector_size = flash->page_size * 16; - flash->size = flash->sector_size * 16 * params->nr_blocks; + flash->size = 16U * spi_flash::SECTOR_SIZE * params->nr_blocks; - return 0; + return true; } diff --git a/lib-flash/src/spi/h3/spi_flash.cpp b/lib-flash/src/spi/h3/spi_flash.cpp index 6afcfda61..91de27b83 100644 --- a/lib-flash/src/spi/h3/spi_flash.cpp +++ b/lib-flash/src/spi/h3/spi_flash.cpp @@ -32,9 +32,7 @@ #endif #include -#include "debug.h" - -#include "./../../spi/spi_flash_internal.h" +#include "../spi_flash_internal.h" #include "h3.h" #include "h3_spi.h" @@ -42,6 +40,8 @@ #include "h3_gpio.h" #include "h3_ccu.h" +#include "debug.h" + struct spi0_status { bool transfer_active; uint8_t *rxbuf; @@ -295,7 +295,7 @@ static void spi0_setup_clock(uint32_t pll_clock, uint32_t spi_clock) { #endif } -int spi_init(void) { +void spi_init(void) { spi0_begin(); spi0_set_chip_select(); // H3_SPI_CS_NONE @@ -304,29 +304,24 @@ int spi_init(void) { h3_gpio_fsel(H3_PORT_TO_GPIO(H3_GPIO_PORTC, 3), GPIO_FSEL_OUTPUT); h3_gpio_set(H3_PORT_TO_GPIO(H3_GPIO_PORTC, 3)); - - return 0; } -int spi_xfer(uint32_t len, const uint8_t *dout, uint8_t *din, uint32_t flags) { - - if (flags & SPI_XFER_BEGIN) { +void spi_xfer(const uint32_t nLength, const uint8_t *pOut, uint8_t *pIn, uint32_t nFlags) { + if (nFlags & SPI_XFER_BEGIN) { h3_gpio_clr(H3_PORT_TO_GPIO(H3_GPIO_PORTC, 3)); } - if (len != 0) { - if (din == 0) { - spi0_writenb((char *) dout, len); - } else if (dout == 0) { - spi0_transfern(reinterpret_cast(din), len); + if (nLength != 0) { + if (pIn == nullptr) { + spi0_writenb((char *) pOut, nLength); + } else if (pOut == nullptr) { + spi0_transfern(reinterpret_cast(pIn), nLength); } else { - spi0_transfernb((char *) dout, (char *) din, len); + spi0_transfernb((char *) pOut, (char *) pIn, nLength); } } - if (flags & SPI_XFER_END) { + if (nFlags & SPI_XFER_END) { h3_gpio_set(H3_PORT_TO_GPIO(H3_GPIO_PORTC, 3)); } - - return 0; } diff --git a/lib-flash/src/spi/macronix.cpp b/lib-flash/src/spi/macronix.cpp index ebff01c6c..cb87df6ec 100644 --- a/lib-flash/src/spi/macronix.cpp +++ b/lib-flash/src/spi/macronix.cpp @@ -19,7 +19,7 @@ /* * Original code : https://github.com/martinezjavier/u-boot/blob/master/drivers/mtd/spi/macronix.c */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,10 +42,10 @@ #include -#include "debug.h" +#include "spi/spi_flash.h" #include "spi_flash_internal.h" -extern int spi_flash_cmd_write_status(uint8_t sr); +#include "debug.h" struct macronix_spi_flash_params { uint16_t idcode; @@ -91,7 +91,7 @@ static constexpr struct macronix_spi_flash_params macronix_spi_flash_table[] = { }, }; -int spi_flash_probe_macronix(struct spi_flash *flash, uint8_t *idcode) { +bool spi_flash_probe_macronix(struct SpiFlashInfo *flash, uint8_t *idcode) { const struct macronix_spi_flash_params *params; unsigned int i; uint32_t id = idcode[2] | static_cast(idcode[1] << 8); @@ -106,16 +106,14 @@ int spi_flash_probe_macronix(struct spi_flash *flash, uint8_t *idcode) { if (i == ARRAY_SIZE(macronix_spi_flash_table)) { DEBUG_PRINTF("Unsupported Macronix ID %04x\n", id); - return -1; + return false; } flash->name = params->name; - flash->page_size = 256; - flash->sector_size = 4096; - flash->size = 16 * flash->sector_size * params->nr_blocks; + flash->size = 16U * spi_flash::SECTOR_SIZE * params->nr_blocks; /* Clear BP# bits for read-only flash */ spi_flash_cmd_write_status(0); - return 0; + return true; } diff --git a/lib-flash/src/spi/spi_flash.cpp b/lib-flash/src/spi/spi_flash.cpp index ab0e11c2e..eae8ba4ed 100644 --- a/lib-flash/src/spi/spi_flash.cpp +++ b/lib-flash/src/spi/spi_flash.cpp @@ -26,380 +26,294 @@ * THE SOFTWARE. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpointer-arith" // FIXME ignored "-Wpointer-arith" - -#include -#include -#include -#include +#include +#include +#include #include #include "spi/spi_flash.h" - #include "spi_flash_internal.h" #include "debug.h" -static struct spi_flash s_flash = { "", 0, 0, 0, CMD_READ_STATUS }; +static struct SpiFlashInfo s_flash = { "", 0, CMD_READ_STATUS }; -#define IDCODE_CONT_LEN 0 #define IDCODE_PART_LEN 5 -static const struct { - const uint8_t shift; +static constexpr struct { const uint8_t idcode; - int(*probe) (struct spi_flash *flash, uint8_t *idcode); + bool(*probe) (struct SpiFlashInfo *flash, uint8_t *idcode); } flashes[] = { /* Keep it sorted by define name */ -#ifdef CONFIG_SPI_FLASH_ATMEL - { 0, 0x1f, spi_flash_probe_atmel, }, -#endif -#ifdef CONFIG_SPI_FLASH_EON - { 0, 0x1c, spi_flash_probe_eon, }, -#endif #ifdef CONFIG_SPI_FLASH_GIGADEVICE - { 0, 0xc8, spi_flash_probe_gigadevice, }, + { 0xc8, spi_flash_probe_gigadevice, }, #endif #ifdef CONFIG_SPI_FLASH_MACRONIX - { 0, 0xc2, spi_flash_probe_macronix, }, -#endif -#ifdef CONFIG_SPI_FLASH_SPANSION - { 0, 0x01, spi_flash_probe_spansion, }, -#endif -#ifdef CONFIG_SPI_FLASH_SST - { 0, 0xbf, spi_flash_probe_sst, }, -#endif -#ifdef CONFIG_SPI_FLASH_STMICRO - { 0, 0x20, spi_flash_probe_stmicro, }, + { 0xc2, spi_flash_probe_macronix, }, #endif #ifdef CONFIG_SPI_FLASH_WINBOND - { 0, 0xef, spi_flash_probe_winbond, }, -#endif -#ifdef CONFIG_SPI_FRAM_RAMTRON - { 6, 0xc2, spi_fram_probe_ramtron, }, -# undef IDCODE_CONT_LEN -# define IDCODE_CONT_LEN 6 -#endif - /* Keep it sorted by best detection */ -#ifdef CONFIG_SPI_FLASH_STMICRO - { 0, 0xff, spi_flash_probe_stmicro, }, -#endif -#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC - { 0, 0xff, spi_fram_probe_ramtron, }, + { 0xef, spi_flash_probe_winbond, }, #endif }; -#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) -static uint32_t get_timer(uint32_t base) { - if (0 == base) { +#define IDCODE_LEN IDCODE_PART_LEN + +static uint32_t get_timer(const uint32_t nBase) { + if (0 == nBase) { return static_cast(time(nullptr)); } - return static_cast(time(nullptr)) - base; + return static_cast(time(nullptr)) - nBase; } uint32_t spi_flash_get_size() { return s_flash.size; } -uint32_t spi_flash_get_sector_size() { - return s_flash.sector_size; -} - const char *spi_flash_get_name() { return s_flash.name; } -static void spi_flash_addr(uint32_t addr, uint8_t *cmd) { +static void spi_flash_addr(const uint32_t nAddress, uint8_t *pCommand) { /* cmd[0] is actual command */ - cmd[1] = static_cast(addr >> 16); - cmd[2] = static_cast(addr >> 8); - cmd[3] = static_cast(addr >> 0); + pCommand[1] = static_cast(nAddress >> 16); + pCommand[2] = static_cast(nAddress >> 8); + pCommand[3] = static_cast(nAddress >> 0); } -static int spi_flash_read_write(const uint8_t *cmd, size_t cmd_len, const uint8_t *data_out, uint8_t *data_in, size_t data_len) { - unsigned long flags = SPI_XFER_BEGIN; - int ret; +static void spi_flash_read_write(const uint8_t *pCommand, const uint32_t nCommandLength, const uint8_t *pDataOut, uint8_t *pDataIn, const uint32_t nDataLength) { + uint32_t nFlags = SPI_XFER_BEGIN; - if (data_len == 0) { - flags |= SPI_XFER_END; + if (nDataLength == 0) { + nFlags |= SPI_XFER_END; } - ret = spi_xfer(cmd_len, cmd, nullptr, flags); + spi_xfer(nCommandLength, pCommand, nullptr, nFlags); - if (data_len != 0) { - ret = spi_xfer(data_len, data_out, data_in, SPI_XFER_END); + if (nDataLength != 0) { + spi_xfer(nDataLength, pDataOut, pDataIn, SPI_XFER_END); } - - return ret; } -static inline int spi_flash_cmd_read(const uint8_t *cmd, size_t cmd_len, uint8_t *data, size_t data_len) { - return spi_flash_read_write(cmd, cmd_len, nullptr, data, data_len); +static inline void spi_flash_cmd_read(const uint8_t *pCommand, const uint32_t nCommandLength, uint8_t *pData, const uint32_t nDataLength) { + return spi_flash_read_write(pCommand, nCommandLength, nullptr, pData, nDataLength); } -static inline int spi_flash_cmd(uint8_t cmd, uint8_t *response, size_t len) { - return spi_flash_cmd_read(&cmd, 1, response, len); +static inline void spi_flash_cmd(uint8_t nCommand, uint8_t *pResponse, const uint32_t nLength) { + return spi_flash_cmd_read(&nCommand, 1, pResponse, nLength); } -static inline int spi_flash_cmd_write(const uint8_t *cmd, size_t cmd_len, const uint8_t *data, size_t data_len) { - return spi_flash_read_write(cmd, cmd_len, data, nullptr, data_len); +static inline void spi_flash_cmd_write(const uint8_t *pCommand, const uint32_t nCommandLength, const uint8_t *pData, const uint32_t nDataLength) { + return spi_flash_read_write(pCommand, nCommandLength, pData, nullptr, nDataLength); } -static inline int spi_flash_cmd_write_enable() { +static inline void spi_flash_cmd_write_enable() { return spi_flash_cmd(CMD_WRITE_ENABLE, nullptr, 0); } -static int spi_flash_cmd_wait_ready(unsigned long timeout) { - unsigned long timebase; - uint8_t status; - uint8_t check_status = 0x0; - uint8_t poll_bit = STATUS_WIP; - uint8_t cmd = s_flash.poll_cmd; - - if (cmd == CMD_FLAG_STATUS) { - poll_bit = STATUS_PEC; - check_status = poll_bit; - } +static bool spi_flash_cmd_wait_ready(const uint32_t nTimeout) { + uint8_t cmd = CMD_READ_STATUS; spi_xfer(1, &cmd, nullptr, SPI_XFER_BEGIN); - timebase = get_timer(0); + const auto nTimebase = get_timer(0); + uint8_t status; do { spi_xfer(1, nullptr, &status, 0); - if ((status & poll_bit) == check_status) { + if ((status & STATUS_WIP) == 0) { break; } - } while (get_timer(timebase) < timeout); + } while (get_timer(nTimebase) < nTimeout); spi_xfer(0, nullptr, nullptr, SPI_XFER_END); - if ((status & poll_bit) == check_status) { - return 0; + if ((status & STATUS_WIP) == 0) { + DEBUG_PRINTF("get_timer(nTimebase)=%u", get_timer(nTimebase)); + DEBUG_EXIT + return true; } DEBUG_PUTS("time out"); - return -1; + DEBUG_EXIT + return false; } -static int spi_flash_write_common(const uint8_t *cmd, size_t cmd_len, const uint8_t *buf, size_t buf_len, bool wait_ready) { - unsigned long timeout = SPI_FLASH_PROG_TIMEOUT; - int ret; - - if (buf == nullptr) { - timeout = SPI_FLASH_PAGE_ERASE_TIMEOUT; - } - - ret = spi_flash_cmd_write_enable(); +static bool spi_flash_write_common(const uint8_t *pCommand, const uint32_t nCommandLength, const uint8_t *pData, const uint32_t nDataLength, const bool bWaitReady) { + uint32_t nTimeout; - if (ret < 0) { - DEBUG_PUTS("enabling write failed"); - return ret; + if (pData == nullptr) { + nTimeout = SPI_FLASH_PAGE_ERASE_TIMEOUT; + } else { + nTimeout = SPI_FLASH_PROG_TIMEOUT; } - ret = spi_flash_cmd_write(cmd, cmd_len, buf, buf_len); - - if (ret < 0) { - DEBUG_PUTS("write cmd failed"); - return ret; - } + spi_flash_cmd_write_enable(); + spi_flash_cmd_write(pCommand, nCommandLength, pData, nDataLength); - if (wait_ready) { - ret = spi_flash_cmd_wait_ready(timeout); + if (bWaitReady) { + const auto ret = spi_flash_cmd_wait_ready(nTimeout); - if (ret < 0) { - DEBUG_PRINTF("write %s timed out", timeout == SPI_FLASH_PROG_TIMEOUT ? "program" : "page erase"); - return ret; + if (!ret) { + DEBUG_PRINTF("write %s timed out", nTimeout == SPI_FLASH_PROG_TIMEOUT ? "program" : "page erase"); + return false; } } - return ret; + return true; } -int spi_flash_cmd_write_multi(uint32_t offset, size_t len, const uint8_t *buf) { +bool spi_flash_cmd_write_multi(uint32_t nOffset, const uint32_t nLength, const uint8_t *pData) { DEBUG_ENTRY - unsigned long byte_addr, page_size; - size_t chunk_len, actual; - uint8_t cmd[4]; - int ret = -1; - - page_size = s_flash.page_size; + if (!spi_flash_cmd_wait_ready(SPI_FLASH_SECTOR_ERASE_TIMEOUT)) { + DEBUG_EXIT + return false; + } + uint32_t nChunkLength; + uint8_t cmd[4]; cmd[0] = CMD_PAGE_PROGRAM; - spi_flash_cmd_wait_ready(SPI_FLASH_SECTOR_ERASE_TIMEOUT); + for (uint32_t nActualLength = 0; nActualLength < nLength; nActualLength += nChunkLength) { + const auto nByteAddress = nOffset % spi_flash::PAGE_SIZE; + nChunkLength = std::min((nLength - nActualLength), (spi_flash::PAGE_SIZE - nByteAddress)); - for (actual = 0; actual < len; actual += chunk_len) { - byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + spi_flash_addr(nOffset, cmd); - spi_flash_addr(offset, cmd); + DEBUG_PRINTF("0x%p => cmd = { 0x%02x 0x%02x%02x%02x } nActualLength=%d, nChunkLength=%d", pData + nActualLength, cmd[0], cmd[1], cmd[2], cmd[3], static_cast(nActualLength),static_cast(nChunkLength)); - DEBUG_PRINTF("0x%p => cmd = { 0x%02x 0x%02x%02x%02x } actual=%d, chunk_len=%d", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], static_cast(actual),static_cast(chunk_len)); + const auto ret = spi_flash_write_common(cmd, sizeof(cmd), pData + nActualLength, nChunkLength, ((nActualLength + nChunkLength) != nLength)); - ret = spi_flash_write_common(cmd, sizeof(cmd), buf + actual, chunk_len, ((actual + chunk_len) != len)); - - if (ret < 0) { + if (!ret) { DEBUG_PUTS("write failed"); + DEBUG_EXIT + return false; break; } - offset += chunk_len; + nOffset += nChunkLength; } DEBUG_EXIT - return ret; + return true; } - -int spi_flash_read_common(const uint8_t *cmd, size_t cmd_len, uint8_t *data, size_t data_len) { - int ret; - - ret = spi_flash_cmd_read(cmd, cmd_len, data, data_len); - - return ret; +void spi_flash_read_common(const uint8_t *pCommand, const uint32_t nCommandLength, uint8_t *pData, const uint32_t nDataLength) { + return spi_flash_cmd_read(pCommand, nCommandLength, pData, nDataLength); } -int spi_flash_cmd_read_fast(uint32_t offset, size_t len, uint8_t *data) { +bool spi_flash_cmd_read_fast(uint32_t nOffset, uint32_t nLength, uint8_t *pData) { DEBUG_ENTRY - uint8_t cmd[5], bank_sel = 0; - uint32_t remain_len, read_len; - int ret = -1; + if (!spi_flash_cmd_wait_ready(SPI_FLASH_PROG_TIMEOUT)) { + DEBUG_EXIT + return false; + } + uint8_t cmd[5]; cmd[0] = CMD_READ_ARRAY_FAST; cmd[4] = 0x00; - spi_flash_cmd_wait_ready(SPI_FLASH_PROG_TIMEOUT); + while (nLength) { + const auto nRemainLength = SPI_FLASH_16MB_BOUN - nOffset; + uint32_t nReadLength; - while (len) { - remain_len = (SPI_FLASH_16MB_BOUN * static_cast(bank_sel + 1) - offset); - - if (len < remain_len) { - read_len = len; - } - else { - read_len = remain_len; + if (nLength < nRemainLength) { + nReadLength = nLength; + } else { + nReadLength = nRemainLength; } - spi_flash_addr(offset, cmd); - - ret = spi_flash_read_common(cmd, sizeof(cmd), data, read_len); - - if (ret < 0) { - DEBUG_PUTS("Read failed"); - DEBUG_EXIT - break; - } + spi_flash_addr(nOffset, cmd); + spi_flash_read_common(cmd, sizeof(cmd), pData, nReadLength); - offset += read_len; - len -= read_len; - data += read_len; + nOffset += nReadLength; + nLength -= nReadLength; + pData += nReadLength; } DEBUG_EXIT - return ret; + return true; } -int spi_flash_cmd_erase(uint32_t offset, size_t len) { +bool spi_flash_cmd_erase(uint32_t nOffset, uint32_t nLength) { DEBUG_ENTRY - uint32_t erase_size; - uint8_t cmd[4]; - int ret = -1; - - erase_size = s_flash.sector_size; - - if (offset % erase_size || len % erase_size) { + if ((nOffset % spi_flash::SECTOR_SIZE) || (nLength % spi_flash::SECTOR_SIZE)) { DEBUG_PUTS("Erase offset/length not multiple of erase size"); DEBUG_EXIT - return -1; + return false; } - if (erase_size == 4096) { - cmd[0] = CMD_ERASE_4K; - } else { - cmd[0] = CMD_ERASE_64K; + if (!spi_flash_cmd_wait_ready(SPI_FLASH_PROG_TIMEOUT)) { + DEBUG_EXIT + return false; } - spi_flash_cmd_wait_ready(SPI_FLASH_PROG_TIMEOUT); + static_assert(spi_flash::SECTOR_SIZE == 4096); + uint8_t cmd[4]; + cmd[0] = CMD_ERASE_4K; - while (len) { - spi_flash_addr(offset, cmd); + while (nLength) { + spi_flash_addr(nOffset, cmd); - DEBUG_PRINTF("erase %2x %2x %2x %2x (%x)", cmd[0], cmd[1], cmd[2], cmd[3], offset); + DEBUG_PRINTF("erase %2x %2x %2x %2x (%x)", cmd[0], cmd[1], cmd[2], cmd[3], nOffset); - ret = spi_flash_write_common(cmd, sizeof(cmd), nullptr, 0, (len != erase_size)); + const auto ret = spi_flash_write_common(cmd, sizeof(cmd), nullptr, 0, (nLength != spi_flash::SECTOR_SIZE)); - if (ret < 0) { + if (!ret) { DEBUG_PUTS("Erase failed"); DEBUG_EXIT - break; + return false; } - offset += erase_size; - len -= erase_size; + nOffset += spi_flash::SECTOR_SIZE; + nLength -= spi_flash::SECTOR_SIZE; } DEBUG_EXIT - return ret; + return true; } -int spi_flash_cmd_write_status(uint8_t sr) { - uint8_t cmd; - int ret; +bool spi_flash_cmd_write_status(uint8_t sr) { + uint8_t cmd = CMD_WRITE_STATUS; + const auto ret = spi_flash_write_common(&cmd, 1, &sr, 1, false); - cmd = CMD_WRITE_STATUS; - ret = spi_flash_write_common(&cmd, 1, &sr, 1, false); - - if (ret < 0) { + if (!ret) { DEBUG_PUTS("Fail to write status register"); - return ret; + return false; } - return 0; + return true; } -int spi_flash_probe([[maybe_unused]] unsigned int cs, [[maybe_unused]] unsigned int max_hz, [[maybe_unused]] unsigned int spi_mode) { - int shift; - unsigned i; - uint8_t idcode[IDCODE_LEN] = {0, }; - uint8_t *idp; +bool spi_flash_probe() { + spi_init(); - if (spi_init() < 0) { - DEBUG_PUTS("spi_init() failed!"); - return -1; - } - - /* Read the ID codes */ + uint8_t idcode[IDCODE_LEN]; spi_flash_cmd(CMD_READ_ID, idcode, sizeof(idcode)); - /* count the number of continuation bytes */ - for (shift = 0, idp = idcode; shift < IDCODE_CONT_LEN && *idp == 0x7f; ++shift, ++idp) { - continue; - } + debug_dump(idcode, sizeof(idcode)); + + uint32_t i; - /* search the table for matches in shift and id */ for (i = 0; i < ARRAY_SIZE(flashes); ++i) { - if (flashes[i].shift == shift && flashes[i].idcode == *idp) { - /* we have a match, call probe */ - if (0 == flashes[i].probe(&s_flash, idp)) { + if (flashes[i].idcode == idcode[0]) { + if (flashes[i].probe(&s_flash, idcode)) { break; } } } if (i == ARRAY_SIZE(flashes)) { - DEBUG_PRINTF("Unsupported manufacturer %02x", *idp); - return -1; + DEBUG_PRINTF("Unsupported manufacturer %02x", idcode[0]); + return false; } - DEBUG_PRINTF("Detected %s with sector size %d total %d bytes", s_flash.name, s_flash.sector_size, s_flash.size); + DEBUG_PRINTF("Detected %s total %d bytes", s_flash.name, s_flash.size); - return 0; + return true; } diff --git a/lib-flash/src/spi/spi_flash_internal.h b/lib-flash/src/spi/spi_flash_internal.h index 0acd9b93a..cf40870af 100644 --- a/lib-flash/src/spi/spi_flash_internal.h +++ b/lib-flash/src/spi/spi_flash_internal.h @@ -1,5 +1,5 @@ /** - * @file spi_internal.h + * @file spi_flash_internal.h * */ /* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@g32-dmx.org @@ -26,20 +26,15 @@ #ifndef SPI_FLASH_INTERNAL_H_ #define SPI_FLASH_INTERNAL_H_ -struct spi_flash { +#include + +struct SpiFlashInfo { const char *name; - /* Total flash size */ uint32_t size; - /* Write (page) size */ - uint32_t page_size; - /* Erase (sector) size */ - uint32_t sector_size; /* Poll cmd - for flash erase/program */ uint8_t poll_cmd; }; -#define min(X, Y) ((X) < (Y) ? (X) : (Y)) - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define SPI_FLASH_PROG_TIMEOUT (2) @@ -74,17 +69,17 @@ struct spi_flash { #define SPI_XFER_SPEED_HZ 6000000 ///< 6MHz -int spi_init(); -int spi_xfer(uint32_t bitlen, const uint8_t *dout, uint8_t *din, uint32_t flags); +void spi_init(); +void spi_xfer(const uint32_t nLength, const uint8_t *pOut, uint8_t *pIn, const uint32_t nFlags); #if defined (H3) # define CONFIG_SPI_FLASH_MACRONIX - int spi_flash_probe_macronix(struct spi_flash *flash, uint8_t *idcode); + bool spi_flash_probe_macronix(struct SpiFlashInfo *flash, uint8_t *idcode); # define CONFIG_SPI_FLASH_GIGADEVICE - int spi_flash_probe_gigadevice(struct spi_flash *spi, uint8_t *idcode); + bool spi_flash_probe_gigadevice(struct SpiFlashInfo *spi, uint8_t *idcode); #endif #define CONFIG_SPI_FLASH_WINBOND -extern int spi_flash_probe_winbond(struct spi_flash *spi, uint8_t *idcode); +bool spi_flash_probe_winbond(struct SpiFlashInfo *spi, uint8_t *idcode); #endif /* SPI_FLASH_INTERNAL_H_ */ diff --git a/lib-flash/src/spi/winbond.cpp b/lib-flash/src/spi/winbond.cpp index e821a3c11..59eda302f 100644 --- a/lib-flash/src/spi/winbond.cpp +++ b/lib-flash/src/spi/winbond.cpp @@ -10,7 +10,7 @@ /* * Original code : https://github.com/martinezjavier/u-boot/blob/master/drivers/mtd/spi/winbond.c */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,33 +31,20 @@ * THE SOFTWARE. */ -#include +#include -#include "debug.h" +#include "spi/spi_flash.h" #include "spi_flash_internal.h" +#include "debug.h" + struct winbond_spi_flash_params { - uint16_t id; - uint16_t nr_blocks; + const uint16_t id; + const uint16_t nr_blocks; const char *name; }; -static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { - { - 0x2014, - 16, - "W25P80", - }, - { - 0x2015, - 32, - "W25P16", - }, - { - 0x2016, - 64, - "W25P32", - }, +static constexpr struct winbond_spi_flash_params winbond_spi_flash_table[] = { { 0x3013, 8, @@ -81,27 +68,27 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { { 0x4014, 16, - "W25Q80BL/W25Q80BV", + "W25Q80BL", }, { 0x4015, 32, - "W25Q16CL/W25Q16DV", + "W25Q16CL", }, { 0x4016, 64, - "W25Q32BV/W25Q32FV_SPI", + "W25Q32BV", }, { 0x4017, 128, - "W25Q64CV/W25Q64FV_SPI", + "W25Q64CV", }, { 0x4018, 256, - "W25Q128BV/W25Q128FV_SPI", + "W25Q128BV", }, { 0x4019, @@ -117,25 +104,10 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { 0x6015, 32, "W25Q16DW", - }, - { - 0x6016, - 64, - "W25Q32DW/W25Q32FV_QPI", - }, - { - 0x6017, - 128, - "W25Q64DW/W25Q64FV_QPI", - }, - { - 0x6018, - 256, - "W25Q128FW/W25Q128FV_QPI", - }, + } }; -int spi_flash_probe_winbond(struct spi_flash *flash, uint8_t *idcode) { +bool spi_flash_probe_winbond(struct SpiFlashInfo *flash, uint8_t *idcode) { const struct winbond_spi_flash_params *params; unsigned int i; @@ -148,13 +120,11 @@ int spi_flash_probe_winbond(struct spi_flash *flash, uint8_t *idcode) { if (i == ARRAY_SIZE(winbond_spi_flash_table)) { DEBUG_PRINTF("Unsupported Winbond ID %02x%02x", idcode[1], idcode[2]); - return -1; + return false; } flash->name = params->name; - flash->page_size = 256; - flash->sector_size = (idcode[1] == 0x20) ? 65536 : 4096; - flash->size = 4096U * 16U * params->nr_blocks; + flash->size = 16U * spi_flash::SECTOR_SIZE * params->nr_blocks; - return 0; + return true; } diff --git a/lib-flashcode/src/h3/flashcode.cpp b/lib-flashcode/src/h3/flashcode.cpp index d7ef989a7..fba77f061 100644 --- a/lib-flashcode/src/h3/flashcode.cpp +++ b/lib-flashcode/src/h3/flashcode.cpp @@ -2,7 +2,7 @@ * @file flashcode.cpp * */ -/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,7 @@ FlashCode::FlashCode() { assert(s_pThis == nullptr); s_pThis = this; - if (spi_flash_probe(0, 0, 0) < 0) { + if (!spi_flash_probe()) { DEBUG_PUTS("No SPI flash chip"); } else { printf("Detected %s with sector size %d total %d bytes\n", @@ -75,8 +75,7 @@ uint32_t FlashCode::GetSectorSize() const { bool FlashCode::Read(uint32_t nOffset, uint32_t nLength, uint8_t *pBuffer, flashcode::result& nResult) { DEBUG_ENTRY - const int nReturn = spi_flash_cmd_read_fast(nOffset, nLength, pBuffer); - nResult = (nReturn < 0) ? result::ERROR : result::OK; + nResult = spi_flash_cmd_read_fast(nOffset, nLength, pBuffer) ? result::OK : result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT @@ -86,8 +85,7 @@ bool FlashCode::Read(uint32_t nOffset, uint32_t nLength, uint8_t *pBuffer, flash bool FlashCode::Erase(uint32_t nOffset, uint32_t nLength, flashcode::result& nResult) { DEBUG_ENTRY - const auto nReturn = spi_flash_cmd_erase(nOffset, nLength); - nResult = (nReturn < 0) ? result::ERROR : result::OK; + nResult = spi_flash_cmd_erase(nOffset, nLength) ? result::OK : result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT @@ -97,8 +95,7 @@ bool FlashCode::Erase(uint32_t nOffset, uint32_t nLength, flashcode::result& nRe bool FlashCode::Write(uint32_t nOffset, uint32_t nLength, const uint8_t *pBuffer, flashcode::result& nResult) { DEBUG_ENTRY - const auto nReturn = spi_flash_cmd_write_multi(nOffset, nLength, pBuffer); - nResult = (nReturn < 0) ? result::ERROR : result::OK; + nResult = spi_flash_cmd_write_multi(nOffset, nLength, pBuffer) ? result::OK : result::ERROR; DEBUG_PRINTF("nResult=%d", static_cast(nResult)); DEBUG_EXIT From bc3b560815dea1a399ec4a07599948b78d03d205 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:25:50 +0100 Subject: [PATCH 23/36] Fixed issue with pixel multi and dmx sync --- lib-artnet/src/node/artnetparams.cpp | 44 ++-- lib-displayudf/.cproject | 6 + .../.settings/language.settings.xml | 2 +- lib-displayudf/include/displayudf.h | 6 + lib-displayudf/src/artnet/artnetdisplay.cpp | 6 +- .../src/artnet/displayudfshowartnet.cpp | 16 +- lib-displayudf/src/displayudf.cpp | 6 +- lib-displayudf/src/displayudfparams.cpp | 28 +-- .../src/e131/displayudfshowe131.cpp | 10 +- lib-dmx/.settings/language.settings.xml | 6 +- lib-dmx/include/dmxsend.h | 22 +- lib-h3/include/board/logic_analyzer.h | 10 +- lib-h3/include/logic_analyzer.h | 34 +-- .../include/gd32/gpio/pixelmulti_config.h | 5 + lib-ws28xx/include/gd32/gpio/ws28xxmulti.h | 203 +++++++++++++++- lib-ws28xx/include/h3/ws28xxmulti.h | 118 +++++++++- lib-ws28xx/include/pixelpatterns.h | 4 - lib-ws28xx/src/h3/ws28xxmulti.cpp | 216 ++++-------------- lib-ws28xx/src/pixeltype.cpp | 5 - opi_emac_artnet_dmx/firmware/main.cpp | 16 +- opi_emac_artnet_dmx_multi/Makefile.H3 | 2 +- opi_emac_artnet_dmx_multi/firmware/main.cpp | 19 +- opi_emac_artnet_pixel/Makefile.H3 | 7 +- opi_emac_artnet_pixel/firmware/main.cpp | 10 +- opi_emac_artnet_pixel_dmx/Makefile.H3 | 3 +- opi_emac_artnet_pixel_dmx/firmware/main.cpp | 14 +- opi_emac_artnet_pixel_dmx_multi/Makefile.H3 | 9 +- .../firmware/main.cpp | 18 +- opi_emac_artnet_pixel_multi/Makefile.H3 | 5 +- opi_emac_artnet_pixel_multi/firmware/main.cpp | 10 +- opi_emac_e131_pixel/Makefile.H3 | 2 + opi_emac_e131_pixel/firmware/main.cpp | 10 +- opi_emac_e131_pixel_dmx/Makefile.H3 | 1 + opi_emac_e131_pixel_dmx/firmware/main.cpp | 14 +- opi_emac_e131_pixel_dmx_multi/Makefile.H3 | 1 + .../firmware/main.cpp | 18 +- opi_emac_e131_pixel_multi/Makefile.H3 | 5 +- opi_emac_e131_pixel_multi/firmware/main.cpp | 10 +- 38 files changed, 513 insertions(+), 408 deletions(-) mode change 100644 => 100755 lib-ws28xx/include/h3/ws28xxmulti.h mode change 100644 => 100755 lib-ws28xx/src/h3/ws28xxmulti.cpp diff --git a/lib-artnet/src/node/artnetparams.cpp b/lib-artnet/src/node/artnetparams.cpp index 65f593de8..7bf5957de 100644 --- a/lib-artnet/src/node/artnetparams.cpp +++ b/lib-artnet/src/node/artnetparams.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2016-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,14 +26,11 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include -#include +#ifndef NDEBUG +# include +#endif #include #include #include @@ -59,15 +56,14 @@ #include "debug.h" -namespace artnetnode { -namespace configstore { -extern uint32_t DMXPORT_OFFSET; -} // namespace configstore -} // namespace artnetnode - static uint32_t s_nPortsMax; namespace artnetparams { +#if !defined(CONFIG_DMX_PORT_OFFSET) + static constexpr uint32_t DMXPORT_OFFSET = 0; +#else + static constexpr uint32_t DMXPORT_OFFSET = CONFIG_DMX_PORT_OFFSET; +#endif #if defined (RDM_CONTROLLER) static constexpr bool is_set(const uint16_t nValue, const uint32_t i) { return (nValue & static_cast(1U << (i + 8))) == static_cast(1U << (i + 8)); @@ -366,7 +362,7 @@ void ArtNetParams::Builder(const struct Params *pParams, char *pBuffer, uint32_t builder.Add(LightSetParamsConst::FAILSAFE, lightset::get_failsafe(static_cast(m_Params.nFailSafe)), isMaskSet(Mask::FAILSAFE)); for (uint32_t nPortIndex = 0; nPortIndex < s_nPortsMax; nPortIndex++) { - const auto nOffset = nPortIndex + artnetnode::configstore::DMXPORT_OFFSET; + const auto nOffset = nPortIndex + artnetparams::DMXPORT_OFFSET; if (nOffset >= artnetnode::MAX_PORTS) { DEBUG_PUTS("break"); @@ -437,11 +433,11 @@ void ArtNetParams::Builder(const struct Params *pParams, char *pBuffer, uint32_t void ArtNetParams::Set() { DEBUG_ENTRY - if (artnetnode::configstore::DMXPORT_OFFSET <= artnetnode::MAX_PORTS) { - s_nPortsMax = std::min(artnet::PORTS, artnetnode::MAX_PORTS - artnetnode::configstore::DMXPORT_OFFSET); + if (artnetparams::DMXPORT_OFFSET <= artnetnode::MAX_PORTS) { + s_nPortsMax = std::min(artnet::PORTS, artnetnode::MAX_PORTS - artnetparams::DMXPORT_OFFSET); } - DEBUG_PRINTF("artnetnode::MAX_PORTS=%u, artnetnode::configstore::DMXPORT_OFFSET=%u, s_nPortsMax=%u", artnetnode::MAX_PORTS, artnetnode::configstore::DMXPORT_OFFSET, s_nPortsMax); + DEBUG_PRINTF("artnetnode::MAX_PORTS=%u, artnetparams::DMXPORT_OFFSET=%u, s_nPortsMax=%u", artnetnode::MAX_PORTS, artnetparams::DMXPORT_OFFSET, s_nPortsMax); auto *const p = ArtNetNode::Get(); assert(p != nullptr); @@ -451,7 +447,7 @@ void ArtNetParams::Set() { } for (uint32_t nPortIndex = 0; nPortIndex < s_nPortsMax; nPortIndex++) { - const auto nOffset = nPortIndex + artnetnode::configstore::DMXPORT_OFFSET; + const auto nOffset = nPortIndex + artnetparams::DMXPORT_OFFSET; if (nOffset >= artnetnode::MAX_PORTS) { DEBUG_PUTS("break"); @@ -459,20 +455,20 @@ void ArtNetParams::Set() { } if (isMaskSet(Mask::LABEL_A << nPortIndex)) { - p->SetShortName(nOffset, reinterpret_cast(m_Params.aLabel[nPortIndex])); + p->SetShortName(nPortIndex, reinterpret_cast(m_Params.aLabel[nPortIndex])); } else { - p->SetShortName(nOffset, nullptr); + p->SetShortName(nPortIndex, nullptr); } - p->SetMergeMode(nOffset, mergemode_get(nPortIndex)); + p->SetMergeMode(nPortIndex, mergemode_get(nPortIndex)); #if (ARTNET_VERSION >= 4) - p->SetPortProtocol4(nOffset, protocol_get(nPortIndex)); + p->SetPortProtocol4(nPortIndex, protocol_get(nPortIndex)); #endif #if defined (ARTNET_HAVE_DMXIN) if (isMaskSet(Mask::DESTINATION_IP_A << nPortIndex)) { - p->SetDestinationIp(nOffset, m_Params.nDestinationIp[nPortIndex]); + p->SetDestinationIp(nPortIndex, m_Params.nDestinationIp[nPortIndex]); } #endif @@ -488,7 +484,7 @@ void ArtNetParams::Set() { #if (ARTNET_VERSION >= 4) if (isMaskSet(Mask::PRIORITY_A << nPortIndex)) { - p->SetPriority4(m_Params.nPriority[nOffset]); + p->SetPriority4(m_Params.nPriority[nPortIndex]); } #endif } diff --git a/lib-displayudf/.cproject b/lib-displayudf/.cproject index 22b72519d..9824998c1 100644 --- a/lib-displayudf/.cproject +++ b/lib-displayudf/.cproject @@ -219,6 +219,8 @@ + + @@ -238,6 +240,8 @@ + + @@ -259,6 +263,8 @@ + + diff --git a/lib-displayudf/.settings/language.settings.xml b/lib-displayudf/.settings/language.settings.xml index b630667cc..3e243c0fe 100644 --- a/lib-displayudf/.settings/language.settings.xml +++ b/lib-displayudf/.settings/language.settings.xml @@ -14,7 +14,7 @@ - + diff --git a/lib-displayudf/include/displayudf.h b/lib-displayudf/include/displayudf.h index d36ac873c..9b3906db4 100644 --- a/lib-displayudf/include/displayudf.h +++ b/lib-displayudf/include/displayudf.h @@ -65,6 +65,12 @@ #endif namespace displayudf { +#if !defined(CONFIG_DMX_PORT_OFFSET) + static constexpr uint32_t DMXPORT_OFFSET = 0; +#else + static constexpr uint32_t DMXPORT_OFFSET = CONFIG_DMX_PORT_OFFSET; +#endif + static constexpr auto LABEL_MAX_ROWS = 6U; #if !defined(NODE_NODE) diff --git a/lib-displayudf/src/artnet/artnetdisplay.cpp b/lib-displayudf/src/artnet/artnetdisplay.cpp index 2a73757e1..088793218 100644 --- a/lib-displayudf/src/artnet/artnetdisplay.cpp +++ b/lib-displayudf/src/artnet/artnetdisplay.cpp @@ -2,7 +2,7 @@ * @file artnetdisplay.cpp * */ -/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2022-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAYUDF) +# undef NDEBUG +#endif + #include #include "displayudf.h" diff --git a/lib-displayudf/src/artnet/displayudfshowartnet.cpp b/lib-displayudf/src/artnet/displayudfshowartnet.cpp index 3f4039ed8..03dd074ec 100644 --- a/lib-displayudf/src/artnet/displayudfshowartnet.cpp +++ b/lib-displayudf/src/artnet/displayudfshowartnet.cpp @@ -2,7 +2,7 @@ * @file displayudfshowartnet.cpp * */ -/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAYUDF) +# undef NDEBUG +#endif + #include #include @@ -35,15 +39,9 @@ #include "debug.h" -namespace artnetnode { -namespace configstore { -extern uint32_t DMXPORT_OFFSET; -} // namespace configstore -} // namespace artnetnode - void DisplayUdf::ShowArtNetNode() { DEBUG_ENTRY - DEBUG_PRINTF("artnetnode::configstore::DMXPORT_OFFSET=%u", artnetnode::configstore::DMXPORT_OFFSET); + DEBUG_PRINTF("displayudf::DMXPORT_OFFSET=%u", displayudf::DMXPORT_OFFSET); auto *pArtNetNode = ArtNetNode::Get(); @@ -65,7 +63,7 @@ void DisplayUdf::ShowUniverseArtNetNode() { uint16_t nUniverse; for (uint32_t nArtNetPortIndex = 0; nArtNetPortIndex < std::min(artnet::PORTS, artnetnode::MAX_PORTS); nArtNetPortIndex++) { - const auto nPortIndex = nArtNetPortIndex + artnetnode::configstore::DMXPORT_OFFSET; + const auto nPortIndex = nArtNetPortIndex + displayudf::DMXPORT_OFFSET; if (nPortIndex >= std::min(artnet::PORTS, artnetnode::MAX_PORTS)) { break; diff --git a/lib-displayudf/src/displayudf.cpp b/lib-displayudf/src/displayudf.cpp index 2548254ed..2223ae09e 100644 --- a/lib-displayudf/src/displayudf.cpp +++ b/lib-displayudf/src/displayudf.cpp @@ -2,7 +2,7 @@ * @file displayudf.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAYUDF) +# undef NDEBUG +#endif + #include #include #include diff --git a/lib-displayudf/src/displayudfparams.cpp b/lib-displayudf/src/displayudfparams.cpp index e234031cc..ddfbd8b4b 100644 --- a/lib-displayudf/src/displayudfparams.cpp +++ b/lib-displayudf/src/displayudfparams.cpp @@ -2,7 +2,7 @@ * @file displayudfparams.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,9 +23,8 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") +#if defined (DEBUG_DISPLAYUDF) +# undef NDEBUG #endif #include @@ -238,13 +237,12 @@ void DisplayUdfParams::callbackFunction(const char *pLine) { } } -void DisplayUdfParams::Builder(const struct displayudfparams::Params *ptDisplayUdfParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { +void DisplayUdfParams::Builder(const struct displayudfparams::Params *pParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { assert(pBuffer != nullptr); - if (ptDisplayUdfParams != nullptr) { - memcpy(&m_Params, ptDisplayUdfParams, sizeof(struct displayudfparams::Params)); + if (pParams != nullptr) { + memcpy(&m_Params, pParams, sizeof(struct displayudfparams::Params)); } else { - assert(m_pDisplayUdfParamsStore != nullptr); DisplayUdfParamsStore::Copy(&m_Params); } @@ -270,10 +268,7 @@ void DisplayUdfParams::Set(DisplayUdf *pDisplayUdf) { pDisplayUdf->SetContrast(m_Params.nIntensity); } - if (isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)) { - pDisplayUdf->SetSleepTimeout(m_Params.nSleepTimeout); - } - + pDisplayUdf->SetSleepTimeout(m_Params.nSleepTimeout); pDisplayUdf->SetFlipVertically(isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY)); for (uint32_t i = 0; i < static_cast(Labels::UNKNOWN); i++) { @@ -293,13 +288,8 @@ void DisplayUdfParams::staticCallbackFunction(void *p, const char *s) { void DisplayUdfParams::Dump() { printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, DisplayUdfParamsConst::FILE_NAME); - if (isMaskSet(displayudfparams::Mask::INTENSITY)) { - printf(" %s=%d\n", DisplayUdfParamsConst::INTENSITY, m_Params.nIntensity); - } - - if (isMaskSet(displayudfparams::Mask::SLEEP_TIMEOUT)) { - printf(" %s=%d\n", DisplayUdfParamsConst::SLEEP_TIMEOUT, m_Params.nSleepTimeout); - } + printf(" %s=%d\n", DisplayUdfParamsConst::INTENSITY, m_Params.nIntensity); + printf(" %s=%d\n", DisplayUdfParamsConst::SLEEP_TIMEOUT, m_Params.nSleepTimeout); if (isMaskSet(displayudfparams::Mask::FLIP_VERTICALLY)) { printf(" Flip vertically\n"); diff --git a/lib-displayudf/src/e131/displayudfshowe131.cpp b/lib-displayudf/src/e131/displayudfshowe131.cpp index 52dac38d4..90ffb31e2 100644 --- a/lib-displayudf/src/e131/displayudfshowe131.cpp +++ b/lib-displayudf/src/e131/displayudfshowe131.cpp @@ -2,7 +2,7 @@ * @file displayudfshowe131.cpp * */ -/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DISPLAYUDF) +# undef NDEBUG +#endif + #include #include @@ -40,14 +44,14 @@ extern uint32_t DMXPORT_OFFSET; void DisplayUdf::ShowE131Bridge() { DEBUG_ENTRY - DEBUG_PRINTF("e131bridge::configstore::DMXPORT_OFFSET=%u", e131bridge::configstore::DMXPORT_OFFSET); + DEBUG_PRINTF("displayudf::DMXPORT_OFFSET=%u", displayudf::DMXPORT_OFFSET); auto *pE131Bridge = E131Bridge::Get(); Printf(m_aLabels[static_cast(displayudf::Labels::AP)], "AP: %d", pE131Bridge->GetActiveOutputPorts() + pE131Bridge->GetActiveInputPorts()); for (uint32_t nBridgePortIndex = 0; nBridgePortIndex < std::min(static_cast(4), e131bridge::MAX_PORTS); nBridgePortIndex++) { - const auto nPortIndex = nBridgePortIndex + e131bridge::configstore::DMXPORT_OFFSET; + const auto nPortIndex = nBridgePortIndex + displayudf::DMXPORT_OFFSET; if (nPortIndex >= std::min(static_cast(4), e131bridge::MAX_PORTS)) { break; diff --git a/lib-dmx/.settings/language.settings.xml b/lib-dmx/.settings/language.settings.xml index 6a1097c7c..815d84995 100644 --- a/lib-dmx/.settings/language.settings.xml +++ b/lib-dmx/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/lib-dmx/include/dmxsend.h b/lib-dmx/include/dmxsend.h index ed44a85df..66afc6649 100755 --- a/lib-dmx/include/dmxsend.h +++ b/lib-dmx/include/dmxsend.h @@ -2,7 +2,7 @@ * @file dmxsend.h * */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,6 +39,14 @@ #include "debug.h" +namespace dmxsend { +#if !defined(CONFIG_DMX_PORT_OFFSET) + static constexpr uint32_t DMXPORT_OFFSET = 0; +#else + static constexpr uint32_t DMXPORT_OFFSET = CONFIG_DMX_PORT_OFFSET; +#endif +} // namespace dmxsend + class DmxSend final: public LightSet { public: void Start(const uint32_t nPortIndex) override { @@ -95,17 +103,19 @@ class DmxSend final: public LightSet { } } - void Sync(uint32_t const nPortIndex) override { - assert(lightset::Data::GetLength(nPortIndex) != 0); - Dmx::Get()->SetSendDataWithoutSC(nPortIndex, lightset::Data::Backup(nPortIndex), lightset::Data::GetLength(nPortIndex)); + void Sync(const uint32_t nPortIndex) override { + const auto nLightsetOffset = nPortIndex + dmxsend::DMXPORT_OFFSET; + assert(lightset::Data::GetLength(nLightsetOffset) != 0); + Dmx::Get()->SetSendDataWithoutSC(nPortIndex, lightset::Data::Backup(nLightsetOffset), lightset::Data::GetLength(nLightsetOffset)); } void Sync() override { Dmx::Get()->Sync(); for (uint32_t nPortIndex = 0; nPortIndex < dmx::config::max::PORTS; nPortIndex++) { - if (lightset::Data::GetLength(nPortIndex) != 0) { - lightset::Data::ClearLength(nPortIndex); + const auto nLightsetOffset = nPortIndex + dmxsend::DMXPORT_OFFSET; + if (lightset::Data::GetLength(nLightsetOffset) != 0) { + lightset::Data::ClearLength(nLightsetOffset); hal::panel_led_on(hal::panelled::PORT_A_TX << nPortIndex); if (!is_started(m_nStarted, nPortIndex)) { Start(nPortIndex); diff --git a/lib-h3/include/board/logic_analyzer.h b/lib-h3/include/board/logic_analyzer.h index 82ad77331..97126dc25 100755 --- a/lib-h3/include/board/logic_analyzer.h +++ b/lib-h3/include/board/logic_analyzer.h @@ -2,7 +2,7 @@ * @file logic_analyzer.h * */ -/* Copyright (C) 2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,10 +30,10 @@ #if defined(ORANGE_PI_ONE) #else -# define LOGIC_ANALYZER_CH0_GPIO_PINx GPIO_EXT_26 -# define LOGIC_ANALYZER_CH1_GPIO_PINx GPIO_EXT_24 -# define LOGIC_ANALYZER_CH2_GPIO_PINx GPIO_EXT_18 -# define LOGIC_ANALYZER_CH3_GPIO_PINx GPIO_EXT_16 +//# define LOGIC_ANALYZER_CH0_GPIO_PINx GPIO_EXT_26 +//# define LOGIC_ANALYZER_CH1_GPIO_PINx GPIO_EXT_24 +//# define LOGIC_ANALYZER_CH2_GPIO_PINx GPIO_EXT_18 +//# define LOGIC_ANALYZER_CH3_GPIO_PINx GPIO_EXT_16 #endif #endif /* BOARD_LOGIC_ANALYZER_H_ */ diff --git a/lib-h3/include/logic_analyzer.h b/lib-h3/include/logic_analyzer.h index 463057169..9f3affb2a 100755 --- a/lib-h3/include/logic_analyzer.h +++ b/lib-h3/include/logic_analyzer.h @@ -2,7 +2,7 @@ * @file logic_analyzer.h * */ -/* Copyright (C) 2023 by Arjan van Vught mailto:info@gd32-dmx.org +/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -76,97 +76,97 @@ inline void init() { } inline void ch0_clear() { -#if defined (LOGIC_ANALYZER_CH0_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH0_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH0_GPIO_PINx); #endif } inline void ch0_set() { -#if defined (LOGIC_ANALYZER_CH0_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH0_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH0_GPIO_PINx); #endif } inline void ch1_clear() { -#if defined (LOGIC_ANALYZER_CH1_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH1_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH1_GPIO_PINx); #endif } inline void ch1_set() { -#if defined (LOGIC_ANALYZER_CH1_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH1_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH1_GPIO_PINx); #endif } inline void ch2_clear() { -#if defined (LOGIC_ANALYZER_CH2_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH2_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH2_GPIO_PINx); #endif } inline void ch2_set() { -#if defined (LOGIC_ANALYZER_CH2_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH2_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH2_GPIO_PINx); #endif } inline void ch3_clear() { -#if defined (LOGIC_ANALYZER_CH3_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH3_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH3_GPIO_PINx); #endif } inline void ch3_set() { -#if defined (LOGIC_ANALYZER_CH3_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH3_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH3_GPIO_PINx); #endif } inline void ch4_clear() { -#if defined (LOGIC_ANALYZER_CH4_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH4_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH4_GPIO_PINx); #endif } inline void ch4_set() { -#if defined (LOGIC_ANALYZER_CH4_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH4_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH4_GPIO_PINx); #endif } inline void ch5_clear() { -#if defined (LOGIC_ANALYZER_CH5_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH5_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH5_GPIO_PINx); #endif } inline void ch5_set() { -#if defined (LOGIC_ANALYZER_CH5_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH5_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH5_GPIO_PINx); #endif } inline void ch6_clear() { -#if defined (LOGIC_ANALYZER_CH6_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH6_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH6_GPIO_PINx); #endif } inline void ch6_set() { -#if defined (LOGIC_ANALYZER_CH6_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH6_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH6_GPIO_PINx); #endif } inline void ch7_clear() { -#if defined (LOGIC_ANALYZER_CH7_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH7_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_clr(LOGIC_ANALYZER_CH7_GPIO_PINx); #endif } inline void ch7_set() { -#if defined (LOGIC_ANALYZER_CH7_GPIO_PINx) +#if defined (LOGIC_ANALYZER_CH7_GPIO_PINx) && defined (LOGIC_ANALYZER) h3_gpio_set(LOGIC_ANALYZER_CH7_GPIO_PINx); #endif } diff --git a/lib-ws28xx/include/gd32/gpio/pixelmulti_config.h b/lib-ws28xx/include/gd32/gpio/pixelmulti_config.h index a6bf29c17..1f93229d0 100644 --- a/lib-ws28xx/include/gd32/gpio/pixelmulti_config.h +++ b/lib-ws28xx/include/gd32/gpio/pixelmulti_config.h @@ -44,4 +44,9 @@ # error Board is not supported #endif +namespace pixel { +static constexpr auto PORT_COUNT = __builtin_popcount(GPIO_PINx); +static_assert(PORT_COUNT <= 16, "Too many ports"); +} // namespace pixel + #endif /* GPIO_PIXELMULTI_CONFIG_H_ */ diff --git a/lib-ws28xx/include/gd32/gpio/ws28xxmulti.h b/lib-ws28xx/include/gd32/gpio/ws28xxmulti.h index 444d5744a..022322da0 100644 --- a/lib-ws28xx/include/gd32/gpio/ws28xxmulti.h +++ b/lib-ws28xx/include/gd32/gpio/ws28xxmulti.h @@ -23,22 +23,192 @@ * THE SOFTWARE. */ -#ifndef GPIO_WS28XXMULTI_H_ -#define GPIO_WS28XXMULTI_H_ +#ifndef GD32_GPIO_WS28XXMULTI_H_ +#define GD32_GPIO_WS28XXMULTI_H_ #include #include "pixelconfiguration.h" +#include "gd32/gpio/pixelmulti_config.h" + +#include "gd32.h" + +#include "debug.h" class WS28xxMulti { public: WS28xxMulti(); - ~WS28xxMulti(); + ~WS28xxMulti() { + DEBUG_ENTRY + DEBUG_EXIT + } + +#define BIT_SET(Addr, Bit) { \ + *(volatile uint32_t *) (BITBAND_SRAM_BASE + (((uint32_t)&Addr) - SRAM_BASE) * 32U + (Bit & 0xFF) * 4U) = 0x1; \ +} + +#define BIT_CLEAR(Addr, Bit) { \ + *(volatile uint32_t *) (BITBAND_SRAM_BASE + (((uint32_t)&(Addr)) - SRAM_BASE) * 32U + (Bit & 0xFF) * 4U) = 0x0; \ +} + + void SetColourRTZ(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3) { + assert(nPortIndex < pixel::PORT_COUNT); + + uint32_t j = 0; + const auto k = nPixelIndex * pixel::single::RGB; + const auto nBit = nPortIndex + GPIO_PIN_OFFSET; + auto *p = &s_pBuffer1[k]; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + auto &p1 = p[j]; + auto &p2 = p[8 + j]; + auto &p3 = p[16 + j]; + + if (!(mask & nColour1)) { + BIT_SET(p1, nBit); + } else { + BIT_CLEAR(p1, nBit); + } + if (!(mask & nColour2)) { + BIT_SET(p2, nBit); + } else { + BIT_CLEAR(p2, nBit); + } + if (!(mask & nColour3)) { + BIT_SET(p3, nBit); + } else { + BIT_CLEAR(p3, nBit); + } + + j++; + } + } + + void SetColourRTZ(const uint32_t nPortIndex, const uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite) { + assert(nPortIndex < 16); + assert(nPixelIndex < m_nBufSize / 8); //FIXME 8 + +#if defined(CONFIG_PIXELDMX_ENABLE_GAMMATABLE) + const auto pGammaTable = pixelConfiguration.GetGammaTable(); + + nRed = pGammaTable[nRed]; + nGreen = pGammaTable[nGreen]; + nBlue = pGammaTable[nBlue]; + nWhite = pGammaTable[nWhite]; +#endif + + const auto k = nPixelIndex * pixel::single::RGBW; + const auto nBit = nPortIndex + GPIO_PIN_OFFSET; + + auto *p = &s_pBuffer1[k]; + uint32_t j = 0; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + auto& p1 = p[j]; + auto& p2 = p[8 + j]; + auto& p3 = p[16 + j]; + auto& p4 = p[24 + j]; + + // GRBW + if (!(mask & nGreen)) { + BIT_SET(p1, nBit); + } else { + BIT_CLEAR(p1, nBit); + } + + if (!(mask & nRed)) { + BIT_SET(p2, nBit); + } else { + BIT_CLEAR(p2, nBit); + } - void SetColourRTZ(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3); - void SetColourRTZ(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nRed, const uint8_t nGreen, const uint8_t nBlue, const uint8_t nWhite); - void SetColourWS2801(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3); - void SetPixel4Bytes(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nCtrl, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3); + if (!(mask & nBlue)) { + BIT_SET(p3, nBit); + } else { + BIT_CLEAR(p3, nBit); + } + + if (!(mask & nWhite)) { + BIT_SET(p4, nBit); + } else { + BIT_CLEAR(p4, nBit); + } + + j++; + } + } + + void SetColourWS2801(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3) { + assert(nPortIndex < 16); + assert(nPixelIndex < m_nBufSize / 8); //FIXME 8 + + uint32_t j = 0; + const auto k = nPixelIndex * pixel::single::RGB; + const auto nBit = nPortIndex + GPIO_PIN_OFFSET; + auto *p = &s_pBuffer1[k]; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + auto& p1 = p[j]; + auto& p2 = p[8 + j]; + auto& p3 = p[16 + j]; + + if (mask & nColour1) { + BIT_SET(p1, nBit); + } else { + BIT_CLEAR(p1, nBit); + } + if (mask & nColour2) { + BIT_SET(p2, nBit); + } else { + BIT_CLEAR(p2, nBit); + } + if (mask & nColour3) { + BIT_SET(p3, nBit); + } else { + BIT_CLEAR(p3, nBit); + } + + j++; + } + } + + void SetPixel4Bytes(const uint32_t nPortIndex, const uint32_t nPixelIndex, const uint8_t nCtrl, const uint8_t nColour1, const uint8_t nColour2, const uint8_t nColour3) { + assert(nPortIndex < 16); + assert(nPixelIndex < m_nBufSize / 8); //FIXME 8 + + uint32_t j = 0; + const auto k = nPixelIndex * pixel::single::RGBW; + const auto nBit = nPortIndex + GPIO_PIN_OFFSET; + auto *p = &s_pBuffer1[k]; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + if (mask & nCtrl) { + BIT_SET(p[j], nBit); + } else { + BIT_CLEAR(p[j], nBit); + } + + if (mask & nColour1) { + BIT_SET(p[8 + j], nBit); + } else { + BIT_CLEAR(p[8 + j], nBit); + } + + if (mask & nColour2) { + BIT_SET(p[16 + j], nBit); + } else { + BIT_CLEAR(p[16 + j], nBit); + } + + if (mask & nColour3) { + BIT_SET(p[24 + j], nBit); + } else { + BIT_CLEAR(p[24 + j], nBit); + } + + j++; + } + } bool IsUpdating(); @@ -59,7 +229,22 @@ class WS28xxMulti { private: uint32_t m_nBufSize { 0 }; - static WS28xxMulti *s_pThis; + /** + * https://www.gd32-dmx.org/memory.html + */ +#if defined (GD32F20X) || defined (GD32F4XX) +# define SECTION_DMA_BUFFER __attribute__ ((section (".pixel"))) +#else +# define SECTION_DMA_BUFFER +#endif + + static inline uint16_t DmaBuffer[2 * 1024 * 16] __attribute__ ((aligned (4))) SECTION_DMA_BUFFER; + static inline constexpr auto DMA_BUFFER_SIZE = sizeof(DmaBuffer) / sizeof(DmaBuffer[0]); + static inline auto *s_pBuffer1 = reinterpret_cast(DmaBuffer); + static inline auto *s_pBuffer2 = reinterpret_cast(DmaBuffer + DMA_BUFFER_SIZE / 2); + static inline constexpr auto MAX_APA102 = ((DMA_BUFFER_SIZE / 8) - 8 ) / 4; + + static inline WS28xxMulti *s_pThis; }; -#endif /* GPIO_WS28XXMULTI_H_ */ +#endif /* GD32_GPIO_WS28XXMULTI_H_ */ diff --git a/lib-ws28xx/include/h3/ws28xxmulti.h b/lib-ws28xx/include/h3/ws28xxmulti.h old mode 100644 new mode 100755 index 9f1725bc3..1b868c8aa --- a/lib-ws28xx/include/h3/ws28xxmulti.h +++ b/lib-ws28xx/include/h3/ws28xxmulti.h @@ -44,12 +44,88 @@ class WS28xxMulti { void SetColourRTZ(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nColour1, uint8_t nColour2, uint8_t nColour3) { SetColour(nPortIndex, nPixelIndex, nColour1, nColour2, nColour3); } - void SetColourRTZ(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite); - void SetColourWS2801(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nColour1, uint8_t nColour2, uint8_t nColour3) { + +#define BIT_SET(a,b) ((a) |= static_cast((1<<(b)))) +#define BIT_CLEAR(a,b) ((a) &= static_cast(~(1<<(b)))) + + void SetColourRTZ(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite) { +#if defined(CONFIG_PIXELDMX_ENABLE_GAMMATABLE) + const auto pGammaTable = m_PixelConfiguration.GetGammaTable(); + + nRed = pGammaTable[nRed]; + nGreen = pGammaTable[nGreen]; + nBlue = pGammaTable[nBlue]; + nWhite = pGammaTable[nWhite]; +#endif + + const auto k = nPixelIndex * pixel::single::RGBW; + uint32_t j = 0; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + // GRBW + if (mask & nGreen) { + BIT_SET(m_pBuffer1[k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[k + j], nPortIndex); + } + + if (mask & nRed) { + BIT_SET(m_pBuffer1[8 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[8 + k + j], nPortIndex); + } + + if (mask & nBlue) { + BIT_SET(m_pBuffer1[16 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[16 + k + j], nPortIndex); + } + + if (mask & nWhite) { + BIT_SET(m_pBuffer1[24 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[24 + k + j], nPortIndex); + } + + j++; + } + } void SetColourWS2801(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nColour1, uint8_t nColour2, uint8_t nColour3) { SetColour(nPortIndex, nPixelIndex, nColour1, nColour2, nColour3); } - void SetPixel4Bytes(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite); + void SetPixel4Bytes(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite) { + const auto k = nPixelIndex * pixel::single::RGBW; + uint32_t j = 0; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + // GRBW + if (mask & nGreen) { + BIT_SET(m_pBuffer1[k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[k + j], nPortIndex); + } + + if (mask & nRed) { + BIT_SET(m_pBuffer1[8 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[8 + k + j], nPortIndex); + } + + if (mask & nBlue) { + BIT_SET(m_pBuffer1[16 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[16 + k + j], nPortIndex); + } + + if (mask & nWhite) { + BIT_SET(m_pBuffer1[24 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[24 + k + j], nPortIndex); + } + + j++; + } + } bool IsUpdating() { return h3_spi_dma_tx_is_active(); // returns TRUE while DMA operation is active } @@ -72,19 +148,43 @@ class WS28xxMulti { void SetupSPI(uint32_t nSpeedHz); bool SetupCPLD(); void SetupBuffers(); - void SetColour(const uint32_t nPortIndex, const uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue); + + void SetColour(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nColour1, uint8_t nColour2, uint8_t nColour3) { + uint32_t j = 0; + const uint32_t k = nPixelIndex * pixel::single::RGB; + + for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { + if (mask & nColour1) { + BIT_SET(m_pBuffer1[k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[k + j], nPortIndex); + } + if (mask & nColour2) { + BIT_SET(m_pBuffer1[8 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[8 + k + j], nPortIndex); + } + if (mask & nColour3) { + BIT_SET(m_pBuffer1[16 + k + j], nPortIndex); + } else { + BIT_CLEAR(m_pBuffer1[16 + k + j], nPortIndex); + } + + j++; + } + } private: - bool m_hasCPLD { false }; uint32_t m_nBufSize { 0 }; - uint8_t *const m_pBuffer { reinterpret_cast(H3_SRAM_A1_BASE + 4096) }; - uint8_t *m_pDmaBuffer { nullptr }; - uint8_t *m_pDmaBufferBlackout { nullptr }; + uint8_t *m_pBuffer1 { nullptr }; + uint8_t *m_pBuffer2 { nullptr }; JamSTAPLDisplay *m_pJamSTAPLDisplay { nullptr }; - static WS28xxMulti *s_pThis; + bool m_hasCPLD { false }; + + static inline WS28xxMulti *s_pThis; }; #endif /* SPI_WS28XXMULTI_H_ */ diff --git a/lib-ws28xx/include/pixelpatterns.h b/lib-ws28xx/include/pixelpatterns.h index a100e9916..b4f427c58 100644 --- a/lib-ws28xx/include/pixelpatterns.h +++ b/lib-ws28xx/include/pixelpatterns.h @@ -69,10 +69,6 @@ class PixelPatterns { void None(const uint32_t nPortIndex) { s_PortConfig[nPortIndex].ActivePattern = pixelpatterns::Pattern::NONE; Clear(nPortIndex); - while (s_pOutput->IsUpdating()) { - - } - s_pOutput->Update(); } void Run() { diff --git a/lib-ws28xx/src/h3/ws28xxmulti.cpp b/lib-ws28xx/src/h3/ws28xxmulti.cpp old mode 100644 new mode 100755 index cfe2ceab3..3571fa8aa --- a/lib-ws28xx/src/h3/ws28xxmulti.cpp +++ b/lib-ws28xx/src/h3/ws28xxmulti.cpp @@ -52,8 +52,6 @@ using namespace pixel; -WS28xxMulti *WS28xxMulti::s_pThis; - WS28xxMulti::WS28xxMulti() { DEBUG_ENTRY @@ -103,8 +101,8 @@ WS28xxMulti::WS28xxMulti() { } WS28xxMulti::~WS28xxMulti() { - m_pDmaBufferBlackout = nullptr; - m_pDmaBuffer = nullptr; + m_pBuffer1 = nullptr; + m_pBuffer2 = nullptr; s_pThis = nullptr; } @@ -114,42 +112,17 @@ void WS28xxMulti::SetupBuffers() { uint32_t nSize; - m_pDmaBuffer = const_cast(FUNC_PREFIX(spi_dma_tx_prepare(&nSize))); - assert(m_pDmaBuffer != nullptr); - - const uint32_t nSizeHalf = nSize / 2; - assert(m_nBufSize <= nSizeHalf); - - m_pDmaBufferBlackout = m_pDmaBuffer + (nSizeHalf & static_cast(~3)); + m_pBuffer1 = const_cast(FUNC_PREFIX(spi_dma_tx_prepare(&nSize))); + assert(m_pBuffer1 != nullptr); - auto& pixelConfiguration = PixelConfiguration::Get(); - - const auto type = pixelConfiguration.GetType(); - const auto nCount = pixelConfiguration.GetCount(); + memset(m_pBuffer1, 0, nSize); - if ((type == Type::APA102) || (type == Type::SK9822) || (type == Type::P9813)) { - DEBUG_PUTS("SPI"); - - for (uint32_t nPortIndex = 0; nPortIndex < 8; nPortIndex++) { - SetPixel4Bytes(nPortIndex, 0, 0, 0, 0, 0); - - for (uint32_t nPixelIndex = 1; nPixelIndex <= nCount; nPixelIndex++) { - SetPixel4Bytes(nPortIndex, nPixelIndex, 0, 0xE0, 0, 0); - } - - if ((type == Type::APA102) || (type == Type::SK9822)) { - SetPixel4Bytes(nPortIndex, 1U + nCount, 0xFF, 0xFF, 0xFF, 0xFF); - } else { - SetPixel4Bytes(nPortIndex, 1U + nCount, 0, 0, 0, 0); - } - } + const auto nSizeHalf = nSize / 2; + assert(m_nBufSize <= nSizeHalf); - memcpy(m_pDmaBufferBlackout, m_pBuffer, m_nBufSize); - } else { - memset(m_pDmaBufferBlackout, 0, m_nBufSize); - } + m_pBuffer2 = m_pBuffer1 + (nSizeHalf & static_cast(~3)); - DEBUG_PRINTF("nSize=%x, m_pDmaBuffer=%p, m_pDmaBufferBlackout=%p", nSize, m_pDmaBuffer, m_pDmaBufferBlackout); + DEBUG_PRINTF("nSize=%x, m_pBuffer1=%p, m_pBuffer2=%p", nSize, m_pBuffer1, m_pBuffer2); DEBUG_EXIT } @@ -225,128 +198,6 @@ uint8_t WS28xxMulti::ReverseBits(uint8_t nBits) { return static_cast((output >> 24)); } -#define BIT_SET(a,b) ((a) |= static_cast((1<<(b)))) -#define BIT_CLEAR(a,b) ((a) &= static_cast(~(1<<(b)))) - -void WS28xxMulti::SetColour(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nColour1, uint8_t nColour2, uint8_t nColour3) { - uint32_t j = 0; - const uint32_t k = nPixelIndex * pixel::single::RGB; - - for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { - if (mask & nColour1) { - BIT_SET(m_pBuffer[k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[k + j], nPortIndex); - } - if (mask & nColour2) { - BIT_SET(m_pBuffer[8 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[8 + k + j], nPortIndex); - } - if (mask & nColour3) { - BIT_SET(m_pBuffer[16 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[16 + k + j], nPortIndex); - } - - j++; - } -} - -void WS28xxMulti::SetPixel4Bytes(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite) { - const auto k = nPixelIndex * pixel::single::RGBW; - uint32_t j = 0; - - for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { - // GRBW - if (mask & nGreen) { - BIT_SET(m_pBuffer[k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[k + j], nPortIndex); - } - - if (mask & nRed) { - BIT_SET(m_pBuffer[8 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[8 + k + j], nPortIndex); - } - - if (mask & nBlue) { - BIT_SET(m_pBuffer[16 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[16 + k + j], nPortIndex); - } - - if (mask & nWhite) { - BIT_SET(m_pBuffer[24 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[24 + k + j], nPortIndex); - } - - j++; - } -} - -void WS28xxMulti::SetColourRTZ(uint32_t nPortIndex, uint32_t nPixelIndex, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, uint8_t nWhite) { -#if defined(CONFIG_PIXELDMX_ENABLE_GAMMATABLE) - const auto pGammaTable = m_PixelConfiguration.GetGammaTable(); - - nRed = pGammaTable[nRed]; - nGreen = pGammaTable[nGreen]; - nBlue = pGammaTable[nBlue]; - nWhite = pGammaTable[nWhite]; -#endif - - const auto k = nPixelIndex * pixel::single::RGBW; - uint32_t j = 0; - - for (uint8_t mask = 0x80; mask != 0; mask = static_cast(mask >> 1)) { - // GRBW - if (mask & nGreen) { - BIT_SET(m_pBuffer[k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[k + j], nPortIndex); - } - - if (mask & nRed) { - BIT_SET(m_pBuffer[8 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[8 + k + j], nPortIndex); - } - - if (mask & nBlue) { - BIT_SET(m_pBuffer[16 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[16 + k + j], nPortIndex); - } - - if (mask & nWhite) { - BIT_SET(m_pBuffer[24 + k + j], nPortIndex); - } else { - BIT_CLEAR(m_pBuffer[24 + k + j], nPortIndex); - } - - j++; - } -} - -inline void memcpy64(void *dest, void const *src, size_t n) { - auto *plDst = reinterpret_cast(dest); - const auto *plSrc = reinterpret_cast(src); - - while (n >= 8) { - *plDst++ = *plSrc++; - n -= 8; - } - - auto *pcDst = reinterpret_cast(plDst); - const auto *pcSrc = reinterpret_cast(plSrc); - - while (n--) { - *pcDst++ = *pcSrc++; - } -} - void WS28xxMulti::Update() { assert(!FUNC_PREFIX(spi_dma_tx_is_active())); @@ -354,22 +205,48 @@ void WS28xxMulti::Update() { asm volatile ("isb" ::: "memory"); } while (FUNC_PREFIX(spi_dma_tx_is_active())); - memcpy64(m_pDmaBuffer, reinterpret_cast(H3_SRAM_A1_BASE + 4096), m_nBufSize); + auto *pTmp = m_pBuffer1; + m_pBuffer1 = m_pBuffer2; + m_pBuffer2 = pTmp; + __DMB(); - FUNC_PREFIX(spi_dma_tx_start(m_pDmaBuffer, m_nBufSize)); + FUNC_PREFIX(spi_dma_tx_start(m_pBuffer2, m_nBufSize)); } void WS28xxMulti::Blackout() { DEBUG_ENTRY + auto& pixelConfiguration = PixelConfiguration::Get(); + + const auto type = pixelConfiguration.GetType(); + const auto nCount = pixelConfiguration.GetCount(); + + if ((type == Type::APA102) || (type == Type::SK9822) || (type == Type::P9813)) { + for (uint32_t nPortIndex = 0; nPortIndex < 8; nPortIndex++) { + SetPixel4Bytes(nPortIndex, 0, 0, 0, 0, 0); + + for (uint32_t nPixelIndex = 1; nPixelIndex <= nCount; nPixelIndex++) { + SetPixel4Bytes(nPortIndex, nPixelIndex, 0, 0xE0, 0, 0); + } + + if ((type == Type::APA102) || (type == Type::SK9822)) { + SetPixel4Bytes(nPortIndex, 1U + nCount, 0xFF, 0xFF, 0xFF, 0xFF); + } else { + SetPixel4Bytes(nPortIndex, 1U + nCount, 0, 0, 0, 0); + } + } + } else { + memset(m_pBuffer1, 0, m_nBufSize); + } + // Can be called any time. do { asm volatile ("isb" ::: "memory"); } while (FUNC_PREFIX(spi_dma_tx_is_active())); - FUNC_PREFIX(spi_dma_tx_start(m_pDmaBufferBlackout, m_nBufSize)); + Update(); - // A blackout may not be interrupted. + // May not be interrupted. do { asm volatile ("isb" ::: "memory"); } while (FUNC_PREFIX(spi_dma_tx_is_active())); @@ -380,21 +257,15 @@ void WS28xxMulti::Blackout() { void WS28xxMulti::FullOn() { DEBUG_ENTRY - // Can be called any time. - do { - asm volatile ("isb" ::: "memory"); - } while (FUNC_PREFIX(spi_dma_tx_is_active())); - auto& pixelConfiguration = PixelConfiguration::Get(); const auto type = pixelConfiguration.GetType(); + const auto nCount = pixelConfiguration.GetCount(); if ((type == Type::APA102) || (type == Type::SK9822) || (type == Type::P9813)) { for (uint32_t nPortIndex = 0; nPortIndex < 8; nPortIndex++) { SetPixel4Bytes(nPortIndex, 0, 0, 0, 0, 0); - const auto nCount = pixelConfiguration.GetCount(); - for (uint32_t nPixelIndex = 1; nPixelIndex <= nCount; nPixelIndex++) { SetPixel4Bytes(nPortIndex, nPixelIndex, 0xFF, 0xE0, 0xFF, 0xFF); } @@ -406,9 +277,14 @@ void WS28xxMulti::FullOn() { } } } else { - memset(m_pBuffer, 0xFF, m_nBufSize); + memset(m_pBuffer1, 0xFF, m_nBufSize); } + // Can be called any time. + do { + asm volatile ("isb" ::: "memory"); + } while (FUNC_PREFIX(spi_dma_tx_is_active())); + Update(); // May not be interrupted. diff --git a/lib-ws28xx/src/pixeltype.cpp b/lib-ws28xx/src/pixeltype.cpp index bcb10b1ea..a0baa0fc3 100644 --- a/lib-ws28xx/src/pixeltype.cpp +++ b/lib-ws28xx/src/pixeltype.cpp @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if defined(__GNUC__) && !defined(__clang__) ///< Needed for macOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/opi_emac_artnet_dmx/firmware/main.cpp b/opi_emac_artnet_dmx/firmware/main.cpp index c38e8c932..8b1a80179 100644 --- a/opi_emac_artnet_dmx/firmware/main.cpp +++ b/opi_emac_artnet_dmx/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -60,12 +60,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { Dmx::Get()->Blackout(); ArtNetNode::Get()->Stop(); @@ -75,9 +69,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -98,9 +90,8 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - const auto nDmxPortIndex = nPortIndex - artnetnode::configstore::DMXPORT_OFFSET; const auto portDirection = (node.GetPortDirection(nPortIndex) == lightset::PortDir::OUTPUT ? dmx::PortDirection::OUTP : dmx::PortDirection::INP); - dmx.SetPortDirection(nDmxPortIndex, portDirection , false); + dmx.SetPortDirection(nPortIndex, portDirection , false); DmxSend dmxSend; dmxSend.Print(); @@ -157,7 +148,7 @@ int main() { while (configStore.Flash()) ; - mdns_print(); // mDns.Print(); + mdns_print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -176,7 +167,6 @@ int main() { #endif remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_dmx_multi/Makefile.H3 b/opi_emac_artnet_dmx_multi/Makefile.H3 index 0812e13db..9f084c660 100644 --- a/opi_emac_artnet_dmx_multi/Makefile.H3 +++ b/opi_emac_artnet_dmx_multi/Makefile.H3 @@ -29,7 +29,7 @@ endif DEFINES+=DISABLE_RTC -DEFINES+=NDEBUG +#DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_dmx_multi/firmware/main.cpp b/opi_emac_artnet_dmx_multi/firmware/main.cpp index 4e47cc95e..170b9802c 100644 --- a/opi_emac_artnet_dmx_multi/firmware/main.cpp +++ b/opi_emac_artnet_dmx_multi/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -60,12 +60,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { Dmx::Get()->Blackout(); ArtNetNode::Get()->Stop(); @@ -75,9 +69,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -99,10 +91,9 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - for (uint32_t nPortIndex = artnetnode::configstore::DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { - const auto nDmxPortIndex = nPortIndex - artnetnode::configstore::DMXPORT_OFFSET; + for (uint32_t nPortIndex = 0; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { const auto portDirection = (node.GetPortDirection(nPortIndex) == lightset::PortDir::OUTPUT ? dmx::PortDirection::OUTP : dmx::PortDirection::INP); - dmx.SetPortDirection(nDmxPortIndex, portDirection , false); + dmx.SetPortDirection(nPortIndex, portDirection , false); } DmxSend dmxSend; @@ -161,7 +152,7 @@ int main() { while (configStore.Flash()) ; - mdns_print(); // mDns.Print(); + mdns_print(); display.TextStatus(ArtNetMsgConst::START, CONSOLE_YELLOW); @@ -180,7 +171,7 @@ int main() { #endif remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_pixel/Makefile.H3 b/opi_emac_artnet_pixel/Makefile.H3 index beba8120e..69cd968b3 100644 --- a/opi_emac_artnet_pixel/Makefile.H3 +++ b/opi_emac_artnet_pixel/Makefile.H3 @@ -7,7 +7,9 @@ DEFINES+=ARTNET_HAVE_FAILSAFE_RECORD DEFINES+=NODE_RDMNET_LLRP_ONLY DEFINES+=OUTPUT_DMX_PIXEL + DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 +DEFINES+=CONFIG_DMX_PORT_OFFSET=4 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA @@ -20,11 +22,8 @@ DEFINES+=DISPLAY_UDF DEFINES+=ENABLE_HTTPD ENABLE_CONTENT -DEFINES+=DISABLE_RTC +DEFINES+=DISABLE_RTC -DEFINES+=DEBUG_PIXEL -DEFINES+=DEBUG_STACK -DEFINES+=DEBUG_HEAP DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_pixel/firmware/main.cpp b/opi_emac_artnet_pixel/firmware/main.cpp index f86fe48dd..a73f5203a 100644 --- a/opi_emac_artnet_pixel/firmware/main.cpp +++ b/opi_emac_artnet_pixel/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -70,12 +70,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 4; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { WS28xx::Get()->Blackout(); ArtNetNode::Get()->Stop(); @@ -85,9 +79,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_artnet_pixel_dmx/Makefile.H3 b/opi_emac_artnet_pixel_dmx/Makefile.H3 index 34ed95cf9..f1a7b03c7 100644 --- a/opi_emac_artnet_pixel_dmx/Makefile.H3 +++ b/opi_emac_artnet_pixel_dmx/Makefile.H3 @@ -10,6 +10,7 @@ DEFINES+=OUTPUT_DMX_PIXEL DEFINES+=OUTPUT_DMX_SEND OUTPUT_HAVE_STYLESWITCH DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 +DEFINES+=CONFIG_DMX_PORT_OFFSET=4 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA @@ -18,7 +19,7 @@ DEFINES+=CONFIG_SHOWFILE_ENABLE_OSC DEFINES+=CONFIG_FS_ENABLE_WRITE SD_EXFAT_SUPPORT -DEFINES+=DISPLAY_UDF +DEFINES+=DISPLAY_UDF DEFINES+=ENABLE_HTTPD ENABLE_CONTENT diff --git a/opi_emac_artnet_pixel_dmx/firmware/main.cpp b/opi_emac_artnet_pixel_dmx/firmware/main.cpp index e9f3ec805..40659d812 100644 --- a/opi_emac_artnet_pixel_dmx/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -75,12 +75,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 4; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { WS28xx::Get()->Blackout(); Dmx::Get()->Blackout(); @@ -91,9 +85,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -137,7 +129,7 @@ int main() { uint32_t nDmxUniverses = 0; if (artnetParams.GetDirection(0) == lightset::PortDir::OUTPUT) { - node.SetUniverse(artnetnode::configstore::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, artnetParams.GetUniverse(0)); + node.SetUniverse(dmxsend::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, artnetParams.GetUniverse(0)); nDmxUniverses = 1; } @@ -147,7 +139,7 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - if (node.GetPortDirection(artnetnode::configstore::DMXPORT_OFFSET) == lightset::PortDir::OUTPUT) { + if (node.GetPortDirection(dmxsend::DMXPORT_OFFSET) == lightset::PortDir::OUTPUT) { dmx.SetPortDirection(0, dmx::PortDirection::OUTP, false); } diff --git a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 index 259cb6c7c..5c2aa6d31 100644 --- a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 +++ b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 @@ -10,6 +10,7 @@ DEFINES+=OUTPUT_DMX_PIXEL_MULTI PIXELPATTERNS_MULTI DEFINES+=OUTPUT_DMX_SEND_MULTI DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=8 +DEFINES+=CONFIG_DMX_PORT_OFFSET=32 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA @@ -25,7 +26,13 @@ DEFINES+=ENABLE_HTTPD ENABLE_CONTENT DEFINES+=DISABLE_RTC -DEFINES+=NDEBUG +DEFINES+=CONFIG_CLIB_ASSERT_REBOOT + +#DEFINES+=DEBUG_DISPLAY +#DEFINES+=DEBUG_DISPLAYUDF +DEFINES+=DEBUG_DMX + +#DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp index c4f304756..d484b4d2d 100644 --- a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -79,12 +79,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 32; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { WS28xxMulti::Get()->Blackout(); Dmx::Get()->Blackout(); @@ -95,9 +89,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -147,8 +139,8 @@ int main() { uint32_t nDmxUniverses = 0; - for (uint32_t nPortIndex = artnetnode::configstore::DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { - const auto nDmxPortIndex = nPortIndex - artnetnode::configstore::DMXPORT_OFFSET; + for (uint32_t nPortIndex = dmxsend::DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { + const auto nDmxPortIndex = nPortIndex - dmxsend::DMXPORT_OFFSET; const auto portDirection = artnetParams.GetDirection(nDmxPortIndex); if (portDirection == lightset::PortDir::OUTPUT) { @@ -164,8 +156,8 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - for (uint32_t nPortIndex = artnetnode::configstore::DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { - const auto nDmxPortIndex = nPortIndex - artnetnode::configstore::DMXPORT_OFFSET; + for (uint32_t nPortIndex = dmxsend::DMXPORT_OFFSET; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { + const auto nDmxPortIndex = nPortIndex - dmxsend::DMXPORT_OFFSET; if (node.GetPortDirection(nPortIndex) == lightset::PortDir::OUTPUT) { dmx.SetPortDirection(nDmxPortIndex, dmx::PortDirection::OUTP, false); diff --git a/opi_emac_artnet_pixel_multi/Makefile.H3 b/opi_emac_artnet_pixel_multi/Makefile.H3 index c0ba70e1c..0baa7fd9f 100755 --- a/opi_emac_artnet_pixel_multi/Makefile.H3 +++ b/opi_emac_artnet_pixel_multi/Makefile.H3 @@ -7,7 +7,9 @@ DEFINES+=ARTNET_HAVE_FAILSAFE_RECORD DEFINES+=NODE_RDMNET_LLRP_ONLY DEFINES+=OUTPUT_DMX_PIXEL_MULTI PIXELPATTERNS_MULTI + DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=8 +DEFINES+=CONFIG_DMX_PORT_OFFSET=32 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA @@ -17,13 +19,12 @@ DEFINES+=CONFIG_SHOWFILE_DISABLE_RECORD DEFINES+=CONFIG_FS_ENABLE_WRITE SD_EXFAT_SUPPORT -DEFINES+=DISPLAY_UDF +DEFINES+=DISPLAY_UDF DEFINES+=ENABLE_HTTPD ENABLE_CONTENT DEFINES+=DISABLE_RTC -#DEFINES+=LOGIC_ANALYZER DO_NOT_USE_EXTERNAL_LED DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_pixel_multi/firmware/main.cpp b/opi_emac_artnet_pixel_multi/firmware/main.cpp index fdd18bb20..57d9104c4 100644 --- a/opi_emac_artnet_pixel_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_multi/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -72,12 +72,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 32; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { WS28xxMulti::Get()->Blackout(); ArtNetNode::Get()->Stop(); @@ -87,9 +81,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_e131_pixel/Makefile.H3 b/opi_emac_e131_pixel/Makefile.H3 index de75f941c..dd0cc4b77 100644 --- a/opi_emac_e131_pixel/Makefile.H3 +++ b/opi_emac_e131_pixel/Makefile.H3 @@ -5,7 +5,9 @@ DEFINES =NODE_E131 LIGHTSET_PORTS=4 DEFINES+=NODE_RDMNET_LLRP_ONLY DEFINES+=OUTPUT_DMX_PIXEL + DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 +DEFINES+=CONFIG_DMX_PORT_OFFSET=4 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA diff --git a/opi_emac_e131_pixel/firmware/main.cpp b/opi_emac_e131_pixel/firmware/main.cpp index d2e494acc..660a00abb 100644 --- a/opi_emac_e131_pixel/firmware/main.cpp +++ b/opi_emac_e131_pixel/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -69,12 +69,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 4; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { WS28xx::Get()->Blackout(); E131Bridge::Get()->Stop(); @@ -84,9 +78,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_e131_pixel_dmx/Makefile.H3 b/opi_emac_e131_pixel_dmx/Makefile.H3 index 5d6ff7bed..59c023a3f 100644 --- a/opi_emac_e131_pixel_dmx/Makefile.H3 +++ b/opi_emac_e131_pixel_dmx/Makefile.H3 @@ -8,6 +8,7 @@ DEFINES+=OUTPUT_DMX_PIXEL DEFINES+=OUTPUT_DMX_SEND OUTPUT_HAVE_STYLESWITCH DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1 +DEFINES+=CONFIG_DMX_PORT_OFFSET=4 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA diff --git a/opi_emac_e131_pixel_dmx/firmware/main.cpp b/opi_emac_e131_pixel_dmx/firmware/main.cpp index 708eb3d45..faa5278da 100644 --- a/opi_emac_e131_pixel_dmx/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -74,12 +74,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 4; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { WS28xx::Get()->Blackout(); Dmx::Get()->Blackout(); @@ -90,9 +84,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -134,7 +126,7 @@ int main() { const auto portDirection = e131params.GetDirection(0); if (portDirection == lightset::PortDir::OUTPUT) { - bridge.SetUniverse(e131bridge::configstore::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, e131params.GetUniverse(0, isDmxUniverseSet)); + bridge.SetUniverse(dmxsend::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, e131params.GetUniverse(0, isDmxUniverseSet)); } Dmx dmx; @@ -145,7 +137,7 @@ int main() { uint16_t nUniverse; - if (bridge.GetUniverse(e131bridge::configstore::DMXPORT_OFFSET, nUniverse, lightset::PortDir::OUTPUT)) { + if (bridge.GetUniverse(dmxsend::DMXPORT_OFFSET, nUniverse, lightset::PortDir::OUTPUT)) { dmx.SetPortDirection(0, dmx::PortDirection::OUTP, false); } else { dmx.SetPortDirection(0, dmx::PortDirection::INP, false); diff --git a/opi_emac_e131_pixel_dmx_multi/Makefile.H3 b/opi_emac_e131_pixel_dmx_multi/Makefile.H3 index 6b32a4c34..a39c74414 100644 --- a/opi_emac_e131_pixel_dmx_multi/Makefile.H3 +++ b/opi_emac_e131_pixel_dmx_multi/Makefile.H3 @@ -8,6 +8,7 @@ DEFINES+=OUTPUT_DMX_PIXEL_MULTI PIXELPATTERNS_MULTI DEFINES+=OUTPUT_DMX_SEND_MULTI DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=8 +DEFINES+=CONFIG_DMX_PORT_OFFSET=32 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA diff --git a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp index 243c0d39b..1b81d757b 100644 --- a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -78,12 +78,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 32; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { WS28xxMulti::Get()->Blackout(); Dmx::Get()->Blackout(); @@ -94,9 +88,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -148,7 +140,7 @@ int main() { auto direction = e131params.GetDirection(0); if (direction == lightset::PortDir::OUTPUT) { - bridge.SetUniverse(e131bridge::configstore::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, nUniverse); + bridge.SetUniverse(dmxsend::DMXPORT_OFFSET, lightset::PortDir::OUTPUT, nUniverse); nDmxUniverses++; } @@ -156,7 +148,7 @@ int main() { direction = e131params.GetDirection(1); if (direction == lightset::PortDir::OUTPUT) { - bridge.SetUniverse(e131bridge::configstore::DMXPORT_OFFSET + 1U, lightset::PortDir::OUTPUT, nUniverse); + bridge.SetUniverse(dmxsend::DMXPORT_OFFSET + 1U, lightset::PortDir::OUTPUT, nUniverse); nDmxUniverses++; } @@ -166,9 +158,9 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - for (uint32_t nPortIndex = e131bridge::configstore::DMXPORT_OFFSET; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { + for (uint32_t nPortIndex = dmxsend::DMXPORT_OFFSET; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { uint16_t nUniverse; - const auto nDmxPortIndex = nPortIndex - e131bridge::configstore::DMXPORT_OFFSET; + const auto nDmxPortIndex = nPortIndex - dmxsend::DMXPORT_OFFSET; if (bridge.GetUniverse(nPortIndex, nUniverse, lightset::PortDir::OUTPUT)) { dmx.SetPortDirection(nDmxPortIndex, dmx::PortDirection::OUTP, false); diff --git a/opi_emac_e131_pixel_multi/Makefile.H3 b/opi_emac_e131_pixel_multi/Makefile.H3 index d8c658750..cda528ad0 100644 --- a/opi_emac_e131_pixel_multi/Makefile.H3 +++ b/opi_emac_e131_pixel_multi/Makefile.H3 @@ -5,7 +5,9 @@ DEFINES =NODE_E131_MULTI LIGHTSET_PORTS=32 DEFINES+=NODE_RDMNET_LLRP_ONLY DEFINES+=OUTPUT_DMX_PIXEL_MULTI PIXELPATTERNS_MULTI + DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=8 +DEFINES+=CONFIG_DMX_PORT_OFFSET=32 DEFINES+=NODE_SHOWFILE DEFINES+=CONFIG_SHOWFILE_FORMAT_OLA @@ -15,13 +17,12 @@ DEFINES+=CONFIG_SHOWFILE_DISABLE_RECORD DEFINES+=CONFIG_FS_ENABLE_WRITE SD_EXFAT_SUPPORT -DEFINES+=DISPLAY_UDF +DEFINES+=DISPLAY_UDF DEFINES+=ENABLE_HTTPD ENABLE_CONTENT DEFINES+=DISABLE_RTC -#DEFINES+=LOGIC_ANALYZER DO_NOT_USE_EXTERNAL_LED DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_e131_pixel_multi/firmware/main.cpp b/opi_emac_e131_pixel_multi/firmware/main.cpp index 4d35c1ede..2a205ba46 100644 --- a/opi_emac_e131_pixel_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_multi/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -72,12 +72,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 32; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { WS28xxMulti::Get()->Blackout(); E131Bridge::Get()->Stop(); @@ -87,9 +81,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; From e7389214434fe3e3f6fae2b0ddd206735b580d4e Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:29:30 +0100 Subject: [PATCH 24/36] Removed rdmsoftwareversion.cpp - The same is available in class FirmwareVersion --- lib-hal/Rules.mk | 1 - lib-hal/include/firmwareversion.h | 15 ++++--- lib-hal/src/firmwareversion.cpp | 18 +++----- lib-rdm/.cproject | 15 +++++++ lib-rdm/.settings/language.settings.xml | 2 +- lib-rdm/example/rdmsoftwareversion.cpp | 43 ------------------- lib-rdm/include/rdmdeviceresponder.h | 20 ++++----- lib-rdm/include/rdmsoftwareversion.h | 38 ---------------- lib-rdm/src/rdmdeviceparams.cpp | 7 +-- lib-rdm/src/rdmdeviceresponder.cpp | 18 +++----- linux_artnet/Makefile | 4 +- linux_artnet/lib/rdmsoftwareversion.cpp | 43 ------------------- linux_artnet/src/main.cpp | 29 +++++-------- linux_ddp/lib/rdmsoftwareversion.cpp | 43 ------------------- linux_e131/lib/rdmsoftwareversion.cpp | 43 ------------------- linux_e131/src/main.cpp | 6 +-- linux_osc/lib/rdmsoftwareversion.cpp | 43 ------------------- linux_pp/lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_artnet_rdm_l6470/firmware/main.cpp | 13 +----- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_artnet_rdm_pca9685/firmware/main.cpp | 13 +----- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_artnet_serial/firmware/main.cpp | 12 +----- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../firmware/main.cpp | 4 +- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_ddp_pixel_multi/firmware/main.cpp | 4 +- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_e131_artnet/firmware/main.cpp | 12 +----- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_e131_dmx/firmware/main.cpp | 10 +---- opi_emac_e131_dmx/lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_e131_dmx_multi/firmware/main.cpp | 14 ++---- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_e131_monitor/firmware/main.cpp | 17 ++------ .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_llrp_tftpd/firmware/main.cpp | 15 +++---- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_ltc_smpte/firmware/main.cpp | 13 +----- opi_emac_ltc_smpte/lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_showfile_artnet/firmware/main.cpp | 6 +-- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_emac_showfile_e131/firmware/main.cpp | 5 +-- .../lib/rdmsoftwareversion.cpp | 43 ------------------- opi_midi_monitor/firmware/main.cpp | 4 -- opi_midi_monitor/lib/midimonitor.cpp | 26 +++++------ opi_rdm_responder/firmware/main.cpp | 11 +---- opi_rdm_responder/lib/rdmsoftwareversion.cpp | 43 ------------------- opi_rdm_responder_l6470/firmware/main.cpp | 13 +----- .../lib/rdmsoftwareversion.cpp | 43 ------------------- 58 files changed, 105 insertions(+), 1507 deletions(-) delete mode 100755 lib-rdm/example/rdmsoftwareversion.cpp delete mode 100644 lib-rdm/include/rdmsoftwareversion.h delete mode 100644 linux_artnet/lib/rdmsoftwareversion.cpp delete mode 100644 linux_ddp/lib/rdmsoftwareversion.cpp delete mode 100644 linux_e131/lib/rdmsoftwareversion.cpp delete mode 100644 linux_osc/lib/rdmsoftwareversion.cpp delete mode 100644 linux_pp/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_pixel/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_pixel_dmx/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_pixel_dmx_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_pixel_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_rdm_l6470/lib/rdmsoftwareversion.cpp delete mode 100755 opi_emac_artnet_rdm_pca9685/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_artnet_serial/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_ddp_pixel_dmx_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_ddp_pixel_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_artnet/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_dmx/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_dmx_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_monitor/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_pixel/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_pixel_dmx/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_pixel_dmx_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_e131_pixel_multi/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_llrp_tftpd/lib/rdmsoftwareversion.cpp delete mode 100644 opi_emac_ltc_smpte/lib/rdmsoftwareversion.cpp delete mode 100755 opi_emac_showfile_artnet/lib/rdmsoftwareversion.cpp delete mode 100755 opi_emac_showfile_e131/lib/rdmsoftwareversion.cpp delete mode 100644 opi_rdm_responder/lib/rdmsoftwareversion.cpp delete mode 100644 opi_rdm_responder_l6470/lib/rdmsoftwareversion.cpp diff --git a/lib-hal/Rules.mk b/lib-hal/Rules.mk index 6f3ba79b7..d51ef257b 100755 --- a/lib-hal/Rules.mk +++ b/lib-hal/Rules.mk @@ -53,7 +53,6 @@ ifneq ($(MAKE_FLAGS),) endif else DEFINES+=DEBUG_I2C DEBUG_STACK DEBUG_POSIX - DEFINES+=LOGIC_ANALYZER EXTRA_INCLUDES+=debug/i2c debug/stack EXTRA_SRCDIR+=console/i2c console/null console/uart0 EXTRA_SRCDIR+=posix diff --git a/lib-hal/include/firmwareversion.h b/lib-hal/include/firmwareversion.h index b2a91a232..48ed08627 100644 --- a/lib-hal/include/firmwareversion.h +++ b/lib-hal/include/firmwareversion.h @@ -2,7 +2,7 @@ * @file firmwareversion.h * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,7 +48,7 @@ struct Info { class FirmwareVersion { public: - FirmwareVersion(const char *pVersion, const char *pDate, const char *pTime); + FirmwareVersion(const char *pSoftwareVersion, const char *pDate, const char *pTime, const uint32_t nSoftwareVersionId = 0); void Print(const char *pTitle = nullptr) { puts(s_Print); @@ -70,14 +70,19 @@ class FirmwareVersion { return s_FirmwareVersion.SoftwareVersion; } + uint32_t GetVersionId() const { + return s_nSoftwareVersionId; + } + static FirmwareVersion *Get() { return s_pThis; } private: - static firmwareversion::Info s_FirmwareVersion; - static char s_Print[64]; - static FirmwareVersion *s_pThis; + const uint32_t s_nSoftwareVersionId; + static inline firmwareversion::Info s_FirmwareVersion; + static inline char s_Print[64]; + static inline FirmwareVersion *s_pThis; }; #endif /* FIRMWAREVERSION_H_ */ diff --git a/lib-hal/src/firmwareversion.cpp b/lib-hal/src/firmwareversion.cpp index 4ceaf3a0c..c500137c1 100644 --- a/lib-hal/src/firmwareversion.cpp +++ b/lib-hal/src/firmwareversion.cpp @@ -2,7 +2,7 @@ * @file firmwareversion.cpp * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include @@ -37,19 +32,16 @@ #include "hardware.h" -firmwareversion::Info FirmwareVersion::s_FirmwareVersion; -char FirmwareVersion::s_Print[64]; -FirmwareVersion *FirmwareVersion::s_pThis; - -FirmwareVersion::FirmwareVersion(const char *pVersion, const char *pDate, const char *pTime) { - assert(pVersion != nullptr); +FirmwareVersion::FirmwareVersion(const char *pSoftwareVersion, const char *pDate, const char *pTime, const uint32_t nSoftwareVersionId) : s_nSoftwareVersionId(nSoftwareVersionId) +{ + assert(pSoftwareVersion != nullptr); assert(pDate != nullptr); assert(pTime != nullptr); assert(s_pThis == nullptr); s_pThis = this; - memcpy(s_FirmwareVersion.SoftwareVersion, pVersion, firmwareversion::length::SOFTWARE_VERSION); + memcpy(s_FirmwareVersion.SoftwareVersion, pSoftwareVersion, firmwareversion::length::SOFTWARE_VERSION); memcpy(s_FirmwareVersion.BuildDate, pDate, firmwareversion::length::GCC_DATE); memcpy(s_FirmwareVersion.BuildTime, pTime, firmwareversion::length::GCC_TIME); diff --git a/lib-rdm/.cproject b/lib-rdm/.cproject index 6022f9c7d..6135ff247 100644 --- a/lib-rdm/.cproject +++ b/lib-rdm/.cproject @@ -323,6 +323,7 @@ @@ -338,6 +339,7 @@ @@ -356,6 +358,7 @@ + @@ -437,8 +440,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/lib-rdm/.settings/language.settings.xml b/lib-rdm/.settings/language.settings.xml index 0f948f1ee..ee8c79bae 100644 --- a/lib-rdm/.settings/language.settings.xml +++ b/lib-rdm/.settings/language.settings.xml @@ -26,7 +26,7 @@ - + diff --git a/lib-rdm/example/rdmsoftwareversion.cpp b/lib-rdm/example/rdmsoftwareversion.cpp deleted file mode 100755 index 6362ca556..000000000 --- a/lib-rdm/example/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion(void) { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/lib-rdm/include/rdmdeviceresponder.h b/lib-rdm/include/rdmdeviceresponder.h index ed36f5d7c..f8834b53b 100644 --- a/lib-rdm/include/rdmdeviceresponder.h +++ b/lib-rdm/include/rdmdeviceresponder.h @@ -2,7 +2,7 @@ * @file rdmdeviceresponder.h * */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,8 @@ #include "lightset.h" +#include "firmwareversion.h" + namespace rdm { namespace device { namespace responder { @@ -175,11 +177,12 @@ class RDMDeviceResponder: public RDMDevice { } // E120_SOFTWARE_VERSION_LABEL 0x00C0 - const char* GetSoftwareVersion() const { - return m_pSoftwareVersion; + const char *GetSoftwareVersion() const { + return FirmwareVersion::Get()->GetSoftwareVersion(); } - uint8_t GetSoftwareVersionLength() const { - return m_nSoftwareVersionLength; + + uint32_t GetSoftwareVersionLength() const { + return firmwareversion::length::SOFTWARE_VERSION; } // E120_DMX_START_ADDRESS 0x00F0 @@ -295,7 +298,7 @@ class RDMDeviceResponder: public RDMDevice { return m_DeviceInfo.current_personality; } - static RDMDeviceResponder* Get() { + static RDMDeviceResponder *Get() { return s_pThis; } @@ -314,17 +317,14 @@ class RDMDeviceResponder: public RDMDevice { RDMSensors m_RDMSensors; RDMSubDevices m_RDMSubDevices; RDMPersonality **m_pRDMPersonalities; - char *m_pSoftwareVersion; - uint8_t m_nSoftwareVersionLength; rdm::device::responder::DeviceInfo m_DeviceInfo; rdm::device::responder::DeviceInfo m_SubDeviceInfo; char m_aLanguage[2]; - // bool m_IsFactoryDefaults { true }; uint16_t m_nCheckSum { 0 }; uint16_t m_nDmxStartAddressFactoryDefault { lightset::dmx::START_ADDRESS_DEFAULT }; - static RDMDeviceResponder *s_pThis; + static inline RDMDeviceResponder *s_pThis; }; #endif /* RDMDEVICERESPONDER_H_ */ diff --git a/lib-rdm/include/rdmsoftwareversion.h b/lib-rdm/include/rdmsoftwareversion.h deleted file mode 100644 index 1abc0a3d7..000000000 --- a/lib-rdm/include/rdmsoftwareversion.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file rdmsoftwareversion.h - * - */ -/* Copyright (C) 2018-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 - -#ifndef RDMSOFTWAREVERSION_H_ -#define RDMSOFTWAREVERSION_H_ - -class RDMSoftwareVersion { -public: - static const char *GetVersion(); - static uint32_t GetVersionLength(); - static uint32_t GetVersionId(); -}; - -#endif /* RDMSOFTWAREVERSION_H_ */ diff --git a/lib-rdm/src/rdmdeviceparams.cpp b/lib-rdm/src/rdmdeviceparams.cpp index aa6644ffa..35421dfe6 100644 --- a/lib-rdm/src/rdmdeviceparams.cpp +++ b/lib-rdm/src/rdmdeviceparams.cpp @@ -2,7 +2,7 @@ * @file rdmdeviceparams.cpp * */ -/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-rdm/src/rdmdeviceresponder.cpp b/lib-rdm/src/rdmdeviceresponder.cpp index de51f5bc4..5c474c670 100644 --- a/lib-rdm/src/rdmdeviceresponder.cpp +++ b/lib-rdm/src/rdmdeviceresponder.cpp @@ -2,7 +2,7 @@ * @file rdmdeviceresponder.cpp * */ -/* Copyright (C) 2018-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,25 +30,20 @@ #include "rdmdeviceresponder.h" #include "rdmdevice.h" - #include "rdmsensors.h" #include "rdmsubdevices.h" - -#include "rdmsoftwareversion.h" #include "rdmpersonality.h" -#include "lightset.h" +#include "rdm_e120.h" +#include "lightset.h" +#include "firmwareversion.h" #include "hardware.h" -#include "rdm_e120.h" - #include "debug.h" static constexpr char LANGUAGE[2] = { 'e', 'n' }; -RDMDeviceResponder *RDMDeviceResponder::s_pThis; - RDMDeviceResponder::RDMDeviceResponder(RDMPersonality **pRDMPersonalities, const uint32_t nPersonalityCount, const uint32_t nCurrentPersonality) : m_pRDMPersonalities(pRDMPersonalities) { @@ -66,9 +61,6 @@ RDMDeviceResponder::RDMDeviceResponder(RDMPersonality **pRDMPersonalities, const m_DeviceInfo.personality_count = static_cast(nPersonalityCount); m_DeviceInfo.current_personality = static_cast(nCurrentPersonality); - m_pSoftwareVersion = const_cast(RDMSoftwareVersion::GetVersion()); - m_nSoftwareVersionLength = static_cast(RDMSoftwareVersion::GetVersionLength()); - assert(nCurrentPersonality != 0); const auto *pLightSet = m_pRDMPersonalities[nCurrentPersonality - 1]->GetLightSet(); @@ -85,7 +77,7 @@ void RDMDeviceResponder::Init() { RDMDevice::Init(); - const auto nSoftwareVersionId = RDMSoftwareVersion::GetVersionId(); + const auto nSoftwareVersionId = FirmwareVersion::Get()->GetVersionId(); const auto nDeviceModel = Hardware::Get()->GetBoardId(); const auto nProductCategory = RDMDevice::GetProductCategory(); const auto nSubDevices = m_RDMSubDevices.GetCount(); diff --git a/linux_artnet/Makefile b/linux_artnet/Makefile index 11396d763..b819d0658 100644 --- a/linux_artnet/Makefile +++ b/linux_artnet/Makefile @@ -4,6 +4,8 @@ DEFINES+=ARTNET_OUTPUT_STYLE_SWITCH DEFINES+=ARTNET_ENABLE_SENDDIAG DEFINES+=ARTNET_PAGE_SIZE=1 +DEFINES+=CONFIG_DMX_PORT_OFFSET=4 + DEFINES+=RDM_RESPONDER DEFINES+=CONFIG_RDMDEVICE_REVERSE_UID @@ -19,7 +21,7 @@ DEFINES+=ENABLE_HTTPD ENABLE_CONTENT DEFINES+=DISABLE_FS -DEFINES+=NDEBUG +#DEFINES+=NDEBUG SRCDIR=src lib diff --git a/linux_artnet/lib/rdmsoftwareversion.cpp b/linux_artnet/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/linux_artnet/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/linux_artnet/src/main.cpp b/linux_artnet/src/main.cpp index 2f1dd24c0..5fd235f06 100644 --- a/linux_artnet/src/main.cpp +++ b/linux_artnet/src/main.cpp @@ -31,7 +31,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "display.h" @@ -65,35 +65,28 @@ #include "firmwareversion.h" #include "software_version.h" +namespace artnetnode { +#if !defined(CONFIG_DMX_PORT_OFFSET) + static constexpr uint32_t DMXPORT_OFFSET = 0; +#else + static constexpr uint32_t DMXPORT_OFFSET = CONFIG_DMX_PORT_OFFSET; +#endif +} // namespace artnetnode + static bool keepRunning = true; void intHandler(int) { keepRunning = false; } -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - int main(int argc, char **argv) { struct sigaction act; act.sa_handler = intHandler; sigaction(SIGINT, &act, nullptr); -#ifndef NDEBUG - if (argc > 2) { - const int c = argv[2][0]; - if (isdigit(c)){ - artnetnode::configstore::DMXPORT_OFFSET = c - '0'; - } - } -#endif Hardware hw; Display display; ConfigStore configStore; Network nw(argc, argv); -// MDNS mDns; FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); hw.Print(); @@ -129,8 +122,8 @@ int main(int argc, char **argv) { for (uint32_t nPortIndex = 0; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { uint32_t nOffset = nPortIndex; - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nOffset = nPortIndex - artnetnode::configstore::DMXPORT_OFFSET; + if (nPortIndex >= artnetnode::DMXPORT_OFFSET) { + nOffset = nPortIndex - artnetnode::DMXPORT_OFFSET; } else { continue; } diff --git a/linux_ddp/lib/rdmsoftwareversion.cpp b/linux_ddp/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/linux_ddp/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/linux_e131/lib/rdmsoftwareversion.cpp b/linux_e131/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/linux_e131/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/linux_e131/src/main.cpp b/linux_e131/src/main.cpp index e6444e261..5ecb888b0 100644 --- a/linux_e131/src/main.cpp +++ b/linux_e131/src/main.cpp @@ -31,7 +31,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "display.h" #include "displayudfparams.h" @@ -64,6 +64,7 @@ #include "firmwareversion.h" #include "software_version.h" +#include "software_version_id.h" static bool keepRunning = true; @@ -93,8 +94,7 @@ int main(int argc, char **argv) { Display display; ConfigStore configStore; Network nw(argc, argv); -// MDNS mDns; - FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); + FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__, DEVICE_SOFTWARE_VERSION_ID); hw.Print(); fw.Print(); diff --git a/linux_osc/lib/rdmsoftwareversion.cpp b/linux_osc/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/linux_osc/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/linux_pp/lib/rdmsoftwareversion.cpp b/linux_pp/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/linux_pp/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_pixel/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_pixel/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 7f3c94a39..000000000 --- a/opi_emac_artnet_pixel/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_pixel_dmx/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_pixel_dmx/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_artnet_pixel_dmx/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_pixel_dmx_multi/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_pixel_dmx_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_artnet_pixel_dmx_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_pixel_multi/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_pixel_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_artnet_pixel_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_rdm_l6470/firmware/main.cpp b/opi_emac_artnet_rdm_l6470/firmware/main.cpp index 179bb9ee5..08e76dcc7 100644 --- a/opi_emac_artnet_rdm_l6470/firmware/main.cpp +++ b/opi_emac_artnet_rdm_l6470/firmware/main.cpp @@ -29,7 +29,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -77,12 +77,6 @@ #include "displayhandler.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { ArtNetNode::Get()->Stop(); } @@ -91,14 +85,11 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("Art-Net 4 Stepper L6470"); - NtpClient ntpClient; ntpClient.Start(); @@ -246,7 +237,7 @@ int main() { ntpClient.Run(); remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_rdm_l6470/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_rdm_l6470/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 6275fea7f..000000000 --- a/opi_emac_artnet_rdm_l6470/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_rdm_pca9685/firmware/main.cpp b/opi_emac_artnet_rdm_pca9685/firmware/main.cpp index 08ff9b126..e1a683166 100755 --- a/opi_emac_artnet_rdm_pca9685/firmware/main.cpp +++ b/opi_emac_artnet_rdm_pca9685/firmware/main.cpp @@ -29,7 +29,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -72,12 +72,6 @@ #include "displayhandler.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { ArtNetNode::Get()->Stop(); } @@ -86,14 +80,11 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("Art-Net 4 PCA9685"); - NtpClient ntpClient; ntpClient.Start(); @@ -203,7 +194,7 @@ int main() { ntpClient.Run(); remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_rdm_pca9685/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_rdm_pca9685/lib/rdmsoftwareversion.cpp deleted file mode 100755 index 6275fea7f..000000000 --- a/opi_emac_artnet_rdm_pca9685/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_artnet_serial/firmware/main.cpp b/opi_emac_artnet_serial/firmware/main.cpp index 7b16afbc6..4b2b63bf3 100644 --- a/opi_emac_artnet_serial/firmware/main.cpp +++ b/opi_emac_artnet_serial/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -62,12 +62,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { ArtNetNode::Get()->Stop(); } @@ -76,9 +70,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -186,7 +178,7 @@ int main() { llrpOnlyDevice.Run(); remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_serial/lib/rdmsoftwareversion.cpp b/opi_emac_artnet_serial/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_artnet_serial/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp index ec51f4713..7c6982f8e 100644 --- a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp @@ -29,7 +29,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -81,9 +81,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_ddp_pixel_dmx_multi/lib/rdmsoftwareversion.cpp b/opi_emac_ddp_pixel_dmx_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_ddp_pixel_dmx_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_ddp_pixel_multi/firmware/main.cpp b/opi_emac_ddp_pixel_multi/firmware/main.cpp index 4b2b626bc..6ebd92489 100644 --- a/opi_emac_ddp_pixel_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_multi/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -76,9 +76,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_ddp_pixel_multi/lib/rdmsoftwareversion.cpp b/opi_emac_ddp_pixel_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_ddp_pixel_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_artnet/firmware/main.cpp b/opi_emac_e131_artnet/firmware/main.cpp index 079e08eb6..07f1db1a5 100644 --- a/opi_emac_e131_artnet/firmware/main.cpp +++ b/opi_emac_e131_artnet/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -58,12 +58,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { E131Bridge::Get()->Stop(); } @@ -72,9 +66,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -181,7 +173,7 @@ int main() { remoteConfig.Run(); llrpOnlyDevice.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_e131_artnet/lib/rdmsoftwareversion.cpp b/opi_emac_e131_artnet/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_e131_artnet/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_dmx/firmware/main.cpp b/opi_emac_e131_dmx/firmware/main.cpp index c9741c238..2562c2a7e 100644 --- a/opi_emac_e131_dmx/firmware/main.cpp +++ b/opi_emac_e131_dmx/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -67,12 +67,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { Dmx::Get()->Blackout(); E131Bridge::Get()->Stop(); @@ -82,9 +76,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; diff --git a/opi_emac_e131_dmx/lib/rdmsoftwareversion.cpp b/opi_emac_e131_dmx/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_e131_dmx/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_dmx_multi/firmware/main.cpp b/opi_emac_e131_dmx_multi/firmware/main.cpp index 61149bac4..c07a8842e 100644 --- a/opi_emac_e131_dmx_multi/firmware/main.cpp +++ b/opi_emac_e131_dmx_multi/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -67,12 +67,6 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace e131bridge - void Hardware::RebootHandler() { Dmx::Get()->Blackout(); E131Bridge::Get()->Stop(); @@ -82,9 +76,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -109,9 +101,9 @@ int main() { dmxparams.Load(); dmxparams.Set(&dmx); - for (uint32_t nPortIndex = e131bridge::configstore::DMXPORT_OFFSET; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { + for (uint32_t nPortIndex = dmxsend::DMXPORT_OFFSET; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { uint16_t nUniverse; - const auto nDmxPortIndex = nPortIndex - e131bridge::configstore::DMXPORT_OFFSET; + const auto nDmxPortIndex = nPortIndex - dmxsend::DMXPORT_OFFSET; if (bridge.GetUniverse(nPortIndex, nUniverse, lightset::PortDir::OUTPUT)) { dmx.SetPortDirection(nDmxPortIndex, dmx::PortDirection::OUTP, false); diff --git a/opi_emac_e131_dmx_multi/lib/rdmsoftwareversion.cpp b/opi_emac_e131_dmx_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_e131_dmx_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_monitor/firmware/main.cpp b/opi_emac_e131_monitor/firmware/main.cpp index 3c93fc065..6ca0be888 100644 --- a/opi_emac_e131_monitor/firmware/main.cpp +++ b/opi_emac_e131_monitor/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -67,22 +67,13 @@ #include "firmwareversion.h" #include "software_version.h" -namespace e131bridge { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace e131bridge - -void Hardware::RebootHandler() { -} +void Hardware::RebootHandler() {} int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -96,8 +87,6 @@ int main() { console_set_fg_color(CONSOLE_WHITE); console_set_top_row(2); - - NtpClient ntpClient; ntpClient.Start(); ntpClient.Print(); @@ -200,7 +189,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_e131_monitor/lib/rdmsoftwareversion.cpp b/opi_emac_e131_monitor/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_e131_monitor/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_pixel/lib/rdmsoftwareversion.cpp b/opi_emac_e131_pixel/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_e131_pixel/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_pixel_dmx/lib/rdmsoftwareversion.cpp b/opi_emac_e131_pixel_dmx/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_e131_pixel_dmx/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_pixel_dmx_multi/lib/rdmsoftwareversion.cpp b/opi_emac_e131_pixel_dmx_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_e131_pixel_dmx_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_e131_pixel_multi/lib/rdmsoftwareversion.cpp b/opi_emac_e131_pixel_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_e131_pixel_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_llrp_tftpd/firmware/main.cpp b/opi_emac_llrp_tftpd/firmware/main.cpp index 88475ca50..b8a13bbe3 100755 --- a/opi_emac_llrp_tftpd/firmware/main.cpp +++ b/opi_emac_llrp_tftpd/firmware/main.cpp @@ -23,12 +23,16 @@ * THE SOFTWARE. */ +#if !defined (NODE_RDMNET_LLRP_ONLY) +# error +#endif + #include #include #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "displayudf.h" #include "displayudfparams.h" @@ -37,12 +41,9 @@ #include "remoteconfig.h" #include "remoteconfigparams.h" -#if defined (NODE_RDMNET_LLRP_ONLY) -# include "rdmnetllrponly.h" -#endif +#include "rdmnetllrponly.h" #include "net/apps/mdns.h" - #include "net/apps/ntpclient.h" #include "factorydefaults.h" @@ -68,9 +69,7 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -80,11 +79,9 @@ int main() { ntpClient.Start(); ntpClient.Print(); -#if defined (NODE_RDMNET_LLRP_ONLY) RDMNetLLRPOnly device; device.Init(); device.Print(); -#endif RemoteConfig remoteConfig(remoteconfig::Node::RDMNET_LLRP_ONLY, remoteconfig::Output::CONFIG, 0); diff --git a/opi_emac_llrp_tftpd/lib/rdmsoftwareversion.cpp b/opi_emac_llrp_tftpd/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 939186eea..000000000 --- a/opi_emac_llrp_tftpd/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 2018 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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_ltc_smpte/firmware/main.cpp b/opi_emac_ltc_smpte/firmware/main.cpp index 2d3cb16d2..cec2a3a44 100644 --- a/opi_emac_ltc_smpte/firmware/main.cpp +++ b/opi_emac_ltc_smpte/firmware/main.cpp @@ -47,7 +47,7 @@ #include "artnetmsgconst.h" #include "artnetconst.h" -#include "networkconst.h" + #include "midi.h" #include "rtpmidi.h" @@ -103,12 +103,6 @@ # include "shell/shell.h" #endif -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { // switch (m_tSource) { // case ltc::source::TCNET: @@ -145,15 +139,12 @@ int main() { Hardware hw; Display display(4); ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("LTC SMPTE"); - #if defined(ENABLE_SHELL) Shell shell; #endif @@ -161,8 +152,6 @@ int main() { display.ClearLine(1); display.ClearLine(2); -// MDNS mdns; - NtpClient ntpClient; ntpClient.Start(); ntpClient.Print(); diff --git a/opi_emac_ltc_smpte/lib/rdmsoftwareversion.cpp b/opi_emac_ltc_smpte/lib/rdmsoftwareversion.cpp deleted file mode 100644 index bf5341bbe..000000000 --- a/opi_emac_ltc_smpte/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_showfile_artnet/firmware/main.cpp b/opi_emac_showfile_artnet/firmware/main.cpp index 7a71b680d..41ff59e5c 100755 --- a/opi_emac_showfile_artnet/firmware/main.cpp +++ b/opi_emac_showfile_artnet/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -75,15 +75,12 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("Showfile player"); - ShowFile showFile; ShowFileParams showFileParams; @@ -129,7 +126,6 @@ int main() { // Fixed row 5, 6, 7 - if (showFileParams.IsArtNetBroadcast()) { Display::Get()->PutString(" "); } diff --git a/opi_emac_showfile_artnet/lib/rdmsoftwareversion.cpp b/opi_emac_showfile_artnet/lib/rdmsoftwareversion.cpp deleted file mode 100755 index 939186eea..000000000 --- a/opi_emac_showfile_artnet/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 2018 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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_emac_showfile_e131/firmware/main.cpp b/opi_emac_showfile_e131/firmware/main.cpp index 0bf5ac772..fbbcedb31 100755 --- a/opi_emac_showfile_e131/firmware/main.cpp +++ b/opi_emac_showfile_e131/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -75,14 +75,11 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("Showfile player"); - ShowFile showFile; diff --git a/opi_emac_showfile_e131/lib/rdmsoftwareversion.cpp b/opi_emac_showfile_e131/lib/rdmsoftwareversion.cpp deleted file mode 100755 index 939186eea..000000000 --- a/opi_emac_showfile_e131/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 2018 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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_midi_monitor/firmware/main.cpp b/opi_midi_monitor/firmware/main.cpp index ae2b603e0..2117e6d78 100644 --- a/opi_midi_monitor/firmware/main.cpp +++ b/opi_midi_monitor/firmware/main.cpp @@ -51,9 +51,7 @@ int main() { Display display; #if !defined(NO_EMAC) ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); #endif FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -66,8 +64,6 @@ int main() { midi.Init(midi::Direction::INPUT); #if !defined(NO_EMAC) - - RemoteConfigParams remoteConfigParams; remoteConfigParams.Load(); remoteConfigParams.Set(&remoteConfig); diff --git a/opi_midi_monitor/lib/midimonitor.cpp b/opi_midi_monitor/lib/midimonitor.cpp index 5a5c9b3fc..83fd6c4d8 100644 --- a/opi_midi_monitor/lib/midimonitor.cpp +++ b/opi_midi_monitor/lib/midimonitor.cpp @@ -1,7 +1,7 @@ /** * @file midimonitor.h */ -/* Copyright (C) 2019-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -44,17 +44,17 @@ static uint8_t s_Qf[8] __attribute__ ((aligned (4))) = { 0, 0, 0, 0, 0, 0, 0, 0 static constexpr auto TC_LENGTH = sizeof(s_aTimecode) - 1; static constexpr char TC_TYPES[4][8] __attribute__ ((aligned (4))) = {"Film " , "EBU " , "DF " , "SMPTE" }; -inline static void itoa_base10(int nArg, char *pBuffer) { +static void itoa(const uint32_t nValue, char *pBuffer) { auto *p = pBuffer; - if (nArg == 0) { + if (nValue == 0) { *p++ = '0'; *p = '0'; return; } - *p++ = static_cast('0' + (nArg / 10)); - *p = static_cast('0' + (nArg % 10)); + *p++ = static_cast('0' + (nValue / 10U)); + *p = static_cast('0' + (nValue % 10U)); } MidiMonitor::MidiMonitor() : @@ -99,10 +99,10 @@ void MidiMonitor::UpdateTimecode(uint8_t nType) { } void MidiMonitor::HandleMtc() { - itoa_base10((m_pMidiMessage->aSystemExclusive[5] & 0x1F), &s_aTimecode[0]); - itoa_base10(m_pMidiMessage->aSystemExclusive[6], &s_aTimecode[3]); - itoa_base10(m_pMidiMessage->aSystemExclusive[7], &s_aTimecode[6]); - itoa_base10(m_pMidiMessage->aSystemExclusive[8], &s_aTimecode[9]); + itoa((m_pMidiMessage->aSystemExclusive[5] & 0x1F), &s_aTimecode[0]); + itoa(m_pMidiMessage->aSystemExclusive[6], &s_aTimecode[3]); + itoa(m_pMidiMessage->aSystemExclusive[7], &s_aTimecode[6]); + itoa(m_pMidiMessage->aSystemExclusive[8], &s_aTimecode[9]); UpdateTimecode(static_cast(m_pMidiMessage->aSystemExclusive[5] >> 5)); } @@ -119,10 +119,10 @@ void MidiMonitor::HandleQf() { } if ((m_bDirection && (nPart == 7)) || (!m_bDirection && (nPart == 0))) { - itoa_base10(s_Qf[6] | ((s_Qf[7] & 0x1) << 4) , &s_aTimecode[0]); - itoa_base10(s_Qf[4] | (s_Qf[5] << 4) , &s_aTimecode[3]); - itoa_base10(s_Qf[2] | (s_Qf[3] << 4) , &s_aTimecode[6]); - itoa_base10(s_Qf[0] | (s_Qf[1] << 4) , &s_aTimecode[9]); + itoa(s_Qf[6] | ((s_Qf[7] & 0x1) << 4) , &s_aTimecode[0]); + itoa(s_Qf[4] | (s_Qf[5] << 4) , &s_aTimecode[3]); + itoa(s_Qf[2] | (s_Qf[3] << 4) , &s_aTimecode[6]); + itoa(s_Qf[0] | (s_Qf[1] << 4) , &s_aTimecode[9]); const auto nType = static_cast(s_Qf[7] >> 1); diff --git a/opi_rdm_responder/firmware/main.cpp b/opi_rdm_responder/firmware/main.cpp index 337c7ceac..16d4f30f7 100644 --- a/opi_rdm_responder/firmware/main.cpp +++ b/opi_rdm_responder/firmware/main.cpp @@ -74,22 +74,13 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; -#if !defined(NO_EMAC) - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); - Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); -#else Network nw; -#endif FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; const auto isConfigMode = is_config_mode(); fw.Print("RDM Responder"); -#if !defined(NO_EMAC) - -#endif PixelDmxConfiguration pixelDmxConfiguration; @@ -203,7 +194,7 @@ int main() { #if !defined(NO_EMAC) nw.Run(); remoteConfig.Run(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + #endif pixelTestPattern.Run(); display.Run(); diff --git a/opi_rdm_responder/lib/rdmsoftwareversion.cpp b/opi_rdm_responder/lib/rdmsoftwareversion.cpp deleted file mode 100644 index fd1037765..000000000 --- a/opi_rdm_responder/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 2018 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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} diff --git a/opi_rdm_responder_l6470/firmware/main.cpp b/opi_rdm_responder_l6470/firmware/main.cpp index c1b049c5a..da0333950 100644 --- a/opi_rdm_responder_l6470/firmware/main.cpp +++ b/opi_rdm_responder_l6470/firmware/main.cpp @@ -62,28 +62,17 @@ #include "factorydefaults.h" -void Hardware::RebootHandler() { - -} +void Hardware::RebootHandler() {} int main() { Hardware hw; Display display; ConfigStore configStore; -#if !defined(NO_EMAC) - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); - Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); -#else Network nw; -#endif FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print(); -#if !defined(NO_EMAC) - -#endif LightSet *pBoard; diff --git a/opi_rdm_responder_l6470/lib/rdmsoftwareversion.cpp b/opi_rdm_responder_l6470/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 28ec303cc..000000000 --- a/opi_rdm_responder_l6470/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 2018-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 "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} From 5577fc9bb27a2ed64af439c91a53cf1539a0d1fd Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:29:48 +0100 Subject: [PATCH 25/36] Added CONFIG_CLIB_ASSERT_REBOOT --- lib-clib/src/h3/assert.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib-clib/src/h3/assert.c b/lib-clib/src/h3/assert.c index b65f687a3..001b75220 100755 --- a/lib-clib/src/h3/assert.c +++ b/lib-clib/src/h3/assert.c @@ -62,8 +62,11 @@ void __assert_func(const char *file, int line, const char *func, const char *fai console_set_fg_color(CONSOLE_WHITE); +#if !defined(CONFIG_CLIB_ASSERT_REBOOT) H3_TIMER->WDOG0_MODE = 0; +#endif for (;;) ; + } From 7dbaedd5cfbdc2ee0d2cf97a89bbc449071bdb8e Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:32:53 +0100 Subject: [PATCH 26/36] Removed pragma GCC optimize ("Os") - Not needed anymore. It's default compile option now. --- lib-artnet/src/node/artnetnodeprint.cpp | 7 +--- lib-configstore/src/envparams.cpp | 5 --- lib-dmx/src/dmxparams.cpp | 29 +++----------- lib-dmxmonitor/src/dmxmonitorparams.cpp | 26 ++++--------- lib-dmxserial/src/dmxserialparams.cpp | 7 +--- lib-e131/src/node/e131bridgeprint.cpp | 7 +--- lib-e131/src/node/e131params.cpp | 38 ++++++++---------- .../src/params/flashcodeinstallparams.cpp | 7 +--- lib-gps/src/gpsparams.cpp | 7 +--- lib-network/src/net/acd.cpp | 3 -- lib-network/src/net/autoip.cpp | 3 -- lib-network/src/net/dhcp.cpp | 3 -- lib-network/src/net/netif.cpp | 3 -- lib-network/src/params/networkparams.cpp | 12 +++--- lib-osc/src/client/oscclientparams.cpp | 7 +--- lib-osc/src/server/oscserverparams.cpp | 7 +--- lib-rdmsensor/src/rdmsensorsparams.cpp | 5 --- lib-rdmsubdevice/src/rdmsubdevicesparams.cpp | 5 --- lib-remoteconfig/include/httpd/httpd.h | 8 ++-- lib-remoteconfig/src/remoteconfig.cpp | 39 ++++++++----------- lib-remoteconfig/src/remoteconfigparams.cpp | 5 --- lib-remoteconfig/src/tftp/remoteconfig.cpp | 5 --- lib-showfile/src/showfileparams.cpp | 7 +--- lib-ws28xxdmx/src/params/pixeldmxparams.cpp | 10 ++--- 24 files changed, 65 insertions(+), 190 deletions(-) diff --git a/lib-artnet/src/node/artnetnodeprint.cpp b/lib-artnet/src/node/artnetnodeprint.cpp index 06f617a70..dfc13a559 100644 --- a/lib-artnet/src/node/artnetnodeprint.cpp +++ b/lib-artnet/src/node/artnetnodeprint.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,11 +26,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include diff --git a/lib-configstore/src/envparams.cpp b/lib-configstore/src/envparams.cpp index c6e18dd94..3227f9c5c 100755 --- a/lib-configstore/src/envparams.cpp +++ b/lib-configstore/src/envparams.cpp @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-dmx/src/dmxparams.cpp b/lib-dmx/src/dmxparams.cpp index 36856ff93..b2eacb0fd 100644 --- a/lib-dmx/src/dmxparams.cpp +++ b/lib-dmx/src/dmxparams.cpp @@ -2,7 +2,7 @@ * @file dmxparams.cpp * */ -/* Copyright (C) 2017-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG @@ -52,8 +47,6 @@ DmxParams::DmxParams() { 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_Params.nSlotsCount=%d", m_Params.nSlotsCount); } void DmxParams::Load() { @@ -205,20 +198,8 @@ void DmxParams::staticCallbackFunction(void *p, const char *s) { void DmxParams::Dump() { printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, DmxParamsConst::FILE_NAME); - - if (isMaskSet(dmxsendparams::Mask::BREAK_TIME)) { - printf(" %s=%d\n", DmxParamsConst::BREAK_TIME, m_Params.nBreakTime); - } - - if (isMaskSet(dmxsendparams::Mask::MAB_TIME)) { - printf(" %s=%d\n", DmxParamsConst::MAB_TIME, m_Params.nMabTime); - } - - if (isMaskSet(dmxsendparams::Mask::REFRESH_RATE)) { - 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_Params.nSlotsCount, dmxsendparams::roundup_slots(m_Params.nSlotsCount)); - } + printf(" %s=%d\n", DmxParamsConst::BREAK_TIME, m_Params.nBreakTime); + printf(" %s=%d\n", DmxParamsConst::MAB_TIME, m_Params.nMabTime); + printf(" %s=%d\n", DmxParamsConst::REFRESH_RATE, m_Params.nRefreshRate); + printf(" %s=%d [%d]\n", DmxParamsConst::SLOTS_COUNT, m_Params.nSlotsCount, dmxsendparams::roundup_slots(m_Params.nSlotsCount)); } diff --git a/lib-dmxmonitor/src/dmxmonitorparams.cpp b/lib-dmxmonitor/src/dmxmonitorparams.cpp index 3ff1799d0..bc07bcfba 100644 --- a/lib-dmxmonitor/src/dmxmonitorparams.cpp +++ b/lib-dmxmonitor/src/dmxmonitorparams.cpp @@ -2,7 +2,7 @@ * @file dmxmonitorparams.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,11 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS - #pragma GCC push_options - #pragma GCC optimize ("Os") -#endif - #include #include -#include +#ifndef NDEBUG +# include +#endif #include #include "dmxmonitor.h" @@ -190,16 +187,7 @@ void DMXMonitorParams::staticCallbackFunction(void *p, const char *s) { void DMXMonitorParams::Dump() { printf("%s::%s \'%s\':\n", __FILE__, __FUNCTION__, DMXMonitorParamsConst::FILE_NAME); - - if (isMaskSet(DMXMonitorParamsMask::START_ADDRESS)) { - printf(" %s=%d\n", LightSetParamsConst::DMX_START_ADDRESS, m_Params.nDmxStartAddress); - } - - if (isMaskSet(DMXMonitorParamsMask::MAX_CHANNELS)) { - printf(" %s=%d\n", DMXMonitorParamsConst::DMX_MAX_CHANNELS, m_Params.nDmxMaxChannels); - } - - if (isMaskSet(DMXMonitorParamsMask::FORMAT)) { - printf(" %s=%d [%s]\n", DMXMonitorParamsConst::FORMAT, static_cast(m_Params.tFormat), m_Params.tFormat == static_cast(Format::PCT) ? "pct" : (m_Params.tFormat == static_cast(Format::DEC) ? "dec" : "hex")); - } + printf(" %s=%d\n", LightSetParamsConst::DMX_START_ADDRESS, m_Params.nDmxStartAddress); + printf(" %s=%d\n", DMXMonitorParamsConst::DMX_MAX_CHANNELS, m_Params.nDmxMaxChannels); + printf(" %s=%d [%s]\n", DMXMonitorParamsConst::FORMAT, static_cast(m_Params.tFormat), m_Params.tFormat == static_cast(Format::PCT) ? "pct" : (m_Params.tFormat == static_cast(Format::DEC) ? "dec" : "hex")); } diff --git a/lib-dmxserial/src/dmxserialparams.cpp b/lib-dmxserial/src/dmxserialparams.cpp index 25f9f5832..7d3c676f0 100644 --- a/lib-dmxserial/src/dmxserialparams.cpp +++ b/lib-dmxserial/src/dmxserialparams.cpp @@ -2,7 +2,7 @@ * @file dmxserialparams.cpp * */ -/* Copyright (C) 2020-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 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 @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG diff --git a/lib-e131/src/node/e131bridgeprint.cpp b/lib-e131/src/node/e131bridgeprint.cpp index 55029594e..d35edc886 100644 --- a/lib-e131/src/node/e131bridgeprint.cpp +++ b/lib-e131/src/node/e131bridgeprint.cpp @@ -2,7 +2,7 @@ * @file e131bridgeprint.cpp * */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-e131/src/node/e131params.cpp b/lib-e131/src/node/e131params.cpp index f06c99cc5..27614657e 100644 --- a/lib-e131/src/node/e131params.cpp +++ b/lib-e131/src/node/e131params.cpp @@ -2,7 +2,7 @@ * @file e131params.cpp * */ -/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,12 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include +#ifndef NDEBUG +# include +#endif #include #include @@ -48,15 +46,15 @@ #include "debug.h" -namespace e131bridge { -namespace configstore { -extern uint32_t DMXPORT_OFFSET; -} // namespace configstore -} // namespace e131bridge - static uint32_t s_nPortsMax; namespace e131params { +#if !defined(CONFIG_DMX_PORT_OFFSET) + static constexpr uint32_t DMXPORT_OFFSET = 0; +#else + static constexpr uint32_t DMXPORT_OFFSET = CONFIG_DMX_PORT_OFFSET; +#endif + static constexpr uint16_t portdir_shift_left(const lightset::PortDir portDir, const uint32_t i) { return static_cast((static_cast(portDir) & 0x3) << (i * 2)); } @@ -309,11 +307,11 @@ void E131Params::Builder(const struct Params *pParams, char *pBuffer, uint32_t n void E131Params::Set() { DEBUG_ENTRY - if (e131bridge::configstore::DMXPORT_OFFSET <= e131bridge::MAX_PORTS) { - s_nPortsMax = std::min(e131params::MAX_PORTS, e131bridge::MAX_PORTS - e131bridge::configstore::DMXPORT_OFFSET); + if (e131params::DMXPORT_OFFSET <= e131bridge::MAX_PORTS) { + s_nPortsMax = std::min(e131params::MAX_PORTS, e131bridge::MAX_PORTS - e131params::DMXPORT_OFFSET); } - DEBUG_PRINTF("e131bridge::MAX_PORTS=%u, e131bridge::configstore::DMXPORT_OFFSET=%u, s_nPortsMax=%u", e131bridge::MAX_PORTS, e131bridge::configstore::DMXPORT_OFFSET, s_nPortsMax); + DEBUG_PRINTF("e131bridge::MAX_PORTS=%u, e131params::DMXPORT_OFFSET=%u, s_nPortsMax=%u", e131bridge::MAX_PORTS, e131params::DMXPORT_OFFSET, s_nPortsMax); if (m_Params.nSetList == 0) { return; @@ -323,7 +321,7 @@ void E131Params::Set() { assert(p != nullptr); for (uint32_t nPortIndex = 0; nPortIndex < s_nPortsMax; nPortIndex++) { - const auto nOffset = nPortIndex + e131bridge::configstore::DMXPORT_OFFSET; + const auto nOffset = nPortIndex + e131params::DMXPORT_OFFSET; if (nOffset >= e131bridge::MAX_PORTS) { DEBUG_EXIT @@ -360,9 +358,7 @@ void E131Params::staticCallbackFunction(void *p, const char *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))); - } + 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)) { @@ -380,9 +376,7 @@ void E131Params::Dump() { } 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]); - } + printf(" %s=%d\n", E131ParamsConst::PRIORITY[i], m_Params.nPriority[i]); } for (uint32_t i = 0; i < e131params::MAX_PORTS; i++) { diff --git a/lib-flashcodeinstall/src/params/flashcodeinstallparams.cpp b/lib-flashcodeinstall/src/params/flashcodeinstallparams.cpp index 2f1ce0b79..f81d7183a 100644 --- a/lib-flashcodeinstall/src/params/flashcodeinstallparams.cpp +++ b/lib-flashcodeinstall/src/params/flashcodeinstallparams.cpp @@ -2,7 +2,7 @@ * @file flashcodeinstallparams.cpp * */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-gps/src/gpsparams.cpp b/lib-gps/src/gpsparams.cpp index 0139ebc77..bb3a9bb51 100644 --- a/lib-gps/src/gpsparams.cpp +++ b/lib-gps/src/gpsparams.cpp @@ -2,7 +2,7 @@ * @file gpsparams.cpp * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,11 +21,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG diff --git a/lib-network/src/net/acd.cpp b/lib-network/src/net/acd.cpp index 456a4bff7..874951c40 100755 --- a/lib-network/src/net/acd.cpp +++ b/lib-network/src/net/acd.cpp @@ -34,9 +34,6 @@ # undef NDEBUG #endif -#pragma GCC push_options -#pragma GCC optimize ("Os") - #include #include #include diff --git a/lib-network/src/net/autoip.cpp b/lib-network/src/net/autoip.cpp index e675fb8a6..cb2fedfd0 100755 --- a/lib-network/src/net/autoip.cpp +++ b/lib-network/src/net/autoip.cpp @@ -34,9 +34,6 @@ # undef NDEBUG #endif -#pragma GCC push_options -#pragma GCC optimize ("Os") - #include #include diff --git a/lib-network/src/net/dhcp.cpp b/lib-network/src/net/dhcp.cpp index 8cc84b6b0..ae4527ef1 100755 --- a/lib-network/src/net/dhcp.cpp +++ b/lib-network/src/net/dhcp.cpp @@ -29,9 +29,6 @@ # undef NDEBUG #endif -#pragma GCC push_options -#pragma GCC optimize ("Os") - #include #include #include diff --git a/lib-network/src/net/netif.cpp b/lib-network/src/net/netif.cpp index 0e86b1d14..975b1e6f5 100755 --- a/lib-network/src/net/netif.cpp +++ b/lib-network/src/net/netif.cpp @@ -27,9 +27,6 @@ # undef NDEBUG #endif -#pragma GCC push_options -#pragma GCC optimize ("Os") - #include #include "netif.h" diff --git a/lib-network/src/params/networkparams.cpp b/lib-network/src/params/networkparams.cpp index 453218181..ec3078b22 100644 --- a/lib-network/src/params/networkparams.cpp +++ b/lib-network/src/params/networkparams.cpp @@ -23,9 +23,8 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") +#ifdef DEBUG_NETWORK +# undef NDEBUG #endif #include @@ -36,7 +35,6 @@ #include "networkparams.h" #include "networkparamsconst.h" - #include "readconfigfile.h" #include "sscan.h" @@ -190,13 +188,13 @@ void NetworkParams::staticCallbackFunction(void *p, const char *s) { (static_cast(p))->callbackFunction(s); } -void NetworkParams::Builder(const struct networkparams::Params *ptNetworkParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { +void NetworkParams::Builder(const struct networkparams::Params *pParams, char *pBuffer, uint32_t nLength, uint32_t& nSize) { DEBUG_ENTRY assert(pBuffer != nullptr); - if (ptNetworkParams != nullptr) { - memcpy(&m_Params, ptNetworkParams, sizeof(struct networkparams::Params)); + if (pParams != nullptr) { + memcpy(&m_Params, pParams, sizeof(struct networkparams::Params)); } else { NetworkParamsStore::Copy(&m_Params); } diff --git a/lib-osc/src/client/oscclientparams.cpp b/lib-osc/src/client/oscclientparams.cpp index 99b9a4101..1aa6796b9 100755 --- a/lib-osc/src/client/oscclientparams.cpp +++ b/lib-osc/src/client/oscclientparams.cpp @@ -2,7 +2,7 @@ * @file oscclientparams.cpp * */ -/* Copyright (C) 2019-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2019-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG diff --git a/lib-osc/src/server/oscserverparams.cpp b/lib-osc/src/server/oscserverparams.cpp index 27d93b404..652820292 100755 --- a/lib-osc/src/server/oscserverparams.cpp +++ b/lib-osc/src/server/oscserverparams.cpp @@ -2,7 +2,7 @@ * @file oscserverparams.cpp * */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG diff --git a/lib-rdmsensor/src/rdmsensorsparams.cpp b/lib-rdmsensor/src/rdmsensorsparams.cpp index 0c63adf0a..f8a62efc1 100644 --- a/lib-rdmsensor/src/rdmsensorsparams.cpp +++ b/lib-rdmsensor/src/rdmsensorsparams.cpp @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-rdmsubdevice/src/rdmsubdevicesparams.cpp b/lib-rdmsubdevice/src/rdmsubdevicesparams.cpp index 82bdb0e9e..8d790c22a 100644 --- a/lib-rdmsubdevice/src/rdmsubdevicesparams.cpp +++ b/lib-rdmsubdevice/src/rdmsubdevicesparams.cpp @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-remoteconfig/include/httpd/httpd.h b/lib-remoteconfig/include/httpd/httpd.h index 80517f3ad..7f579c55e 100755 --- a/lib-remoteconfig/include/httpd/httpd.h +++ b/lib-remoteconfig/include/httpd/httpd.h @@ -2,7 +2,7 @@ * @file httpd.h * */ -/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,7 @@ class HttpDaemon { void Run() { uint32_t nConnectionHandle; - const auto nBytesReceived = Network::Get()->TcpRead(m_nHandle, const_cast(reinterpret_cast(&m_RequestHeaderResponse)), nConnectionHandle); + const auto nBytesReceived = Network::Get()->TcpRead(m_nHandle, const_cast(reinterpret_cast(&m_pReceiveBuffer)), nConnectionHandle); if (__builtin_expect((nBytesReceived == 0), 1)) { return; @@ -50,13 +50,13 @@ class HttpDaemon { DEBUG_PRINTF("nConnectionHandle=%u", nConnectionHandle); - pHandleRequest[nConnectionHandle]->HandleRequest(nBytesReceived, m_RequestHeaderResponse); + pHandleRequest[nConnectionHandle]->HandleRequest(nBytesReceived, m_pReceiveBuffer); } private: HttpDeamonHandleRequest *pHandleRequest[TCP_MAX_TCBS_ALLOWED]; int32_t m_nHandle { -1 }; - char *m_RequestHeaderResponse { nullptr }; + char *m_pReceiveBuffer { nullptr }; }; #endif /* HTTPD_HTTPD_H_ */ diff --git a/lib-remoteconfig/src/remoteconfig.cpp b/lib-remoteconfig/src/remoteconfig.cpp index 954ce492f..f005f430a 100644 --- a/lib-remoteconfig/src/remoteconfig.cpp +++ b/lib-remoteconfig/src/remoteconfig.cpp @@ -23,10 +23,7 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif +#define USE_UDP_CALLBACK #include #include @@ -240,13 +237,9 @@ constexpr struct RemoteConfig::Commands RemoteConfig::s_SET[] = { static constexpr char s_Node[static_cast(remoteconfig::Node::LAST)][18] = { "Art-Net", "sACN E1.31", "OSC Server", "LTC", "OSC Client", "RDMNet LLRP Only", "Showfile", "MIDI", "DDP", "PixelPusher", "Node", "Bootloader TFTP", "RDM Responder" }; static constexpr char s_Output[static_cast(remoteconfig::Output::LAST)][12] = { "DMX", "RDM", "Monitor", "Pixel", "TimeCode", "OSC", "Config", "Stepper", "Player", "Art-Net", "Serial", "RGB Panel", "PWM" }; -RemoteConfig *RemoteConfig::s_pThis; -RemoteConfig::ListBin RemoteConfig::s_RemoteConfigListBin; -char *RemoteConfig::s_pUdpBuffer; - RemoteConfig::RemoteConfig(const remoteconfig::Node node, const remoteconfig::Output output, const uint32_t nActiveOutputs): - m_tNode(node), - m_tOutput(output), + m_Node(node), + m_Output(output), m_nActiveOutputs(nActiveOutputs) { DEBUG_ENTRY @@ -263,17 +256,17 @@ RemoteConfig::RemoteConfig(const remoteconfig::Node node, const remoteconfig::Ou s_RemoteConfigListBin.nActiveOutputs = static_cast(nActiveOutputs); s_RemoteConfigListBin.aDisplayName[0] = '\0'; -// m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); +#if defined (USE_UDP_CALLBACK) + m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); +#else m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT); +#endif assert(m_nHandle != -1); #if !defined (CONFIG_REMOTECONFIG_MINIMUM) -// assert(MDNS::Get() != nullptr); -// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); mdns_service_record_add(nullptr, mdns::Services::CONFIG); # if defined(ENABLE_TFTP_SERVER) -// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::TFTP); mdns_service_record_add(nullptr, mdns::Services::TFTP); # endif @@ -296,7 +289,6 @@ RemoteConfig::~RemoteConfig() { } # endif -// MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); mdns_service_record_delete(mdns::Services::CONFIG); #endif @@ -321,16 +313,17 @@ void RemoteConfig::SetDisable(bool bDisable) { Network::Get()->End(remoteconfig::udp::PORT); m_nHandle = -1; #if !defined (CONFIG_REMOTECONFIG_MINIMUM) -// MDNS::Get()->ServiceRecordDelete(mdns::Services::CONFIG); mdns_service_record_delete(mdns::Services::CONFIG); #endif m_bDisable = true; } else if (!bDisable && m_bDisable) { -// m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); +#if defined (USE_UDP_CALLBACK) + m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT, RemoteConfig::staticCallbackFunction); +#else m_nHandle = Network::Get()->Begin(remoteconfig::udp::PORT); +#endif assert(m_nHandle != -1); #if !defined (CONFIG_REMOTECONFIG_MINIMUM) -// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::CONFIG); mdns_service_record_add(nullptr, mdns::Services::CONFIG); #endif m_bDisable = false; @@ -448,7 +441,7 @@ void RemoteConfig::HandleVersion() { DEBUG_ENTRY const auto *p = FirmwareVersion::Get()->GetPrint(); - const auto nLength = snprintf(s_pUdpBuffer, remoteconfig::udp::BUFFER_SIZE - 1, "version:%s", p); + const auto nLength = snprintf(s_pUdpBuffer, remoteconfig::udp::BUFFER_SIZE - 1, "version:%s\n", p); Network::Get()->SendTo(m_nHandle, s_pUdpBuffer, static_cast(nLength), m_nIPAddressFrom, remoteconfig::udp::PORT); DEBUG_EXIT @@ -465,15 +458,15 @@ void RemoteConfig::HandleList() { if (s_RemoteConfigListBin.aDisplayName[0] != '\0') { nListLength = snprintf(pListResponse, nListResponseBufferLength - 1, "" IPSTR ",%s,%s,%u,%s\n", IP2STR(Network::Get()->GetIp()), - s_Node[static_cast(m_tNode)], - s_Output[static_cast(m_tOutput)], + s_Node[static_cast(m_Node)], + s_Output[static_cast(m_Output)], static_cast(m_nActiveOutputs), s_RemoteConfigListBin.aDisplayName); } else { nListLength = snprintf(pListResponse, nListResponseBufferLength - 1, "" IPSTR ",%s,%s,%u\n", IP2STR(Network::Get()->GetIp()), - s_Node[static_cast(m_tNode)], - s_Output[static_cast(m_tOutput)], + s_Node[static_cast(m_Node)], + s_Output[static_cast(m_Output)], static_cast(m_nActiveOutputs)); } diff --git a/lib-remoteconfig/src/remoteconfigparams.cpp b/lib-remoteconfig/src/remoteconfigparams.cpp index b78b21385..4795963da 100644 --- a/lib-remoteconfig/src/remoteconfigparams.cpp +++ b/lib-remoteconfig/src/remoteconfigparams.cpp @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-remoteconfig/src/tftp/remoteconfig.cpp b/lib-remoteconfig/src/tftp/remoteconfig.cpp index 01a61dd6f..6824b8463 100644 --- a/lib-remoteconfig/src/tftp/remoteconfig.cpp +++ b/lib-remoteconfig/src/tftp/remoteconfig.cpp @@ -28,11 +28,6 @@ # undef NDEBUG # endif -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include #include diff --git a/lib-showfile/src/showfileparams.cpp b/lib-showfile/src/showfileparams.cpp index c4b73eb80..03e2d35be 100644 --- a/lib-showfile/src/showfileparams.cpp +++ b/lib-showfile/src/showfileparams.cpp @@ -2,7 +2,7 @@ * @file showfileparams.cpp * */ -/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,6 @@ * THE SOFTWARE. */ -#if !defined(__clang__) // Needed for compiling on MacOS - #pragma GCC push_options - #pragma GCC optimize ("Os") -#endif - #include #include #ifndef NDEBUG diff --git a/lib-ws28xxdmx/src/params/pixeldmxparams.cpp b/lib-ws28xxdmx/src/params/pixeldmxparams.cpp index 6cdd42ccd..cd9b8b1a9 100644 --- a/lib-ws28xxdmx/src/params/pixeldmxparams.cpp +++ b/lib-ws28xxdmx/src/params/pixeldmxparams.cpp @@ -2,7 +2,7 @@ * @file pixeldmxparams.cpp * */ -/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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,13 +27,11 @@ # undef NDEBUG #endif -#if !defined(__clang__) // Needed for compiling on MacOS -# pragma GCC push_options -# pragma GCC optimize ("Os") -#endif - #include #include +#ifndef NDEBUG +# include +#endif #include #include From b9537f7386ac4deeb345984fd3820b984b29820d Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:33:24 +0100 Subject: [PATCH 27/36] Fixed issue with pixel multi and dmx sync --- lib-lightset/include/lightsetwith4.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib-lightset/include/lightsetwith4.h b/lib-lightset/include/lightsetwith4.h index ae81bc7f6..6c4eccb4f 100755 --- a/lib-lightset/include/lightsetwith4.h +++ b/lib-lightset/include/lightsetwith4.h @@ -83,11 +83,11 @@ class LightSetWith4 final: public LightSet { } void Sync(const uint32_t nPortIndex) override { - if (m_pA != nullptr) { - m_pA->Sync(nPortIndex); + if ((nPortIndex < nMaxPorts) && (m_pA != nullptr)) { + return m_pA->Sync(nPortIndex); } if (m_pB != nullptr) { - m_pB->Sync(nPortIndex); + return m_pB->Sync(nPortIndex & 0x3); } } @@ -106,7 +106,7 @@ class LightSetWith4 final: public LightSet { return m_pA->SetOutputStyle(nPortIndex, outputStyle); } if (m_pB != nullptr) { - return m_pB->SetOutputStyle(nPortIndex, outputStyle); + return m_pB->SetOutputStyle(nPortIndex & 0x3, outputStyle); } } @@ -115,7 +115,7 @@ class LightSetWith4 final: public LightSet { return m_pA->GetOutputStyle(nPortIndex); } if (m_pB != nullptr) { - return m_pB->GetOutputStyle(nPortIndex); + return m_pB->GetOutputStyle(nPortIndex & 0x3); } return lightset::OutputStyle::DELTA; From d0f6882c3357d2d494963720986d9329b962e2ff Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:35:14 +0100 Subject: [PATCH 28/36] Minor code cleanup - Refactoring --- lib-artnet/include/artnetnode.h | 41 ++++++---- lib-artnet/src/node/artnetnode.cpp | 17 ++-- lib-artnet/src/node/artnetnodehandlesync.cpp | 2 +- lib-ddp/include/ddpdisplay.h | 15 ++-- lib-ddp/src/ddpdisplay.cpp | 77 +++++++++--------- lib-display/src/sleep/display.cpp | 3 +- lib-dmx/src/h3/multi/dmx.cpp | 4 + lib-e131/include/e131bridge.h | 55 ++++++++----- lib-e131/include/e131controller.h | 17 ++-- lib-e131/src/controller/e131controller.cpp | 50 ++++-------- lib-e131/src/node/dmxin/discoverypacket.cpp | 25 +++--- lib-e131/src/node/e131bridge.cpp | 21 ++++- lib-network/include/emac/network.h | 6 +- lib-network/include/net.h | 21 ++--- lib-network/include/net/apps/tftpdaemon.h | 2 +- lib-network/src/linux/network.cpp | 7 ++ .../src/net/apps/ntp/gd32/ptp/net_ptp.cpp | 8 +- .../include/httpd/httpdhandlerequest.h | 8 +- lib-remoteconfig/include/remoteconfig.h | 26 +++--- lib-remoteconfig/src/httpd/httpd.cpp | 3 - .../src/httpd/httpdhandlerequest.cpp | 80 ++++++++++--------- lib-remoteconfig/src/shell/shellcmd.cpp | 4 +- lib-showfile/Rules.mk | 1 + .../include/protocols/showfileprotocole131.h | 2 +- lib-showfile/src/osc/showfileosc.cpp | 2 +- lib-tcnet/include/tcnet.h | 8 +- lib-ws28xxdmx/include/ws28xxdmxmulti.h | 7 +- 27 files changed, 273 insertions(+), 239 deletions(-) diff --git a/lib-artnet/include/artnetnode.h b/lib-artnet/include/artnetnode.h index c2d1dd234..8eb6cf411 100755 --- a/lib-artnet/include/artnetnode.h +++ b/lib-artnet/include/artnetnode.h @@ -29,6 +29,10 @@ #ifndef ARTNETNODE_H_ #define ARTNETNODE_H_ +#if defined(DEBUG_ARTNETNODE) +# undef NDEBUG +#endif + #include #include #include @@ -73,6 +77,7 @@ #include "lightset.h" #include "hardware.h" #include "network.h" +#include "softwaretimers.h" #include "panel_led.h" @@ -182,7 +187,6 @@ class ArtNetNode { #endif public: ArtNetNode(); - ~ArtNetNode(); void Start(); void Stop(); @@ -232,20 +236,6 @@ class ArtNetNode { } } #endif - if ((m_nCurrentPacketMillis - m_nPreviousLedpanelMillis) > 200) { - m_nPreviousLedpanelMillis = m_nCurrentPacketMillis; - for (uint32_t nPortIndex = 0; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { - hal::panel_led_off(hal::panelled::PORT_A_TX << nPortIndex); -#if defined (ARTNET_HAVE_DMXIN) - hal::panel_led_off(hal::panelled::PORT_A_RX << nPortIndex); -#endif -#if defined(CONFIG_PANELLED_RDM_PORT) - hal::panel_led_off(hal::panelled::PORT_A_RDM << nPortIndex); -#elif defined(CONFIG_PANELLED_RDM_NO_PORT) - hal::panel_led_off(hal::panelled::RDM << nPortIndex); -#endif - } - } } #if defined (ARTNET_SHOWFILE) @@ -635,6 +625,24 @@ class ArtNetNode { void Process(const uint32_t); + void LedPanelOff() { + for (uint32_t nPortIndex = 0; nPortIndex < artnetnode::MAX_PORTS; nPortIndex++) { + hal::panel_led_off(hal::panelled::PORT_A_TX << nPortIndex); +#if defined (ARTNET_HAVE_DMXIN) + hal::panel_led_off(hal::panelled::PORT_A_RX << nPortIndex); +#endif +#if defined(CONFIG_PANELLED_RDM_PORT) + hal::panel_led_off(hal::panelled::PORT_A_RDM << nPortIndex); +#elif defined(CONFIG_PANELLED_RDM_NO_PORT) + hal::panel_led_off(hal::panelled::RDM << nPortIndex); +#endif + } + } + + void static staticCallbackFunctionLedPanelOff([[maybe_unused]] TimerHandle_t timerHandle) { + s_pThis->LedPanelOff(); + } + #if defined (RDM_CONTROLLER) bool RdmDiscoveryRun() { if ((GetPortDirection(m_State.rdm.nDiscoveryPortIndex) == lightset::PortDir::OUTPUT) @@ -683,7 +691,6 @@ class ArtNetNode { uint32_t m_nIpAddressFrom; uint32_t m_nCurrentPacketMillis { 0 }; uint32_t m_nPreviousPacketMillis { 0 }; - uint32_t m_nPreviousLedpanelMillis { 0 }; LightSet *m_pLightSet { nullptr }; @@ -723,7 +730,7 @@ class ArtNetNode { DmxConfigUdp m_DmxConfigUdp; #endif - static ArtNetNode *s_pThis; + static inline ArtNetNode *s_pThis; }; #endif /* ARTNETNODE_H_ */ diff --git a/lib-artnet/src/node/artnetnode.cpp b/lib-artnet/src/node/artnetnode.cpp index faba18713..cda9a5113 100755 --- a/lib-artnet/src/node/artnetnode.cpp +++ b/lib-artnet/src/node/artnetnode.cpp @@ -56,6 +56,7 @@ void record(const struct artnet::ArtSync *pArtSync, const uint32_t nMillis); #include "hardware.h" #include "network.h" +#include "softwaretimers.h" #include "panel_led.h" @@ -65,8 +66,6 @@ void record(const struct artnet::ArtSync *pArtSync, const uint32_t nMillis); static constexpr auto ARTNET_MIN_HEADER_SIZE = 12; -ArtNetNode *ArtNetNode::s_pThis; - ArtNetNode::ArtNetNode() { DEBUG_ENTRY @@ -144,12 +143,6 @@ ArtNetNode::ArtNetNode() { DEBUG_EXIT } -ArtNetNode::~ArtNetNode() { - DEBUG_ENTRY - - DEBUG_EXIT -} - void ArtNetNode::Start() { DEBUG_ENTRY @@ -235,6 +228,8 @@ void ArtNetNode::Start() { E131Bridge::Start(); #endif + SoftwareTimerAdd(200, staticCallbackFunctionLedPanelOff); + m_State.status = artnet::Status::ON; Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); @@ -445,6 +440,12 @@ static artnet::OpCodes get_op_code(const uint32_t nBytesReceived, const uint8_t return artnet::OpCodes::OP_NOT_DEFINED; } +#if !defined(__clang__) +# pragma GCC push_options +# pragma GCC optimize ("O2") +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +#endif + void ArtNetNode::Process(const uint32_t nBytesReceived) { if (__builtin_expect((nBytesReceived == 0), 1)) { const auto nDeltaMillis = m_nCurrentPacketMillis - m_nPreviousPacketMillis; diff --git a/lib-artnet/src/node/artnetnodehandlesync.cpp b/lib-artnet/src/node/artnetnodehandlesync.cpp index 17c5f0ffa..f9e179593 100755 --- a/lib-artnet/src/node/artnetnodehandlesync.cpp +++ b/lib-artnet/src/node/artnetnodehandlesync.cpp @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * 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-ddp/include/ddpdisplay.h b/lib-ddp/include/ddpdisplay.h index c15c5d116..7990893a8 100644 --- a/lib-ddp/include/ddpdisplay.h +++ b/lib-ddp/include/ddpdisplay.h @@ -2,7 +2,7 @@ * @file ddpdisplay.h * */ -/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -99,7 +99,7 @@ class DdpDisplay { return m_pLightSet; } - static DdpDisplay* Get() { + static DdpDisplay *Get() { return s_pThis; } @@ -109,8 +109,8 @@ class DdpDisplay { void HandleData(); private: - uint8_t m_macAddress[network::MAC_SIZE]; int32_t m_nHandle { -1 }; + uint8_t *m_pReceiveBuffer { nullptr }; uint32_t m_nFromIp { 0 }; uint32_t m_nCount { 0 }; uint32_t m_nStripDataLength { 0 }; @@ -119,12 +119,11 @@ class DdpDisplay { LightSet *m_pLightSet { nullptr }; - ddp::Packet m_Packet; - - static uint32_t s_nLightsetPortLength[ddpdisplay::lightset::MAX_PORTS]; - static uint32_t s_nOffsetCompare[ddpdisplay::configuration::MAX_PORTS]; + uint8_t m_macAddress[network::MAC_SIZE]; - static DdpDisplay *s_pThis; + static inline uint32_t s_nLightsetPortLength[ddpdisplay::lightset::MAX_PORTS]; + static inline uint32_t s_nOffsetCompare[ddpdisplay::configuration::MAX_PORTS]; + static inline DdpDisplay *s_pThis; }; #endif /* DDPDISPLAY_H_ */ diff --git a/lib-ddp/src/ddpdisplay.cpp b/lib-ddp/src/ddpdisplay.cpp index 13c4a6f80..562b15b43 100644 --- a/lib-ddp/src/ddpdisplay.cpp +++ b/lib-ddp/src/ddpdisplay.cpp @@ -2,7 +2,7 @@ * @file ddpdisplay.h * */ -/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,6 +34,7 @@ #include "hardware.h" #include "network.h" +#include "net/protocol/udp.h" #include "debug.h" @@ -74,10 +75,6 @@ static constexpr auto START = sizeof(json::START) - 1U; } // namespace size } // namespace json -uint32_t DdpDisplay::s_nLightsetPortLength[ddpdisplay::lightset::MAX_PORTS]; -uint32_t DdpDisplay::s_nOffsetCompare[ddpdisplay::configuration::MAX_PORTS]; -DdpDisplay *DdpDisplay::s_pThis; - DdpDisplay::DdpDisplay() { DEBUG_ENTRY assert(s_pThis == nullptr); @@ -133,15 +130,17 @@ void DdpDisplay::Start() { m_nHandle = Network::Get()->Begin(ddp::UDP_PORT); assert(m_nHandle != -1); - memset(&m_Packet.header, 0, HEADER_LEN); - m_Packet.header.flags1 = flags1::VER1 | flags1::REPLY; - m_Packet.header.id = id::STATUS; - m_Packet.header.len[1] = json::size::START; - memcpy(m_Packet.data, json::START, json::size::START); + ddp::Packet packet; + + memset(&packet.header, 0, HEADER_LEN); + packet.header.flags1 = flags1::VER1 | flags1::REPLY; + packet.header.id = id::STATUS; + packet.header.len[1] = json::size::START; + memcpy(packet.data, json::START, json::size::START); - Network::Get()->SendTo(m_nHandle, &m_Packet, HEADER_LEN + json::size::START, Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), ddp::UDP_PORT); + Network::Get()->SendTo(m_nHandle, &packet, HEADER_LEN + json::size::START, Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), ddp::UDP_PORT); - debug_dump(&m_Packet, HEADER_LEN + json::size::START); + debug_dump(&packet, HEADER_LEN + json::size::START); CalculateOffsets(); DEBUG_EXIT @@ -159,23 +158,25 @@ void DdpDisplay::Stop() { void DdpDisplay::HandleQuery() { DEBUG_ENTRY - if ((m_Packet.header.id & id::STATUS) == id::STATUS) { + auto *pPacket = reinterpret_cast(m_pReceiveBuffer); + + if ((pPacket->header.id & id::STATUS) == id::STATUS) { DEBUG_PUTS("id::STATUS"); - const auto nLength = snprintf(reinterpret_cast(m_Packet.data), sizeof(m_Packet.data), + const auto nLength = snprintf(reinterpret_cast(pPacket->data), UDP_DATA_SIZE - 1, json::DISCOVER_REPLY, Hardware::Get()->GetWebsiteUrl(), MAC2STR(m_macAddress) ); - m_Packet.header.flags1 = flags1::VER1 | flags1::REPLY | flags1::PUSH; - m_Packet.header.len[0] = static_cast(nLength >> 8); - m_Packet.header.len[1] = static_cast(nLength); + pPacket->header.flags1 = flags1::VER1 | flags1::REPLY | flags1::PUSH; + pPacket->header.len[0] = static_cast(nLength >> 8); + pPacket->header.len[1] = static_cast(nLength); - Network::Get()->SendTo(m_nHandle, &m_Packet, (HEADER_LEN + static_cast(nLength)), Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), ddp::UDP_PORT); + Network::Get()->SendTo(m_nHandle, &pPacket, (HEADER_LEN + static_cast(nLength)), Network::Get()->GetIp() | ~(Network::Get()->GetNetmask()), ddp::UDP_PORT); } - if ((m_Packet.header.id & id::STATUS) == id::CONFIG) { + if ((pPacket->header.id & id::STATUS) == id::CONFIG) { DEBUG_PUTS("id::CONFIG"); - const auto nLength = snprintf(reinterpret_cast(m_Packet.data), sizeof(m_Packet.data), + const auto nLength = snprintf(reinterpret_cast(pPacket->data), UDP_DATA_SIZE - 1, json::CONFIG_REPLY, IP2STR(Network::Get()->GetIp()), IP2STR(Network::Get()->GetNetmask()), IP2STR(Network::Get()->GetGatewayIp()), m_nActivePorts > 0 ? m_nCount : 0, @@ -202,27 +203,29 @@ void DdpDisplay::HandleQuery() { ddpdisplay::configuration::dmx::MAX_PORTS == 0 ? 0 : lightset::dmx::UNIVERSE_SIZE ); - m_Packet.header.flags1 = flags1::VER1 | flags1::REPLY | flags1::PUSH; - m_Packet.header.len[0] = static_cast(nLength >> 8); - m_Packet.header.len[1] = static_cast(nLength); + pPacket->header.flags1 = flags1::VER1 | flags1::REPLY | flags1::PUSH; + pPacket->header.len[0] = static_cast(nLength >> 8); + pPacket->header.len[1] = static_cast(nLength); - Network::Get()->SendTo(m_nHandle, &m_Packet, HEADER_LEN + nLength, m_nFromIp, ddp::UDP_PORT); + Network::Get()->SendTo(m_nHandle, &pPacket, HEADER_LEN + nLength, m_nFromIp, ddp::UDP_PORT); - debug_dump(&m_Packet, HEADER_LEN + nLength); + debug_dump(&pPacket, HEADER_LEN + nLength); } DEBUG_EXIT } void DdpDisplay::HandleData() { + const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); + auto nOffset = static_cast( - (m_Packet.header.offset[0] << 24) - | (m_Packet.header.offset[1] << 16) - | (m_Packet.header.offset[2] << 8) - | m_Packet.header.offset[3]); + (pPacket->header.offset[0] << 24) + | (pPacket->header.offset[1] << 16) + | (pPacket->header.offset[2] << 8) + | pPacket->header.offset[3]); - auto nLength = ((static_cast(m_Packet.header.len[0]) << 8) | m_Packet.header.len[1]); - const auto *receiveBuffer = m_Packet.data; + auto nLength = ((static_cast(pPacket->header.len[0]) << 8) | pPacket->header.len[1]); + const auto *receiveBuffer = pPacket->data; // DEBUG_PRINTF("nOffset=%u, nLength=%u, s_nOffsetCompare[0]=%u", nOffset, nLength, s_nOffsetCompare[0]); @@ -279,7 +282,7 @@ void DdpDisplay::HandleData() { } } - if ((m_Packet.header.flags1 & flags1::PUSH) == flags1::PUSH) { + if ((pPacket->header.flags1 & flags1::PUSH) == flags1::PUSH) { for (uint32_t nLightSetPortIndex = 0; nLightSetPortIndex < ddpdisplay::lightset::MAX_PORTS; nLightSetPortIndex++) { lightset::Data::Output(m_pLightSet, nLightSetPortIndex); lightset::Data::ClearLength(nLightSetPortIndex); @@ -290,7 +293,7 @@ void DdpDisplay::HandleData() { void DdpDisplay::Run() { uint16_t nFromPort; - const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, &m_Packet, sizeof(m_Packet), &m_nFromIp, &nFromPort); + const auto nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&m_pReceiveBuffer)), &m_nFromIp, &nFromPort); if (__builtin_expect((nBytesReceived < HEADER_LEN), 1)) { return; @@ -301,17 +304,19 @@ void DdpDisplay::Run() { return; } - if ((m_Packet.header.flags1 & flags1::VER_MASK) != flags1::VER1) { + const auto *pPacket = reinterpret_cast(m_pReceiveBuffer); + + if ((pPacket->header.flags1 & flags1::VER_MASK) != flags1::VER1) { DEBUG_PUTS("Invalid version"); return; } - if (m_Packet.header.id == id::DISPLAY) { + if (pPacket->header.id == id::DISPLAY) { HandleData(); return; } - if ((m_Packet.header.flags1 & flags1::QUERY) == flags1::QUERY) { + if ((pPacket->header.flags1 & flags1::QUERY) == flags1::QUERY) { HandleQuery(); return; } diff --git a/lib-display/src/sleep/display.cpp b/lib-display/src/sleep/display.cpp index 4b4a6df59..eb59a085c 100755 --- a/lib-display/src/sleep/display.cpp +++ b/lib-display/src/sleep/display.cpp @@ -45,6 +45,7 @@ static void sleep_timer([[maybe_unused]] TimerHandle_t nHandle) { void Display::SetSleepTimer(const bool bActive) { DEBUG_ENTRY + DEBUG_PRINTF("bActive=%d, m_nSleepTimeout=%u, s_nTimerId=%d", bActive, m_nSleepTimeout, s_nTimerId); if (!bActive) { SoftwareTimerDelete(s_nTimerId); @@ -52,7 +53,7 @@ void Display::SetSleepTimer(const bool bActive) { return; } - if (s_nTimerId != TIMER_ID_NONE) { + if (s_nTimerId == TIMER_ID_NONE) { s_nTimerId = SoftwareTimerAdd(m_nSleepTimeout, sleep_timer); DEBUG_EXIT return; diff --git a/lib-dmx/src/h3/multi/dmx.cpp b/lib-dmx/src/h3/multi/dmx.cpp index 810d2d69c..2cdb0d597 100644 --- a/lib-dmx/src/h3/multi/dmx.cpp +++ b/lib-dmx/src/h3/multi/dmx.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#if defined (DEBUG_DMX) +# undef NDEBUG +#endif + #if __GNUC__ > 8 # pragma GCC target ("general-regs-only") #endif diff --git a/lib-e131/include/e131bridge.h b/lib-e131/include/e131bridge.h index 575ee17ad..1bedd4f15 100755 --- a/lib-e131/include/e131bridge.h +++ b/lib-e131/include/e131bridge.h @@ -37,7 +37,11 @@ #include "lightset.h" #include "lightsetdata.h" -#if !(ARTNET_VERSION >= 4) +#if defined(ARTNET_VERSION) && (ARTNET_VERSION >= 4) +# define E131_HAVE_ARTNET +#endif + +#if !defined(E131_HAVE_ARTNET) # if defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI) # if !defined(E131_DISABLE_DMX_CONFIG_UDP) # include "dmxconfigudp.h" @@ -49,6 +53,8 @@ #include "hardware.h" #include "panel_led.h" +#include "softwaretimers.h" + #include "debug.h" #ifndef ALIGNED @@ -72,7 +78,6 @@ namespace e131bridge { struct State { uint32_t SynchronizationTime; - uint32_t DiscoveryTime; uint16_t DiscoveryPacketLength; uint16_t nSynchronizationAddressSourceA; uint16_t nSynchronizationAddressSourceB; @@ -312,14 +317,13 @@ class E131Bridge { } } - if ((m_nCurrentPacketMillis - m_nPreviousPacketMillis) >= 1000) { + if ((m_nCurrentPacketMillis - m_nPreviousPacketMillis) >= 1000U) { m_State.nReceivingDmx &= static_cast(~(1U << static_cast(lightset::PortDir::OUTPUT))); } } #if defined (E131_HAVE_DMXIN) HandleDmxIn(); - SendDiscoveryPacket(); #endif // The hardware::ledblink::Mode::FAST is for RDM Identify (Art-Net 4) @@ -339,18 +343,6 @@ class E131Bridge { } Process(); - -#if !(ARTNET_VERSION >= 4) - if ((m_nCurrentPacketMillis - m_nPreviousLedpanelMillis) > 200) { - m_nPreviousLedpanelMillis = m_nCurrentPacketMillis; - for (uint32_t nPortIndex = 0; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { - hal::panel_led_off(hal::panelled::PORT_A_TX << nPortIndex); -#if defined (E131_HAVE_DMXIN) - hal::panel_led_off(hal::panelled::PORT_A_RX << nPortIndex); -#endif - } - } -#endif } #if defined (NODE_SHOWFILE) && defined (CONFIG_SHOWFILE_PROTOCOL_NODE_E131) @@ -364,7 +356,7 @@ class E131Bridge { void Print(); - static E131Bridge* Get() { + static E131Bridge *Get() { return s_pThis; } @@ -392,13 +384,31 @@ class E131Bridge { void FillDiscoveryPacket(); void SendDiscoveryPacket(); + void static staticCallbackFunctionSendDiscoveryPacket([[maybe_unused]] TimerHandle_t timerHandle) { + s_pThis->SendDiscoveryPacket(); + } + +#if !defined(E131_HAVE_ARTNET) + void LedPanelOff() { + for (uint32_t nPortIndex = 0; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { + hal::panel_led_off(hal::panelled::PORT_A_TX << nPortIndex); +#if defined (E131_HAVE_DMXIN) + hal::panel_led_off(hal::panelled::PORT_A_RX << nPortIndex); +#endif + } + } + + void static staticCallbackFunctionLedPanelOff([[maybe_unused]] TimerHandle_t timerHandle) { + s_pThis->LedPanelOff(); + } +#endif + void Process(); private: int32_t m_nHandle { -1 }; uint32_t m_nCurrentPacketMillis { 0 }; uint32_t m_nPreviousPacketMillis { 0 }; - uint32_t m_nPreviousLedpanelMillis { 0 }; e131bridge::State m_State; e131bridge::Bridge m_Bridge; @@ -407,8 +417,8 @@ class E131Bridge { bool m_bEnableDataIndicator { true }; - uint8_t *m_pReceiveBuffer; - uint32_t m_nIpAddressFrom; + uint8_t *m_pReceiveBuffer { nullptr }; + uint32_t m_nIpAddressFrom { 0 }; LightSet *m_pLightSet { nullptr }; // Synchronization handler @@ -422,7 +432,8 @@ class E131Bridge { #if defined (E131_HAVE_DMXIN) TE131DataPacket m_E131DataPacket; TE131DiscoveryPacket m_E131DiscoveryPacket; - uint32_t m_DiscoveryIpAddress { 0 }; + uint32_t m_nDiscoveryIpAddress { 0 }; + TimerHandle_t m_timerHandleSendDiscoveryPacket { -1 }; #endif #if defined (DMXCONFIGUDP_H_) @@ -432,7 +443,7 @@ class E131Bridge { DmxConfigUdp m_DmxConfigUdp; #endif - static E131Bridge *s_pThis; + static inline E131Bridge *s_pThis; }; #endif /* E131BRIDGE_H_ */ diff --git a/lib-e131/include/e131controller.h b/lib-e131/include/e131controller.h index ef6f6d3de..d18b397b9 100644 --- a/lib-e131/include/e131controller.h +++ b/lib-e131/include/e131controller.h @@ -2,7 +2,7 @@ * @file e131controller.h * */ -/* Copyright (C) 2020-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 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 @@ -31,6 +31,8 @@ #include "e131.h" #include "e131packets.h" +#include "softwaretimers.h" + enum { DEFAULT_SYNCHRONIZATION_ADDRESS = 5000 }; @@ -40,7 +42,6 @@ enum { #endif struct TE131ControllerState { - bool bIsRunning; uint16_t nActiveUniverses; uint32_t DiscoveryTime; uint8_t nPriority; @@ -58,7 +59,6 @@ class E131Controller { void Start(); void Stop(); - void Run(); void Print(); @@ -98,12 +98,16 @@ class E131Controller { void FillDataPacket(); void FillDiscoveryPacket(); void FillSynchronizationPacket(); - void SendDiscoveryPacket(); uint8_t GetSequenceNumber(uint16_t nUniverse, uint32_t &nMulticastIpAddress); + void SendDiscoveryPacket(); + + void static staticCallbackFunctionSendDiscoveryPacket([[maybe_unused]] TimerHandle_t timerHandle) { + s_pThis->SendDiscoveryPacket(); + } + private: int32_t m_nHandle { -1 }; - uint32_t m_nCurrentPacketMillis { 0 }; struct TE131ControllerState m_State; TE131DataPacket *m_pE131DataPacket { nullptr }; TE131DiscoveryPacket *m_pE131DiscoveryPacket { nullptr }; @@ -112,8 +116,9 @@ class E131Controller { uint8_t m_Cid[e131::CID_LENGTH]; char m_SourceName[e131::SOURCE_NAME_LENGTH]; uint32_t m_nMaster { DMX_MAX_VALUE }; + TimerHandle_t m_timerHandleSendDiscoveryPacket { -1 }; - static E131Controller *s_pThis; + static inline E131Controller *s_pThis; }; #endif /* E131CONTROLLER_H_ */ diff --git a/lib-e131/src/controller/e131controller.cpp b/lib-e131/src/controller/e131controller.cpp index fe0c66cae..f496b3071 100644 --- a/lib-e131/src/controller/e131controller.cpp +++ b/lib-e131/src/controller/e131controller.cpp @@ -2,7 +2,7 @@ * @file e131controller.cpp * */ -/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2020-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,10 +40,11 @@ #include "debug.h" -using namespace e131; +#include "softwaretimers.h" +using namespace e131; -static const uint8_t DEVICE_SOFTWARE_VERSION[] = { 1, 0 }; +static constexpr uint8_t DEVICE_SOFTWARE_VERSION[] = { 1, 0 }; struct TSequenceNumbers { uint16_t nUniverse; @@ -53,8 +54,6 @@ struct TSequenceNumbers { static struct TSequenceNumbers s_SequenceNumbers[512] __attribute__ ((aligned (8))); -E131Controller *E131Controller::s_pThis = nullptr; - E131Controller::E131Controller() { DEBUG_ENTRY @@ -128,20 +127,14 @@ void E131Controller::Start() { FillDiscoveryPacket(); FillSynchronizationPacket(); - m_State.bIsRunning = true; + m_timerHandleSendDiscoveryPacket = SoftwareTimerAdd(e131::UNIVERSE_DISCOVERY_INTERVAL_SECONDS * 1000U, staticCallbackFunctionSendDiscoveryPacket); + assert(m_timerHandleSendDiscoveryPacket >= 0); DEBUG_EXIT } void E131Controller::Stop() { - m_State.bIsRunning = false; -} - -void E131Controller::Run() { - if (__builtin_expect((m_State.bIsRunning), 1)) { - m_nCurrentPacketMillis = Hardware::Get()->Millis(); - SendDiscoveryPacket(); - } + SoftwareTimerDelete(m_timerHandleSendDiscoveryPacket); } void E131Controller::FillDataPacket() { @@ -269,17 +262,8 @@ const uint8_t *E131Controller::GetSoftwareVersion() { void E131Controller::SetSourceName(const char *pSourceName) { assert(pSourceName != nullptr); - - //TODO https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88780 -#if (__GNUC__ > 8) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" -#endif strncpy(m_SourceName, pSourceName, e131::SOURCE_NAME_LENGTH - 1); m_SourceName[e131::SOURCE_NAME_LENGTH - 1] = '\0'; -#if (__GNUC__ > 8) -#pragma GCC diagnostic pop -#endif } void E131Controller::SetPriority(uint8_t nPriority) { //TODO SetPriority @@ -289,21 +273,17 @@ void E131Controller::SetPriority(uint8_t nPriority) { //TODO SetPriority void E131Controller::SendDiscoveryPacket() { assert(m_DiscoveryIpAddress != 0); - if (m_nCurrentPacketMillis - m_State.DiscoveryTime >= (UNIVERSE_DISCOVERY_INTERVAL_SECONDS * 1000)) { - m_State.DiscoveryTime = m_nCurrentPacketMillis; - - m_pE131DiscoveryPacket->RootLayer.FlagsLength = __builtin_bswap16(static_cast((0x07 << 12) | (DISCOVERY_ROOT_LAYER_LENGTH(m_State.nActiveUniverses)))); - m_pE131DiscoveryPacket->FrameLayer.FLagsLength = __builtin_bswap16(static_cast((0x07 << 12) | (DISCOVERY_FRAME_LAYER_LENGTH(m_State.nActiveUniverses)))); - m_pE131DiscoveryPacket->UniverseDiscoveryLayer.FlagsLength = __builtin_bswap16(static_cast((0x07 << 12) | DISCOVERY_LAYER_LENGTH(m_State.nActiveUniverses))); + m_pE131DiscoveryPacket->RootLayer.FlagsLength = __builtin_bswap16(static_cast((0x07 << 12) | (DISCOVERY_ROOT_LAYER_LENGTH(m_State.nActiveUniverses)))); + m_pE131DiscoveryPacket->FrameLayer.FLagsLength = __builtin_bswap16(static_cast((0x07 << 12) | (DISCOVERY_FRAME_LAYER_LENGTH(m_State.nActiveUniverses)))); + m_pE131DiscoveryPacket->UniverseDiscoveryLayer.FlagsLength = __builtin_bswap16(static_cast((0x07 << 12) | DISCOVERY_LAYER_LENGTH(m_State.nActiveUniverses))); - for (uint32_t i = 0; i < m_State.nActiveUniverses; i++) { - m_pE131DiscoveryPacket->UniverseDiscoveryLayer.ListOfUniverses[i] = __builtin_bswap16(s_SequenceNumbers[i].nUniverse); - } + for (uint32_t i = 0; i < m_State.nActiveUniverses; i++) { + m_pE131DiscoveryPacket->UniverseDiscoveryLayer.ListOfUniverses[i] = __builtin_bswap16(s_SequenceNumbers[i].nUniverse); + } - Network::Get()->SendTo(m_nHandle, m_pE131DiscoveryPacket, static_cast(DISCOVERY_PACKET_SIZE(m_State.nActiveUniverses)), m_DiscoveryIpAddress, e131::UDP_PORT); + Network::Get()->SendTo(m_nHandle, m_pE131DiscoveryPacket, static_cast(DISCOVERY_PACKET_SIZE(m_State.nActiveUniverses)), m_DiscoveryIpAddress, e131::UDP_PORT); - DEBUG_PUTS("Discovery sent"); - } + DEBUG_PUTS("Discovery sent"); } uint8_t E131Controller::GetSequenceNumber(uint16_t nUniverse, uint32_t &nMulticastIpAddress) { diff --git a/lib-e131/src/node/dmxin/discoverypacket.cpp b/lib-e131/src/node/dmxin/discoverypacket.cpp index 95a6fc27d..5da31831d 100644 --- a/lib-e131/src/node/dmxin/discoverypacket.cpp +++ b/lib-e131/src/node/dmxin/discoverypacket.cpp @@ -33,6 +33,8 @@ #include "network.h" +#include "softwaretimers.h" + void E131Bridge::FillDiscoveryPacket() { m_State.DiscoveryPacketLength = static_cast(DISCOVERY_PACKET_SIZE(m_State.nEnabledInputPorts)); @@ -56,22 +58,17 @@ void E131Bridge::FillDiscoveryPacket() { } void E131Bridge::SendDiscoveryPacket() { - assert(m_DiscoveryIpAddress != 0); - - if (m_nCurrentPacketMillis - m_State.DiscoveryTime >= (e131::UNIVERSE_DISCOVERY_INTERVAL_SECONDS * 1000)) { - m_State.DiscoveryTime = m_nCurrentPacketMillis; - - uint32_t nListOfUniverses = 0; + uint32_t nListOfUniverses = 0; - if (m_State.nEnabledInputPorts != 0) { - for (uint32_t i = 0; i < e131bridge::MAX_PORTS; i++) { - uint16_t nUniverse; - if (GetUniverse(i, nUniverse, lightset::PortDir::INPUT)) { - m_E131DiscoveryPacket.UniverseDiscoveryLayer.ListOfUniverses[nListOfUniverses++] = __builtin_bswap16(nUniverse); - } + if (m_State.nEnabledInputPorts != 0) { + for (uint32_t i = 0; i < e131bridge::MAX_PORTS; i++) { + uint16_t nUniverse; + if (GetUniverse(i, nUniverse, lightset::PortDir::INPUT)) { + m_E131DiscoveryPacket.UniverseDiscoveryLayer.ListOfUniverses[nListOfUniverses++] = __builtin_bswap16(nUniverse); } - - Network::Get()->SendTo(m_nHandle, &m_E131DiscoveryPacket, m_State.DiscoveryPacketLength, m_DiscoveryIpAddress, e131::UDP_PORT); } + + Network::Get()->SendTo(m_nHandle, &m_E131DiscoveryPacket, m_State.DiscoveryPacketLength, m_nDiscoveryIpAddress, e131::UDP_PORT); } + } diff --git a/lib-e131/src/node/e131bridge.cpp b/lib-e131/src/node/e131bridge.cpp index 01e97c194..b5c5e5f76 100755 --- a/lib-e131/src/node/e131bridge.cpp +++ b/lib-e131/src/node/e131bridge.cpp @@ -49,12 +49,11 @@ #include "hardware.h" #include "network.h" +#include "softwaretimers.h" #include "panel_led.h" #include "debug.h" -E131Bridge *E131Bridge::s_pThis = nullptr; - E131Bridge::E131Bridge() { DEBUG_ENTRY @@ -101,7 +100,7 @@ E131Bridge::~E131Bridge() { void E131Bridge::Start() { #if defined (E131_HAVE_DMXIN) const auto nIpMulticast = network::convert_to_uint(239, 255, 0, 0); - m_DiscoveryIpAddress = nIpMulticast | ((e131::universe::DISCOVERY & static_cast(0xFF)) << 24) | ((e131::universe::DISCOVERY & 0xFF00) << 8); + m_nDiscoveryIpAddress = nIpMulticast | ((e131::universe::DISCOVERY & static_cast(0xFF)) << 24) | ((e131::universe::DISCOVERY & 0xFF00) << 8); FillDataPacket(); FillDiscoveryPacket(); @@ -112,6 +111,9 @@ void E131Bridge::Start() { } SetLocalMerging(); + + m_timerHandleSendDiscoveryPacket = SoftwareTimerAdd(e131::UNIVERSE_DISCOVERY_INTERVAL_SECONDS * 1000U, staticCallbackFunctionSendDiscoveryPacket); + assert(m_timerHandleSendDiscoveryPacket >= 0); #endif #if defined (OUTPUT_HAVE_STYLESWITCH) @@ -127,6 +129,10 @@ void E131Bridge::Start() { } #endif +#if !defined(E131_HAVE_ARTNET) + SoftwareTimerAdd(200, staticCallbackFunctionLedPanelOff); +#endif + m_State.status = e131bridge::Status::ON; Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL); } @@ -142,6 +148,8 @@ void E131Bridge::Stop() { } #if defined (E131_HAVE_DMXIN) + SoftwareTimerDelete(m_timerHandleSendDiscoveryPacket); + for (uint32_t nPortIndex = 0; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) { if (m_Bridge.Port[nPortIndex].direction == lightset::PortDir::INPUT) { Dmx::Get()->SetPortDirection(nPortIndex, dmx::PortDirection::INP, false); @@ -708,6 +716,12 @@ bool E131Bridge::IsValidDataPacket() { return true; } +#if !defined(__clang__) +# pragma GCC push_options +# pragma GCC optimize ("O2") +# pragma GCC optimize ("no-tree-loop-distribute-patterns") +#endif + void E131Bridge::Process() { m_State.IsNetworkDataLoss = false; m_nPreviousPacketMillis = m_nCurrentPacketMillis; @@ -742,7 +756,6 @@ void E131Bridge::Process() { #if defined (E131_HAVE_DMXIN) HandleDmxIn(); - SendDiscoveryPacket(); #endif // The hardware::ledblink::Mode::FAST is for RDM Identify (Art-Net 4) diff --git a/lib-network/include/emac/network.h b/lib-network/include/emac/network.h index 0bb1cb76a..c64a250fe 100755 --- a/lib-network/include/emac/network.h +++ b/lib-network/include/emac/network.h @@ -214,9 +214,11 @@ class Network { return net::tcp_begin(nLocalPort); } - int32_t TcpEnd(const int32_t nHandle); + int32_t TcpEnd(const int32_t nHandle) { + return net::tcp_end(nHandle); + } - uint16_t TcpRead(const int32_t nHandleListen, const uint8_t **ppBuffer, uint32_t &HandleConnection) { + uint32_t TcpRead(const int32_t nHandleListen, const uint8_t **ppBuffer, uint32_t &HandleConnection) { return net::tcp_read(nHandleListen, ppBuffer, HandleConnection); } diff --git a/lib-network/include/net.h b/lib-network/include/net.h index 514dc7d13..670d686b9 100755 --- a/lib-network/include/net.h +++ b/lib-network/include/net.h @@ -62,22 +62,23 @@ inline void net_link_down() { typedef void (*UdpCallbackFunctionPtr)(const uint8_t *, uint32_t, uint32_t, uint16_t); -int udp_begin(uint16_t, UdpCallbackFunctionPtr callback = nullptr); -int udp_end(uint16_t); -uint32_t udp_recv1(int, uint8_t *, uint32_t, uint32_t *, uint16_t *); -uint32_t udp_recv2(int, const uint8_t **, uint32_t *, uint16_t *); -void udp_send(int, const uint8_t *, uint32_t, uint32_t, uint16_t); -void udp_send_timestamp(int, const uint8_t *, uint32_t, uint32_t, uint16_t); +int32_t udp_begin(uint16_t, UdpCallbackFunctionPtr callback = nullptr); +int32_t udp_end(uint16_t); +uint32_t udp_recv1(const int32_t, uint8_t *, uint32_t, uint32_t *, uint16_t *); +uint32_t udp_recv2(const int32_t, const uint8_t **, uint32_t *, uint16_t *); +void udp_send(int32_t, const uint8_t *, uint32_t, uint32_t, uint16_t); +void udp_send_timestamp(int32_t, const uint8_t *, uint32_t, uint32_t, uint16_t); void igmp_join(uint32_t); void igmp_leave(uint32_t); -int tcp_begin(const uint16_t); -uint16_t tcp_read(const int32_t, const uint8_t **, uint32_t &); +int32_t tcp_begin(const uint16_t); +int32_t tcp_end(const int32_t); +uint32_t tcp_read(const int32_t, const uint8_t **, uint32_t &); void tcp_write(const int32_t, const uint8_t *, uint32_t, const uint32_t); /** - * Must be provided by the application + * Must be provided by the user application */ void display_emac_config(); void display_emac_start(); @@ -88,6 +89,6 @@ void display_netmask(); void display_gateway(); void display_hostname(); void display_dhcp_status(net::dhcp::State); -} // namespace het +} // namespace net #endif /* NET_H_ */ diff --git a/lib-network/include/net/apps/tftpdaemon.h b/lib-network/include/net/apps/tftpdaemon.h index 7f70172c9..b809617cd 100755 --- a/lib-network/include/net/apps/tftpdaemon.h +++ b/lib-network/include/net/apps/tftpdaemon.h @@ -71,7 +71,7 @@ class TFTPDaemon { WRQ_RECV_PACKET }; TFTPState m_nState { TFTPState::INIT }; - int m_nIdx { -1 }; + int32_t m_nIdx { -1 }; uint8_t *m_pBuffer { nullptr }; uint32_t m_nFromIp { 0 }; uint32_t m_nLength { 0 }; diff --git a/lib-network/src/linux/network.cpp b/lib-network/src/linux/network.cpp index e4e9143ce..3256daa3a 100644 --- a/lib-network/src/linux/network.cpp +++ b/lib-network/src/linux/network.cpp @@ -37,6 +37,9 @@ #include #include "network.h" +#if !defined(CONFIG_NET_APPS_NO_MDNS) +# include "net/apps/mdns.h" +#endif #include "debug.h" @@ -146,6 +149,10 @@ Network::Network(int argc, char **argv) { } m_aDomainName[j] = '\0'; + +#if !defined(CONFIG_NET_APPS_NO_MDNS) + mdns_init(); +#endif } Network::~Network() { diff --git a/lib-network/src/net/apps/ntp/gd32/ptp/net_ptp.cpp b/lib-network/src/net/apps/ntp/gd32/ptp/net_ptp.cpp index 4f69e6309..4e1c841dc 100644 --- a/lib-network/src/net/apps/ntp/gd32/ptp/net_ptp.cpp +++ b/lib-network/src/net/apps/ntp/gd32/ptp/net_ptp.cpp @@ -47,8 +47,6 @@ T3 - remote transmit timestamp from the latest response (t3) T4 - local receive timestamp of the previous response (t4) */ -#undef NDEBUG - #if !defined (CONFIG_ENET_ENABLE_PTP) # error #endif @@ -56,6 +54,10 @@ T4 - local receive timestamp of the previous response (t4) # error #endif +#if defined (DEBUG_NTP_PTP_CLIENT) +# undef NDEBUG +#endif + #pragma GCC push_options #pragma GCC optimize ("O2") #pragma GCC optimize ("no-tree-loop-distribute-patterns") @@ -124,7 +126,7 @@ static ntpClient s_ntpClient; static uint16_t s_id; static constexpr uint16_t REQUEST_SIZE = sizeof s_ntpClient.Request; -static void print(const char *pText, const struct ntp::TimeStamp *pNtpTime) { +static void print([[maybe_unused]] const char *pText, [[maybe_unused]] const struct ntp::TimeStamp *pNtpTime) { #ifndef NDEBUG const auto nSeconds = static_cast(pNtpTime->nSeconds - ntp::JAN_1970); const auto *pTm = localtime(&nSeconds); diff --git a/lib-remoteconfig/include/httpd/httpdhandlerequest.h b/lib-remoteconfig/include/httpd/httpdhandlerequest.h index 6de1fd728..f7ead5afc 100755 --- a/lib-remoteconfig/include/httpd/httpdhandlerequest.h +++ b/lib-remoteconfig/include/httpd/httpdhandlerequest.h @@ -48,7 +48,7 @@ class HttpDeamonHandleRequest { DEBUG_EXIT } - void HandleRequest(const uint32_t nBytesReceived, char *pRequestHeaderResponse); + void HandleRequest(const uint32_t nBytesReceived, char *m_pReceiveBuffer); private: http::Status ParseRequest(); @@ -64,17 +64,17 @@ class HttpDeamonHandleRequest { int32_t m_nHandle; uint32_t m_nContentSize { 0 }; uint32_t m_nFileDataLength { 0 }; - uint32_t m_nRequestContentSize { 0 }; + uint32_t m_nRequestContentLength { 0 }; uint32_t m_nBytesReceived { 0 }; char *m_pUri { nullptr }; char *m_pFileData { nullptr }; const char *m_pContent { nullptr }; - char *m_RequestHeaderResponse { nullptr }; + char *m_pReceiveBuffer { nullptr }; http::Status m_Status { http::Status::UNKNOWN_ERROR }; http::RequestMethod m_RequestMethod { http::RequestMethod::UNKNOWN }; - http::contentTypes m_ContentType { http::contentTypes::NOT_DEFINED }; + http::contentTypes m_RequestContentType { http::contentTypes::NOT_DEFINED }; bool m_IsAction { false }; diff --git a/lib-remoteconfig/include/remoteconfig.h b/lib-remoteconfig/include/remoteconfig.h index 994829ff7..442c7bfb7 100644 --- a/lib-remoteconfig/include/remoteconfig.h +++ b/lib-remoteconfig/include/remoteconfig.h @@ -216,12 +216,6 @@ class RemoteConfig { return; } -//#if defined (ENABLE_TFTP_SERVER) -// if (__builtin_expect((m_pTFTPFileServer != nullptr), 0)) { -// m_pTFTPFileServer->Run(); -// } -//#endif - uint16_t nForeignPort; m_nBytesReceived = Network::Get()->RecvFrom(m_nHandle, const_cast(reinterpret_cast(&s_pUdpBuffer)), &m_nIPAddressFrom, &nForeignPort); @@ -481,10 +475,15 @@ class RemoteConfig { void PlatformHandleTftpGet(); private: - remoteconfig::Node m_tNode; - remoteconfig::Output m_tOutput; + remoteconfig::Node m_Node; + remoteconfig::Output m_Output; uint32_t m_nActiveOutputs; + char *s_pUdpBuffer { nullptr }; + int32_t m_nHandle { -1 }; + uint32_t m_nIPAddressFrom { 0 }; + uint32_t m_nBytesReceived { 0 }; + struct Commands { void (RemoteConfig::*pHandler)(); const char *pCmd; @@ -512,8 +511,6 @@ class RemoteConfig { char aDisplayName[remoteconfig::DISPLAY_NAME_LENGTH]; }; - static ListBin s_RemoteConfigListBin; - bool m_bDisable { false }; bool m_bDisableWrite { false }; bool m_bEnableReboot { false }; @@ -522,10 +519,6 @@ class RemoteConfig { bool m_bIsReboot { false }; - int32_t m_nHandle { -1 }; - uint32_t m_nIPAddressFrom { 0 }; - uint32_t m_nBytesReceived { 0 }; - #if defined(ENABLE_TFTP_SERVER) TFTPFileServer *m_pTFTPFileServer { nullptr }; #endif @@ -535,12 +528,13 @@ class RemoteConfig { HttpDaemon *m_pHttpDaemon { nullptr }; #endif - static char *s_pUdpBuffer; void static staticCallbackFunction(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) { RemoteConfig::Get()->Input(pBuffer, nSize, nFromIp, nFromPort); } - static RemoteConfig *s_pThis; + + static inline ListBin s_RemoteConfigListBin; + static inline RemoteConfig *s_pThis; }; #endif /* REMOTECONFIG_H_ */ diff --git a/lib-remoteconfig/src/httpd/httpd.cpp b/lib-remoteconfig/src/httpd/httpd.cpp index 914f66c89..e11545e01 100755 --- a/lib-remoteconfig/src/httpd/httpd.cpp +++ b/lib-remoteconfig/src/httpd/httpd.cpp @@ -51,8 +51,6 @@ HttpDaemon::HttpDaemon() { assert(pHandleRequest[nIndex] != nullptr); } -// assert(MDNS::Get() != nullptr); -// MDNS::Get()->ServiceRecordAdd(nullptr, mdns::Services::HTTP); mdns_service_record_add(nullptr, mdns::Services::HTTP); DEBUG_EXIT @@ -61,7 +59,6 @@ HttpDaemon::HttpDaemon() { HttpDaemon::~HttpDaemon() { DEBUG_ENTRY -// MDNS::Get()->ServiceRecordDelete(mdns::Services::HTTP); mdns_service_record_delete(mdns::Services::HTTP); for (uint32_t nIndex = 0; nIndex < TCP_MAX_TCBS_ALLOWED; nIndex++) { diff --git a/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp b/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp index 69a34d702..b17ad6fdb 100755 --- a/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp +++ b/lib-remoteconfig/src/httpd/httpdhandlerequest.cpp @@ -85,11 +85,11 @@ static constexpr char s_request_method[][8] = {"GET", "POST", "DELETE", "UNKNOWN static constexpr char s_contentType[static_cast(http::contentTypes::NOT_DEFINED)][32] = { "text/html", "text/css", "text/javascript", "application/json", "application/octet-stream" }; -void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char *pRequestHeaderResponse) { +void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char *pReceiveBuffer) { DEBUG_ENTRY m_nBytesReceived = nBytesReceived; - m_RequestHeaderResponse = pRequestHeaderResponse; + m_pReceiveBuffer = pReceiveBuffer; const char *pStatusMsg = "OK"; @@ -99,7 +99,9 @@ void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char // This is an initial incoming HTTP request m_Status = ParseRequest(); - DEBUG_PRINTF("%s %s", s_request_method[static_cast(m_RequestMethod)], m_ContentType < http::contentTypes::NOT_DEFINED ? s_contentType[static_cast(m_ContentType)] : "Unknown"); +#ifndef NDEBUG + DEBUG_PRINTF("%s %s", s_request_method[static_cast(m_RequestMethod)], m_RequestContentType < http::contentTypes::NOT_DEFINED ? s_contentType[static_cast(m_RequestContentType)] : "Unknown"); +#endif if (m_Status == http::Status::OK) { // It is a supported request @@ -164,7 +166,7 @@ void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char break; } - m_ContentType = http::contentTypes::TEXT_HTML; + m_RequestContentType = http::contentTypes::TEXT_HTML; m_pContent = m_DynamicContent; m_nContentSize = static_cast(snprintf(m_DynamicContent, sizeof(m_DynamicContent) - 1U, "\n" @@ -174,15 +176,15 @@ void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char "\n", static_cast(m_Status), pStatusMsg, pStatusMsg)); } - const auto nHeaderLength = static_cast(snprintf(m_RequestHeaderResponse, sizeof(m_DynamicContent) - 1U, + const auto nHeaderLength = static_cast(snprintf(m_pReceiveBuffer, sizeof(m_DynamicContent) - 1U, "HTTP/1.1 %u %s\r\n" "Server: %s\r\n" "Content-Type: %s\r\n" "Content-Length: %u\r\n" "Connection: close\r\n" - "\r\n", static_cast(m_Status), pStatusMsg, Network::Get()->GetHostName(), s_contentType[static_cast(m_ContentType)], static_cast(m_nContentSize))); + "\r\n", static_cast(m_Status), pStatusMsg, Network::Get()->GetHostName(), s_contentType[static_cast(m_RequestContentType)], static_cast(m_nContentSize))); - Network::Get()->TcpWrite(m_nHandle, reinterpret_cast(m_RequestHeaderResponse), nHeaderLength, m_nConnectionHandle); + Network::Get()->TcpWrite(m_nHandle, reinterpret_cast(m_pReceiveBuffer), nHeaderLength, m_nConnectionHandle); Network::Get()->TcpWrite(m_nHandle, reinterpret_cast(m_pContent), m_nContentSize, m_nConnectionHandle); DEBUG_PRINTF("m_nContentLength=%u", m_nContentSize); @@ -193,17 +195,17 @@ void HttpDeamonHandleRequest::HandleRequest(const uint32_t nBytesReceived, char } http::Status HttpDeamonHandleRequest::ParseRequest() { - char *pLine = m_RequestHeaderResponse; + char *pLine = m_pReceiveBuffer; uint32_t nLine = 0; http::Status status = http::Status::UNKNOWN_ERROR; - m_ContentType = http::contentTypes::NOT_DEFINED; - m_nRequestContentSize = 0; + m_RequestContentType = http::contentTypes::NOT_DEFINED; + m_nRequestContentLength = 0; m_nFileDataLength = 0; for (uint32_t i = 0; i < m_nBytesReceived; i++) { - if (m_RequestHeaderResponse[i] == '\n') { + if (m_pReceiveBuffer[i] == '\n') { assert(i > 1); - m_RequestHeaderResponse[i - 1] = '\0'; + m_pReceiveBuffer[i - 1] = '\0'; if (nLine++ == 0) { status = ParseMethod(pLine); @@ -211,10 +213,12 @@ http::Status HttpDeamonHandleRequest::ParseRequest() { if (pLine[0] == '\0') { assert((i + 1) <= m_nBytesReceived); m_nFileDataLength = static_cast(m_nBytesReceived - 1 - i); + if (m_nFileDataLength > 0) { - m_pFileData = &m_RequestHeaderResponse[i + 1]; + m_pFileData = &m_pReceiveBuffer[i + 1]; m_pFileData[m_nFileDataLength] = '\0'; } + return http::Status::OK; } status = ParseHeaderField(pLine); @@ -224,7 +228,7 @@ http::Status HttpDeamonHandleRequest::ParseRequest() { return status; } - pLine = &m_RequestHeaderResponse[++i]; + pLine = &m_pReceiveBuffer[++i]; } } @@ -300,12 +304,12 @@ http::Status HttpDeamonHandleRequest::ParseHeaderField(char *pLine) { } if (memcmp(pToken, "application/", 12) == 0) { if (strcmp(&pToken[12], "json") == 0) { - m_ContentType = http::contentTypes::APPLICATION_JSON; + m_RequestContentType = http::contentTypes::APPLICATION_JSON; DEBUG_ENTRY return http::Status::OK; } if (strcmp(&pToken[12], "octet-stream") == 0) { - m_ContentType = http::contentTypes::APPLICATION_OCTET_STREAM; + m_RequestContentType = http::contentTypes::APPLICATION_OCTET_STREAM; DEBUG_ENTRY return http::Status::OK; } @@ -326,7 +330,7 @@ http::Status HttpDeamonHandleRequest::ParseHeaderField(char *pLine) { nTmp += nDigit; } - m_nRequestContentSize = nTmp; + m_nRequestContentLength = nTmp; } DEBUG_EXIT @@ -344,7 +348,7 @@ http::Status HttpDeamonHandleRequest::HandleGet() { m_pContent = &m_DynamicContent[0]; if (memcmp(m_pUri, "/json/", 6) == 0) { - m_ContentType = http::contentTypes::APPLICATION_JSON; + m_RequestContentType = http::contentTypes::APPLICATION_JSON; const auto *pGet = &m_pUri[6]; switch (http::get_uint(pGet)) { case http::json::get::LIST: @@ -507,40 +511,40 @@ http::Status HttpDeamonHandleRequest::HandleGet() { } #if defined (ENABLE_CONTENT) else if (strcmp(m_pUri, "/") == 0) { - m_pContent = get_file_content("index.html", nLength, m_ContentType); + m_pContent = get_file_content("index.html", nLength, m_RequestContentType); } #if defined (HAVE_DMX) else if (strcmp(m_pUri, "/dmx") == 0) { - m_pContent = get_file_content("dmx.html", nLength, m_ContentType); + m_pContent = get_file_content("dmx.html", nLength, m_RequestContentType); } #endif #if defined (RDM_CONTROLLER) && !defined (CONFIG_HTTP_HTML_NO_RDM) else if (strcmp(m_pUri, "/rdm") == 0) { - m_pContent = get_file_content("rdm.html", nLength, m_ContentType); + m_pContent = get_file_content("rdm.html", nLength, m_RequestContentType); } #endif #if defined (NODE_SHOWFILE) else if (strcmp(m_pUri, "/showfile") == 0) { - m_pContent = get_file_content("showfile.html", nLength, m_ContentType); + m_pContent = get_file_content("showfile.html", nLength, m_RequestContentType); } #endif #if defined (ENABLE_PHY_SWITCH) else if (strcmp(m_pUri, "/dsa") == 0) { - m_pContent = get_file_content("dsa.html", nLength, m_ContentType); + m_pContent = get_file_content("dsa.html", nLength, m_RequestContentType); } #endif #if !defined (CONFIG_HTTP_HTML_NO_TIME) else if (strcmp(m_pUri, "/time") == 0) { - m_pContent = get_file_content("time.html", nLength, m_ContentType); + m_pContent = get_file_content("time.html", nLength, m_RequestContentType); } #endif #if !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC) else if (strcmp(m_pUri, "/rtc") == 0) { - m_pContent = get_file_content("rtc.html", nLength, m_ContentType); + m_pContent = get_file_content("rtc.html", nLength, m_RequestContentType); } #endif else { - m_pContent = get_file_content(&m_pUri[1], nLength, m_ContentType); + m_pContent = get_file_content(&m_pUri[1], nLength, m_RequestContentType); } #endif @@ -584,10 +588,10 @@ http::Status HttpDeamonHandleRequest::HandleGetTxt() { http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { DEBUG_ENTRY - DEBUG_PRINTF("m_nBytesReceived=%d, m_nFileDataLength=%u, m_nRequestContentLength=%u -> hasDataOnly=%c", m_nBytesReceived, m_nFileDataLength, m_nRequestContentSize, hasDataOnly ? 'Y' : 'N'); + DEBUG_PRINTF("m_nBytesReceived=%d, m_nFileDataLength=%u, m_nRequestContentLength=%u -> hasDataOnly=%c", m_nBytesReceived, m_nFileDataLength, m_nRequestContentLength, hasDataOnly ? 'Y' : 'N'); if (!hasDataOnly) { - if (m_ContentType != http::contentTypes::APPLICATION_JSON) { + if (m_RequestContentType != http::contentTypes::APPLICATION_JSON) { DEBUG_EXIT return http::Status::BAD_REQUEST; } @@ -600,7 +604,7 @@ http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { } } - const auto hasHeadersOnly = (!hasDataOnly && ((m_nBytesReceived < m_nRequestContentSize) || m_nFileDataLength == 0)); + const auto hasHeadersOnly = (!hasDataOnly && ((m_nBytesReceived < m_nRequestContentLength) || m_nFileDataLength == 0)); if (hasHeadersOnly) { DEBUG_PUTS("hasHeadersOnly"); @@ -609,7 +613,7 @@ http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { } if (hasDataOnly) { - m_pFileData = m_RequestHeaderResponse; + m_pFileData = m_pReceiveBuffer; m_nFileDataLength = static_cast(m_nBytesReceived); } @@ -682,7 +686,7 @@ http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { PropertiesConfig::EnableJSON(bIsJSON); } - m_ContentType = http::contentTypes::TEXT_HTML; + m_RequestContentType = http::contentTypes::TEXT_HTML; m_nContentSize = static_cast(snprintf(m_DynamicContent, sizeof(m_DynamicContent) - 1U, "\n" "\n" @@ -694,11 +698,15 @@ http::Status HttpDeamonHandleRequest::HandlePost(const bool hasDataOnly) { return http::Status::OK; } +/** + * DELETE + */ + http::Status HttpDeamonHandleRequest::HandleDelete(const bool hasDataOnly) { - DEBUG_PRINTF("m_nBytesReceived=%d, m_nFileDataLength=%u, m_nRequestContentLength=%u -> hasDataOnly=%c", m_nBytesReceived, m_nFileDataLength, m_nRequestContentSize, hasDataOnly ? 'Y' : 'N'); + DEBUG_PRINTF("m_nBytesReceived=%d, m_nFileDataLength=%u, m_nRequestContentLength=%u -> hasDataOnly=%c", m_nBytesReceived, m_nFileDataLength, m_nRequestContentLength, hasDataOnly ? 'Y' : 'N'); if (!hasDataOnly) { - if (m_ContentType != http::contentTypes::APPLICATION_JSON) { + if (m_RequestContentType != http::contentTypes::APPLICATION_JSON) { DEBUG_EXIT return http::Status::BAD_REQUEST; } @@ -711,7 +719,7 @@ http::Status HttpDeamonHandleRequest::HandleDelete(const bool hasDataOnly) { } } - const auto hasHeadersOnly = (!hasDataOnly && ((m_nBytesReceived < m_nRequestContentSize) || m_nFileDataLength == 0)); + const auto hasHeadersOnly = (!hasDataOnly && ((m_nBytesReceived < m_nRequestContentLength) || m_nFileDataLength == 0)); if (hasHeadersOnly) { DEBUG_PUTS("hasHeadersOnly"); @@ -720,7 +728,7 @@ http::Status HttpDeamonHandleRequest::HandleDelete(const bool hasDataOnly) { } if (hasDataOnly) { - m_pFileData = m_RequestHeaderResponse; + m_pFileData = m_pReceiveBuffer; m_nFileDataLength = static_cast(m_nBytesReceived); } @@ -748,7 +756,7 @@ http::Status HttpDeamonHandleRequest::HandleDelete(const bool hasDataOnly) { return http::Status::BAD_REQUEST; } - m_ContentType = http::contentTypes::TEXT_HTML; + m_RequestContentType = http::contentTypes::TEXT_HTML; m_nContentSize = static_cast(snprintf(m_DynamicContent, sizeof(m_DynamicContent) - 1U, "\n" "\n" diff --git a/lib-remoteconfig/src/shell/shellcmd.cpp b/lib-remoteconfig/src/shell/shellcmd.cpp index 457fcbe53..8837e1efc 100755 --- a/lib-remoteconfig/src/shell/shellcmd.cpp +++ b/lib-remoteconfig/src/shell/shellcmd.cpp @@ -45,8 +45,8 @@ // Firmware specific BEGIN #if defined (LTC_READER) # include "ltc.h" -# include "ltcgenerator.h" -# include "systimereader.h" +# include "arm/ltcgenerator.h" +# include "arm/systimereader.h" #endif // Firmware specific BEGIN diff --git a/lib-showfile/Rules.mk b/lib-showfile/Rules.mk index 21bb2b9fc..be9bc5fa6 100755 --- a/lib-showfile/Rules.mk +++ b/lib-showfile/Rules.mk @@ -51,6 +51,7 @@ else # DEFINES+=CONFIG_SHOWFILE_PROTOCOL_E131 DEFINES+=CONFIG_SHOWFILE_PROTOCOL_NODE_E131 DEFINES+=CONFIG_SHOWFILE_ENABLE_OSC + DEFINES+=DEBUG_SHOWFILEOSC endif $(info $$EXTRA_SRCDIR [${EXTRA_SRCDIR}]) diff --git a/lib-showfile/include/protocols/showfileprotocole131.h b/lib-showfile/include/protocols/showfileprotocole131.h index 975ac7fba..d86009b8d 100755 --- a/lib-showfile/include/protocols/showfileprotocole131.h +++ b/lib-showfile/include/protocols/showfileprotocole131.h @@ -87,7 +87,7 @@ class ShowFileProtocol { } void Run() { - m_E131Controller.Run(); + // Nothing todo here } bool IsSyncDisabled() { diff --git a/lib-showfile/src/osc/showfileosc.cpp b/lib-showfile/src/osc/showfileosc.cpp index ece8e6124..9564b2650 100644 --- a/lib-showfile/src/osc/showfileosc.cpp +++ b/lib-showfile/src/osc/showfileosc.cpp @@ -78,7 +78,7 @@ namespace length { } void ShowFileOSC::Process() { - DEBUG_PRINTF("[%s] %d,%d %s", m_pBuffer, static_cast(strlen(m_pBuffer)), static_cast(showfileosc::PATH_LENGTH), &m_pBuffer[showfileosc::PATH_LENGTH]); + DEBUG_PRINTF("[%s] %d,%d %s", m_pBuffer, static_cast(strlen(reinterpret_cast(m_pBuffer))), static_cast(showfileosc::PATH_LENGTH), &m_pBuffer[showfileosc::PATH_LENGTH]); if (memcmp(&m_pBuffer[showfileosc::PATH_LENGTH], cmd::START, length::START) == 0) { ShowFile::Get()->Play(); diff --git a/lib-tcnet/include/tcnet.h b/lib-tcnet/include/tcnet.h index d94ee5634..093b3251a 100755 --- a/lib-tcnet/include/tcnet.h +++ b/lib-tcnet/include/tcnet.h @@ -26,16 +26,12 @@ #ifndef TCNET_H_ #define TCNET_H_ -#pragma GCC push_options -#pragma GCC optimize ("O2") -#pragma GCC optimize ("no-tree-loop-distribute-patterns") - #include #include #include +#include #include -#include "tcnet.h" #include "tcnetconst.h" #include "tcnetpackets.h" #include "tcnettimecode.h" @@ -423,6 +419,4 @@ class TCNet { static inline TCNet *s_pThis; }; -#pragma GCC pop_options - #endif /* TCNET_H_ */ diff --git a/lib-ws28xxdmx/include/ws28xxdmxmulti.h b/lib-ws28xxdmx/include/ws28xxdmxmulti.h index ebbf18091..0e72e91d6 100644 --- a/lib-ws28xxdmx/include/ws28xxdmxmulti.h +++ b/lib-ws28xxdmx/include/ws28xxdmxmulti.h @@ -26,6 +26,11 @@ #ifndef WS28XXDMXMULTI_H_ #define WS28XXDMXMULTI_H_ +#pragma GCC push_options +#pragma GCC optimize ("O3") +#pragma GCC optimize ("-funroll-loops") +#pragma GCC optimize ("-fprefetch-loop-arrays") + #include #include @@ -35,7 +40,6 @@ #include "ws28xxmulti.h" #include "pixeldmxconfiguration.h" -#include "pixelpatterns.h" #include "logic_analyzer.h" @@ -152,4 +156,5 @@ class WS28xxDmxMulti final: public LightSet { bool m_bBlackout { false }; }; +#pragma GCC pop_options #endif /* WS28XXDMXMULTI_H_ */ From 8d8e71d62329d798f7a736eefd9374a3e8d62765 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:35:28 +0100 Subject: [PATCH 29/36] Fixed issue with pixel multi and dmx sync --- lib-artnet/include/artnetstore.h | 55 ++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/lib-artnet/include/artnetstore.h b/lib-artnet/include/artnetstore.h index c627eb01f..6225a6502 100644 --- a/lib-artnet/include/artnetstore.h +++ b/lib-artnet/include/artnetstore.h @@ -5,7 +5,7 @@ /** * Art-Net Designed by and Copyright Artistic Licence Holdings Ltd. */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,16 +33,11 @@ #include #include "artnetparams.h" -#include "configstore.h" #include "artnetnode.h" -#include "debug.h" +#include "configstore.h" -namespace artnetnode { -namespace configstore { -extern uint32_t DMXPORT_OFFSET; -} // namespace configstore -} // namespace artnetnode +#include "debug.h" class ArtNetStore { public: @@ -57,12 +52,14 @@ class ArtNetStore { DEBUG_ENTRY DEBUG_PRINTF("%u, %s", nPortIndex, pShortName); - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); @@ -98,12 +95,14 @@ class ArtNetStore { DEBUG_ENTRY DEBUG_PRINTF("%u, %u", nPortIndex, static_cast(mergeMode)); - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); @@ -125,14 +124,16 @@ class ArtNetStore { static void SavePortProtocol(uint32_t nPortIndex, const artnet::PortProtocol portProtocol) { DEBUG_ENTRY - DEBUG_PRINTF("artnetnode::configstore::DMXPORT_OFFSET=%u, nPortIndex=%u, portProtocol=%u", artnetnode::configstore::DMXPORT_OFFSET, nPortIndex, static_cast(portProtocol)); + DEBUG_PRINTF("nPortIndex=%u, portProtocol=%u", nPortIndex, static_cast(portProtocol)); - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); @@ -153,14 +154,16 @@ class ArtNetStore { static void SaveOutputStyle(uint32_t nPortIndex, const lightset::OutputStyle outputStyle) { DEBUG_ENTRY - DEBUG_PRINTF("artnetnode::configstore::DMXPORT_OFFSET=%u, nPortIndex=%u, outputStyle=%u", artnetnode::configstore::DMXPORT_OFFSET, nPortIndex, static_cast(outputStyle)); + DEBUG_PRINTF("nPortIndex=%u, outputStyle=%u", nPortIndex, static_cast(outputStyle)); - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); @@ -185,14 +188,16 @@ class ArtNetStore { static void SaveRdmEnabled(uint32_t nPortIndex, const bool isEnabled) { DEBUG_ENTRY - DEBUG_PRINTF("artnetnode::configstore::DMXPORT_OFFSET=%u, nPortIndex=%u, isEnabled=%d", artnetnode::configstore::DMXPORT_OFFSET, nPortIndex, isEnabled); + DEBUG_PRINTF(" nPortIndex=%u, isEnabled=%d", nPortIndex, isEnabled); - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); @@ -225,17 +230,19 @@ class ArtNetStore { private: void static SaveUniverse(uint32_t nPortIndex) { DEBUG_ENTRY - DEBUG_PRINTF("artnetnode::configstore::DMXPORT_OFFSET=%u, nPortIndex=%u", artnetnode::configstore::DMXPORT_OFFSET, nPortIndex); + DEBUG_PRINTF("nPortIndex=%u", nPortIndex); uint16_t nUniverse; if (ArtNetNode::Get()->GetPortAddress(nPortIndex, nUniverse)) { - if (nPortIndex >= artnetnode::configstore::DMXPORT_OFFSET) { - nPortIndex -= artnetnode::configstore::DMXPORT_OFFSET; +#if defined(CONFIG_DMX_PORT_OFFSET) + if (nPortIndex >= CONFIG_DMX_PORT_OFFSET) { + nPortIndex -= CONFIG_DMX_PORT_OFFSET; } else { DEBUG_EXIT return; } +#endif DEBUG_PRINTF("nPortIndex=%u", nPortIndex); From 60f78586c0906bb908b26274ad18f1204880e9e3 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:35:50 +0100 Subject: [PATCH 30/36] Added support for bitbang SPI --- lib-h3/include/h3_spi.h | 12 ++++++- lib-h3/src/h3_spi.cpp | 72 ++++++++++++++++++++++++++++++----------- 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/lib-h3/include/h3_spi.h b/lib-h3/include/h3_spi.h index 2f1df62c7..24793650a 100644 --- a/lib-h3/include/h3_spi.h +++ b/lib-h3/include/h3_spi.h @@ -2,7 +2,7 @@ * @file h3_spi.h * */ -/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -79,4 +79,14 @@ const uint8_t *h3_spi_dma_tx_prepare(uint32_t *data_length); void h3_spi_dma_tx_start(const uint8_t *tx_buffer, uint32_t length); bool h3_spi_dma_tx_is_active(); +/* + * bitbang support + */ + +void h3_bitbang_spi_begin(); +void h3_bitbang_spi_chipSelect(const uint8_t chip_select); +void h3_bitbang_spi_set_speed_hz(const uint32_t speed_hz); +void h3_bitbang_spi_setDataMode(const uint8_t mode); +void h3_bitbang_spi_writenb(const char *tx_buffer, uint32_t data_length); +void h3_bitbang_spi_write(uint16_t data); #endif /* H3_SPI_H_ */ diff --git a/lib-h3/src/h3_spi.cpp b/lib-h3/src/h3_spi.cpp index f0f7f3a66..571c89e81 100644 --- a/lib-h3/src/h3_spi.cpp +++ b/lib-h3/src/h3_spi.cpp @@ -2,7 +2,7 @@ * @file h3_spi.c * */ -/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2018-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -535,14 +535,8 @@ uint8_t h3_spi_transfer(uint8_t data) { * DMA support */ -#if 0 -# define SPI_DMA_COHERENT_REGION_SIZE (MEGABYTE/8) -# define SPI_DMA_COHERENT_REGION (H3_MEM_COHERENT_REGION + MEGABYTE/2 + MEGABYTE/4) -#else -# define SPI_DMA_COHERENT_REGION_SIZE (H3_SRAM_A2_SIZE) -# define SPI_DMA_COHERENT_REGION (H3_SRAM_A2_BASE) -#endif - +#define SPI_DMA_COHERENT_REGION_SIZE (MEGABYTE/8) +#define SPI_DMA_COHERENT_REGION (H3_MEM_COHERENT_REGION + MEGABYTE/2 + MEGABYTE/4) #define SPI_DMA_TX_BUFFER_SIZE (SPI_DMA_COHERENT_REGION_SIZE - sizeof(struct sunxi_dma_lli)) struct dma_spi { @@ -589,14 +583,14 @@ const uint8_t *h3_spi_dma_tx_prepare(uint32_t *size) { return reinterpret_cast(&p_dma_tx->tx_buffer); } -void h3_spi_dma_tx_start(const uint8_t *tx_buffer, uint32_t data_length) { +void h3_spi_dma_tx_start(const uint8_t *pTxBuffer, uint32_t nLength) { assert(!is_running); - assert(tx_buffer != 0); // TODO Not valid when SRAM is used - assert(data_length <= static_cast(sizeof(p_dma_tx->tx_buffer)) - (reinterpret_cast(tx_buffer)) - reinterpret_cast(&p_dma_tx->tx_buffer)); -// assert(((uint32_t) tx_buffer & H3_MEM_COHERENT_REGION) == H3_MEM_COHERENT_REGION); + assert(pTxBuffer != 0); + assert(nLength <= static_cast(sizeof(p_dma_tx->tx_buffer)) - (reinterpret_cast(pTxBuffer)) - reinterpret_cast(&p_dma_tx->tx_buffer)); + assert(((uint32_t) pTxBuffer & H3_MEM_COHERENT_REGION) == H3_MEM_COHERENT_REGION); - p_dma_tx->lli.src = reinterpret_cast(tx_buffer); - p_dma_tx->lli.len = data_length; + p_dma_tx->lli.src = reinterpret_cast(pTxBuffer); + p_dma_tx->lli.len = nLength; dmb(); EXT_SPI->GC &= static_cast(~(1U << 7)); @@ -605,9 +599,9 @@ void h3_spi_dma_tx_start(const uint8_t *tx_buffer, uint32_t data_length) { EXT_SPI->IS = static_cast(~0); EXT_SPI->IE = IE_TC; - EXT_SPI->MBC = data_length; - EXT_SPI->MTC = data_length; - EXT_SPI->BCC = data_length; + EXT_SPI->MBC = nLength; + EXT_SPI->MTC = nLength; + EXT_SPI->BCC = nLength; EXT_SPI->TC |= (1U << 31); EXT_SPI->FC |= (1 << 24); @@ -617,3 +611,45 @@ void h3_spi_dma_tx_start(const uint8_t *tx_buffer, uint32_t data_length) { is_running = true; } + +/* + * bitbang support + */ + +void __attribute__((cold)) h3_bitbang_spi_begin() { + h3_gpio_fsel(EXT_SPI_CS, GPIO_FSEL_OUTPUT); + h3_gpio_fsel(EXT_SPI_CLK, GPIO_FSEL_OUTPUT); + h3_gpio_fsel(EXT_SPI_MOSI, GPIO_FSEL_OUTPUT); + h3_gpio_fsel(EXT_SPI_MISO, GPIO_FSEL_INPUT); +} + +void __attribute__((cold)) h3_bitbang_spi_chipSelect([[maybe_unused]] const uint8_t chip_select) { + +} + +void __attribute__((cold)) h3_bitbang_spi_set_speed_hz([[maybe_unused]] const uint32_t speed_hz) { + +} + +void __attribute__((cold)) h3_bitbang_spi_setDataMode([[maybe_unused]] const uint8_t mode) { + +} + +static inline void bitbang_spi_write(const char c) { + for (uint32_t nMask = (1U << 7); nMask != 0; nMask = (nMask >> 1U)) { + if (c & nMask) { + h3_gpio_set(EXT_SPI_MOSI); + } else { + h3_gpio_clr(EXT_SPI_MOSI); + } + + h3_gpio_set(EXT_SPI_CLK); + h3_gpio_clr(EXT_SPI_CLK); + } +} + +void h3_bitbang_spi_writenb(const char *pTxBuffer, uint32_t nLength) { + for (uint32_t i = 0; i < nLength; i++) { + bitbang_spi_write(pTxBuffer[i]); + } +} From 1d3ac619e36fa92d5f50961dab5b1ad3888c188d Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Mon, 11 Nov 2024 21:37:21 +0100 Subject: [PATCH 31/36] Removed #include "networkconst.h" Removed: - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); --- opi_dmx_monitor/firmware/main.cpp | 3 -- opi_emac_artnet_monitor/firmware/main.cpp | 12 +----- opi_emac_artnet_monitor/lib/timecode.cpp | 18 ++++---- opi_emac_osc_client/firmware/main.cpp | 7 +-- opi_emac_osc_dmx/firmware/main.cpp | 7 +-- opi_emac_osc_monitor/firmware/main.cpp | 8 +--- opi_emac_osc_pixel/firmware/main.cpp | 6 +-- opi_emac_pp_pixel_multi/firmware/main.cpp | 5 +-- .../lib/rdmsoftwareversion.cpp | 43 ------------------- 9 files changed, 20 insertions(+), 89 deletions(-) delete mode 100644 opi_emac_pp_pixel_multi/lib/rdmsoftwareversion.cpp diff --git a/opi_dmx_monitor/firmware/main.cpp b/opi_dmx_monitor/firmware/main.cpp index 43ce29a67..916582e7c 100644 --- a/opi_dmx_monitor/firmware/main.cpp +++ b/opi_dmx_monitor/firmware/main.cpp @@ -61,10 +61,7 @@ int main() { DisplayUdf display; #if !defined(NO_EMAC) ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); - #endif console_clear(); diff --git a/opi_emac_artnet_monitor/firmware/main.cpp b/opi_emac_artnet_monitor/firmware/main.cpp index 31a3d4e97..3a12f3f17 100644 --- a/opi_emac_artnet_monitor/firmware/main.cpp +++ b/opi_emac_artnet_monitor/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -63,21 +63,13 @@ #include "firmwareversion.h" #include "software_version.h" -namespace artnetnode { -namespace configstore { -uint32_t DMXPORT_OFFSET = 0; -} // namespace configstore -} // namespace artnetnode - void Hardware::RebootHandler() { } int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -174,7 +166,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_artnet_monitor/lib/timecode.cpp b/opi_emac_artnet_monitor/lib/timecode.cpp index 8186bdac2..31cc289a2 100644 --- a/opi_emac_artnet_monitor/lib/timecode.cpp +++ b/opi_emac_artnet_monitor/lib/timecode.cpp @@ -2,7 +2,7 @@ * @file timecode.cpp * */ -/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl +/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,17 +39,17 @@ static constexpr auto COLUMN = 80; static constexpr auto TC_LENGTH = sizeof(s_aTimecode) - 1; static constexpr char TC_TYPES[4][8] __attribute__ ((aligned (4))) = { "Film ", "EBU ", "DF ", "SMPTE" }; -inline static void itoa_base10(uint32_t nArg, char *pBuffer) { +static void itoa(const uint32_t nValue, char *pBuffer) { auto *nDst = pBuffer; - if (nArg == 0) { + if (nValue == 0) { *nDst++ = '0'; *nDst = '0'; return; } - *nDst++ = static_cast('0' + (nArg / 10)); - *nDst = static_cast('0' + (nArg % 10)); + *nDst++ = static_cast('0' + (nValue / 10)); + *nDst = static_cast('0' + (nValue % 10)); } void TimeCode::Start() { @@ -66,10 +66,10 @@ void TimeCode::Stop() { } void TimeCode::Handler(const struct artnet::TimeCode *ArtNetTimeCode) { - itoa_base10(ArtNetTimeCode->Hours, &s_aTimecode[0]); - itoa_base10(ArtNetTimeCode->Minutes, &s_aTimecode[3]); - itoa_base10(ArtNetTimeCode->Seconds, &s_aTimecode[6]); - itoa_base10(ArtNetTimeCode->Frames, &s_aTimecode[9]); + itoa(ArtNetTimeCode->Hours, &s_aTimecode[0]); + itoa(ArtNetTimeCode->Minutes, &s_aTimecode[3]); + itoa(ArtNetTimeCode->Seconds, &s_aTimecode[6]); + itoa(ArtNetTimeCode->Frames, &s_aTimecode[9]); if ((nTypePrevious != ArtNetTimeCode->Type) && (ArtNetTimeCode->Type < 4)) { memcpy(&s_aTimecode[12], TC_TYPES[ArtNetTimeCode->Type], 5); diff --git a/opi_emac_osc_client/firmware/main.cpp b/opi_emac_osc_client/firmware/main.cpp index 3229b218a..55f27e4d0 100644 --- a/opi_emac_osc_client/firmware/main.cpp +++ b/opi_emac_osc_client/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "display.h" @@ -60,15 +60,12 @@ int main() { Hardware hw; Display display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("OSC Client"); - OscClientParams params; OscClient client; @@ -139,7 +136,7 @@ int main() { pButtonsSet->Run(); remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_osc_dmx/firmware/main.cpp b/opi_emac_osc_dmx/firmware/main.cpp index 8822c040d..ea623e1e9 100644 --- a/opi_emac_osc_dmx/firmware/main.cpp +++ b/opi_emac_osc_dmx/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "display.h" @@ -61,14 +61,11 @@ int main() { Hardware hw; Display display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("OSC Server DMX"); - OSCServerParams params; OscServer server; @@ -129,7 +126,7 @@ int main() { server.Run(); remoteConfig.Run(); configStore.Flash(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_osc_monitor/firmware/main.cpp b/opi_emac_osc_monitor/firmware/main.cpp index ca2218ebc..8bbb173d9 100644 --- a/opi_emac_osc_monitor/firmware/main.cpp +++ b/opi_emac_osc_monitor/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "console.h" @@ -64,9 +64,7 @@ int main() { Hardware hw; Display display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -80,8 +78,6 @@ int main() { console_set_fg_color(CONSOLE_WHITE); console_set_top_row(2); - - ShowSystime showSystime; display.TextStatus(OscServerMsgConst::PARAMS, CONSOLE_YELLOW); @@ -142,7 +138,7 @@ int main() { configStore.Flash(); ntpClient.Run(); showSystime.Run(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_osc_pixel/firmware/main.cpp b/opi_emac_osc_pixel/firmware/main.cpp index ca8d2363e..da62ed071 100644 --- a/opi_emac_osc_pixel/firmware/main.cpp +++ b/opi_emac_osc_pixel/firmware/main.cpp @@ -27,7 +27,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -63,9 +63,7 @@ int main() { Hardware hw; Display display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; @@ -138,7 +136,7 @@ int main() { remoteConfig.Run(); configStore.Flash(); pixelTestPattern.Run(); -// mdns_run(); // mDns.Run(); // mDns.Run(); + display.Run(); hw.Run(); } diff --git a/opi_emac_pp_pixel_multi/firmware/main.cpp b/opi_emac_pp_pixel_multi/firmware/main.cpp index 33665f76d..ec6c14457 100644 --- a/opi_emac_pp_pixel_multi/firmware/main.cpp +++ b/opi_emac_pp_pixel_multi/firmware/main.cpp @@ -28,7 +28,7 @@ #include "hardware.h" #include "network.h" -#include "networkconst.h" + #include "net/apps/mdns.h" @@ -75,14 +75,11 @@ int main() { Hardware hw; DisplayUdf display; ConfigStore configStore; - display.TextStatus(NetworkConst::MSG_NETWORK_INIT, CONSOLE_YELLOW); Network nw; - display.TextStatus(NetworkConst::MSG_NETWORK_STARTED, CONSOLE_GREEN); FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__); FlashCodeInstall spiFlashInstall; fw.Print("PixelPusher controller 8x 4U"); - mdns_service_record_add(nullptr, mdns::Services::PP, "type=PixelPusher"); diff --git a/opi_emac_pp_pixel_multi/lib/rdmsoftwareversion.cpp b/opi_emac_pp_pixel_multi/lib/rdmsoftwareversion.cpp deleted file mode 100644 index 31ac23881..000000000 --- a/opi_emac_pp_pixel_multi/lib/rdmsoftwareversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rdmsoftwareversion.cpp - * - */ -/* Copyright (C) 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. - */ - -#include - -#include "rdmsoftwareversion.h" - -#include "software_version.h" -#include "software_version_id.h" - -const char *RDMSoftwareVersion::GetVersion() { - return SOFTWARE_VERSION; -} - -uint32_t RDMSoftwareVersion::GetVersionLength() { - return sizeof(SOFTWARE_VERSION) / sizeof(SOFTWARE_VERSION[0]) - 1; -} - -uint32_t RDMSoftwareVersion::GetVersionId() { - return DEVICE_SOFTWARE_VERSION_ID; -} From 0a4bd1373345bf1d00dedd77e3f6e8dc12d4bc31 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Tue, 12 Nov 2024 12:21:39 +0100 Subject: [PATCH 32/36] Updated build_h3-firmware.sh --- scripts/build_h3-firmware.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build_h3-firmware.sh b/scripts/build_h3-firmware.sh index 886e42d11..6b155a943 100755 --- a/scripts/build_h3-firmware.sh +++ b/scripts/build_h3-firmware.sh @@ -21,9 +21,13 @@ do_check() maxsize=139264 filesize=$(stat -c%s "$1") if (( filesize > maxsize )); then - echo -e "\e[31m[$1 is too big for SPI Flash -> $filesize]\e[0m" + echo -e "\e[33m[$1 is too big for SPI Flash -> $filesize]\e[0m" rm -rf $1 ls -al "$1.gz" + filesize=$(stat -c%s "$1.gz") + if (( filesize > maxsize )); then + echo -e "\e[31m[Error: $1.gz is too big for SPI Flash -> $filesize]\e[0m" + fi else ls -al "$1" fi From aa5e3ec656ba7e7622ff8b41f9d2448f8105a54e Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Tue, 12 Nov 2024 15:46:41 +0100 Subject: [PATCH 33/36] Updated SOFTWARE_VERSION[] --- opi_dmx_monitor/include/software_version.h | 2 +- opi_dmx_usb_pro/include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_artnet_dmx_multi/Makefile.H3 | 2 +- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_artnet_pixel/firmware/main.cpp | 6 ++++-- .../include/software_version.h | 2 +- opi_emac_artnet_pixel_dmx/firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- opi_emac_artnet_pixel_dmx_multi/Makefile.H3 | 6 +----- .../firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- opi_emac_artnet_pixel_multi/firmware/main.cpp | 6 ++++-- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- .../firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- opi_emac_ddp_pixel_multi/firmware/main.cpp | 7 ++++--- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_e131_dmx/include/software_version.h | 2 +- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_e131_pixel/firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- opi_emac_e131_pixel_dmx/firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- .../firmware/main.cpp | 5 ++++- .../include/software_version.h | 2 +- opi_emac_e131_pixel_multi/firmware/main.cpp | 6 ++++-- .../include/software_version.h | 2 +- opi_emac_llrp_tftpd/Makefile.H3 | 20 +++++++++++++++---- .../include/software_version.h | 2 +- opi_emac_ltc_smpte/Makefile.H3 | 20 ------------------- opi_emac_ltc_smpte/firmware/main.cpp | 5 ++++- opi_emac_ltc_smpte/include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_osc_dmx/include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_emac_osc_pixel/include/software_version.h | 2 +- opi_emac_pp_pixel_multi/firmware/main.cpp | 7 ++++--- .../include/software_version.h | 2 +- opi_emac_showfile_artnet/Makefile.H3 | 3 --- .../include/software_version.h | 2 +- .../include/software_version.h | 2 +- opi_midi_monitor/include/software_version.h | 2 +- opi_rdm_responder/include/software_version.h | 2 +- .../include/software_version.h | 2 +- 51 files changed, 100 insertions(+), 86 deletions(-) diff --git a/opi_dmx_monitor/include/software_version.h b/opi_dmx_monitor/include/software_version.h index 5d0ab9767..d62e76e4b 100644 --- a/opi_dmx_monitor/include/software_version.h +++ b/opi_dmx_monitor/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.9"; +constexpr char SOFTWARE_VERSION[] = "3.0"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_dmx_usb_pro/include/software_version.h b/opi_dmx_usb_pro/include/software_version.h index d62e76e4b..613f7331d 100644 --- a/opi_dmx_usb_pro/include/software_version.h +++ b/opi_dmx_usb_pro/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.0"; +constexpr char SOFTWARE_VERSION[] = "3.1"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_dmx/include/software_version.h b/opi_emac_artnet_dmx/include/software_version.h index 7ec209076..7f465a8b9 100644 --- a/opi_emac_artnet_dmx/include/software_version.h +++ b/opi_emac_artnet_dmx/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "4.9"; +constexpr char SOFTWARE_VERSION[] = "5.0"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_dmx_multi/Makefile.H3 b/opi_emac_artnet_dmx_multi/Makefile.H3 index 9f084c660..0812e13db 100644 --- a/opi_emac_artnet_dmx_multi/Makefile.H3 +++ b/opi_emac_artnet_dmx_multi/Makefile.H3 @@ -29,7 +29,7 @@ endif DEFINES+=DISABLE_RTC -#DEFINES+=NDEBUG +DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_dmx_multi/include/software_version.h b/opi_emac_artnet_dmx_multi/include/software_version.h index 21fa986a1..a5522bb98 100644 --- a/opi_emac_artnet_dmx_multi/include/software_version.h +++ b/opi_emac_artnet_dmx_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "4.2"; +constexpr char SOFTWARE_VERSION[] = "4.3"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_monitor/include/software_version.h b/opi_emac_artnet_monitor/include/software_version.h index 2b5c09491..d25e610ac 100644 --- a/opi_emac_artnet_monitor/include/software_version.h +++ b/opi_emac_artnet_monitor/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.3"; +constexpr char SOFTWARE_VERSION[] = "3.4"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_pixel/firmware/main.cpp b/opi_emac_artnet_pixel/firmware/main.cpp index a73f5203a..d6e505166 100644 --- a/opi_emac_artnet_pixel/firmware/main.cpp +++ b/opi_emac_artnet_pixel/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" @@ -46,7 +49,6 @@ #include "pixeldmxparams.h" #include "ws28xxdmx.h" - #if defined (NODE_RDMNET_LLRP_ONLY) # include "rdmdeviceparams.h" # include "rdmnetdevice.h" diff --git a/opi_emac_artnet_pixel/include/software_version.h b/opi_emac_artnet_pixel/include/software_version.h index 7f465a8b9..ac0982cf6 100644 --- a/opi_emac_artnet_pixel/include/software_version.h +++ b/opi_emac_artnet_pixel/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "5.0"; +constexpr char SOFTWARE_VERSION[] = "5.1"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_pixel_dmx/firmware/main.cpp b/opi_emac_artnet_pixel_dmx/firmware/main.cpp index 40659d812..bf62d01a9 100644 --- a/opi_emac_artnet_pixel_dmx/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_artnet_pixel_dmx/include/software_version.h b/opi_emac_artnet_pixel_dmx/include/software_version.h index 960640a8c..0d08d12bb 100644 --- a/opi_emac_artnet_pixel_dmx/include/software_version.h +++ b/opi_emac_artnet_pixel_dmx/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.4"; +constexpr char SOFTWARE_VERSION[] = "2.5"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 index 5c2aa6d31..4c861acc0 100644 --- a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 +++ b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 @@ -28,11 +28,7 @@ DEFINES+=DISABLE_RTC DEFINES+=CONFIG_CLIB_ASSERT_REBOOT -#DEFINES+=DEBUG_DISPLAY -#DEFINES+=DEBUG_DISPLAYUDF -DEFINES+=DEBUG_DMX - -#DEFINES+=NDEBUG +DEFINES+=NDEBUG LIBS= diff --git a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp index d484b4d2d..3f63870a7 100644 --- a/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_dmx_multi/firmware/main.cpp @@ -23,13 +23,16 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_artnet_pixel_dmx_multi/include/software_version.h b/opi_emac_artnet_pixel_dmx_multi/include/software_version.h index 1bb26302c..eac346c32 100644 --- a/opi_emac_artnet_pixel_dmx_multi/include/software_version.h +++ b/opi_emac_artnet_pixel_dmx_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.4"; +constexpr char SOFTWARE_VERSION[] = "2.5"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_pixel_multi/firmware/main.cpp b/opi_emac_artnet_pixel_multi/firmware/main.cpp index 57d9104c4..5f34dbb1c 100644 --- a/opi_emac_artnet_pixel_multi/firmware/main.cpp +++ b/opi_emac_artnet_pixel_multi/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" @@ -48,7 +51,6 @@ #include "pixeldmxparams.h" #include "ws28xxdmxmulti.h" - #if defined (NODE_RDMNET_LLRP_ONLY) # include "rdmdeviceparams.h" # include "rdmnetdevice.h" diff --git a/opi_emac_artnet_pixel_multi/include/software_version.h b/opi_emac_artnet_pixel_multi/include/software_version.h index c1088d59a..4c9ec8e65 100644 --- a/opi_emac_artnet_pixel_multi/include/software_version.h +++ b/opi_emac_artnet_pixel_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.5"; +constexpr char SOFTWARE_VERSION[] = "3.6"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_rdm_l6470/include/software_version.h b/opi_emac_artnet_rdm_l6470/include/software_version.h index 613f7331d..a6c2bcd99 100644 --- a/opi_emac_artnet_rdm_l6470/include/software_version.h +++ b/opi_emac_artnet_rdm_l6470/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.1"; +constexpr char SOFTWARE_VERSION[] = "3.2"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_rdm_pca9685/include/software_version.h b/opi_emac_artnet_rdm_pca9685/include/software_version.h index 0781cf4ad..ffe492815 100755 --- a/opi_emac_artnet_rdm_pca9685/include/software_version.h +++ b/opi_emac_artnet_rdm_pca9685/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "1.6"; +constexpr char SOFTWARE_VERSION[] = "1.7"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_artnet_serial/include/software_version.h b/opi_emac_artnet_serial/include/software_version.h index 80dc9877d..b6fed7c5a 100644 --- a/opi_emac_artnet_serial/include/software_version.h +++ b/opi_emac_artnet_serial/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.8"; +constexpr char SOFTWARE_VERSION[] = "2.9"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp index 7c6982f8e..0e6916ca0 100644 --- a/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_dmx_multi/firmware/main.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include @@ -30,7 +34,6 @@ #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_ddp_pixel_dmx_multi/include/software_version.h b/opi_emac_ddp_pixel_dmx_multi/include/software_version.h index 87675180e..960640a8c 100644 --- a/opi_emac_ddp_pixel_dmx_multi/include/software_version.h +++ b/opi_emac_ddp_pixel_dmx_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.3"; +constexpr char SOFTWARE_VERSION[] = "2.4"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_ddp_pixel_multi/firmware/main.cpp b/opi_emac_ddp_pixel_multi/firmware/main.cpp index 6ebd92489..d5748fd8d 100644 --- a/opi_emac_ddp_pixel_multi/firmware/main.cpp +++ b/opi_emac_ddp_pixel_multi/firmware/main.cpp @@ -23,13 +23,16 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" @@ -62,8 +65,6 @@ #include "flashcodeinstall.h" #include "configstore.h" - - #include "firmwareversion.h" #include "software_version.h" diff --git a/opi_emac_ddp_pixel_multi/include/software_version.h b/opi_emac_ddp_pixel_multi/include/software_version.h index 960640a8c..0d08d12bb 100644 --- a/opi_emac_ddp_pixel_multi/include/software_version.h +++ b/opi_emac_ddp_pixel_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.4"; +constexpr char SOFTWARE_VERSION[] = "2.5"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_artnet/include/software_version.h b/opi_emac_e131_artnet/include/software_version.h index 61de6c8df..fbdf5a2f3 100644 --- a/opi_emac_e131_artnet/include/software_version.h +++ b/opi_emac_e131_artnet/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.0"; +constexpr char SOFTWARE_VERSION[] = "3.1"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_dmx/include/software_version.h b/opi_emac_e131_dmx/include/software_version.h index 144db8a79..1916f5ad9 100644 --- a/opi_emac_e131_dmx/include/software_version.h +++ b/opi_emac_e131_dmx/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "4.5"; +constexpr char SOFTWARE_VERSION[] = "4.6"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_dmx_multi/include/software_version.h b/opi_emac_e131_dmx_multi/include/software_version.h index 4c9ec8e65..2b6aa83e3 100644 --- a/opi_emac_e131_dmx_multi/include/software_version.h +++ b/opi_emac_e131_dmx_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.6"; +constexpr char SOFTWARE_VERSION[] = "3.7"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_monitor/include/software_version.h b/opi_emac_e131_monitor/include/software_version.h index 2b5c09491..d25e610ac 100644 --- a/opi_emac_e131_monitor/include/software_version.h +++ b/opi_emac_e131_monitor/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.3"; +constexpr char SOFTWARE_VERSION[] = "3.4"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_pixel/firmware/main.cpp b/opi_emac_e131_pixel/firmware/main.cpp index 660a00abb..416954ca1 100644 --- a/opi_emac_e131_pixel/firmware/main.cpp +++ b/opi_emac_e131_pixel/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_e131_pixel/include/software_version.h b/opi_emac_e131_pixel/include/software_version.h index 1916f5ad9..f36d12ec5 100644 --- a/opi_emac_e131_pixel/include/software_version.h +++ b/opi_emac_e131_pixel/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "4.6"; +constexpr char SOFTWARE_VERSION[] = "4.7"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_pixel_dmx/firmware/main.cpp b/opi_emac_e131_pixel_dmx/firmware/main.cpp index faa5278da..8a59a8954 100644 --- a/opi_emac_e131_pixel_dmx/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_e131_pixel_dmx/include/software_version.h b/opi_emac_e131_pixel_dmx/include/software_version.h index 960640a8c..0d08d12bb 100644 --- a/opi_emac_e131_pixel_dmx/include/software_version.h +++ b/opi_emac_e131_pixel_dmx/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.4"; +constexpr char SOFTWARE_VERSION[] = "2.5"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp index 1b81d757b..8f27562cb 100644 --- a/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_dmx_multi/firmware/main.cpp @@ -23,13 +23,16 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" diff --git a/opi_emac_e131_pixel_dmx_multi/include/software_version.h b/opi_emac_e131_pixel_dmx_multi/include/software_version.h index 960640a8c..0d08d12bb 100644 --- a/opi_emac_e131_pixel_dmx_multi/include/software_version.h +++ b/opi_emac_e131_pixel_dmx_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.4"; +constexpr char SOFTWARE_VERSION[] = "2.5"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_e131_pixel_multi/firmware/main.cpp b/opi_emac_e131_pixel_multi/firmware/main.cpp index 2a205ba46..61a3be1a8 100644 --- a/opi_emac_e131_pixel_multi/firmware/main.cpp +++ b/opi_emac_e131_pixel_multi/firmware/main.cpp @@ -23,12 +23,15 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" @@ -48,7 +51,6 @@ #include "pixeldmxparams.h" #include "ws28xxdmxmulti.h" - #if defined (NODE_RDMNET_LLRP_ONLY) # include "rdmdeviceparams.h" # include "rdmnetdevice.h" diff --git a/opi_emac_e131_pixel_multi/include/software_version.h b/opi_emac_e131_pixel_multi/include/software_version.h index c1088d59a..4c9ec8e65 100644 --- a/opi_emac_e131_pixel_multi/include/software_version.h +++ b/opi_emac_e131_pixel_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.5"; +constexpr char SOFTWARE_VERSION[] = "3.6"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_llrp_tftpd/Makefile.H3 b/opi_emac_llrp_tftpd/Makefile.H3 index 9dac20bfb..0f3093b33 100644 --- a/opi_emac_llrp_tftpd/Makefile.H3 +++ b/opi_emac_llrp_tftpd/Makefile.H3 @@ -7,8 +7,20 @@ DEFINES+=ENABLE_SSD1311 DEFINES+=ENABLE_HTTPD ENABLE_CONTENT -DEFINES+=ENET_LINK_CHECK_REG_POLL - +#DEFINES+=CONFIG_DISPLAY_USE_SPI +#DEFINES+=CONFIG_USE_ST7789 +#DEFINES+=CONFIG_USE_ST7735S +#DEFINES+=SPI_LCD_240X320 +#DEFINES+=SPI_LCD_128X128 +DEFINES+=SPI_LCD_160X80 +DEFINES+=SPI_LCD_HAVE_CS_GPIO +DEFINES+=SPI_LCD_FRAME_BUFFER_ROWS=8 + +#DEFINES+=CONFIG_LCD_SPI_BITBANG +#DEFINES+=CONFIG_SPI_LCD_OPTIMIZE_O2 +#DEFINES+=CONFIG_SPI_LCD_OPTIMIZE_O3 + +DEFINES+=DEBUG_I2C DEFINES+=DEBUG_STACK DEFINES+=DEBUG_HEAP @@ -20,9 +32,9 @@ DEFINES+=DEBUG_HEAP #DEFINES+=DEBUG_NET_ACD #DEFINES+=DEBUG_NET_DHCP #DEFINES+=DEBUG_NET_IGMP -DEFINES+=DEBUG_NET_NETIF +#DEFINES+=DEBUG_NET_NETIF #DEFINES+=DEBUG_NET_NET -DEFINES+=DEBUG_NETWORK +#DEFINES+=DEBUG_NETWORK #DEFINES+=DEBUG_HTTPD #DEFINES+=DEBUG_NET_APPS_MDNS diff --git a/opi_emac_llrp_tftpd/include/software_version.h b/opi_emac_llrp_tftpd/include/software_version.h index 613f7331d..a6c2bcd99 100755 --- a/opi_emac_llrp_tftpd/include/software_version.h +++ b/opi_emac_llrp_tftpd/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.1"; +constexpr char SOFTWARE_VERSION[] = "3.2"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_ltc_smpte/Makefile.H3 b/opi_emac_ltc_smpte/Makefile.H3 index e0a0d70db..fe30c7c34 100644 --- a/opi_emac_ltc_smpte/Makefile.H3 +++ b/opi_emac_ltc_smpte/Makefile.H3 @@ -12,26 +12,6 @@ DEFINES+=ENABLE_HTTPD ENABLE_CONTENT #DEFINES+=ENABLE_SHELL UART0_ECHO LTC_READER -DEFINES+=DEBUG_STACK -#DEFINES+=DEBUG_HEAP - -#DEFINES+=DEBUG_EMAC -#DEFINES+=DEBUG_NET_IP -#DEFINES+=DEBUG_NET_UDP -#DEFINES+=DEBUG_NET_TCP -#DEFINES+=DEBUG_NET_ARP -#DEFINES+=DEBUG_NET_ACD -#DEFINES+=DEBUG_NET_DHCP -#DEFINES+=DEBUG_NET_NETIF -#DEFINES+=DEBUG_NET_NET -#DEFINES+=DEBUG_NET_APPS_MDNS -#DEFINES+=DEBUG_NETWORK -#DEFINES+=DEBUG_HTTPD - -#DEFINES+=DEBUG_DISPLAY - -DEFINES+=DEBUG_LTCOSCSERVER - LIBS= SRCDIR=firmware lib diff --git a/opi_emac_ltc_smpte/firmware/main.cpp b/opi_emac_ltc_smpte/firmware/main.cpp index cec2a3a44..e8be18a5c 100644 --- a/opi_emac_ltc_smpte/firmware/main.cpp +++ b/opi_emac_ltc_smpte/firmware/main.cpp @@ -23,6 +23,10 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include @@ -48,7 +52,6 @@ #include "artnetconst.h" - #include "midi.h" #include "rtpmidi.h" #include "midiparams.h" diff --git a/opi_emac_ltc_smpte/include/software_version.h b/opi_emac_ltc_smpte/include/software_version.h index 6c5526ace..468ead4a5 100644 --- a/opi_emac_ltc_smpte/include/software_version.h +++ b/opi_emac_ltc_smpte/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "4.8"; +constexpr char SOFTWARE_VERSION[] = "4.9"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_osc_client/include/software_version.h b/opi_emac_osc_client/include/software_version.h index a6c2bcd99..2b5c09491 100644 --- a/opi_emac_osc_client/include/software_version.h +++ b/opi_emac_osc_client/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.2"; +constexpr char SOFTWARE_VERSION[] = "3.3"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_osc_dmx/include/software_version.h b/opi_emac_osc_dmx/include/software_version.h index 4c9ec8e65..2b6aa83e3 100644 --- a/opi_emac_osc_dmx/include/software_version.h +++ b/opi_emac_osc_dmx/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.6"; +constexpr char SOFTWARE_VERSION[] = "3.7"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_osc_monitor/include/software_version.h b/opi_emac_osc_monitor/include/software_version.h index 2b5c09491..d25e610ac 100644 --- a/opi_emac_osc_monitor/include/software_version.h +++ b/opi_emac_osc_monitor/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.3"; +constexpr char SOFTWARE_VERSION[] = "3.4"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_osc_pixel/include/software_version.h b/opi_emac_osc_pixel/include/software_version.h index ce045ee3b..72dfe43ea 100644 --- a/opi_emac_osc_pixel/include/software_version.h +++ b/opi_emac_osc_pixel/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.8"; +constexpr char SOFTWARE_VERSION[] = "3.9"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_pp_pixel_multi/firmware/main.cpp b/opi_emac_pp_pixel_multi/firmware/main.cpp index ec6c14457..c9a204355 100644 --- a/opi_emac_pp_pixel_multi/firmware/main.cpp +++ b/opi_emac_pp_pixel_multi/firmware/main.cpp @@ -23,13 +23,16 @@ * THE SOFTWARE. */ +#pragma GCC push_options +#pragma GCC optimize ("O2") +#pragma GCC optimize ("no-tree-loop-distribute-patterns") + #include #include #include "hardware.h" #include "network.h" - #include "net/apps/mdns.h" #include "displayudf.h" @@ -61,8 +64,6 @@ #include "flashcodeinstall.h" #include "configstore.h" - - #include "firmwareversion.h" #include "software_version.h" diff --git a/opi_emac_pp_pixel_multi/include/software_version.h b/opi_emac_pp_pixel_multi/include/software_version.h index 522b7f7cd..58b56824f 100644 --- a/opi_emac_pp_pixel_multi/include/software_version.h +++ b/opi_emac_pp_pixel_multi/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "2.0"; +constexpr char SOFTWARE_VERSION[] = "2.1"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_showfile_artnet/Makefile.H3 b/opi_emac_showfile_artnet/Makefile.H3 index 114cad434..d6a15967e 100755 --- a/opi_emac_showfile_artnet/Makefile.H3 +++ b/opi_emac_showfile_artnet/Makefile.H3 @@ -20,9 +20,6 @@ DEFINES+=CONFIG_FS_ENABLE_WRITE SD_EXFAT_SUPPORT DEFINES+=ENABLE_HTTPD ENABLE_CONTENT -#DEFINES+=DEBUG_POSIX -#DEFINES+=DEBUG_HTTPD - DEFINES+=NDEBUG SRCDIR=firmware lib diff --git a/opi_emac_showfile_artnet/include/software_version.h b/opi_emac_showfile_artnet/include/software_version.h index f22a0650c..9353b33f7 100755 --- a/opi_emac_showfile_artnet/include/software_version.h +++ b/opi_emac_showfile_artnet/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "1.5"; +constexpr char SOFTWARE_VERSION[] = "1.6"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_emac_showfile_e131/include/software_version.h b/opi_emac_showfile_e131/include/software_version.h index f22a0650c..9353b33f7 100755 --- a/opi_emac_showfile_e131/include/software_version.h +++ b/opi_emac_showfile_e131/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "1.5"; +constexpr char SOFTWARE_VERSION[] = "1.6"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_midi_monitor/include/software_version.h b/opi_midi_monitor/include/software_version.h index 613f7331d..a6c2bcd99 100644 --- a/opi_midi_monitor/include/software_version.h +++ b/opi_midi_monitor/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.1"; +constexpr char SOFTWARE_VERSION[] = "3.2"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_rdm_responder/include/software_version.h b/opi_rdm_responder/include/software_version.h index b0df77b13..42404740f 100644 --- a/opi_rdm_responder/include/software_version.h +++ b/opi_rdm_responder/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.2"; +constexpr char SOFTWARE_VERSION[] = "3.3"; #endif /* SOFTWARE_VERSION_H_ */ diff --git a/opi_rdm_responder_l6470/include/software_version.h b/opi_rdm_responder_l6470/include/software_version.h index d62e76e4b..613f7331d 100644 --- a/opi_rdm_responder_l6470/include/software_version.h +++ b/opi_rdm_responder_l6470/include/software_version.h @@ -26,6 +26,6 @@ #ifndef SOFTWARE_VERSION_H_ #define SOFTWARE_VERSION_H_ -constexpr char SOFTWARE_VERSION[] = "3.0"; +constexpr char SOFTWARE_VERSION[] = "3.1"; #endif /* SOFTWARE_VERSION_H_ */ From b3dba5526e676af32d42eb66a1127e50cfa69dbe Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 16 Nov 2024 19:36:36 +0100 Subject: [PATCH 34/36] Moved RDM E1.37-2 code from network.cpp to rdmhandlere137.cpp --- lib-network/include/emac/network.h | 47 +-------- lib-network/include/linux/network.h | 44 -------- lib-network/include/network.h | 10 -- lib-network/src/emac/network.cpp | 90 +--------------- lib-network/src/linux/network.cpp | 89 ---------------- lib-rdm/src/llrp/rdmhandlere1372.cpp | 151 ++++++++++++++++++++++++--- 6 files changed, 143 insertions(+), 288 deletions(-) diff --git a/lib-network/include/emac/network.h b/lib-network/include/emac/network.h index c64a250fe..cb521fd7b 100755 --- a/lib-network/include/emac/network.h +++ b/lib-network/include/emac/network.h @@ -102,22 +102,13 @@ class Network { void EnableDhcp(); bool IsDhcpUsed() { - const auto b = net::netif_dhcp(); - return b; + return net::netif_dhcp(); } bool IsDhcpKnown() const { return true; } - network::dhcp::Mode GetDhcpMode() { - if (IsDhcpUsed()) { - return network::dhcp::Mode::ACTIVE; - } - - return network::dhcp::Mode::INACTIVE; - } - /* * Zeroconf / autoip */ @@ -197,7 +188,7 @@ class Network { } void SendTo(int32_t nHandle, const void *pBuffer, uint32_t nLength, uint32_t to_ip, uint16_t remote_port) { - if (__builtin_expect((GetIp() != 0), 1)) { + if (__builtin_expect((GetIp() != 0), 1)) { //FIXME net::udp_send(nHandle, reinterpret_cast(pBuffer), nLength, to_ip, remote_port); } } @@ -238,18 +229,6 @@ class Network { net::igmp_leave(nIp); } - void SetQueuedStaticIp(const uint32_t nStaticIp, const uint32_t nNetmask); - void SetQueuedDefaultRoute(const uint32_t nGatewayIp); - void SetQueuedDhcp(const network::dhcp::Mode mode) { - m_QueuedConfig.mode = mode; - m_QueuedConfig.nMask |= QueuedConfig::DHCP; - } - void SetQueuedZeroconf() { - m_QueuedConfig.nMask |= QueuedConfig::ZEROCONF; - } - - bool ApplyQueuedConfig(); - uint32_t GetNetmaskCIDR() { return static_cast(__builtin_popcount(GetNetmask())); } @@ -303,27 +282,7 @@ class Network { char m_aDomainName[network::DOMAINNAME_SIZE]; uint32_t m_nNameservers[network::NAMESERVERS_COUNT]; - struct QueuedConfig { - static constexpr uint32_t NONE = 0; - static constexpr uint32_t STATIC_IP = (1U << 0); - static constexpr uint32_t NETMASK = (1U << 1); - static constexpr uint32_t GW = (1U << 2); - static constexpr uint32_t DHCP = (1U << 3); - static constexpr uint32_t ZEROCONF = (1U << 4); - uint32_t nMask = QueuedConfig::NONE; - uint32_t nStaticIp; - uint32_t nNetmask; - uint32_t nGateway; - network::dhcp::Mode mode; - }; - - QueuedConfig m_QueuedConfig; - - bool isQueuedMaskSet(const uint32_t nMask) { - return (m_QueuedConfig.nMask & nMask) == nMask; - } - - static Network *s_pThis; + static inline Network *s_pThis; }; #endif /* EMAC_NETWORK_H_ */ diff --git a/lib-network/include/linux/network.h b/lib-network/include/linux/network.h index 629981d58..8db846852 100644 --- a/lib-network/include/linux/network.h +++ b/lib-network/include/linux/network.h @@ -108,18 +108,6 @@ class Network { return false; } - void SetQueuedStaticIp(const uint32_t nStaticIp, const uint32_t nNetmask); - void SetQueuedDefaultRoute(const uint32_t nGatewayIp); - void SetQueuedDhcp(const network::dhcp::Mode mode) { - m_QueuedConfig.mode = mode; - m_QueuedConfig.nMask |= QueuedConfig::DHCP; - } - void SetQueuedZeroconf() { - m_QueuedConfig.nMask |= QueuedConfig::ZEROCONF; - } - - bool ApplyQueuedConfig(); - uint32_t GetGatewayIp() const { return m_nGatewayIp; } @@ -174,18 +162,6 @@ class Network { #endif } - network::dhcp::Mode GetDhcpMode() const { - if (IsDhcpKnown()) { - if (m_IsDhcpUsed) { - return network::dhcp::Mode::ACTIVE; - } - - return network::dhcp::Mode::INACTIVE; - } - - return network::dhcp::Mode::UNKNOWN; - } - const char *GetIfName() const { return m_aIfName; } @@ -247,26 +223,6 @@ class Network { uint8_t m_aNetMacaddr[network::MAC_SIZE]; char m_aIfName[IFNAMSIZ]; - struct QueuedConfig { - static constexpr uint32_t NONE = 0; - static constexpr uint32_t STATIC_IP = (1U << 0); - static constexpr uint32_t NETMASK = (1U << 1); - static constexpr uint32_t GW = (1U << 2); - static constexpr uint32_t DHCP = (1U << 3); - static constexpr uint32_t ZEROCONF = (1U << 4); - uint32_t nMask = QueuedConfig::NONE; - uint32_t nStaticIp; - uint32_t nNetmask; - uint32_t nGateway; - network::dhcp::Mode mode; - }; - - QueuedConfig m_QueuedConfig; - - bool isQueuedMaskSet(uint32_t nMask) { - return (m_QueuedConfig.nMask & nMask) == nMask; - } - static Network *s_pThis; }; diff --git a/lib-network/include/network.h b/lib-network/include/network.h index 7fe09f459..53875905a 100644 --- a/lib-network/include/network.h +++ b/lib-network/include/network.h @@ -30,16 +30,6 @@ #include "ip4_address.h" -namespace network { -namespace dhcp { -enum class Mode: uint8_t { - INACTIVE = 0x00, ///< The IP address was not obtained via DHCP - ACTIVE = 0x01, ///< The IP address was obtained via DHCP - UNKNOWN = 0x02 ///< The system cannot determine if the address was obtained via DHCP -}; -} // namespace dhcp -} // namespace network - #if defined(__linux__) || defined (__APPLE__) # if defined (CONFIG_NETWORK_USE_MINIMUM) # include "linux/minimum/network.h" diff --git a/lib-network/src/emac/network.cpp b/lib-network/src/emac/network.cpp index 63e0eedec..3698fc5a5 100755 --- a/lib-network/src/emac/network.cpp +++ b/lib-network/src/emac/network.cpp @@ -100,8 +100,6 @@ static void netif_ext_callback(const uint16_t reason, [[maybe_unused]] const net DEBUG_EXIT } -Network *Network::s_pThis; - Network::Network() { DEBUG_ENTRY assert(s_pThis == nullptr); @@ -242,6 +240,7 @@ void Network::SetHostName(const char *pHostName) { m_aHostName[network::HOSTNAME_SIZE - 1] = '\0'; NetworkStore::SaveHostName(m_aHostName, static_cast(strlen(m_aHostName))); + #if !defined(CONFIG_NET_APPS_NO_MDNS) mdns_send_announcement(mdns::MDNS_RESPONSE_TTL); #endif @@ -270,93 +269,6 @@ void Network::EnableDhcp() { DEBUG_EXIT } -void Network::SetQueuedStaticIp(const uint32_t nStaticIp, const uint32_t nNetmask) { - DEBUG_ENTRY - DEBUG_PRINTF(IPSTR ", nNetmask=" IPSTR, IP2STR(nStaticIp), IP2STR(nNetmask)); - - if (nStaticIp != 0) { - m_QueuedConfig.nStaticIp = nStaticIp; - } else { - m_QueuedConfig.nStaticIp = GetIp(); - } - - if (nNetmask != 0) { - m_QueuedConfig.nNetmask = nNetmask; - } else { - m_QueuedConfig.nNetmask = GetNetmask(); - } - - m_QueuedConfig.nMask |= QueuedConfig::STATIC_IP; - m_QueuedConfig.nMask |= QueuedConfig::NETMASK; - - DEBUG_EXIT -} - -void Network::SetQueuedDefaultRoute(const uint32_t nGatewayIp) { - if (nGatewayIp != 0) { - m_QueuedConfig.nGateway = nGatewayIp; - } else { - m_QueuedConfig.nGateway = GetGatewayIp(); - } - - m_QueuedConfig.nMask |= QueuedConfig::GW; -} - -bool Network::ApplyQueuedConfig() { - DEBUG_ENTRY - DEBUG_PRINTF("m_QueuedConfig.nMask=%x, " IPSTR ", " IPSTR, m_QueuedConfig.nMask, IP2STR(m_QueuedConfig.nStaticIp), IP2STR(m_QueuedConfig.nNetmask)); - - if (m_QueuedConfig.nMask == QueuedConfig::NONE) { - DEBUG_EXIT - return false; - } - - if ((isQueuedMaskSet(QueuedConfig::STATIC_IP)) || (isQueuedMaskSet(QueuedConfig::NETMASK)) || (isQueuedMaskSet(QueuedConfig::GW))) { - // After SetIp all ip address might be zero. - if (isQueuedMaskSet(QueuedConfig::STATIC_IP)) { - SetIp(m_QueuedConfig.nStaticIp); - } - - if (isQueuedMaskSet(QueuedConfig::NETMASK)) { - SetNetmask(m_QueuedConfig.nNetmask); - } - - if (isQueuedMaskSet(QueuedConfig::GW)) { - SetGatewayIp(m_QueuedConfig.nGateway); - } - - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - if (isQueuedMaskSet(QueuedConfig::DHCP)) { - if (m_QueuedConfig.mode == network::dhcp::Mode::ACTIVE) { - EnableDhcp(); - } else if (m_QueuedConfig.mode == network::dhcp::Mode::INACTIVE) { - - } - - m_QueuedConfig.mode = network::dhcp::Mode::UNKNOWN; - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - if (isQueuedMaskSet(QueuedConfig::ZEROCONF)) { - SetZeroconf(); - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - DEBUG_EXIT - return false; -} - void Network::Print() { printf("Network [%c]\n", GetAddressingMode()); printf(" Hostname : %s\n", m_aHostName); diff --git a/lib-network/src/linux/network.cpp b/lib-network/src/linux/network.cpp index 3256daa3a..45dfa0c55 100644 --- a/lib-network/src/linux/network.cpp +++ b/lib-network/src/linux/network.cpp @@ -581,95 +581,6 @@ void Network::SetHostName(const char *pHostName) { } -// COMMON - -void Network::SetQueuedStaticIp(const uint32_t nStaticIp, const uint32_t nNetmask) { - DEBUG_ENTRY - DEBUG_PRINTF(IPSTR ", nNetmask=" IPSTR, IP2STR(nStaticIp), IP2STR(nNetmask)); - - if (nStaticIp != 0) { - m_QueuedConfig.nStaticIp = nStaticIp; - } else { - m_QueuedConfig.nStaticIp = GetIp(); - } - - if (nNetmask != 0) { - m_QueuedConfig.nNetmask = nNetmask; - } else { - m_QueuedConfig.nNetmask = GetNetmask(); - } - - m_QueuedConfig.nMask |= QueuedConfig::STATIC_IP; - m_QueuedConfig.nMask |= QueuedConfig::NETMASK; - - DEBUG_EXIT -} - -void Network::SetQueuedDefaultRoute(const uint32_t nGatewayIp) { - if (nGatewayIp != 0) { - m_QueuedConfig.nGateway = nGatewayIp; - } else { - m_QueuedConfig.nGateway = GetGatewayIp(); - } - - m_QueuedConfig.nMask |= QueuedConfig::GW; -} - -bool Network::ApplyQueuedConfig() { - DEBUG_ENTRY - DEBUG_PRINTF("m_QueuedConfig.nMask=%x, " IPSTR ", " IPSTR, m_QueuedConfig.nMask, IP2STR(m_QueuedConfig.nStaticIp), IP2STR(m_QueuedConfig.nNetmask)); - - if (m_QueuedConfig.nMask == QueuedConfig::NONE) { - DEBUG_EXIT - return false; - } - - if ((isQueuedMaskSet(QueuedConfig::STATIC_IP)) || (isQueuedMaskSet(QueuedConfig::NETMASK)) || (isQueuedMaskSet(QueuedConfig::GW))) { - // After SetIp all ip address might be zero. - if (isQueuedMaskSet(QueuedConfig::STATIC_IP)) { - SetIp(m_QueuedConfig.nStaticIp); - } - - if (isQueuedMaskSet(QueuedConfig::NETMASK)) { - SetNetmask(m_QueuedConfig.nNetmask); - } - - if (isQueuedMaskSet(QueuedConfig::GW)) { - SetGatewayIp(m_QueuedConfig.nGateway); - } - - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - if (isQueuedMaskSet(QueuedConfig::DHCP)) { - if (m_QueuedConfig.mode == network::dhcp::Mode::ACTIVE) { - EnableDhcp(); - } else if (m_QueuedConfig.mode == network::dhcp::Mode::INACTIVE) { - - } - - m_QueuedConfig.mode = network::dhcp::Mode::UNKNOWN; - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - if (isQueuedMaskSet(QueuedConfig::ZEROCONF)) { - SetZeroconf(); - m_QueuedConfig.nMask = QueuedConfig::NONE; - - DEBUG_EXIT - return true; - } - - DEBUG_EXIT - return false; -} - void Network::Print() { printf("Network\n"); printf(" Hostname : %s\n", m_aHostName); diff --git a/lib-rdm/src/llrp/rdmhandlere1372.cpp b/lib-rdm/src/llrp/rdmhandlere1372.cpp index b2fa97c65..8c938f543 100755 --- a/lib-rdm/src/llrp/rdmhandlere1372.cpp +++ b/lib-rdm/src/llrp/rdmhandlere1372.cpp @@ -36,10 +36,137 @@ #include "debug.h" -enum { - IPV4_UNCONFIGURED = 0x00000000, - NO_DEFAULT_ROUTE = 0x00000000 +namespace dhcp { +enum class Mode: uint8_t { + INACTIVE = 0x00, ///< The IP address was not obtained via DHCP + ACTIVE = 0x01, ///< The IP address was obtained via DHCP + UNKNOWN = 0x02 ///< The system cannot determine if the address was obtained via DHCP }; +} // namespace dhcp + +static dhcp::Mode get_dhcp_mode() { + if (Network::Get()->IsDhcpUsed()) { + return dhcp::Mode::ACTIVE; + } + + return dhcp::Mode::INACTIVE; +} + +struct QueuedConfig { + static constexpr uint32_t NONE = 0; + static constexpr uint32_t STATIC_IP = (1U << 0); + static constexpr uint32_t NETMASK = (1U << 1); + static constexpr uint32_t GW = (1U << 2); + static constexpr uint32_t DHCP = (1U << 3); + static constexpr uint32_t ZEROCONF = (1U << 4); + uint32_t nMask = QueuedConfig::NONE; + uint32_t nStaticIp; + uint32_t nNetmask; + uint32_t nGateway; + dhcp::Mode mode; +}; + +static QueuedConfig s_QueuedConfig; + +static bool is_queued_mask_set(const uint32_t nMask) { + return (s_QueuedConfig.nMask & nMask) == nMask; +} + +static void set_queued_static_ip(const uint32_t nStaticIp, const uint32_t nNetmask) { + DEBUG_ENTRY + DEBUG_PRINTF(IPSTR ", nNetmask=" IPSTR, IP2STR(nStaticIp), IP2STR(nNetmask)); + + if (nStaticIp != 0) { + s_QueuedConfig.nStaticIp = nStaticIp; + } else { + s_QueuedConfig.nStaticIp = Network::Get()->GetIp(); + } + + if (nNetmask != 0) { + s_QueuedConfig.nNetmask = nNetmask; + } else { + s_QueuedConfig.nNetmask = Network::Get()->GetNetmask(); + } + + s_QueuedConfig.nMask |= QueuedConfig::STATIC_IP; + s_QueuedConfig.nMask |= QueuedConfig::NETMASK; + + DEBUG_EXIT +} + +static void set_queued_default_route(const uint32_t nGatewayIp) { + if (nGatewayIp != 0) { + s_QueuedConfig.nGateway = nGatewayIp; + } else { + s_QueuedConfig.nGateway = Network::Get()->GetGatewayIp(); + } + + s_QueuedConfig.nMask |= QueuedConfig::GW; +} + +static void set_queued_dhcp(const dhcp::Mode mode) { + s_QueuedConfig.mode = mode; + s_QueuedConfig.nMask |= QueuedConfig::DHCP; +} + +static void set_queued_zeroconf() { + s_QueuedConfig.nMask |= QueuedConfig::ZEROCONF; +} + +static bool apply_queued_config() { + DEBUG_ENTRY + DEBUG_PRINTF("s_QueuedConfig.nMask=%x, " IPSTR ", " IPSTR, s_QueuedConfig.nMask, IP2STR(s_QueuedConfig.nStaticIp), IP2STR(s_QueuedConfig.nNetmask)); + + if (s_QueuedConfig.nMask == QueuedConfig::NONE) { + DEBUG_EXIT + return false; + } + + if ((is_queued_mask_set(QueuedConfig::STATIC_IP)) || (is_queued_mask_set(QueuedConfig::NETMASK)) || (is_queued_mask_set(QueuedConfig::GW))) { + // After SetIp all ip address might be zero. + if (is_queued_mask_set(QueuedConfig::STATIC_IP)) { + Network::Get()->SetIp(s_QueuedConfig.nStaticIp); + } + + if (is_queued_mask_set(QueuedConfig::NETMASK)) { + Network::Get()->SetNetmask(s_QueuedConfig.nNetmask); + } + + if (is_queued_mask_set(QueuedConfig::GW)) { + Network::Get()->SetGatewayIp(s_QueuedConfig.nGateway); + } + + s_QueuedConfig.nMask = QueuedConfig::NONE; + + DEBUG_EXIT + return true; + } + + if (is_queued_mask_set(QueuedConfig::DHCP)) { + if (s_QueuedConfig.mode == dhcp::Mode::ACTIVE) { + Network::Get()->EnableDhcp(); + } else if (s_QueuedConfig.mode == dhcp::Mode::INACTIVE) { + + } + + s_QueuedConfig.mode = dhcp::Mode::UNKNOWN; + s_QueuedConfig.nMask = QueuedConfig::NONE; + + DEBUG_EXIT + return true; + } + + if (is_queued_mask_set(QueuedConfig::ZEROCONF)) { + Network::Get()->SetZeroconf(); + s_QueuedConfig.nMask = QueuedConfig::NONE; + + DEBUG_EXIT + return true; + } + + DEBUG_EXIT + return false; +} /* * ANSI E1.37-2 @@ -169,10 +296,10 @@ void RDMHandler::SetDHCPMode([[maybe_unused]] bool IsBroadcast, [[maybe_unused]] return; } - const auto mode = static_cast(pRdmDataIn->param_data[4]); + const auto mode = static_cast(pRdmDataIn->param_data[4]); - if ((mode == network::dhcp::Mode::ACTIVE) || mode == network::dhcp::Mode::INACTIVE) { - Network::Get()->SetQueuedDhcp(mode); + if ((mode == dhcp::Mode::ACTIVE) || mode == dhcp::Mode::INACTIVE) { + set_queued_dhcp(mode); RespondMessageAck(); DEBUG_EXIT @@ -254,7 +381,7 @@ void RDMHandler::SetZeroconf([[maybe_unused]] bool IsBroadcast, [[maybe_unused]] } if (pRdmDataIn->param_data[4] == 1) { - Network::Get()->SetQueuedZeroconf(); + set_queued_zeroconf(); RespondMessageAck(); DEBUG_EXIT @@ -262,7 +389,7 @@ void RDMHandler::SetZeroconf([[maybe_unused]] bool IsBroadcast, [[maybe_unused]] } if (pRdmDataIn->param_data[4] == 0) { - Network::Get()->SetQueuedStaticIp(0, 0); + set_queued_static_ip(0, 0); RespondMessageAck(); DEBUG_EXIT @@ -325,7 +452,7 @@ void RDMHandler::GetAddressNetmask([[maybe_unused]] uint16_t nSubDevice) { memcpy(&pRdmDataOut->param_data[0], &pRdmDataIn->param_data[0], 4); memcpy(&pRdmDataOut->param_data[4], p, 4); pRdmDataOut->param_data[8] = static_cast(Network::Get()->GetNetmaskCIDR()); - pRdmDataOut->param_data[9] = static_cast(Network::Get()->GetDhcpMode()); + pRdmDataOut->param_data[9] = static_cast(get_dhcp_mode()); pRdmDataOut->param_data_length = 10; @@ -383,7 +510,7 @@ void RDMHandler::SetStaticAddress([[maybe_unused]] bool IsBroadcast, [[maybe_unu auto *p = reinterpret_cast(&nIpAddress); memcpy(p, &pRdmDataIn->param_data[4], 4); - Network::Get()->SetQueuedStaticIp(nIpAddress, network::cidr_to_netmask(pRdmDataIn->param_data[8])); + set_queued_static_ip(nIpAddress, network::cidr_to_netmask(pRdmDataIn->param_data[8])); RespondMessageAck(); @@ -401,7 +528,7 @@ void RDMHandler::ApplyConfiguration([[maybe_unused]] bool IsBroadcast, [[maybe_u return; } - if (Network::Get()->ApplyQueuedConfig()) { // Not Queuing -> Apply + if (apply_queued_config()) { // Not Queuing -> Apply RespondMessageAck(); DEBUG_EXIT @@ -461,7 +588,7 @@ void RDMHandler::SetDefaultRoute([[maybe_unused]] bool IsBroadcast, [[maybe_unus auto *p = reinterpret_cast(&nIpAddress); memcpy(p, &pRdmDataIn->param_data[4], 4); - Network::Get()->SetQueuedDefaultRoute(nIpAddress); + set_queued_default_route(nIpAddress); RespondMessageAck(); From 950cce5e64e239fddd6c2a1dd47860cc321c5d4a Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sat, 16 Nov 2024 19:37:10 +0100 Subject: [PATCH 35/36] Updated make files --- firmware-template-h3/Rules.mk | 10 +++++----- firmware-template-h3/lib/Rules.mk | 3 ++- firmware-template/libs.mk | 4 ---- opi_emac_ltc_smpte/Makefile.H3 | 2 ++ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/firmware-template-h3/Rules.mk b/firmware-template-h3/Rules.mk index 2b165ca5b..0ceee6adc 100644 --- a/firmware-template-h3/Rules.mk +++ b/firmware-template-h3/Rules.mk @@ -27,10 +27,6 @@ ifeq ($(findstring ORANGE_PI,$(PLATFORM)),ORANGE_PI) COND=1 endif -include ../firmware-template/libs.mk - -LIBS+=h3 clib arm - # Output TARGET=$(SUFFIX).img LIST=$(SUFFIX).list @@ -64,8 +60,12 @@ ifeq ($(findstring ARTNET_VERSION=4,$(DEFINES)),ARTNET_VERSION=4) endif endif +include ../firmware-template/libs.mk + +LIBS+=h3 clib arm + # The variable for the firmware include directories -INCDIRS+=../include $(wildcard ./include) $(wildcard ./*/include) ../firmware-template-h3/include ../lib-h3/CMSIS/Core_A/Include +INCDIRS+=../include $(wildcard ./include) $(wildcard ./*/include) ../firmware-template-h3/include ../lib-h3/CMSIS/Core_A/Include -I../lib-flashcodeinstall/include INCDIRS:=$(addprefix -I,$(INCDIRS)) # The variable for the libraries include directory diff --git a/firmware-template-h3/lib/Rules.mk b/firmware-template-h3/lib/Rules.mk index 2474f6666..7e1ea35aa 100644 --- a/firmware-template-h3/lib/Rules.mk +++ b/firmware-template-h3/lib/Rules.mk @@ -25,7 +25,8 @@ SRCDIR+=src/debug $(info [${SRCDIR}]) -INCLUDES:=-I./include -I../include -I../lib-device/include -I../lib-flash/include -I../lib-configstore/include -I../lib-hal/include -I../lib-debug/include -I../lib-h3/include -I../lib-arm/include +INCLUDES:=-I./include -I../include -I../lib-device/include -I../lib-configstore/include -I../lib-hal/include -I../lib-debug/include -I../lib-h3/include -I../lib-arm/include +INCLUDES+=-I../lib-flash/include -I../lib-flashcodeinstall/include INCLUDES+=-I../lib-h3/CMSIS/Core_A/Include INCLUDES+=$(addprefix -I,$(EXTRA_INCLUDES)) diff --git a/firmware-template/libs.mk b/firmware-template/libs.mk index 484b704af..44eb42fc8 100755 --- a/firmware-template/libs.mk +++ b/firmware-template/libs.mk @@ -154,10 +154,6 @@ else LIBS+=flashcodeinstall flashcode flash endif -ifeq ($(findstring NODE_LTC_SMPTE,$(DEFINES)),NODE_LTC_SMPTE) - DEFINES+=CONFIG_DISPLAY_ENABLE_SSD1311 CONFIG_DISPLAY_ENABLE_HD44780 CONFIG_DISPLAY_ENABLE_CURSOR_MODE -endif - ifneq ($(findstring network,$(LIBS)),network) LIBS+=network endif diff --git a/opi_emac_ltc_smpte/Makefile.H3 b/opi_emac_ltc_smpte/Makefile.H3 index fe30c7c34..fccfacdc2 100644 --- a/opi_emac_ltc_smpte/Makefile.H3 +++ b/opi_emac_ltc_smpte/Makefile.H3 @@ -3,6 +3,8 @@ PLATFORM=ORANGE_PI DEFINES =NODE_LTC_SMPTE ARM_ALLOW_MULTI_CORE DEFINES+=CONFIG_LTC_USE_DAC +DEFINES+=CONFIG_DISPLAY_ENABLE_SSD1311 CONFIG_DISPLAY_ENABLE_HD44780 CONFIG_DISPLAY_ENABLE_CURSOR_MODE + DEFINES+=NODE_RDMNET_LLRP_ONLY DEFINES+=NODE_ARTNET ARTNET_VERSION=3 From ed4468e77e6480405594a6100df397ac21aaf4e4 Mon Sep 17 00:00:00 2001 From: Arjan van Vught Date: Sun, 17 Nov 2024 18:10:12 +0100 Subject: [PATCH 36/36] Fix for Sync --- lib-ws28xxdmx/include/ws28xxdmxmulti.h | 8 ++++++++ opi_emac_artnet_pixel_dmx_multi/Makefile.H3 | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib-ws28xxdmx/include/ws28xxdmxmulti.h b/lib-ws28xxdmx/include/ws28xxdmxmulti.h index 0e72e91d6..8dfb4bcd4 100644 --- a/lib-ws28xxdmx/include/ws28xxdmxmulti.h +++ b/lib-ws28xxdmx/include/ws28xxdmxmulti.h @@ -100,11 +100,16 @@ class WS28xxDmxMulti final: public LightSet { logic_analyzer::ch2_set(); SetData(nPortIndex, lightset::Data::Backup(nPortIndex), lightset::Data::GetLength(nPortIndex)); + m_bNeedSync = true; logic_analyzer::ch2_clear(); } void Sync() override { + if (!m_bNeedSync) { + return; + } + logic_analyzer::ch1_set(); logic_analyzer::ch3_set(); @@ -116,6 +121,8 @@ class WS28xxDmxMulti final: public LightSet { m_pWS28xxMulti->Update(); + m_bNeedSync = false; + logic_analyzer::ch1_clear(); } @@ -154,6 +161,7 @@ class WS28xxDmxMulti final: public LightSet { uint32_t m_bIsStarted { 0 }; bool m_bBlackout { false }; + bool m_bNeedSync { false }; }; #pragma GCC pop_options diff --git a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 index 4c861acc0..0383dd1d3 100644 --- a/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 +++ b/opi_emac_artnet_pixel_dmx_multi/Makefile.H3 @@ -26,8 +26,6 @@ DEFINES+=ENABLE_HTTPD ENABLE_CONTENT DEFINES+=DISABLE_RTC -DEFINES+=CONFIG_CLIB_ASSERT_REBOOT - DEFINES+=NDEBUG LIBS=