Skip to content

Commit 246aa5b

Browse files
committed
Refactor JSON param constants and update headers
Normalize and refactor multiple JSON params headers: replace multi-line inline constexpr initializers with compact braced initializers, add #include "common/utils/utils_hash.h" for Fnv1a32, and standardize namespace/formatting/header-guard comments. Update copyright years and add/expand license blocks where applicable. Also add hal::Init() declaration in lib-hal/include/gd32/hal.h. Files changed: displayudfparamsconst.h, dmxsendparamsconst.h, dmxledparamsconst.h, hal.h, globalparamsconst.h, pixeldmxparamsconst.h, rdmdeviceparamsconst.h, rdmsensorsparamsconst.h.
1 parent 34877de commit 246aa5b

8 files changed

Lines changed: 201 additions & 435 deletions

File tree

lib-displayudf/include/json/displayudfparamsconst.h

Lines changed: 66 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file displayudfparamsconst.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 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
@@ -27,145 +27,83 @@
2727
#define JSON_DISPLAYUDFPARAMSCONST_H_
2828

2929
#include "json/json_key.h"
30-
#if defined (DMXNODE_PORTS) && (DMXNODE_PORTS > 0)
30+
#include "common/utils/utils_hash.h"
31+
#if defined(DMXNODE_PORTS) && (DMXNODE_PORTS > 0)
3132
#include "json/dmxnodeparamsconst.h"
3233
#endif
33-
#if defined(NODE_ARTNET) || defined (NODE_ARTNET_MULTI)
34+
#if defined(NODE_ARTNET) || defined(NODE_ARTNET_MULTI)
3435
#include "json/artnetparamsconst.h"
3536
#endif
3637
#if defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI)
3738
#include "dmx.h"
3839
#endif
3940

