Skip to content

Commit ddeb118

Browse files
committed
Refactor watchdog/board APIs and RDM handling
Update code to use new board/watchdog APIs and adjust related RDM/pixel logic: - Replace gd32-specific headers and calls with new modules: gd32/hal_watchdog.h -> watchdog.h, hal_boardinfo.h -> board.h; hal::WatchdogInit/Feed -> watchdog::Init/Feed; hal::BoardName -> board::BoardName. - Use updated DMX enum: dmx::PortDirection::kInput -> dmx::Direction::kInput. - RDM responder changes: instantiate PixelTestPattern earlier and use GetPattern() consistently when calling common::firmware::pixeldmx::Show; rename RDMPersonality -> RdmPersonality; use rdm::personality::kDescriptionMaxLength for description buffer. - Simplify and reorder PersonalityUpdate logic to reuse the test pattern, update display handling, and ensure PixelOutputType configuration is applied correctly. - Minor formatting/brace adjustments and a small signature/style tweak in DmxStartAddressUpdate. These changes align the code with renamed APIs and improve consistency in pixel test pattern handling and RDM personality setup.
1 parent 8514b7f commit ddeb118

5 files changed

Lines changed: 31 additions & 44 deletions

File tree

gd32_dmx_usb_pro/firmware/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include <cstdio>
2727

2828
#include "hal.h"
29-
#include "gd32/hal_watchdog.h"
30-
#include "hal_boardinfo.h"
29+
#include "watchdog.h"
30+
#include "board.h"
3131
#include "rdmdevice.h"
3232
#include "widget.h"
3333
#include "widgetparams.h"
@@ -53,7 +53,7 @@ int main() // NOLINT
5353
ConfigStore config_store;
5454

5555
Widget widget;
56-
widget.SetPortDirection(0, dmx::PortDirection::kInput, false);
56+
widget.SetPortDirection(0, dmx::Direction::kInput, false);
5757

5858
WidgetParams widget_params;
5959
widget_params.Load();
@@ -68,20 +68,20 @@ int main() // NOLINT
6868
const auto kWidgetMode = widget_params.GetMode();
6969

7070
uint8_t hw_text_length;
71-
printf("[V%s] %s Compiled on %s at %s\n", kSoftwareVersion, hal::BoardName(hw_text_length), __DATE__, __TIME__);
71+
printf("[V%s] %s Compiled on %s at %s\n", kSoftwareVersion, board::BoardName(hw_text_length), __DATE__, __TIME__);
7272
printf("RDM Controller with USB [Compatible with Enttec USB Pro protocol], Widget mode : %d (%s)\n", kWidgetMode, kWidgetModeNames[static_cast<uint32_t>(kWidgetMode)]);
7373
printf("Device UUID : %.2x%.2x:%.2x%.2x%.2x%.2x, ", uid[0], uid[1], uid[2], uid[3], uid[4], uid[5]);
7474
printf("Label : %.*s\n", static_cast<int>(label.length), reinterpret_cast<const char*>(label.data));
7575

76-
hal::WatchdogInit();
76+
watchdog::Init();
7777

7878
if (kWidgetMode == widget::Mode::kRdmSniffer) {
79-
widget.SetPortDirection(0, dmx::PortDirection::kInput, true);
79+
widget.SetPortDirection(0, dmx::Direction::kInput, true);
8080
widget.SnifferFillTransmitBuffer(); // Prevent missing first frame
8181
}
8282

8383
for (;;) {
84-
hal::WatchdogFeed();
84+
watchdog::Feed();
8585
widget.Run();
8686
hal::Run();
8787
}

gd32_rdm_responder/firmware/main.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <cstdio>
2626

2727
#include "gd32/hal.h"
28-
#include "gd32/hal_watchdog.h"
28+
#include "watchdog.h"
2929
#include "displayudf.h"
3030
#include "hal_statusled.h"
3131
#include "json/displayudfparams.h"
@@ -69,32 +69,31 @@ int main() // NOLINT
6969
fw.Print("RDM Responder");
7070

7171
PixelDmx pixeldmx;
72+
PixelTestPattern pixel_test_pattern(pixelpatterns::Pattern::kNone, 1);
7273

7374
json::PixelDmxParams pixeldmx_params;
7475
pixeldmx_params.Load();
7576
pixeldmx_params.Set();
7677

