MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/power_mgt.cpp:10–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "hsv2rgb.h"
9
10FL_TEST_FILE(FL_FILEPATH) {
11
12struct ScopedPowerScalingExponent {
13 explicit ScopedPowerScalingExponent(float exponent)
14 : previous_model(get_power_model()) {
15 PowerModelRGB updated_model = previous_model;
16 updated_model.exponent = exponent;
17 set_power_model(updated_model);
18 }
19
20 ~ScopedPowerScalingExponent() {
21 set_power_model(previous_model);
22 }
23
24 PowerModelRGB previous_model;
25};
26
27FL_TEST_CASE("PowerModelRGB - constructor") {
28 PowerModelRGB model(40, 40, 40, 2);
29 FL_CHECK(model.red_mW == 40);
30 FL_CHECK(model.green_mW == 40);
31 FL_CHECK(model.blue_mW == 40);
32 FL_CHECK(model.dark_mW == 2);
33}
34
35FL_TEST_CASE("PowerModelRGB - default constructor") {
36 PowerModelRGB model;
37 FL_CHECK(model.red_mW == 80); // WS2812 @ 5V
38 FL_CHECK(model.green_mW == 55);
39 FL_CHECK(model.blue_mW == 75);
40 FL_CHECK(model.dark_mW == 5);
41}
42
43FL_TEST_CASE("PowerModelRGBW - constructor") {
44 PowerModelRGBW model(90, 70, 90, 100, 5);
45 FL_CHECK(model.red_mW == 90);
46 FL_CHECK(model.green_mW == 70);
47 FL_CHECK(model.blue_mW == 90);
48 FL_CHECK(model.white_mW == 100);
49 FL_CHECK(model.dark_mW == 5);
50}
51
52FL_TEST_CASE("PowerModelRGBWW - constructor") {
53 PowerModelRGBWW model(85, 65, 85, 95, 95, 5);
54 FL_CHECK(model.red_mW == 85);
55 FL_CHECK(model.green_mW == 65);
56 FL_CHECK(model.blue_mW == 85);
57 FL_CHECK(model.white_mW == 95);
58 FL_CHECK(model.warm_white_mW == 95);
59 FL_CHECK(model.dark_mW == 5);
60}
61
62FL_TEST_CASE("PowerModelRGBW - toRGB conversion") {
63 PowerModelRGBW rgbw(90, 70, 90, 100, 5);
64 PowerModelRGB rgb = rgbw.toRGB();
65
66 // Only RGB + dark should be extracted
67 FL_CHECK(rgb.red_mW == 90);

Callers

nothing calls this directly

Calls 9

get_power_modelFunction · 0.85
PowerModelRGBClass · 0.85
PowerModelRGBWClass · 0.85
set_power_modelFunction · 0.50
CRGBClass · 0.50
toRGBMethod · 0.45

Tested by

no test coverage detected