Skip to content

Commit 3d37e41

Browse files
committed
Refactor pixel types; add TypeInfo and helpers
Replace legacy pixel::Type/Map with strongly-typed LedType/LedMap and introduce a compact TypeInfo table (name, protocol, led count, default/max SPI Hz, RTZ codes, map). Add common enum utilities (constexpr ToValue/FromValue), GetTypeName/GetMapName/GetTypeInfo helpers and GetTxH/GetTypeByName/GetMapByName. Update callers across pixel, pixeloutput, pixelconfiguration, test patterns, OSC handler, RDM responder, display and JSON status code to use the new types and APIs. Also refactor PixelTestPattern class formatting/identifiers, tidy diagnostics/whitespace, bump copyright years to 2026 in several files, remove obsolete pixeltype.cpp, and add/adjust HTTPD build defines (CONFIG_HTTPD_OPTIMIZE_O2, ENABLE_CONTENT and HTML config flags) in multiple Makefiles/Board.mk.
1 parent 76322af commit 3d37e41

45 files changed

Lines changed: 1263 additions & 1162 deletions

File tree

Some content is hidden

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

common/include/common/utils/utils_enum.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file utils_enum.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
@@ -30,19 +30,20 @@
3030

3131
namespace common
3232
{
33-
3433
/// Converts an enum class value to its underlying integer type.
35-
template <typename Enum>
36-
inline auto ToValue(Enum e) noexcept {
34+
template <typename Enum> constexpr auto ToValue(Enum e) noexcept -> std::underlying_type_t<Enum>
35+
{
36+
static_assert(std::is_enum_v<Enum>);
3737
return static_cast<std::underlying_type_t<Enum>>(e);
3838
}
3939

4040
/// 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 {
41+
template <typename Enum> constexpr Enum FromValue(std::underlying_type_t<Enum> value) noexcept
42+
{
43+
static_assert(std::is_enum_v<Enum>);
4344
return static_cast<Enum>(value);
4445
}
4546

4647
} // namespace common
4748

48-
#endif // COMMON_UTILS_UTILS_ENUM_H_
49+
#endif // COMMON_UTILS_UTILS_ENUM_H_

common/include/firmware/pixeldmx/show.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* display.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
@@ -41,8 +41,8 @@ inline void Show(uint32_t line, pixelpatterns::Pattern pattern = pixelpatterns::
4141
assert(display != nullptr);
4242

4343
display->ClearEndOfLine();
44-
display->Printf(line, "%s:%d G%d %s", pixel::GetType(configuration.GetType()), configuration.GetCount(), configuration.GetGroupingCount(),
45-
pixel::GetMap(configuration.GetMap()));
44+
display->Printf(line, "%s:%d G%d %s", pixel::GetTypeName(configuration.GetType()), configuration.GetCount(), configuration.GetGroupingCount(),
45+
pixel::GetMapName(configuration.GetMap()));
4646
display->ClearLine(8); // Status line
4747

4848
if (pattern != pixelpatterns::Pattern::kNone)

common/make/gd32/Board.mk

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ endif
2222
ifeq ($(strip $(BOARD)),BOARD_GD32F207RG)
2323
MCU=GD32F207RG
2424
DEFINES+=-DCONFIG_STORE_USE_SPI
25-
endif
26-
27-
ifeq ($(strip $(BOARD)),BOARD_GD32F303CB)
28-
MCU=GD32F303CB
29-
DEFINES+=-DCONFIG_STORE_USE_ROM
30-
DEFINES+=-DNO_EMAC
25+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
3126
endif
3227

3328
ifeq ($(strip $(BOARD)),BOARD_GD32F303RC)
@@ -39,18 +34,22 @@ endif
3934
ifeq ($(strip $(BOARD)),BOARD_GD32F407RE)
4035
MCU=GD32F407RE
4136
DEFINES+=-DCONFIG_STORE_USE_SPI
37+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
4238
endif
4339

4440
ifeq ($(strip $(BOARD)),BOARD_GD32F450VI)
4541
MCU=GD32F450VI
42+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
4643
endif
4744

4845
ifeq ($(strip $(BOARD)),BOARD_16X4U_PIXEL)
4946
MCU=GD32F450VI
47+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
5048
endif
5149

5250
ifeq ($(strip $(BOARD)),BOARD_GD32F470VG)
5351
MCU=GD32F470VG
52+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
5453
endif
5554

5655
ifeq ($(strip $(BOARD)),BOARD_GD32F207C_EVAL)
@@ -71,16 +70,19 @@ endif
7170
ifeq ($(strip $(BOARD)),BOARD_BW_OPIDMX4)
7271
BOARD_DMX=4
7372
DEFINES+=-DCONFIG_STORE_USE_SPI
73+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
7474
endif
7575

7676
ifeq ($(strip $(BOARD)),BOARD_DMX3)
7777
BOARD_DMX=3
7878
DEFINES+=-DCONFIG_STORE_USE_SPI
79+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
7980
endif
8081

8182
ifeq ($(strip $(BOARD)),BOARD_DMX4)
82-
DEFINES+=-DCONFIG_STORE_USE_SPI
8383
BOARD_DMX=4
84+
DEFINES+=-DCONFIG_STORE_USE_SPI
85+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
8486
endif
8587

8688
ifdef BOARD_DMX

gd32_emac_artnet_dmx/Makefile.GD32

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ DEFINES+=ARTNET_HAVE_DMXIN
33

44
DEFINES+=DMXNODE_PORTS=1
55

6-
DEFINES+=OUTPUT_DMX_SEND
6+
DEFINES+=OUTPUT_DMX_SEND
77

88
DEFINES+=RDM_CONTROLLER RDM_DISCOVERY_TOD_TABLE_SIZE=8
99

@@ -13,7 +13,8 @@ DEFINES+=RTL8201F_LED1_LINK_ALL
1313

1414
DEFINES+=DISPLAY_UDF
1515

16-
DEFINES+=ENABLE_HTTPD
16+
DEFINES+=ENABLE_HTTPD ENABLE_CONTENT
17+
DEFINES+=CONFIG_HTTP_HTML_INDEX_ONLY
1718
DEFINES+=CONFIG_HTTP_HTML_NO_RDM
1819
DEFINES+=CONFIG_HTTP_HTML_NO_DMX
1920
DEFINES+=CONFIG_HTTP_HTML_NO_TIME

gd32_emac_artnet_pixel/Makefile.GD32

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ DEFINES+=ENET_RXBUF_NUM=8 ENET_TXBUF_NUM=2
1010

1111
DEFINES+=RTL8201F_LED1_LINK_ALL
1212

13-
DEFINES+=DISPLAY_UDF
13+
DEFINES+=DISPLAY_UDF
14+
15+
DEFINES+=ENABLE_HTTPD ENABLE_CONTENT
16+
DEFINES+=CONFIG_HTTP_HTML_INDEX_ONLY
17+
DEFINES+=CONFIG_HTTP_HTML_NO_RDM
18+
DEFINES+=CONFIG_HTTP_HTML_NO_DMX
19+
DEFINES+=CONFIG_HTTP_HTML_NO_TIME
1420

1521
DEFINES+=DISABLE_RTC
1622
DEFINES+=DISABLE_FS

gd32_emac_artnet_rdm_pca9685/Makefile.GD32

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ DEFINES+=CONFIG_RDM_SENSORS_DISABLE_THERMISTOR
77

88
DEFINES+=OUTPUT_DMX_PCA9685
99

10-
DEFINES+=ENABLE_HTTPD
10+
DEFINES+=ENABLE_HTTPD ENABLE_CONTENT
11+
DEFINES+=CONFIG_HTTP_HTML_INDEX_ONLY
12+
DEFINES+=CONFIG_HTTP_HTML_NO_RDM
13+
DEFINES+=CONFIG_HTTP_HTML_NO_DMX
14+
DEFINES+=CONFIG_HTTP_HTML_NO_TIME
1115

1216
DEFINES+=ENET_RXBUF_NUM=4 ENET_TXBUF_NUM=2
1317

gd32_emac_e131_dmx/Makefile.GD32

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ DEFINES+=RTL8201F_LED1_LINK_ALL
1313
DEFINES+=DISPLAY_UDF
1414

1515
DEFINES+=ENABLE_HTTPD ENABLE_CONTENT
16+
DEFINES+=CONFIG_HTTP_HTML_INDEX_ONLY
17+
DEFINES+=CONFIG_HTTP_HTML_NO_RDM
18+
DEFINES+=CONFIG_HTTP_HTML_NO_DMX
19+
DEFINES+=CONFIG_HTTP_HTML_NO_TIME
1620

1721
DEFINES+=DISABLE_PRINTF_FLOAT
1822
DEFINES+=DISABLE_RTC

gd32_emac_e131_pixel/Makefile.GD32

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ DEFINES+=RTL8201F_LED1_LINK_ALL
99

1010
DEFINES+=DISPLAY_UDF
1111

12-
DEFINES+=ENABLE_HTTPD
12+
DEFINES+=ENABLE_HTTPD ENABLE_CONTENT
13+
DEFINES+=CONFIG_HTTP_HTML_INDEX_ONLY
14+
DEFINES+=CONFIG_HTTP_HTML_NO_RDM
15+
DEFINES+=CONFIG_HTTP_HTML_NO_DMX
16+
DEFINES+=CONFIG_HTTP_HTML_NO_TIME
1317

1418
DEFINES+=DISABLE_RTC
1519
DEFINES+=DISABLE_FS

gd32_emac_osc_pixel/include/handler.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file handler.h
33
*/
4-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
4+
/* Copyright (C) 2022-2026 by Arjan van Vught mailto:info@gd32-dmx.org
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -29,39 +29,37 @@
2929

3030
#include "oscserver.h"
3131
#include "oscsimplesend.h"
32-
3332
#include "pixeltype.h"
3433
#include "pixeldmx.h"
35-
3634
#include "firmware/debug/debug_debug.h"
3735

3836
class Handler: public OscServerHandler {
3937
public:
40-
Handler(PixelDmx *pPixelDmx): m_pPixelDmx(pPixelDmx) {
38+
Handler(PixelDmx *pixel_dmx): pixel_dmx_(pixel_dmx) {
4139
DEBUG_ENTRY();
4240
DEBUG_EXIT();
4341
}
4442

4543
void Blackout() override {
4644
DEBUG_ENTRY();
47-
m_pPixelDmx->Blackout(true);
45+
pixel_dmx_->Blackout(true);
4846
DEBUG_EXIT();
4947
}
5048

5149
void Update() override {
5250
DEBUG_ENTRY();
53-
m_pPixelDmx->Blackout(false);
51+
pixel_dmx_->Blackout(false);
5452
DEBUG_EXIT();
5553
}
5654

57-
void Info(int32_t nHandle, uint32_t nRemoteIp, uint16_t nPortOutgoing) override {
58-
OscSimpleSend MsgSendLedType(nHandle, nRemoteIp, nPortOutgoing, "/info/ledtype", "s", const_cast<char *>(pixel::GetType(PixelConfiguration::Get().GetType())));
59-
OscSimpleSend MsgSendLedCount(nHandle, nRemoteIp, nPortOutgoing, "/info/ledcount", "i", static_cast<int>(PixelConfiguration::Get().GetCount()));
60-
OscSimpleSend MsgSendGroupCount(nHandle, nRemoteIp, nPortOutgoing, "/info/groupcount", "i", static_cast<int>(PixelDmxConfiguration::Get().GetGroupingCount()));
55+
void Info(int32_t handle, uint32_t remote_ip, uint16_t port_outgoing) override {
56+
OscSimpleSend MsgSendLedType(handle, remote_ip, port_outgoing, "/info/ledtype", "s", const_cast<char *>(pixel::GetTypeName(PixelConfiguration::Get().GetType())));
57+
OscSimpleSend MsgSendLedCount(handle, remote_ip, port_outgoing, "/info/ledcount", "i", static_cast<int>(PixelConfiguration::Get().GetCount()));
58+
OscSimpleSend MsgSendGroupCount(handle, remote_ip, port_outgoing, "/info/groupcount", "i", static_cast<int>(PixelDmxConfiguration::Get().GetGroupingCount()));
6159
}
6260

6361
private:
64-
PixelDmx *m_pPixelDmx;
62+
PixelDmx *pixel_dmx_;
6563
};
6664

6765
#endif /* HANDLER_H_ */

gd32_rdm_responder/firmware/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ int main() // NOLINT
8282
PixelDmxParamsRdm pixeldmx_paramsrdm;
8383

8484
#if defined(CONFIG_RDM_MANUFACTURER_PIDS_SET)
85-
static constexpr auto kPersonalityCount = static_cast<uint32_t>(pixel::Type::UNDEFINED);
85+
static constexpr auto kPersonalityCount = static_cast<uint32_t>(pixel::LedType::kUndefined);
8686
RDMPersonality* personalities[kPersonalityCount];
8787

8888
for (uint32_t index = 0; index < kPersonalityCount; index++)
8989
{
90-
const auto* description = pixel::GetType(static_cast<pixel::Type>(index));
90+
const auto* description = pixel::GetTypeName(static_cast<pixel::LedType>(index));
9191
personalities[index] = new RDMPersonality(description, &pixeldmx);
9292
}
9393

0 commit comments

Comments
 (0)