Skip to content

Commit 872f087

Browse files
committed
fix(testing): don't skip the trailing partial pixel in test patterns
1 parent d990791 commit 872f087

4 files changed

Lines changed: 36 additions & 33 deletions

File tree

src/channeltester/RGBChase.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ int TestPatternRGBChase::SetupTest(void) {
9090
bzero(m_testData, m_channelCount);
9191
}
9292

93+
// A trailing partial pixel (a channel count that is not a multiple of the
94+
// stride, as an arbitrary set of discrete channels gives) is filled with as
95+
// much of its color as fits instead of being skipped and left dark. The
96+
// pattern offset still advances by a whole stride so the wrap point is
97+
// unchanged for the whole-pixel case.
9398
char* c = m_testData;
9499
int offset = 0;
95-
for (int i = 0; i + stride <= m_channelCount; i += stride) {
96-
for (int j = 0; j < stride; j++)
97-
*(c++) = m_colorPattern[offset++];
100+
for (int i = 0; i < m_channelCount; i += stride) {
101+
int count = std::min(stride, m_channelCount - i);
102+
for (int j = 0; j < count; j++)
103+
*(c++) = m_colorPattern[offset + j];
98104

105+
offset += stride;
99106
if (offset >= m_colorPattern.size())
100107
offset = 0;
101108
}

src/channeltester/RGBCycle.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ int TestPatternRGBCycle::SetupTest(void) {
8181
m_colorPattern.push_back(0);
8282
}
8383

84+
// A trailing partial pixel (a channel count that is not a multiple of the
85+
// stride, as an arbitrary set of discrete channels gives) gets the leading
86+
// channels of the color rather than being skipped and left dark.
8487
char* c = m_testData;
85-
for (int i = 0; i + stride <= m_channelCount; i += stride) {
86-
for (int j = 0; j < stride; j++)
87-
*(c++) = m_colorPattern[j];
88+
for (int i = 0; i < m_channelCount; i++) {
89+
*(c++) = m_colorPattern[i % stride];
8890
}
8991

9092
m_patternOffset = 0;
@@ -102,10 +104,12 @@ void TestPatternRGBCycle::CycleData(void) {
102104
if (m_patternOffset >= m_colorPattern.size()) {
103105
m_patternOffset = 0;
104106
}
107+
// Same trailing-partial-pixel handling as SetupTest(): unlike the chase,
108+
// which shifts the whole buffer with memmove(), every cycle here rewrites
109+
// the data from scratch, so skipping the tail left it dark permanently.
105110
char* c = m_testData;
106-
for (int i = 0; i + stride <= m_channelCount; i += stride) {
107-
for (int j = 0; j < stride; j++)
108-
*(c++) = m_colorPattern[m_patternOffset + j];
111+
for (int i = 0; i < m_channelCount; i++) {
112+
*(c++) = m_colorPattern[m_patternOffset + (i % stride)];
109113
}
110114
}
111115

src/channeltester/RGBFill.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,17 @@ int TestPatternRGBFill::SetupTest(void) {
8888
// Stride is driven by the model/color order (3 for RGB, 4 for RGBW), not by
8989
// whether the white value happens to be non-zero, so RGBW pixels stay aligned
9090
// even when filling a pure color (W = 0).
91-
if (m_channelsPerNode == 4) {
92-
for (int i = 0; i + 4 <= m_channelCount; i += 4) {
93-
*(c++) = m_color1;
94-
*(c++) = m_color2;
95-
*(c++) = m_color3;
96-
*(c++) = m_color4;
97-
}
98-
} else {
99-
for (int i = 0; i + 3 <= m_channelCount; i += 3) {
100-
*(c++) = m_color1;
101-
*(c++) = m_color2;
102-
*(c++) = m_color3;
103-
}
91+
//
92+
// The channel set need not be a whole number of pixels - eight discrete
93+
// channels ("151;167;...;263") tested as RGB is a channelCount of 8 with a
94+
// stride of 3 - so the trailing partial pixel is filled too rather than
95+
// left at the bzero() value, which used to leave those channels dark for
96+
// the whole test.
97+
const char colors[4] = { (char)m_color1, (char)m_color2, (char)m_color3, (char)m_color4 };
98+
const int stride = m_channelsPerNode;
99+
100+
for (int i = 0; i < m_channelCount; i++) {
101+
*(c++) = colors[i % stride];
104102
}
105103

106104
return TestPatternBase::SetupTest();

www/testing.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,18 +1121,12 @@ function SetDMXTestMode() {
11211121
for (var i = 0; i < count; i++) {
11221122
pattern += dmxToHex(dmxValues[i]);
11231123
}
1124-
// Pad to a multiple of 6 hex chars (RGB triplet) so the pattern parser
1125-
// doesn't append zeros that would alter our channel count.
1126-
while ((pattern.length % 6) !== 0) {
1127-
pattern += '00';
1128-
}
1129-
1124+
// Neither the pattern nor the range is padded out to a whole RGB
1125+
// triplet: fppd fills a trailing partial pixel, so the fixture's
1126+
// channels are driven exactly as selected. Rounding the range up (as
1127+
// this did while the test patterns skipped that partial pixel) drove
1128+
// up to two channels past the end of the fixture.
11301129
var endCh = startCh + count - 1;
1131-
// Ensure channel range is a multiple of 3 to align with the pattern's
1132-
// triplet-based padding above.
1133-
while (((endCh - startCh + 1) % 3) !== 0) {
1134-
endCh++;
1135-
}
11361130

11371131
data = {
11381132
"command": "Test Start",

0 commit comments

Comments
 (0)