77-
const auto kTestPattern = common::FromValue<pixelpatterns::Pattern>(ConfigStore::Instance().DmxLedGet(&common::store::DmxLed::test_pattern));
78-
79-
PixelTestPattern pixel_test_pattern(kTestPattern, 1);
78+
const auto kTestPattern = pixel_test_pattern.GetPattern();
8079

8180
PixelDmxParamsRdm pixeldmx_paramsrdm;
8281

8382
#if defined(CONFIG_RDM_MANUFACTURER_PIDS_SET)
8483
static constexpr auto kPersonalityCount = static_cast<uint32_t>(pixel::LedType::kUndefined);
85-
RDMPersonality* personalities[kPersonalityCount];
84+
RdmPersonality* personalities[kPersonalityCount];
8685

8786
for (uint32_t index = 0; index < kPersonalityCount; index++) {
8887
const auto* description = pixel::GetTypeName(static_cast<pixel::LedType>(index));
89-
personalities[index] = new RDMPersonality(description, &pixeldmx);
88+
personalities[index] = new RdmPersonality(description, &pixeldmx);
9089
}
9190

9291
RDMResponder rdm_responder(personalities, kPersonalityCount, static_cast<uint32_t>(pixeldmx.GetType()) + 1U);
9392
#else
94-
char description[rdm::personality::DESCRIPTION_MAX_LENGTH];
93+
char description[rdm::personality::kDescriptionMaxLength];
9594
pixeldmx::paramsdmx::SetPersonalityDescription(description);
9695

97-
RDMPersonality* personalities[2] = {new RDMPersonality(description, &pixeldmx), new RDMPersonality("Config mode", &pixeldmx_paramsrdm)};
96+
RdmPersonality* personalities[2] = {new RdmPersonality(description, &pixeldmx), new RdmPersonality("Config mode", &pixeldmx_paramsrdm)};
9897
RDMResponder rdm_responder(personalities, 2);
9998
#endif
10099
rdm_responder.Init();
@@ -124,7 +123,7 @@ int main() // NOLINT
124123
displayudf_params.Load();
125124
displayudf_params.SetAndShow();
126125

127-
common::firmware::pixeldmx::Show(7);
126+
common::firmware::pixeldmx::Show(7, kTestPattern);
128127

129128
if (kIsConfigMode) {
130129
display.ClearLine(3);
@@ -134,10 +133,10 @@ int main() // NOLINT
134133
}
135134

136135
hal::statusled::SetMode(hal::statusled::Mode::kNormal);
137-
hal::WatchdogInit();
136+
watchdog::Init();
138137

