| 145 | }; |
| 146 | |
| 147 | fl::json measureTightTiming(const fl::string& driver_name, |
| 148 | const fl::ChipsetTimingConfig& timing, |
| 149 | const fl::vector<fl::ChannelConfig>& tx_configs, |
| 150 | int iterations, |
| 151 | uint32_t max_allowed_overhead_us, |
| 152 | bool& out_passed) { |
| 153 | fl::json metric = fl::json::object(); |
| 154 | out_passed = false; |
| 155 | |
| 156 | metric.set("requested", true); |
| 157 | metric.set("supported", false); |
| 158 | metric.set("driver", driver_name.c_str()); |
| 159 | |
| 160 | if (iterations < 1) { |
| 161 | metric.set("message", "iterations must be >= 1"); |
| 162 | return metric; |
| 163 | } |
| 164 | if (tx_configs.empty()) { |
| 165 | metric.set("message", "no channel configs"); |
| 166 | return metric; |
| 167 | } |
| 168 | for (fl::size i = 0; i < tx_configs.size(); i++) { |
| 169 | if (tx_configs[i].isSpi()) { |
| 170 | metric.set("message", "clocked SPI timing metric is not supported"); |
| 171 | return metric; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | fl::vector<fl::ChannelConfig> sample_configs = tx_configs; |
| 176 | fl::vector<fl::shared_ptr<fl::Channel>> channels; |
| 177 | for (fl::size i = 0; i < sample_configs.size(); i++) { |
| 178 | fl::ChannelConfig channel_config( |
| 179 | sample_configs[i].getDataPin(), |
| 180 | timing, |
| 181 | sample_configs[i].mLeds, |
| 182 | sample_configs[i].rgb_order); |
| 183 | fl::shared_ptr<fl::Channel> channel = FastLED.add(channel_config); |
| 184 | if (!channel) { |
| 185 | FastLED.clear(ClearFlags::CHANNELS); |
| 186 | metric.set("message", "failed to create channel"); |
| 187 | return metric; |
| 188 | } |
| 189 | channels.push_back(channel); |
| 190 | } |
| 191 | |
| 192 | ScopedFastLedBrightness scoped_brightness(255); |
| 193 | for (fl::size lane = 0; lane < sample_configs.size(); lane++) { |
| 194 | fill_solid(sample_configs[lane].mLeds.data(), |
| 195 | sample_configs[lane].mLeds.size(), |
| 196 | CRGB::Black); |
| 197 | } |
| 198 | FastLED.show(); |
| 199 | if (!FastLED.wait(1000)) { |
| 200 | FastLED.clear(ClearFlags::CHANNELS); |
| 201 | metric.set("message", "warmup wait timeout"); |
| 202 | return metric; |
| 203 | } |
| 204 | delay(2); |
no test coverage detected