Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 23, 2023
1 parent 1e89856 commit 1500f9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
31 changes: 8 additions & 23 deletions Marlin/src/lcd/e3v2/proui/dwinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,16 @@ uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t colo
// minv : Minimum value
// maxv : Maximum value
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
uint8_t B, G, R;
const uint8_t maxB = 28, maxR = 28, maxG = 38;
const int16_t limv = _MAX(abs(minv), abs(maxv));
float n = (minv >= 0) ? (float)(val - minv) / (maxv - minv) : (float)val / limv;
float n = (minv >= 0) ? float(val - minv) / (maxv - minv) : (float)val / limv;
LIMIT(n, -1, 1);
if (n <= -0.5) {
R = 0;
G = maxG * (1 + n);
B = maxB;
}
else if (n <= 0) {
R = 0;
G = maxG;
B = maxB * (-n) * 2;
}
else if (n < 0.5) {
R = maxR * n * 2;
G = maxG;
B = 0;
}
else {
R = maxR;
G = maxG * (1 - n);
B = 0;
}

constexpr uint8_t maxB = 28, maxR = 28, maxG = 38;
uint8_t R, G, B;
if (n <= -0.5f) { R = 0; G = maxG * (1 + n); B = maxB; }
else if (n <= 0.0f) { R = 0; G = maxG; B = maxB * (-n) * 2; }
else if (n < 0.5f) { R = maxR * n * 2; G = maxG; B = 0; }
else { R = maxR; G = maxG * (1 - n); B = 0; }
return RGB(R, G, B);
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/proui/meshviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ void MeshViewer::drawMeshPoint(const uint8_t x, const uint8_t y, const float z)
switch (v) {
case -999 ... -100:
case 100 ... 999: DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3 * fs, fy, z); break;
case -99 ... -1: sprintf_P(msg, PSTR("-.%02i"), -v); break;
case 1 ... 99: sprintf_P(msg, PSTR( ".%02i"), v); break;
case -99 ... -1: sprintf_P(msg, PSTR("-.%02i"), -v); break;
case 1 ... 99: sprintf_P(msg, PSTR( ".%02i"), v); break;
default:
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 4, fy, "0");
return;
Expand Down

0 comments on commit 1500f9a

Please sign in to comment.