Skip to content

Commit 2e0bcff

Browse files
committed
Refactor board/panelled APIs and rename files
Move and rename board and panel LED APIs into common modules and update usages across the codebase. Key changes: - Rename hal_boardinfo.h -> common/include/board.h and hal_boardinfo.cpp -> lib-gd32/src/board.cpp; introduce board namespace (replacing hal), add BootDevice enum and new board helpers (Init, Reboot, RebootHandler, GetBootDevice, CoreTemperatureMin/Max/Current, Website). - Rename hal_panelled header/source to panelled.h/.cpp and remove old hal_panelled.h; switch namespace usages from hal::panelled to panelled and update callers. - Update includes (firmwareversion, hal.h, hal_init, hal_statusled, etc.) to use new headers and symbols. - Delete unused hwclockrtc.cpp and adjust remoteconfig to skip display messages before calling reboot. - Misc: formatting/brace style changes, small debug/log additions (Show), inline constexpr adjustments, and pixel/ArtNet handler formatting fixes. These changes consolidate board/panel LED APIs, simplify namespaces, and harmonize file locations.
1 parent aacbd86 commit 2e0bcff

21 files changed

Lines changed: 133 additions & 471 deletions

File tree

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file hal_boardinfo.h
2+
* @file board.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 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
@@ -23,18 +23,31 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#ifndef HAL_BOARDINFO_H_
27-
#define HAL_BOARDINFO_H_
26+
#ifndef BOARD_H_
27+
#define BOARD_H_
2828

2929
#include <cstdint>
3030

31-
namespace hal
32-
{
31+
namespace board {
32+
enum class BootDevice { kUnkown, kFel, kMmc0, kSpi, kHdd, kFlash, kRam };
33+
34+
void Init();
35+
bool Reboot();
36+
void RebootHandler();
37+
38+
BootDevice GetBootDevice();
39+
3340
const char* BoardName(uint8_t& length);
3441
const char* SocName(uint8_t& length);
3542
const char* CpuName(uint8_t& length);
36-
const char* SysName(uint8_t& length);
3743
const char* MachineName(uint8_t& length);
38-
} // namespace hal
44+
const char* SysName(uint8_t& length);
45+
46+
float CoreTemperatureMin();
47+
float CoreTemperatureMax();
48+
float CoreTemperatureCurrent();
49+
50+
const char* Website();
51+
} // namespace board
3952

40-
#endif // HAL_BOARDINFO_H_
53+
#endif // BOARD_H_

common/include/firmware/artnet/pixel/artnettriggerhandler.h

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
#include "pixeldmxconfiguration.h"
3636
#include "displayudf.h"
3737

