Skip to content

Commit 86a1276

Browse files
committed
Improved color type
1 parent 245ddc3 commit 86a1276

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

OS/Framework/Color/Color.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,32 @@ Color::Color(uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nW) {
3030
W = nW;
3131
}
3232

33-
uint32_t Color::RGB(uint8_t brightness) {
33+
uint32_t Color::RGB(uint8_t brightness) const {
3434
if (brightness != 255)
3535
return (scale8_video(R, brightness) << 16) | (scale8_video(G, brightness) << 8) | scale8_video(B, brightness); // Use scale_video to ensure it doesn't get completely removed
3636
return (R << 16) | (G << 8) | B;
3737
}
3838

39-
uint32_t Color::GRB(uint8_t brightness) {
39+
uint32_t Color::GRB(uint8_t brightness) const {
4040
if (brightness != 255)
4141
return (scale8_video(G, brightness) << 16) | (scale8_video(R, brightness) << 8) | scale8_video(B, brightness); // Use scale_video to ensure it doesn't get completely removed
4242
return (G << 16) | (R << 8) | B;
4343
}
4444

45-
Color Color::Scale(uint8_t brightness) {
45+
Color Color::Scale(uint8_t brightness) const {
4646
return Color(scale8_video(R, brightness), scale8_video(G, brightness), scale8_video(B, brightness)); // Use scale_video to ensure it doesn't get completely removed
4747
}
48-
Color Color::Dim(uint8_t scale) {
48+
Color Color::Dim(uint8_t scale) const {
4949
return Scale(scale);
5050
}
5151

52-
Color Color::DimIfNot(bool not_dim, uint8_t scale) {
52+
Color Color::DimIfNot(bool not_dim, uint8_t scale) const {
5353
if (!not_dim)
5454
{ return Scale(scale); }
5555
return Color(R, G, B, W);
5656
}
5757

58-
Color Color::Gamma() {
58+
Color Color::Gamma() const {
5959
return Color(led_gamma[R], led_gamma[G], led_gamma[B]);
6060
}
6161

OS/Framework/Color/Color.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@ class Color {
1616
Color(uint32_t WRGB);
1717
Color(uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nW = 0);
1818

19-
virtual void Update(){};
20-
21-
uint32_t RGB(uint8_t brightness = 255);
22-
uint32_t GRB(uint8_t brightness = 255);
23-
Color Scale(uint8_t scale);
24-
Color Dim(uint8_t scale = COLOR_LOW_STATE_SCALE);
25-
Color DimIfNot(bool not_dim = false, uint8_t scale = COLOR_LOW_STATE_SCALE); // Helper for UI, make ui variable
26-
// as parameter so the output
27-
// dynamically change based on the
28-
// variable
29-
30-
Color Gamma();
19+
uint32_t RGB(uint8_t brightness = 255) const;
20+
uint32_t GRB(uint8_t brightness = 255) const;
21+
Color Scale(uint8_t scale) const;
22+
Color Dim(uint8_t scale = COLOR_LOW_STATE_SCALE) const;
23+
Color DimIfNot(bool not_dim = false, uint8_t scale = COLOR_LOW_STATE_SCALE) const; // Helper for UI, make ui variable
24+
// as parameter so the output // dynamically change based on the // variable
25+
Color Gamma() const;
3126

3227
static uint8_t scale8(uint8_t i, uint8_t scale);
3328

0 commit comments

Comments
 (0)