Skip to content

Commit 8ffe40e

Browse files
committed
Refactor RDM device handling and unify device info
Refactored RDM device management by introducing a singleton RdmDevice class, consolidating device info and label handling. Removed the now-redundant RDMDeviceController class and updated RDMDeviceResponder and related code to use the new RdmDevice interface. Updated all references and method signatures to use the new rdm::DeviceInfoData and rdm::DeviceInfo structures, improving code clarity and maintainability.
1 parent c002c8d commit 8ffe40e

12 files changed

Lines changed: 1483 additions & 1308 deletions

File tree

gd32_dmx_usb_pro/firmware/main.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "hal.h"
2929
#include "gd32/hal_watchdog.h"
3030
#include "hal_boardinfo.h"
31+
#include "rdmdevice.h"
3132
#include "widget.h"
3233
#include "widgetparams.h"
3334
#include "configstore.h"
@@ -45,13 +46,13 @@ static constexpr char kWidgetModeNames[4][12] ALIGNED =
4546
"RDM_SNIFFER"
4647
};
4748

48-
static constexpr TRDMDeviceInfoData kDeviceLabel ALIGNED =
49+
static constexpr rdm::DeviceInfoData kDeviceLabel ALIGNED =
4950
{
5051
const_cast<char*>("GD32F103RC DMX USB Pro"),
5152
22
5253
};
5354

54-
int main()
55+
int main() // NOLINT
5556
{
5657
hal::Init();
5758
ConfigStore config_store;
@@ -63,12 +64,13 @@ int main()
6364
widget_params.Load();
6465
widget_params.Set();
6566

66-
widget.SetLabel(&kDeviceLabel);
67-
widget.Init();
67+
auto& rdm_device = RdmDevice::Get();
68+
rdm_device.SetLabel(&kDeviceLabel);
69+
rdm_device.Init();
6870

69-
const auto* rdm_device_uid = widget.GetUID();
70-
TRDMDeviceInfoData rdm_device_label;
71-
widget.GetLabel(&rdm_device_label);
71+
const auto* rdm_device_uid = rdm_device.GetUID();
72+
struct rdm::DeviceInfoData rdm_device_label;
73+
rdm_device.GetLabel(&rdm_device_label);
7274
const auto kWidgetMode = widget_params.GetMode();
7375

7476
uint8_t hw_text_length;

gd32_rdm_responder/firmware/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "gd32/hal_watchdog.h"
2929
#include "displayudf.h"
3030
#include "json/displayudfparams.h"
31+
#include "rdmdevice.h"
3132
#include "rdmresponder.h"
3233
#include "rdmpersonality.h"
3334
#include "json/pixeldmxparams.h"
@@ -60,7 +61,7 @@ int main() // NOLINT
6061
DisplayUdf display;
6162
ConfigStore config_store;
6263
#if !defined(NO_EMAC)
63-
Network nw;
64+
network::Init();
6465
#endif
6566
FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__);
6667

@@ -79,6 +80,10 @@ int main() // NOLINT
7980
PixelTestPattern pixel_test_pattern(kTestPattern, 1);
8081

8182
PixelDmxParamsRdm pixeldmx_paramsrdm;
83+
84+
auto& rdm_device = RdmDevice::Get();
85+
rdm_device.SetProductCategory(E120_PRODUCT_CATEGORY_FIXTURE);
86+
rdm_device.SetProductDetail(E120_PRODUCT_DETAIL_LED);
8287

8388
#if defined(CONFIG_RDM_MANUFACTURER_PIDS_SET)
8489
static constexpr auto kPersonalityCount = static_cast<uint32_t>(pixel::Type::UNDEFINED);
@@ -98,8 +103,6 @@ int main() // NOLINT
98103
RDMPersonality* personalities[2] = {new RDMPersonality(description, &pixeldmx), new RDMPersonality("Config mode", &pixeldmx_paramsrdm)};
99104
RDMResponder rdm_responder(personalities, 2);
100105
#endif
101-
rdm_responder.SetProductCategory(E120_PRODUCT_CATEGORY_FIXTURE);
102-
rdm_responder.SetProductDetail(E120_PRODUCT_DETAIL_LED);
103106
rdm_responder.Init();
104107
rdm_responder.Start();
105108
rdm_responder.DmxDisableOutput(!kIsConfigMode && (kTestPattern != pixelpatterns::Pattern::kNone));
@@ -149,7 +152,7 @@ int main() // NOLINT
149152
hal::WatchdogFeed();
150153
rdm_responder.Run();
151154
#if !defined(NO_EMAC)
152-
net::Run();
155+
network::Run();
153156
#endif
154157
pixel_test_pattern.Run();
155158
display.Run();

0 commit comments

Comments
 (0)