139138
for (;;) {
140-
hal::WatchdogFeed();
139+
watchdog::Feed();
141140
rdm_responder.Run();
142141
#if !defined(NO_EMAC)
143142
network::Run();

gd32_rdm_responder/lib/dmxstartaddressupdate.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "rdmresponder.h"
2929
#include "displayudf.h"
3030

31-
void RDMResponder::DmxStartAddressUpdate([[maybe_unused]] uint16_t dmx_start_address)
32-
{
31+
void RDMResponder::DmxStartAddressUpdate([[maybe_unused]] uint16_t dmx_start_address) {
3332
DisplayUdf::Get()->Show();
3433
}

gd32_rdm_responder/lib/personalityupdate.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
#include "firmware/pixeldmx/show.h"
3636
#include "firmware/debug/debug_debug.h"
3737

38-
void RDMResponder::PersonalityUpdate(uint32_t personality)
39-
{
38+
void RDMResponder::PersonalityUpdate(uint32_t personality) {
4039
DEBUG_PRINTF("personality=%u", personality);
4140

4241
#if defined(CONFIG_RDM_MANUFACTURER_PIDS_SET)
@@ -50,38 +49,28 @@ void RDMResponder::PersonalityUpdate(uint32_t personality)
5049

5150
dmxled_store::SaveType(kType);
5251

53-
common::firmware::pixeldmx::Show(7);
54-
5552
const auto kTestPattern = PixelTestPattern::Get()->GetPattern();
5653

57-
if (kTestPattern == pixelpatterns::Pattern::kNone)
58-
{
54+
common::firmware::pixeldmx::Show(7, kTestPattern);
55+
56+
if (kTestPattern == pixelpatterns::Pattern::kNone) {
5957
PixelOutputType::Get()->ApplyConfiguration();
60-
}
61-
else
62-
{
58+
} else {
6359
DisplayUdf::Get()->ClearEndOfLine();
6460
DisplayUdf::Get()->Printf(6, "%s:%u", PixelPatterns::GetName(kTestPattern), static_cast<uint32_t>(kTestPattern));
6561
}
6662
#else
67-
common::firmware::pixeldmx::Show(7);
68-
69-
if (personality == 1)
70-
{
71-
const auto kTestPattern = PixelTestPattern::Get()->GetPattern();
63+
const auto kTestPattern = PixelTestPattern::Get()->GetPattern();
64+
common::firmware::pixeldmx::Show(7, kTestPattern);
7265

73-
if (kTestPattern == pixelpatterns::Pattern::kNone)
74-
{
75-
PixelOutputType::Get()->ApplyConfiguration();
76-
}
77-
else
78-
{
66+
if (personality == 1) {
67+
if (kTestPattern == pixelpatterns::Pattern::kNone) {
68+
PixelOutputType::Get()->ApplyConfiguration();
69+
} else {
7970
DisplayUdf::Get()->ClearEndOfLine();
8071
DisplayUdf::Get()->Printf(6, "%s:%u", PixelPatterns::GetName(kTestPattern), static_cast<uint32_t>(kTestPattern));
8172
}
82-
}
83-
else if (personality == 2)
84-
{
73+
} else if (personality == 2) {
8574
DisplayUdf::Get()->ClearLine(3);
8675
DisplayUdf::Get()->ClearEndOfLine();
8776
DisplayUdf::Get()->Write(4, "Config Mode");

gen_compile_commands.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ INCLUDE_PATHS="-I./common/include $INCLUDE_PATHS "
4949
# Add paths to freestanding headers for toolchain
5050
INCLUDE_PATHS="$INCLUDE_PATHS $SYSINC"
5151

52-
DEFINES="-DGD32 -DGD32F30X -DGD32F30X_HD -DGD32F303RC -DBOARD_GD32F303RC -DNDEBUG -DCONFIG_STORE_USE_ROM -DNO_EMAC -DCONFIG_HAL_USE_SYSTICK -DCONFIG_EMAC_HASH_MULTICAST_FILTER -DRDM_RESPONDER -DCONFIG_DISPLAY_FIX_FLIP_VERTICALLY -DNDEBUG -DCONFIG_RDM_ENABLE_SELF_TEST -DCONFIG_RDM_ENABLE_MANUFACTURER_PIDS -DCONFIG_DMXNODE_PIXEL_MAX_PORTS=1 -DOUTPUT_DMX_PIXEL -DDISPLAY_UDF -DCONFIG_STORE_USE_ROM -DDISABLE_FS -DCONFIG_STORE_USE_ROM -DNO_EMAC -D_TIME_STAMP_YEAR_=2025 -D_TIME_STAMP_MONTH_=12 -D_TIME_STAMP_DAY_=29 -DCONFIG_HAL_USE_SYSTICK"
52+
DEFINES="-DGD32F30X -DGD32F30X_HD -DGD32F303RC -DBOARD_GD32F303RC -DNDEBUG -DCONFIG_STORE_USE_ROM -DNO_EMAC -DCONFIG_HAL_USE_SYSTICK -DCONFIG_EMAC_HASH_MULTICAST_FILTER -DRDM_RESPONDER -DCONFIG_DISPLAY_FIX_FLIP_VERTICALLY -DNDEBUG -DCONFIG_RDM_ENABLE_SELF_TEST -DCONFIG_RDM_ENABLE_MANUFACTURER_PIDS -DRDM_DEVICE_PRODUCT_CATEGORY=E120_PRODUCT_CATEGORY_FIXTURE -DRDM_DEVICE_PRODUCT_DETAIL=E120_PRODUCT_DETAIL_LED -DCONFIG_DMXNODE_PIXEL_MAX_PORTS=1 -DOUTPUT_DMX_PIXEL -DDISPLAY_UDF -DDISABLE_FS -DCONFIG_STORE_USE_ROM -DNO_EMAC -D_TIME_STAMP_=1780654371 -D_TIME_STAMP_YEAR_=2026 -D_TIME_STAMP_MONTH_=6 -D_TIME_STAMP_DAY_=5 -DCONFIG_HAL_USE_SYSTICK -DCONFIG_EMAC_HASH_MULTICAST_FILTER -DCONFIG_CLIB_USE_UART0"
5353

5454
echo $INCLUDE_PATHS
5555
echo $DEFINES

0 commit comments

Comments
 (0)