| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 3 | * 2013-2022 by the Falcon Player Developers. | ||
| 4 | * | ||
| 5 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 6 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 7 | * file for descriptions of what files are covered by each license. | ||
| 8 | * | ||
| 9 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 10 | * included LICENSE.LGPL file. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "fpp-pch.h" | ||
| 14 | |||
| 15 | #include "fpp-json.h" | ||
| 16 | |||
| 17 | #include "../log.h" | ||
| 18 | |||
| 19 | #include "RGBCycle.h" | ||
| 20 | |||
| 21 | /* | ||
| 22 | * | ||
| 23 | */ | ||
| 24 | 67 | TestPatternRGBCycle::TestPatternRGBCycle() : | |
| 25 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67 | m_colorPatternStr(""), |
| 26 | 67 | m_colorPatternSize(0), | |
| 27 | 67 | m_patternOffset(0), | |
| 28 | 134 | m_channelsPerNode(3) { | |
| 29 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67 | LogExcess(VB_CHANNELOUT, "TestPatternRGBCycle::TestPatternRGBCycle()\n"); |
| 30 | |||
| 31 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67 | m_testPatternName = "RGBCycle"; |
| 32 | 67 | } | |
| 33 | |||
| 34 | /* | ||
| 35 | * | ||
| 36 | */ | ||
| 37 | 132 | TestPatternRGBCycle::~TestPatternRGBCycle() { | |
| 38 | 66 | LogExcess(VB_CHANNELOUT, "TestPatternRGBCycle::~TestPatternRGBCycle()\n"); | |
| 39 | 132 | } | |
| 40 | |||
| 41 | /* | ||
| 42 | * | ||
| 43 | */ | ||
| 44 | 67 | int TestPatternRGBCycle::Init(Json::Value config) { | |
| 45 | 67 | m_configChanged = 0; | |
| 46 | |||
| 47 |
3/6✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
|
201 | std::string colorPattern = JsonString(config, "colorPattern"); |
| 48 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67 | if (m_colorPatternStr != colorPattern) { |
| 49 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67 | m_colorPatternStr = colorPattern; |
| 50 | 67 | m_configChanged = 1; | |
| 51 | } | ||
| 52 | |||
| 53 |
2/4✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
|
67 | int cpn = JsonInt(config, "channelsPerNode", 3); |
| 54 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
67 | if (cpn != 3 && cpn != 4) { |
| 55 | ✗ | cpn = 3; | |
| 56 | } | ||
| 57 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
|
67 | if (m_channelsPerNode != cpn) { |
| 58 | 1 | m_channelsPerNode = cpn; | |
| 59 | 1 | m_configChanged = 1; | |
| 60 | } | ||
| 61 | |||
| 62 |
2/4✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
|
134 | return TestPatternBase::Init(config); |
| 63 | 67 | } | |
| 64 | |||
| 65 | /* | ||
| 66 | * | ||
| 67 | */ | ||
| 68 | 72 | int TestPatternRGBCycle::SetupTest(void) { | |
| 69 | 72 | bzero(m_testData, m_channelCount); | |
| 70 | |||
| 71 | 72 | m_colorPattern.clear(); | |
| 72 | |||
| 73 | 72 | char digit = 0; | |
| 74 |
2/2✓ Branch 0 taken 655 times.
✓ Branch 1 taken 72 times.
|
727 | for (int i = 0; i < m_colorPatternStr.size(); i += 2) { |
| 75 |
1/2✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
|
655 | digit = (char)strtol(m_colorPatternStr.substr(i, 2).c_str(), NULL, 16); |
| 76 |
1/2✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
|
655 | m_colorPattern.push_back(digit); |
| 77 | } | ||
| 78 | |||
| 79 | // Make sure we have a valid set of color groups (3 channels for RGB, 4 for RGBW) | ||
| 80 | 72 | const int stride = m_channelsPerNode; | |
| 81 |
3/6✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
|
72 | while (m_colorPattern.size() < stride || m_colorPattern.size() % stride) { |
| 82 | ✗ | m_colorPattern.push_back(0); | |
| 83 | } | ||
| 84 | |||
| 85 | // A trailing partial pixel (a channel count that is not a multiple of the | ||
| 86 | // stride, as an arbitrary set of discrete channels gives) gets the leading | ||
| 87 | // channels of the color rather than being skipped and left dark. | ||
| 88 | 72 | char* c = m_testData; | |
| 89 |
2/2✓ Branch 0 taken 565307 times.
✓ Branch 1 taken 72 times.
|
565379 | for (int i = 0; i < m_channelCount; i++) { |
| 90 | 565307 | *(c++) = m_colorPattern[i % stride]; | |
| 91 | } | ||
| 92 | |||
| 93 | 72 | m_patternOffset = 0; | |
| 94 | 72 | m_colorPatternSize = m_colorPattern.size() / stride; | |
| 95 | |||
| 96 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
144 | return TestPatternBase::SetupTest(); |
| 97 | } | ||
| 98 | |||
| 99 | /* | ||
| 100 | * | ||
| 101 | */ | ||
| 102 | 5360 | void TestPatternRGBCycle::CycleData(void) { | |
| 103 | 5360 | const int stride = m_channelsPerNode; | |
| 104 | 5360 | m_patternOffset += stride; | |
| 105 |
2/2✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 3591 times.
|
5360 | if (m_patternOffset >= m_colorPattern.size()) { |
| 106 | 1769 | m_patternOffset = 0; | |
| 107 | } | ||
| 108 | // Same trailing-partial-pixel handling as SetupTest(): unlike the chase, | ||
| 109 | // which shifts the whole buffer with memmove(), every cycle here rewrites | ||
| 110 | // the data from scratch, so skipping the tail left it dark permanently. | ||
| 111 | 5360 | char* c = m_testData; | |
| 112 |
2/2✓ Branch 0 taken 164554052 times.
✓ Branch 1 taken 5360 times.
|
164559412 | for (int i = 0; i < m_channelCount; i++) { |
| 113 | 164554052 | *(c++) = m_colorPattern[m_patternOffset + (i % stride)]; | |
| 114 | } | ||
| 115 | 5360 | } | |
| 116 | |||
| 117 | /* | ||
| 118 | * | ||
| 119 | */ | ||
| 120 | 67 | void TestPatternRGBCycle::DumpConfig(void) { | |
| 121 | 67 | LogDebug(VB_CHANNELOUT, "TestPatternRGBCycle::DumpConfig\n"); | |
| 122 | 67 | LogDebug(VB_CHANNELOUT, " colorPattern : %s\n", m_colorPatternStr.c_str()); | |
| 123 | 67 | LogDebug(VB_CHANNELOUT, " colorPatternSize: %d\n", m_colorPatternSize); | |
| 124 | |||
| 125 | 67 | TestPatternBase::DumpConfig(); | |
| 126 | 67 | } | |
| 127 |