Skip to content

Commit 0e7f2a5

Browse files
committed
Refactor and modularize codebase structure
* Major project restructuring * Reorganized libraries and source files into a clearer, more modular directory structure. * Moved, renamed, or removed numerous files to reduce duplication and improve maintainability. * Legacy code cleanup * Removed deprecated and unused code from lib-lightset, lib-network, lib-properties, and older display components. * Eliminated redundant parameter and platform-specific files no longer in use. * Centralized common functionality * Migrated shared network, properties, and parameter code into a unified common directory. * Added new utility headers and source files for reusable functionality. * JSON-based configuration support * Added new JSON configuration and parameter files. * Introduced JSON helper utilities and parameter classes to standardize configuration handling and prepare for future extensibility. * DMX, RDM, and pixel refactor * Refactored DMX, RDM device handling, and pixel-related libraries for clearer structure and better separation of responsibilities. * Unified RDM device information handling. * Build system updates * Updated Makefiles, build scripts, and compile_commands.json to reflect the new project structure. * Improved GD32 platform support and hardware abstraction organization. * Network stack reorganization * Flattened lib-network source layout by moving files from subdirectories into a simpler structure. * Improved clarity of EMAC and Linux network interface implementations (no functional changes). * Debug macro consistency * Replaced DEBUG_ENTRY / DEBUG_EXIT macros with function-style DEBUG_ENTRY() / DEBUG_EXIT() across the codebase for consistency and readability. * Overall impact * Significantly improved modularity, readability, and long-term maintainability. * Laid groundwork for future feature expansion and more robust JSON-based configuration across modules.
1 parent 644e355 commit 0e7f2a5

File tree

2,205 files changed

+97569
-161893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,205 files changed

+97569
-161893
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ linux_pp/linux_pp
108108
software_version_id.h
109109

110110
/lib-eve
111-
/lib-network/src/emac/gd32/dsa
112111
/lib-nextion
113-
/lib-node
114112
/lib-showfile/Doxygen
115113
/opi_emac_eve_example
116114
*._h
117115
*._cpp
118116
/opi_emac_debug_lcd_udp
119-
opi_emac_llrp_tftpd/do-tftp-bad.sh
117+
do-tftp-bad.sh
118+
dummy.h
119+
*.su

common/.cproject

Lines changed: 149 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>lib-ws28xx</name>
3+
<name>common</name>
44
<comment></comment>
55
<projects>
66
</projects>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project>
3+
<configuration id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.306944287" name="Default">
4+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
7+
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
8+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1123310493009100238" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
9+
<language-scope id="org.eclipse.cdt.core.gcc"/>
10+
<language-scope id="org.eclipse.cdt.core.g++"/>
11+
</provider>
12+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
13+
</extension>
14+
</configuration>
15+
</project>

