MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / getPercentileColor

Function getPercentileColor

ESP32_AP-Flasher/src/contentmanager.cpp:1611–1646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1609
1610#ifdef CONTENT_DAYAHEAD
1611uint16_t getPercentileColor(const double *prices, int numPrices, double price, HwType hwdata) {
1612 const char *colorsDefault[] = {"black", "darkgray", "pink", "red"};
1613 const double boundariesDefault[] = {40.0, 80.0, 90.0};
1614
1615 const char *colors3bpp[] = {"blue", "green", "yellow", "orange", "red"};
1616 const double boundaries3bpp[] = {20.0, 50.0, 70.0, 90.0};
1617
1618 const char **colors;
1619 const double *boundaries;
1620 int numColors, numBoundaries;
1621
1622 if (hwdata.bpp == 3 || hwdata.bpp == 4) {
1623 colors = colors3bpp;
1624 boundaries = boundaries3bpp;
1625 numColors = sizeof(colors3bpp) / sizeof(colors3bpp[0]);
1626 numBoundaries = sizeof(boundaries3bpp) / sizeof(boundaries3bpp[0]);
1627 } else {
1628 colors = colorsDefault;
1629 boundaries = boundariesDefault;
1630 numColors = sizeof(colorsDefault) / sizeof(colorsDefault[0]);
1631 numBoundaries = sizeof(boundariesDefault) / sizeof(boundariesDefault[0]);
1632 if (hwdata.highlightColor == 3) {
1633 colors[2] = "brown";
1634 colors[3] = "yellow";
1635 }
1636 }
1637 int colorIndex = numColors - 1;
1638
1639 for (int i = 0; i < numBoundaries; i++) {
1640 if (price < prices[int(numPrices * boundaries[i] / 100.0)]) {
1641 colorIndex = i;
1642 break;
1643 }
1644 }
1645 return getColor(String(colors[constrain(colorIndex, 0, numColors - 1)]));
1646}
1647
1648struct YAxisScale {
1649 double min;

Callers 1

getDayAheadFeedFunction · 0.85

Calls 1

getColorFunction · 0.85

Tested by

no test coverage detected