40-
namespace json
41-
{
42-
struct DisplayUdfParamsConst
43-
{
44-
static constexpr char kFileName[] = "display.json";
45-
46-
static constexpr json::SimpleKey kIntensity {
47-
"intensity",
48-
9,
49-
Fnv1a32("intensity", 9)
50-
};
51-
52-
static constexpr json::SimpleKey kSleepTimeout {
53-
"sleep_timeout",
54-
13,
55-
Fnv1a32("sleep_timeout", 13)
56-
};
57-
58-
static constexpr json::SimpleKey kFlipVertically {
59-
"flip_vertically",
60-
15,
61-
Fnv1a32("flip_vertically", 15)
62-
};
63-
64-
static constexpr json::PortKey kTitle {
65-
"title",
66-
5,
67-
Fnv1a32("title", 5)
68-
};
69-
70-
static constexpr json::PortKey kBoardName {
71-
"board_name",
72-
10,
73-
Fnv1a32("board_name", 10)
74-
};
75-
76-
static constexpr json::PortKey kVersion {
77-
"version",
78-
7,
79-
Fnv1a32("version", 7)
80-
};
41+
namespace json {
42+
struct DisplayUdfParamsConst {
43+
static constexpr char kFileName[] = "display.json";
8144

82-
static constexpr json::PortKey kActivePorts {
83-
"active_ports",
84-
12,
85-
Fnv1a32("active_ports", 12)
86-
};
87-
88-
static constexpr json::PortKey kHostname {
89-
"hostname",
90-
8,
91-
Fnv1a32("hostname", 8)
92-
};
93-
94-
static constexpr json::PortKey kIpAddress {
95-
"ip_address",
96-
10,
97-
Fnv1a32("ip_address", 10)
98-
};
99-
100-
static constexpr json::PortKey kNetMask {
101-
"net_mask",
102-
8,
103-
Fnv1a32("net_mask", 8)
104-
};
105-
106-
static constexpr json::PortKey kDefaultGateway {
107-
"default_gateway",
108-
15,
109-
Fnv1a32("default_gateway", 15)
110-
};
111-
112-
static constexpr json::PortKey kDmxStartAddress {
113-
"dmx_start_address",
114-
17,
115-
Fnv1a32("dmx_start_address", 17)
116-
};
117-
118-
static constexpr json::PortKey kLabels[] =
119-
{
120-
kTitle,
121-
kBoardName,
122-
kVersion,
123-
kHostname,
124-
kIpAddress,
125-
kNetMask,
126-
kDefaultGateway,
127-
kActivePorts,
128-
kDmxStartAddress,
129-
#if defined (DMX_MAX_PORTS)
130-
#if (DMX_MAX_PORTS == 1)
131-
DmxNodeParamsConst::kUniversePortA,
132-
#if defined(NODE_ARTNET) || defined (NODE_ARTNET_MULTI)
133-
ArtNetParamsConst::kDestinationIpPortA
134-
#endif
135-
#endif
136-
#if (DMX_MAX_PORTS == 2)
137-
DmxNodeParamsConst::kUniversePortA,
138-
DmxNodeParamsConst::kUniversePortB,
139-
#if defined(NODE_ARTNET) || defined (NODE_ARTNET_MULTI)
140-
ArtNetParamsConst::kDestinationIpPortA,
141-
ArtNetParamsConst::kDestinationIpPortB
142-
#endif
45+
static constexpr json::SimpleKey kIntensity{"intensity", 9, Fnv1a32("intensity", 9)};
46+
static constexpr json::SimpleKey kSleepTimeout{"sleep_timeout", 13, Fnv1a32("sleep_timeout", 13)};
47+
static constexpr json::SimpleKey kFlipVertically{"flip_vertically", 15, Fnv1a32("flip_vertically", 15)};
48+
static constexpr json::PortKey kTitle{"title", 5, Fnv1a32("title", 5)};
49+
static constexpr json::PortKey kBoardName{"board_name", 10, Fnv1a32("board_name", 10)};
50+
static constexpr json::PortKey kVersion{"version", 7, Fnv1a32("version", 7)};
51+
static constexpr json::PortKey kActivePorts{"active_ports", 12, Fnv1a32("active_ports", 12)};
52+
static constexpr json::PortKey kHostname{"hostname", 8, Fnv1a32("hostname", 8)};
53+
static constexpr json::PortKey kIpAddress{"ip_address", 10, Fnv1a32("ip_address", 10)};
54+
static constexpr json::PortKey kNetMask{"net_mask", 8, Fnv1a32("net_mask", 8)};
55+
static constexpr json::PortKey kDefaultGateway{"default_gateway", 15, Fnv1a32("default_gateway", 15)};
56+
static constexpr json::PortKey kDmxStartAddress{"dmx_start_address", 17, Fnv1a32("dmx_start_address", 17)};
57+
58+
static constexpr json::PortKey kLabels[] = {kTitle,
59+
kBoardName,
60+
kVersion,
61+
kHostname,
62+
kIpAddress,
63+
kNetMask,
64+
kDefaultGateway,
65+
kActivePorts,
66+
kDmxStartAddress,
67+
#if defined(DMX_MAX_PORTS)
68+
#if (DMX_MAX_PORTS == 1)
69+
DmxNodeParamsConst::kUniversePortA,
70+
#if defined(NODE_ARTNET) || defined(NODE_ARTNET_MULTI)
71+
ArtNetParamsConst::kDestinationIpPortA
72+
#endif
73+
#endif
74+
#if (DMX_MAX_PORTS == 2)
75+
DmxNodeParamsConst::kUniversePortA,
76+
DmxNodeParamsConst::kUniversePortB,
77+
#if defined(NODE_ARTNET) || defined(NODE_ARTNET_MULTI)
78+
ArtNetParamsConst::kDestinationIpPortA,
79+
ArtNetParamsConst::kDestinationIpPortB
80+
#endif
81+
#endif
82+
#if (DMX_MAX_PORTS == 3)
83+
DmxNodeParamsConst::kUniversePortA,
84+
DmxNodeParamsConst::kUniversePortB,
85+
DmxNodeParamsConst::kUniversePortC,
86+
#if defined(NODE_ARTNET) || defined(NODE_ARTNET_MULTI)
87+
ArtNetParamsConst::kDestinationIpPortA,
88+
ArtNetParamsConst::kDestinationIpPortB,
89+
ArtNetParamsConst::kDestinationIpPortC
90+
#endif
91+
#endif
92+
#if (DMX_MAX_PORTS == 4)
93+
DmxNodeParamsConst::kUniversePortA,
94+
DmxNodeParamsConst::kUniversePortB,
95+
DmxNodeParamsConst::kUniversePortC,
96+
DmxNodeParamsConst::kUniversePortD,
97+
#if defined(NODE_ARTNET) || defined(NODE_ARTNET_MULTI)
98+
ArtNetParamsConst::kDestinationIpPortA,
99+
ArtNetParamsConst::kDestinationIpPortB,
100+
ArtNetParamsConst::kDestinationIpPortC,
101+
ArtNetParamsConst::kDestinationIpPortD
143102
#endif
144-
#if (DMX_MAX_PORTS == 3)
145-
DmxNodeParamsConst::kUniversePortA,
146-
DmxNodeParamsConst::kUniversePortB,
147-
DmxNodeParamsConst::kUniversePortC,
148-
#if defined(NODE_ARTNET) || defined (NODE_ARTNET_MULTI)
149-
ArtNetParamsConst::kDestinationIpPortA,
150-
ArtNetParamsConst::kDestinationIpPortB,
151-
ArtNetParamsConst::kDestinationIpPortC
152-
#endif
153103
#endif
154-
#if (DMX_MAX_PORTS == 4)
155-
DmxNodeParamsConst::kUniversePortA,
156-
DmxNodeParamsConst::kUniversePortB,
157-
DmxNodeParamsConst::kUniversePortC,
158-
DmxNodeParamsConst::kUniversePortD,
159-
#if defined(NODE_ARTNET) || defined (NODE_ARTNET_MULTI)
160-
ArtNetParamsConst::kDestinationIpPortA,
161-
ArtNetParamsConst::kDestinationIpPortB,
162-
ArtNetParamsConst::kDestinationIpPortC,
163-
ArtNetParamsConst::kDestinationIpPortD
164-
#endif
165104
#endif
166-
#endif
167-
};
105+
};
168106
};
169107
} // namespace json
170108

171-
#endif // JSON_DISPLAYUDFPARAMSCONST_H_
109+
#endif // JSON_DISPLAYUDFPARAMSCONST_H_

lib-dmx/include/json/dmxsendparamsconst.h

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,17 @@
77
#define JSON_DMXSENDPARAMSCONST_H_
88

99
#include "json/json_key.h"
10+
#include "common/utils/utils_hash.h"
1011

11-
namespace json
12-
{
13-
struct DmxSendParamsConst
14-
{
12+
namespace json {
13+
struct DmxSendParamsConst {
1514
static constexpr char kFileName[] = "dmxsend.json";
1615

17-
inline static constexpr SimpleKey kBreakTime {
18-
"break_time",
19-
10,
20-
Fnv1a32("break_time", 10)
21-
};
22-
23-
inline static constexpr SimpleKey kMabTime {
24-
"mab_time",
25-
8,
26-
Fnv1a32("mab_time", 8)
27-
};
28-
29-
inline static constexpr SimpleKey kRefreshRate {
30-
"refresh_rate",
31-
12,
32-
Fnv1a32("refresh_rate", 12)
33-
};
34-
35-
inline static constexpr SimpleKey kSlotsCount {
36-
"slots_count",
37-
11,
38-
Fnv1a32("slots_count", 11)
39-
};
16+
static constexpr SimpleKey kBreakTime{"break_time", 10, Fnv1a32("break_time", 10)};
17+
static constexpr SimpleKey kMabTime{"mab_time", 8, Fnv1a32("mab_time", 8)};
18+
static constexpr SimpleKey kRefreshRate{"refresh_rate", 12, Fnv1a32("refresh_rate", 12)};
19+
static constexpr SimpleKey kSlotsCount{"slots_count", 11, Fnv1a32("slots_count", 11)};
4020
};
4121
} // namespace json
4222

43-
#endif // JSON_DMXSENDPARAMSCONST_H_
23+
#endif // JSON_DMXSENDPARAMSCONST_H_
Lines changed: 37 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,51 @@
11
/**
22
* @file dmxledparamsconst.h
33
*/
4+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
424

525
#ifndef JSON_DMXLEDPARAMSCONST_H_
626
#define JSON_DMXLEDPARAMSCONST_H_
727

828
#include "json/json_key.h"
29+
#include "common/utils/utils_hash.h"
930

10-
namespace json
11-
{
12-
struct DmxLedParamsConst
13-
{
31+
namespace json {
32+
struct DmxLedParamsConst {
1433
static constexpr char kFileName[] = "dmxled.json";
15-
16-
inline static constexpr json::SimpleKey kType {
17-
"type",
18-
4,
19-
Fnv1a32("type", 4)
20-
};
21-
22-
inline static constexpr json::SimpleKey kMap {
23-
"map",
24-
3,
25-
Fnv1a32("map", 3)
26-
};
27-
28-
inline static constexpr json::SimpleKey kCount {
29-
"count",
30-
5,
31-
Fnv1a32("count", 5)
32-
};
33-
34-
inline static constexpr json::SimpleKey kGroupingCount {
35-
"group_count",
36-
11,
37-
Fnv1a32("group_count", 11)
38-
};
39-
40-
inline static constexpr json::SimpleKey kT0H {
41-
"t0h",
42-
3,
43-
Fnv1a32("t0h", 3)
44-
};
45-
46-
inline static constexpr json::SimpleKey kT1H {
47-
"t1h",
48-
3,
49-
Fnv1a32("t1h", 3)
50-
};
51-
52-
inline static constexpr json::SimpleKey kActiveOutputPorts {
53-
"active_out",
54-
10,
55-
Fnv1a32("active_out", 10)
56-
};
57-
58-
inline static constexpr json::SimpleKey kTestPattern {
59-
"test_pattern",
60-
12,
61-
Fnv1a32("test_pattern", 12)
62-
};
6334

64-
inline static constexpr json::SimpleKey kSpiSpeedHz {
65-
"clock_speed_hz",
66-
14,
67-
Fnv1a32("clock_speed_hz", 14)
68-
};
69-
70-
inline static constexpr json::SimpleKey kGlobalBrightness {
71-
"global_brightness",
72-
17,
73-
Fnv1a32("global_brightness", 17)
74-
};
75-
76-
77-
inline static constexpr json::SimpleKey kGammaCorrection {
78-
"gamma_correction",
79-
16,
80-
Fnv1a32("gamma_correction", 16)
81-
};
82-
83-
inline static constexpr json::SimpleKey kGammaValue {
84-
"gamma_value",
85-
11,
86-
Fnv1a32("gamma_value", 11)
87-
};
35+
static constexpr json::SimpleKey kType{"type", 4, Fnv1a32("type", 4)};
36+
static constexpr json::SimpleKey kMap{"map", 3, Fnv1a32("map", 3)};
37+
static constexpr json::SimpleKey kCount{"count", 5, Fnv1a32("count", 5)};
38+
static constexpr json::SimpleKey kGroupingCount{"group_count", 11, Fnv1a32("group_count", 11)};
39+
static constexpr json::SimpleKey kT0H{"t0h", 3, Fnv1a32("t0h", 3)};
40+
41+
static constexpr json::SimpleKey kT1H{"t1h", 3, Fnv1a32("t1h", 3)};
42+
static constexpr json::SimpleKey kActiveOutputPorts{"active_out", 10, Fnv1a32("active_out", 10)};
43+
static constexpr json::SimpleKey kTestPattern{"test_pattern", 12, Fnv1a32("test_pattern", 12)};
44+
static constexpr json::SimpleKey kSpiSpeedHz{"clock_speed_hz", 14, Fnv1a32("clock_speed_hz", 14)};
45+
static constexpr json::SimpleKey kGlobalBrightness{"global_brightness", 17, Fnv1a32("global_brightness", 17)};
46+
static constexpr json::SimpleKey kGammaCorrection{"gamma_correction", 16, Fnv1a32("gamma_correction", 16)};
47+
static constexpr json::SimpleKey kGammaValue{"gamma_value", 11, Fnv1a32("gamma_value", 11)};
8848
};
8949
} // namespace json
9050

91-
#endif // JSON_DMXLEDPARAMSCONST_H_
51+
#endif // JSON_DMXLEDPARAMSCONST_H_

0 commit comments

Comments
 (0)