lib-remoteconfig/src/gd32/tftpfileserver.cpp renamed to common/include/common/utils/utils_array.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file tftpfileserver.cpp
2+
* @file utils_array.h
33
*
44
*/
5-
/* Copyright (C) 2021-2023 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,15 +23,17 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#include <cstdint>
27-
#include <cassert>
26+
#ifndef COMMON_UTILS_UTILS_ARRAY_H_
27+
#define COMMON_UTILS_UTILS_ARRAY_H_
2828

29-
#include "remoteconfig.h"
29+
#include <cstddef>
3030

31-
#include "debug.h"
32-
33-
namespace tftpfileserver {
34-
bool is_valid([[maybe_unused]] const void *pBuffer) {
35-
return true;
31+
namespace common
32+
{
33+
template <typename T, size_t N> constexpr size_t ArraySize(const T (&)[N]) noexcept
34+
{
35+
return N;
3636
}
37-
} // namespace tftpfileserver
37+
} // namespace common
38+
39+
#endif // COMMON_UTILS_UTILS_ARRAY_H_
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file flashcode.cpp
2+
* @file utils_enum.h
33
*
44
*/
5-
/* Copyright (C) 2021-2024 by Arjan van Vught mailto:[email protected]
5+
/* Copyright (C) 2025 by Arjan van Vught mailto:[email protected]
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,34 +23,26 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#include <cstdio>
27-
#include <cassert>
26+
#ifndef COMMON_UTILS_UTILS_ENUM_H_
27+
#define COMMON_UTILS_UTILS_ENUM_H_
2828

29-
#include "flashcode.h"
29+
#include <type_traits>
3030

31-
#include "gd32.h"
31+
namespace common
32+
{
3233

33-
#include "debug.h"
34-
35-
FlashCode *FlashCode::s_pThis;
36-
37-
FlashCode::FlashCode() {
38-
DEBUG_ENTRY
39-
assert(s_pThis == nullptr);
40-
s_pThis = this;
41-
42-
m_IsDetected = true;
43-
44-
printf("FMC: %s %u [%u]\n", GetName(), static_cast<unsigned int>(GetSize()), static_cast<unsigned int>(GetSize() / 1024U));
45-
DEBUG_EXIT
34+
/// Converts an enum class value to its underlying integer type.
35+
template <typename Enum>
36+
inline auto ToValue(Enum e) noexcept {
37+
return static_cast<std::underlying_type_t<Enum>>(e);
4638
}
4739

48-
FlashCode::~FlashCode() {
49-
DEBUG_ENTRY
50-
51-
DEBUG_EXIT
40+
/// Converts an integer value to the corresponding enum class value.
41+
template <typename Enum>
42+
inline Enum FromValue(std::underlying_type_t<Enum> value) noexcept {
43+
return static_cast<Enum>(value);
5244
}
5345

54-
const char *FlashCode::GetName() const{
55-
return GD32_MCU_NAME;
56-
}
46+
} // namespace common
47+
48+
#endif // COMMON_UTILS_UTILS_ENUM_H_
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
* @file utils_flags.h
3+
* Generic enum class bitmask helpers (C++20, freestanding-safe, Google Style)
4+
*/
5+
/* Copyright (C) 2025 by Arjan van Vught mailto:[email protected]
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef COMMON_UTILS_UTILS_FLAGS_H_
27+
#define COMMON_UTILS_UTILS_FLAGS_H_
28+
29+
#include <cstdint>
30+
#include <type_traits>
31+
32+
#include "common/utils/utils_enum.h" // Ensure this provides ToValue and FromValue
33+
34+
namespace common
35+
{
36+
37+
template <typename E>
38+
requires std::is_enum_v<E>
39+
constexpr E operator|(E lhs, E rhs)
40+
{
41+
return static_cast<E>(ToValue(lhs) | ToValue(rhs));
42+
}
43+
44+
template <typename E>
45+
requires std::is_enum_v<E>
46+
constexpr E operator&(E lhs, E rhs)
47+
{
48+
return static_cast<E>(ToValue(lhs) & ToValue(rhs));
49+
}
50+
51+
template <typename E>
52+
requires std::is_enum_v<E>
53+
constexpr E operator~(E e)
54+
{
55+
return static_cast<E>(~ToValue(e));
56+
}
57+
58+
template <typename E>
59+
requires std::is_enum_v<E>
60+
constexpr E& operator|=(E& lhs, E rhs)
61+
{
62+
lhs = lhs | rhs;
63+
return lhs;
64+
}
65+
66+
template <typename E>
67+
requires std::is_enum_v<E>
68+
constexpr E& operator&=(E& lhs, E rhs)
69+
{
70+
lhs = lhs & rhs;
71+
return lhs;
72+
}
73+
74+
template <typename E>
75+
requires std::is_enum_v<E>
76+
constexpr void SetFlag(uint32_t& flags, E bit, bool enable)
77+
{
78+
if (enable)
79+
{
80+
flags |= ToValue(bit);
81+
}
82+
else
83+
{
84+
flags &= ~ToValue(bit);
85+
}
86+
}
87+
88+
template <typename E>
89+
requires std::is_enum_v<E>
90+
constexpr uint32_t SetFlagValue(uint32_t flags, E bit, bool enable)
91+
{
92+
if (enable)
93+
{
94+
return flags | ToValue(bit);
95+
}
96+
else
97+
{
98+
return flags & ~ToValue(bit);
99+
}
100+
}
101+
102+
template <typename E>
103+
requires std::is_enum_v<E>
104+
constexpr bool IsFlagSet(uint32_t flags, E bit) {
105+
return (flags & ToValue(bit)) != 0;
106+
}
107+
108+
} // namespace common
109+
110+
#endif // COMMON_UTILS_UTILS_FLAGS_H_
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @file utils_hash.h
3+
*
4+
*/
5+
/* Copyright (C) 2025 by Arjan van Vught mailto:[email protected]
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef COMMON_UTILS_UTILS_HASH_H_
27+
#define COMMON_UTILS_UTILS_HASH_H_
28+
29+
#include <cstdint>
30+
31+
// Compile-time FNV-1a 32-bit hash
32+
consteval uint32_t Fnv1a32(const char* str, uint8_t length)
33+
{
34+
uint32_t hash = 0x811c9dc5u;
35+
for (uint8_t i = 0; i < length; ++i)
36+
{
37+
hash ^= static_cast<uint8_t>(str[i]);
38+
hash *= 0x01000193u;
39+
}
40+
return hash;
41+
}
42+
43+
// Runtime version for raw filenames
44+
inline uint32_t Fnv1a32Runtime(const char* str, uint32_t length)
45+
{
46+
uint32_t hash = 0x811c9dc5u;
47+
for (uint32_t i = 0; i < length; ++i)
48+
{
49+
hash ^= static_cast<uint8_t>(str[i]);
50+
hash *= 0x01000193u;
51+
}
52+
return hash;
53+
}
54+
55+
#endif // COMMON_UTILS_UTILS_HASH_H_

0 commit comments

Comments
 (0)