38-
class ArtNetTriggerHandler : ArtNetTrigger
39-
{
38+
class ArtNetTriggerHandler : ArtNetTrigger {
4039
public:
41-
explicit ArtNetTriggerHandler(DmxNodeOutputType* output_type) : dmxnode_output_type_(output_type)
42-
{
40+
explicit ArtNetTriggerHandler(DmxNodeOutputType* output_type) : dmxnode_output_type_(output_type) {
4341
assert(s_this == nullptr);
4442
s_this = this;
4543

@@ -48,68 +46,55 @@ class ArtNetTriggerHandler : ArtNetTrigger
4846

4947
~ArtNetTriggerHandler() = default;
5048

51-
void static StaticCallbackFunction(const ArtNetTrigger* trigger)
52-
{
49+
void static StaticCallbackFunction(const ArtNetTrigger* trigger) {
5350
assert(s_this != nullptr);
5451
s_this->Handler(trigger);
5552
}
5653

5754
private:
58-
void Handler(const ArtNetTrigger* trigger)
59-
{
60-
if (trigger->key == ArtTriggerKey::kArtTriggerKeyShow)
61-
{
55+
void Handler(const ArtNetTrigger* trigger) {
56+
if (trigger->key == ArtTriggerKey::kArtTriggerKeyShow) {
6257
ArtNetNode::Get()->SetOutput(dmxnode_output_type_);
6358

6459
const auto kShow = static_cast<pixelpatterns::Pattern>(trigger->sub_key);
6560

66-
if (kShow == PixelTestPattern::Get()->GetPattern())
67-
{
61+
if (kShow == PixelTestPattern::Get()->GetPattern()) {
6862
return;
6963
}
7064

7165
const auto kIsSet = PixelTestPattern::Get()->SetPattern(kShow);
7266

73-
if (!kIsSet)
74-
{
67+
if (!kIsSet) {
7568
return;
7669
}
7770

78-
if (static_cast<pixelpatterns::Pattern>(kShow) != pixelpatterns::Pattern::kNone)
79-
{
71+
if (static_cast<pixelpatterns::Pattern>(kShow) != pixelpatterns::Pattern::kNone) {
8072
ArtNetNode::Get()->SetOutput(nullptr);
8173
Display::Get()->ClearLine(6);
8274
Display::Get()->Printf(6, "%s:%u", PixelPatterns::GetName(kShow), static_cast<uint32_t>(kShow));
83-
}
84-
else
85-
{
75+
} else {
8676
dmxnode_output_type_->Blackout(true);
8777
DisplayUdf::Get()->Show();
8878
}
8979

9080
return;
9181
}
9282

93-
if (trigger->key == ArtTriggerKey::kArtTriggerUndefined)
94-
{
95-
if (trigger->sub_key == 0)
96-
{
83+
if (trigger->key == ArtTriggerKey::kArtTriggerUndefined) {
84+
if (trigger->sub_key == 0) {
9785
const auto kIsSet = PixelTestPattern::Get()->SetPattern(pixelpatterns::Pattern::kNone);
9886

99-
if (!kIsSet)
100-
{
87+
if (!kIsSet) {
10188
return;
10289
}
10390

10491
ArtNetNode::Get()->SetOutput(nullptr);
10592

10693
auto& configuration = PixelDmxConfiguration::Get();
10794
const auto* trigger_data = &trigger->data[0];
108-
const uint32_t kColour = trigger_data[0] | (static_cast<uint32_t>(trigger_data[1]) << 8) | (static_cast<uint32_t>(trigger_data[2]) << 16) |
109-
(static_cast<uint32_t>(trigger_data[3]) << 24);
95+
const uint32_t kColour = trigger_data[0] | (static_cast<uint32_t>(trigger_data[1]) << 8) | (static_cast<uint32_t>(trigger_data[2]) << 16) | (static_cast<uint32_t>(trigger_data[3]) << 24);
11096

111-
for (uint32_t active_port = 0; active_port < configuration.GetOutputPorts(); active_port++)
112-
{
97+
for (uint32_t active_port = 0; active_port < configuration.GetOutputPorts(); active_port++) {
11398
pixel::SetPixelColour(active_port, kColour);
11499
}
115100

common/include/firmware/pixeldmx/show.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,34 @@
2929
#include <cstdint>
3030

3131
#include "pixeldmxconfiguration.h"
32-
#include "display.h"
32+
#include "display.h" // IWYU pragma: keep
3333
#include "pixelpatterns.h"
34+
#include "firmware/debug/debug_debug.h"
3435

3536
namespace common::firmware::pixeldmx {
36-
inline void Show(uint32_t line, pixelpatterns::Pattern pattern = pixelpatterns::Pattern::kNone) {
37+
inline void Show(uint32_t line, pixelpatterns::Pattern pattern) {
38+
DEBUG_PRINTF("line=%u, pattern=%u", line, static_cast<uint32_t>(pattern));
39+
3740
auto& configuration = PixelDmxConfiguration::Get();
3841
auto* display = Display::Get();
3942
assert(display != nullptr);
4043

4144
display->ClearEndOfLine();
4245
display->Printf(line, "%s:%d G%d %s",
4346
pixel::GetTypeName(configuration.GetType()),
44-
configuration.GetCount(), configuration.GetGroupingCount(),
45-
pixel::GetMapName(configuration.GetMap()));
47+
configuration.GetCount(),
48+
configuration.GetGroupingCount(),
49+
pixel::GetMapName(configuration.GetMap())
50+
);
51+
4652
display->ClearLine(8); // Status line
4753

54+
display->ClearLine(6);
4855
if (pattern != pixelpatterns::Pattern::kNone) {
49-
display->ClearLine(6);
50-
display->Printf(6, "%s:%u", PixelPatterns::GetName(pattern), static_cast<uint32_t>(pattern));
56+
display->Printf(6, "%s:%u",
57+
PixelPatterns::GetName(pattern),
58+
static_cast<uint32_t>(pattern)
59+
);
5160
}
5261
}
5362
} // namespace common::firmware::pixeldmx

lib-gd32/include/board/16x4u-pixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
// Panel LEDs
113113
#ifdef __cplusplus
114114
#include <cstdint>
115-
namespace hal::panelled {
115+
namespace panelled {
116116
inline constexpr uint32_t kActivity = 0;
117117
inline constexpr uint32_t kArtnet = 0;
118118
inline constexpr uint32_t kDdp = 0;
@@ -127,7 +127,7 @@ inline constexpr uint32_t kTcnet = 0;
127127
// DMX
128128
static constexpr uint32_t kPortARx = 0;
129129
static constexpr uint32_t kPortATx = 0;
130-
} // namespace hal::panelled
130+
} // namespace panelled
131131
#endif
132132

133133
/**

lib-gd32/include/board/bw_opidmx4.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
// Panel LEDs
118118
#ifdef __cplusplus
119119
#include <cstdint>
120-
namespace hal::panelled {
120+
namespace panelled {
121121
inline constexpr uint32_t kActivity = 0;
122122
inline constexpr uint32_t kArtnet = 0;
123123
inline constexpr uint32_t kDdp = 0;
@@ -132,7 +132,7 @@ inline constexpr uint32_t kTcnet = 0;
132132
// DMX
133133
static constexpr uint32_t kPortARx = 0;
134134
static constexpr uint32_t kPortATx = 0;
135-
} // namespace hal::panelled
135+
} // namespace panelled
136136
#endif
137137

138138
/**

lib-gd32/include/board/dmx3.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
// Panel LEDs
114114
#ifdef __cplusplus
115-
namespace hal::panelled {
115+
namespace panelled {
116116
inline constexpr uint32_t kActivity = 0;
117117
inline constexpr uint32_t kArtnet = 0;
118118
inline constexpr uint32_t kDdp = 0;
@@ -129,7 +129,7 @@ inline constexpr uint32_t kPortATx = (1U << 0);
129129
inline constexpr uint32_t kPortARx = (1U << 8);
130130
#define CONFIG_PANELLED_RDM_PORT
131131
inline constexpr uint32_t kPortARdm = (1U << 16);
132-
} // namespace hal::panelled
132+
} // namespace panelled
133133
#endif
134134

135135
#define PANELLED_595_COUNT 2

lib-gd32/include/board/dmx4.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
// Panel LEDs
118118
#ifdef __cplusplus
119-
namespace hal::panelled {
119+
namespace panelled {
120120
inline constexpr uint32_t kActivity = 0;
121121
inline constexpr uint32_t kArtnet = 0;
122122
inline constexpr uint32_t kDdp = 0;
@@ -133,7 +133,7 @@ inline constexpr uint32_t kPortATx = (1U << 0);
133133
inline constexpr uint32_t kPortARx = (1U << 8);
134134
#define CONFIG_PANELLED_RDM_PORT
135135
inline constexpr uint32_t kPortARdm = (1U << 16);
136-
} // namespace hal::panelled
136+
} // namespace panelled
137137
#endif
138138

139139
#define PANELLED_595_COUNT 2

lib-gd32/include/board/gd32f407re.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
// Panel LEDs
163163
#ifdef __cplusplus
164164
#include <cstdint>
165-
namespace hal::panelled {
165+
namespace panelled {
166166
inline constexpr uint32_t kActivity = 0;
167167
inline constexpr uint32_t kArtnet = 0;
168168
inline constexpr uint32_t kDdp = 0;
@@ -177,7 +177,7 @@ inline constexpr uint32_t kTcnet = 0;
177177
// DMX
178178
static constexpr uint32_t kPortARx = 0;
179179
static constexpr uint32_t kPortATx = 0;
180-
} // namespace hal::panelled
180+
} // namespace panelled
181181
#endif
182182

183183
/**

lib-gd32/include/board/gd32f450vi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
// Panel LEDs
122122
#ifdef __cplusplus
123123
#include <cstdint>
124-
namespace hal::panelled {
124+
namespace panelled {
125125
inline constexpr uint32_t kActivity = 0;
126126
inline constexpr uint32_t kArtnet = 0;
127127
inline constexpr uint32_t kDdp = 0;
@@ -136,7 +136,7 @@
136136
// DMX
137137
static constexpr uint32_t kPortARx = 0;
138138
static constexpr uint32_t kPortATx = 0;
139-
} // namespace hal::panelled
139+
} // namespace panelled
140140
#endif
141141

142142
/**
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file hal_panelled.h
2+
* @file panelled.h
33
*
44
*/
55
/* Copyright (C) 2023-2026 by Arjan van Vught mailto:info@gd32-dmx.org
@@ -23,16 +23,16 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#ifndef GD32_HAL_PANELLED_H_
27-
#define GD32_HAL_PANELLED_H_
26+
#ifndef PANELLED_H_
27+
#define PANELLED_H_
2828

2929
#include <cstdint>
3030

3131
#if defined(PANELLED_595_COUNT)
3232
#include "gd32.h"
3333
#endif
3434

35-
namespace hal::panelled {
35+
namespace panelled {
3636
namespace global {
3737
extern uint32_t data;
3838
}
@@ -117,6 +117,6 @@ inline void Run() {
117117

118118
#endif
119119
}
120-
} // namespace hal::panelled
120+
} // namespace panelled
121121

122-
#endif // GD32_HAL_PANELLED_H_
122+
#endif // PANELLED_H_

0 commit comments

Comments
 (0)