Skip to content

Commit ad416d1

Browse files
committed
Refactor pixel types & config; add build flags
Rename and consolidate pixel type/map enums and metadata into a compact, constexpr TypeInfo layout in pixeltype.h (Type->LedType, Map->LedMap, etc.), remove the old pixeltype.cpp, and add helper functions (GetTypeInfo, GetTypeName, GetMapName, GetTxH, GetTypeByName/GetMapByName). Update PixelConfiguration to use the new TypeInfo (led count, protocol, default/max Hz, maps), improve validation logic, and propagate enum/name changes across pixel output, patterns, test pattern, JSON status, and other pixel-related files. Add common::ToValue/FromValue constexpr helpers with static_assert checks. Apply IWYU pragma comments, tighten constexpr/formatting, bump copyright years to 2026 where applicable, and tidy minor warnings (pragmas, spacing). Also add CONFIG_HTTPD_OPTIMIZE_O2 define to several BOARD entries in common Makefile and adjust some remoteconfig/http headers and generated content includes. These changes centralize pixel metadata, simplify runtime logic, and standardize naming/API across the codebase.
1 parent 829a026 commit ad416d1

39 files changed

Lines changed: 1240 additions & 1152 deletions

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

lib-network/src/core/tcp.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#if defined(DEBUG_NET_TCP)
4747
#undef NDEBUG
4848
#endif
49-
5049
#pragma GCC diagnostic push
5150
#if (__GNUC__ < 10)
5251
#pragma GCC diagnostic ignored "-Wconversion"

lib-pixel/include/gd32/gpio/pixeloutputmulti.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file pixeloutputmulti.h
33
*
44
*/
5-
/* Copyright (C) 2021-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2021-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
@@ -40,8 +40,8 @@
4040
#include <cstdint>
4141

4242
#include "pixeltype.h"
43-
#include "gd32/gpio/pixeloutputmulti_config.h"
44-
#include "gd32.h"
43+
#include "gd32/gpio/pixeloutputmulti_config.h" // IWYU pragma: keep
44+
#include "gd32.h" // IWYU pragma: keep
4545

4646
class PixelOutputMulti
4747
{

lib-pixel/include/pixel.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ inline void SetPixelColour([[maybe_unused]] uint32_t port_index, uint32_t pixel_
8080
#if defined(PIXELPATTERNS_MULTI)
8181
switch (PixelConfiguration::Get().GetType())
8282
{
83-
case pixel::Type::WS2801:
83+
case pixel::LedType::kWS2801:
8484
output_type->SetColourWS2801(port_index, pixel_index, kColours.Red(), kColours.Green(), kColours.Blue());
8585
break;
8686

87-
case pixel::Type::APA102:
88-
case pixel::Type::SK9822:
87+
case pixel::LedType::kAPA102:
88+
case pixel::LedType::kSK9822:
8989
output_type->SetPixel4Bytes(port_index, pixel_index, 0xFF, kColours.Red(), kColours.Green(), kColours.Blue());
9090
break;
9191

92-
case pixel::Type::P9813:
92+
case pixel::LedType::kP9813:
9393
{
9494
const auto kRed = kColours.Red();
9595
const auto kBlue = kColours.Blue();
@@ -98,7 +98,7 @@ inline void SetPixelColour([[maybe_unused]] uint32_t port_index, uint32_t pixel_
9898
break;
9999
}
100100

101-
case pixel::Type::SK6812W:
101+
case pixel::LedType::kSK6812W:
102102
output_type->SetColourRTZ(port_index, pixel_index, kColours.Red(), kColours.Green(), kColours.Blue(), kColours.White());
103103
break;
104104

@@ -110,7 +110,7 @@ inline void SetPixelColour([[maybe_unused]] uint32_t port_index, uint32_t pixel_
110110
auto& pixel_configuration = PixelConfiguration::Get();
111111
const auto kType = pixel_configuration.GetType();
112112

113-
if (kType != pixel::Type::SK6812W)
113+
if (kType != pixel::LedType::kSK6812W)
114114
{
115115
output_type->SetPixel(pixel_index, kColours.Red(), kColours.Green(), kColours.Blue());
116116
}

0 commit comments

Comments
 (0)