4141#include " pixelconfiguration.h"
4242#include " pixeltype.h"
4343
44- namespace pixeldmxconfiguration
45- {
46- struct PortInfo
47- {
44+ namespace pixeldmxconfiguration {
45+ struct PortInfo {
4846 uint16_t begin_index_port[4 ];
4947 uint16_t protocol_port_index_last;
5048};
5149} // namespace pixeldmxconfiguration
5250
5351class PixelDmxConfiguration : public PixelConfiguration {
5452 public:
55- PixelDmxConfiguration ()
56- {
53+ PixelDmxConfiguration () {
5754 DEBUG_ENTRY ();
5855
5956 assert (s_this == nullptr );
@@ -79,10 +76,8 @@ class PixelDmxConfiguration : public PixelConfiguration {
7976
8077 pixeldmxconfiguration::PortInfo& GetPortInfo () { return port_info_; }
8178
82- void SetDmxStartAddress (uint16_t dmx_start_address)
83- {
84- if ((dmx_start_address > 0 ) && (dmx_start_address <= dmxnode::kUniverseSize ))
85- {
79+ void SetDmxStartAddress (uint16_t dmx_start_address) {
80+ if ((dmx_start_address > 0 ) && (dmx_start_address <= dmxnode::kUniverseSize )) {
8681 dmx_start_address_ = dmx_start_address;
8782 return ;
8883 }
@@ -92,17 +87,13 @@ class PixelDmxConfiguration : public PixelConfiguration {
9287
9388 uint16_t GetDmxFootprint () const { return dmx_footprint_; }
9489
95- void Validate (uint32_t ports_max)
96- {
90+ void Validate (uint32_t ports_max) {
9791 DEBUG_ENTRY ();
9892
9993 PixelConfiguration::Validate ();
10094
101- if (!PixelConfiguration::IsRTZProtocol ())
102- {
103- if (!((PixelConfiguration::GetType () == pixel::LedType::kWS2801 ) || (PixelConfiguration::GetType () == pixel::LedType::kAPA102 ) ||
104- (PixelConfiguration::GetType () == pixel::LedType::kSK9822 )))
105- {
95+ if (!PixelConfiguration::IsRTZProtocol ()) {
96+ if ((PixelConfiguration::GetType () != pixel::LedType::kWS2801 ) && (PixelConfiguration::GetType () != pixel::LedType::kAPA102 ) && (PixelConfiguration::GetType () != pixel::LedType::kSK9822 )) {
10697 PixelConfiguration::SetType (pixel::LedType::kWS2801 );
10798 }
10899
@@ -111,36 +102,32 @@ class PixelDmxConfiguration : public PixelConfiguration {
111102
112103 port_info_.begin_index_port [0 ] = 0 ;
113104
114- if (PixelConfiguration::GetType () == pixel::LedType::kSK6812W )
115- {
105+ if (PixelConfiguration::GetType () == pixel::LedType::kSK6812W ) {
116106 port_info_.begin_index_port [1 ] = 128 ;
117107 port_info_.begin_index_port [2 ] = 256 ;
118108 port_info_.begin_index_port [3 ] = 384 ;
119- }
120- else
121- {
109+ } else {
122110 port_info_.begin_index_port [1 ] = 170 ;
123111 port_info_.begin_index_port [2 ] = 340 ;
124112 port_info_.begin_index_port [3 ] = 510 ;
125113 }
126114
127- if ((grouping_count_ == 0 ) || (grouping_count_ > PixelConfiguration::GetCount ()))
128- {
115+ if ((grouping_count_ == 0 ) || (grouping_count_ > PixelConfiguration::GetCount ())) {
129116 grouping_count_ = PixelConfiguration::GetCount ();
130117 }
131118
132119 groups_ = PixelConfiguration::GetCount () / grouping_count_;
133120 output_ports_ = std::min (ports_max, output_ports_);
134121 universes_ = (1U + (groups_ / (1U + port_info_.begin_index_port [1 ])));
135122 dmx_footprint_ = static_cast <uint16_t >(PixelConfiguration::GetLedsPerPixel () * groups_);
136- if (dmx_start_address_ == 0 ) dmx_start_address_ = dmxnode::kStartAddressDefault ;
123+
124+ if (dmx_start_address_ == 0 ) {
125+ dmx_start_address_ = dmxnode::kStartAddressDefault ;
126+ }
137127
138- if (ports_max == 1 )
139- {
128+ if (ports_max == 1 ) {
140129 port_info_.protocol_port_index_last = static_cast <uint16_t >(groups_ / (1U + port_info_.begin_index_port [1 ]));
141- }
142- else
143- {
130+ } else {
144131#if defined(NODE_DDP_DISPLAY)
145132 port_info_.protocol_port_index_last = static_cast <uint16_t >(((output_ports_ - 1U ) * 4U ) + universes_ - 1U );
146133#else
@@ -151,23 +138,26 @@ class PixelDmxConfiguration : public PixelConfiguration {
151138 DEBUG_EXIT ();
152139 }
153140
154- void Print ()
155- {
141+ void Print () {
156142 PixelConfiguration::Print ();
157143 puts (" Pixel DMX configuration" );
158- printf (" Outputs : %u\n " , output_ports_);
159- printf (" Grouping count : %u [Groups : %u]\n " , grouping_count_, groups_);
160- printf (" Universes : %u\n " , universes_);
161- printf (" DmxFootprint : %u\n " , dmx_footprint_);
144+ printf (" Outputs : %u\n " , static_cast < unsigned >( output_ports_) );
145+ printf (" Grouping count : %u [Groups : %u]\n " , static_cast < unsigned >( grouping_count_), static_cast < unsigned >( groups_) );
146+ printf (" Universes : %u\n " , static_cast < unsigned >( universes_) );
147+ printf (" DmxFootprint : %u\n " , static_cast < unsigned >( dmx_footprint_) );
162148
163149#ifndef NDEBUG
164150 const auto & begin_index_port = port_info_.begin_index_port ;
165- printf (" %u:%u:%u:%u -> %u\n " , begin_index_port[0 ], begin_index_port[1 ], begin_index_port[2 ], begin_index_port[3 ], port_info_.protocol_port_index_last );
151+ printf (" %u:%u:%u:%u -> %u\n " ,
152+ static_cast <unsigned >(begin_index_port[0 ]),
153+ static_cast <unsigned >(begin_index_port[1 ]),
154+ static_cast <unsigned >(begin_index_port[2 ]),
155+ static_cast <unsigned >(begin_index_port[3 ]),
156+ static_cast <unsigned >(port_info_.protocol_port_index_last ));
166157#endif
167158 }
168159
169- static PixelDmxConfiguration& Get ()
170- {
160+ static PixelDmxConfiguration& Get () {
171161 assert (s_this != nullptr );
172162 return *s_this;
173163 }
@@ -184,4 +174,4 @@ class PixelDmxConfiguration : public PixelConfiguration {
184174 static inline PixelDmxConfiguration* s_this;
185175};
186176
187- #endif // PIXELDMXCONFIGURATION_H_
177+ #endif // PIXELDMXCONFIGURATION_H_
0 commit comments