Skip to content

Commit 1b1c499

Browse files
committed
lib-showfile: style and API cleanups
Apply widespread formatting and API refinements across lib-showfile: adjust brace/whitespace style and header guard comments; bump copyright years to 2026 (one file shows 2065 as in diff); normalize namespaces and inline/static declarations. Make small API/identifier changes: rename record handlers to Record, rename function parameters for clarity (e.g. ArtNetTrigger handler), replace hal_uuid usage with uuid/UuidCopy, switch network includes to network_udp, and convert several constant arrays to constexpr. Simplify one-line static callbacks and other small function-body adjustments. These changes are non-functional refactors and header/source tidy-ups to improve consistency and modernize usage.
1 parent e7ba68b commit 1b1c499

15 files changed

Lines changed: 182 additions & 289 deletions

lib-showfile/include/protocols/showfileprotocolartnet.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,33 @@
3131
#include "artnetcontroller.h"
3232
#include "firmware/debug/debug_debug.h"
3333

34-
class ShowFileProtocol
35-
{
34+
class ShowFileProtocol {
3635
public:
37-
ShowFileProtocol()
38-
{
36+
ShowFileProtocol() {
3937
DEBUG_ENTRY();
4038

4139
DEBUG_EXIT();
4240
}
4341

4442
~ShowFileProtocol() { controller_.Stop(); }
4543

46-
void Start()
47-
{
44+
void Start() {
4845
DEBUG_ENTRY();
4946

5047
controller_.Start();
5148

5249
DEBUG_EXIT();
5350
}
5451

55-
void Stop()
56-
{
52+
void Stop() {
5753
DEBUG_ENTRY();
5854

5955
controller_.Stop();
6056

6157
DEBUG_EXIT();
6258
}
6359

64-
void Record()
65-
{
60+
void Record() {
6661
DEBUG_ENTRY();
6762

6863
DEBUG_EXIT();
@@ -74,8 +69,7 @@ class ShowFileProtocol
7469

7570
void DmxBlackout() { controller_.HandleBlackout(); }
7671

77-
void DmxMaster([[maybe_unused]] uint32_t master)
78-
{
72+
void DmxMaster([[maybe_unused]] uint32_t master) {
7973
#if defined(CONFIG_ARTNET_CONTROLLER_ENABLE_MASTER)
8074
controller_.SetMaster(master);
8175
#endif
@@ -93,4 +87,4 @@ class ShowFileProtocol
9387
ArtNetController controller_;
9488
};
9589

96-
#endif /* PROTOCOLS_SHOWFILEPROTOCOLARTNET_H_ */
90+
#endif // PROTOCOLS_SHOWFILEPROTOCOLARTNET_H_

lib-showfile/include/protocols/showfileprotocolartnettrigger.h

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file showfileprotocolartnettrigger.h
33
*
44
*/
5-
/* Copyright (C) 2024 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2024-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
@@ -26,60 +26,56 @@
2626
#ifndef PROTOCOLS_SHOWFILEPROTOCOLARTNETTRIGGER_H_
2727
#define PROTOCOLS_SHOWFILEPROTOCOLARTNETTRIGGER_H_
2828

29-
#include <cstdint>
30-
#include <cstdio>
31-
3229
#include "artnetcontroller.h"
3330
#include "artnettrigger.h"
34-
35-
#include "firmware/debug/debug_debug.h"
31+
#include "firmware/debug/debug_debug.h"
3632

3733
class ShowFileProtocolArtNetTrigger {
38-
public:
39-
ShowFileProtocolArtNetTrigger() {
40-
DEBUG_ENTRY();
41-
42-
assert(s_this == nullptr);
43-
s_this = this;
44-
45-
ArtNetController::Get()->SetArtTriggerCallbackFunctionPtr(StaticCallbackFunction);
46-
47-
DEBUG_EXIT();
48-
}
49-
50-
private:
51-
void Handler(const struct ArtNetTrigger *pArtNetTrigger) {
52-
DEBUG_ENTRY();
53-
DEBUG_PRINTF("Key=%d, SubKey=%d", pArtNetTrigger->key, pArtNetTrigger->sub_key);
54-
55-
if (pArtNetTrigger->key == ArtTriggerKey::ART_TRIGGER_KEY_SOFT) {
56-
switch (pArtNetTrigger->sub_key) {
57-
case 'B':
58-
ShowFile::Get()->BlackOut();
59-
break;
60-
case 'G':
61-
ShowFile::Get()->Play();
62-
break;
63-
case 'R':
64-
ShowFile::Get()->Resume();
65-
break;
66-
case 'S':
67-
ShowFile::Get()->Stop();
68-
break;
69-
default:
70-
break;
71-
}
72-
}
73-
74-
if (pArtNetTrigger->key == ArtTriggerKey::kArtTriggerKeyShow) {
75-
ShowFile::Get()->SetPlayerShowFileCurrent(pArtNetTrigger->sub_key);
76-
}
77-
78-
DEBUG_EXIT();
79-
}
80-
81-
private:
82-
static inline ShowFileProtocolArtNetTrigger *s_this;
34+
public:
35+
ShowFileProtocolArtNetTrigger() {
36+
DEBUG_ENTRY();
37+
38+
assert(s_this == nullptr);
39+
s_this = this;
40+
41+
ArtNetController::Get()->SetArtTriggerCallbackFunctionPtr(StaticCallbackFunction);
42+
43+
DEBUG_EXIT();
44+
}
45+
46+
private:
47+
void Handler(const struct ArtNetTrigger* trigger) {
48+
DEBUG_ENTRY();
49+
DEBUG_PRINTF("Key=%d, SubKey=%d", trigger->key, trigger->sub_key);
50+
51+
if (trigger->key == ArtTriggerKey::ART_TRIGGER_KEY_SOFT) {
52+
switch (trigger->sub_key) {
53+
case 'B':
54+
ShowFile::Get()->BlackOut();
55+
break;
56+
case 'G':
57+
ShowFile::Get()->Play();
58+
break;
59+
case 'R':
60+
ShowFile::Get()->Resume();
61+
break;
62+
case 'S':
63+
ShowFile::Get()->Stop();
64+
break;
65+
default:
66+
break;
67+
}
68+
}
69+
70+
if (trigger->key == ArtTriggerKey::kArtTriggerKeyShow) {
71+
ShowFile::Get()->SetPlayerShowFileCurrent(trigger->sub_key);
72+
}
73+
74+
DEBUG_EXIT();
75+
}
76+
77+
private:
78+
static inline ShowFileProtocolArtNetTrigger* s_this;
8379
};
8480

85-
#endif /* PROTOCOLS_SHOWFILEPROTOCOLARTNETTRIGGER_H_ */
81+
#endif // PROTOCOLS_SHOWFILEPROTOCOLARTNETTRIGGER_H_

lib-showfile/include/protocols/showfileprotocole131.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file showfileprotocole131.h
33
*
44
*/
5-
/* Copyright (C) 2020-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2020-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
@@ -29,40 +29,35 @@
2929
#include <cstdint>
3030

3131
#include "e131controller.h"
32-
#include "firmware/debug/debug_debug.h"
32+
#include "firmware/debug/debug_debug.h"
3333

34-
class ShowFileProtocol
35-
{
34+
class ShowFileProtocol {
3635
public:
37-
ShowFileProtocol()
38-
{
36+
ShowFileProtocol() {
3937
DEBUG_ENTRY();
4038

4139
DEBUG_EXIT();
4240
}
4341

4442
void SetSynchronizationAddress(uint16_t synchronization_address) { e131_controller_.SetSynchronizationAddress(synchronization_address); }
4543

46-
void Start()
47-
{
44+
void Start() {
4845
DEBUG_ENTRY();
4946

5047
e131_controller_.Start();
5148

5249
DEBUG_EXIT();
5350
}
5451

55-
void Stop()
56-
{
52+
void Stop() {
5753
DEBUG_ENTRY();
5854

5955
e131_controller_.Stop();
6056

6157
DEBUG_EXIT();
6258
}
6359

64-
void Record()
65-
{
60+
void Record() {
6661
DEBUG_ENTRY();
6762

6863
DEBUG_EXIT();
@@ -75,8 +70,7 @@ class ShowFileProtocol
7570

7671
void DoRunCleanupProcess([[maybe_unused]] bool do_run) {}
7772

78-
void Run()
79-
{
73+
void Run() {
8074
// Nothing todo here
8175
}
8276

@@ -88,4 +82,4 @@ class ShowFileProtocol
8882
E131Controller e131_controller_;
8983
};
9084

91-
#endif // PROTOCOLS_SHOWFILEPROTOCOLE131_H_
85+
#endif // PROTOCOLS_SHOWFILEPROTOCOLE131_H_

lib-showfile/include/protocols/showfileprotocolnodeartnet.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
#include "artnet.h"
3434
#include "firmware/debug/debug_debug.h"
3535

36-
class ShowFileProtocol
37-
{
36+
class ShowFileProtocol {
3837
public:
39-
ShowFileProtocol()
40-
{
38+
ShowFileProtocol() {
4139
DEBUG_ENTRY();
4240

4341
memcpy(dmx_.id, artnet::kNodeId, sizeof(dmx_.id));
@@ -50,37 +48,32 @@ class ShowFileProtocol
5048

5149
void SetSynchronizationAddress([[maybe_unused]] uint16_t synchronization_address) {}
5250

53-
void Start()
54-
{
51+
void Start() {
5552
DEBUG_ENTRY();
5653

5754
DEBUG_EXIT();
5855
}
5956

60-
void Stop()
61-
{
57+
void Stop() {
6258
DEBUG_ENTRY();
6359

6460
ArtNetNode::Get()->SetRecordShowfile(false);
6561

6662
DEBUG_EXIT();
6763
}
6864

69-
void Record()
70-
{
65+
void Record() {
7166
DEBUG_ENTRY();
7267

7368
ArtNetNode::Get()->SetRecordShowfile(true);
7469

7570
DEBUG_EXIT();
7671
}
7772

78-
void DmxOut(uint16_t universe, const uint8_t* data, uint32_t length)
79-
{
73+
void DmxOut(uint16_t universe, const uint8_t* data, uint32_t length) {
8074
memcpy(dmx_.data, data, length);
8175

82-
if ((length & 0x1) == 0x1)
83-
{
76+
if ((length & 0x1) == 0x1) {
8477
dmx_.data[length] = 0x00;
8578
length++;
8679
}
@@ -113,4 +106,4 @@ class ShowFileProtocol
113106
uint8_t sequence_{0};
114107
};
115108

116-
#endif /* PROTOCOLS_SHOWFILEPROTOCOLNODEARTNET_H_ */
109+
#endif // PROTOCOLS_SHOWFILEPROTOCOLNODEARTNET_H_

lib-showfile/include/protocols/showfileprotocolnodee131.h

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file showfileprotocolnodee131.h
33
*
44
*/
5-
/* Copyright (C) 2024-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2024-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
@@ -32,23 +32,19 @@
3232
#include "e131bridge.h"
3333
#include "e131.h"
3434
#include "e117.h"
35+
#include "uuid.h"
36+
#include "firmware/debug/debug_debug.h"
3537

36-
#include "hal_uuid.h"
37-
38-
#include "firmware/debug/debug_debug.h"
39-
40-
class ShowFileProtocol
41-
{
38+
class ShowFileProtocol {
4239
public:
43-
ShowFileProtocol()
44-
{
40+
ShowFileProtocol() {
4541
DEBUG_ENTRY();
4642
// Root Layer (See Section 5)
4743
e131_data_packet_.root_layer.pre_amble_size = __builtin_bswap16(0x0010);
4844
e131_data_packet_.root_layer.post_amble_size = __builtin_bswap16(0x0000);
4945
memcpy(e131_data_packet_.root_layer.acn_packet_identifier, e117::kAcnPacketIdentifier, e117::kAcnPacketIdentifierLength);
5046
e131_data_packet_.root_layer.vector = __builtin_bswap32(e131::vector::root::kData);
51-
hal::UuidCopy(e131_data_packet_.root_layer.cid);
47+
UuidCopy(e131_data_packet_.root_layer.cid);
5248
// E1.31 Framing Layer (See Section 6)
5349
e131_data_packet_.frame_layer.vector = __builtin_bswap32(e131::vector::data::kPacket);
5450
memcpy(e131_data_packet_.frame_layer.source_name, E131Bridge::Get()->GetSourceName(), e131::kSourceNameLength);
@@ -67,29 +63,25 @@ class ShowFileProtocol
6763

6864
void SetSynchronizationAddress([[maybe_unused]] uint16_t synchronization_address) {}
6965

70-
void Start()
71-
{
66+
void Start() {
7267
DEBUG_ENTRY();
7368

7469
DEBUG_EXIT();
7570
}
7671

77-
void Stop()
78-
{
72+
void Stop() {
7973
DEBUG_ENTRY();
8074

8175
DEBUG_EXIT();
8276
}
8377

84-
void Record()
85-
{
78+
void Record() {
8679
DEBUG_ENTRY();
8780

8881
DEBUG_EXIT();
8982
}
9083

91-
void DmxOut(uint16_t universe, const uint8_t* dmx_data, uint32_t length)
92-
{
84+
void DmxOut(uint16_t universe, const uint8_t* dmx_data, uint32_t length) {
9385
length++; // Add 1 for SC
9486
// Root Layer (See Section 5)
9587
e131_data_packet_.root_layer.flags_length = __builtin_bswap16(static_cast<uint16_t>((0x07 << 12) | (e131::DataRootLayerLength(length))));
@@ -124,4 +116,4 @@ class ShowFileProtocol
124116
uint8_t sequence_number_{0};
125117
};
126118

127-
#endif // PROTOCOLS_SHOWFILEPROTOCOLNODEE131_H_
119+
#endif // PROTOCOLS_SHOWFILEPROTOCOLNODEE131_H_

0 commit comments

Comments
 (0)