Skip to content

Commit 25e5c64

Browse files
committed
We can only turn the backlight on or off, there's no RGB background LED for our display.
1 parent f3890f8 commit 25e5c64

File tree

3 files changed

+22
-78
lines changed

3 files changed

+22
-78
lines changed

src/Braccio++.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool BraccioClass::begin(voidFuncPtr custom_menu)
7373
if (_bl.getChipID() != 0xCE) {
7474
return false;
7575
}
76-
_bl.setColor(red);
76+
_bl.on();
7777

7878
int ret = _expander.testConnection();
7979

src/lib/display/Backlight.cpp

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,75 +35,26 @@ void Backlight::end()
3535
powerDown();
3636
}
3737

38-
void Backlight::setColor(RGBColors color)
38+
void Backlight::on()
3939
{
40-
if(color == off) {
41-
_blue = 0x00;
42-
_green = 0x00;
43-
_red = 0x00;
44-
}
45-
46-
if(color == green) {
47-
_blue = 0x00;
48-
_green = 0xFF;
49-
_red = 0x00;
50-
}
51-
52-
if(color == blue) {
53-
_blue = 0xFF;
54-
_green = 0x00;
55-
_red = 0x00;
56-
}
57-
58-
if(color == red) {
59-
_blue = 0x00;
60-
_green = 0x00;
61-
_red = 0xFF;
62-
}
63-
64-
if(color == cyan) {
65-
_blue = 0x20;
66-
_green = 0x20;
67-
_red = 0x00;
68-
}
69-
70-
if(color == magenta) {
71-
_blue = 0x20;
72-
_green = 0x00;
73-
_red = 0x20;
74-
}
75-
76-
if(color == yellow) {
77-
_blue = 0x00;
78-
_green = 0x20;
79-
_red = 0x20;
80-
}
81-
82-
setColor(_blue, _green, _red);
83-
40+
setColor(0xFF, 0xFF, 0xFF);
8441
}
8542

86-
void Backlight::setColor(uint8_t blue, uint8_t green, uint8_t red)
43+
void Backlight::off()
8744
{
88-
// set rgb led current
89-
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT1, blue); //maximum current
90-
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT2, green);
91-
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT3, red);
92-
writeByte(IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5); // write to color update register for changes to take effect
93-
45+
setColor(0, 0, 0);
9446
}
9547

96-
/**************************************************************************************
97-
* PRIVATE MEMBER FUNCTIONS
98-
**************************************************************************************/
99-
10048
// Read the Chip ID register, this is a good test of communication
10149
uint8_t Backlight::getChipID()
10250
{
10351
uint8_t c = readByte(IS31FL3194_ADDRESS, IS31FL3194_PRODUCT_ID); // Read PRODUCT_ID register for IS31FL3194
10452
return c;
10553
}
10654

55+
/**************************************************************************************
56+
* PRIVATE MEMBER FUNCTIONS
57+
**************************************************************************************/
10758

10859
void Backlight::reset()
10960
{
@@ -134,6 +85,15 @@ void Backlight::init()// configure rgb led function
13485
writeByte(IS31FL3194_ADDRESS, 0x32, 0xFF); // Max power on led R (OUT 3)
13586
}
13687

88+
void Backlight::setColor(uint8_t blue, uint8_t green, uint8_t red)
89+
{
90+
// set rgb led current
91+
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT1, blue); //maximum current
92+
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT2, green);
93+
writeByte(IS31FL3194_ADDRESS, IS31FL3194_OUT3, red);
94+
writeByte(IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5); // write to color update register for changes to take effect
95+
}
96+
13797
void Backlight::writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
13898
{
13999
Wire.beginTransmission(address);

src/lib/display/Backlight.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,6 @@
135135
// light intensity (fraction of current max)
136136
#define Imax_frac 0x80 // Imax_frac/256 * Imax = current
137137

138-
/**************************************************************************************
139-
* TYPEDEF
140-
**************************************************************************************/
141-
142-
enum RGBColors {
143-
off = 0,
144-
red = 1,
145-
green = 2,
146-
blue = 3,
147-
yellow = 4,
148-
magenta = 5,
149-
cyan = 6
150-
};
151-
152138
/**************************************************************************************
153139
* CLASS DECLARATION
154140
**************************************************************************************/
@@ -161,8 +147,10 @@ class Backlight
161147

162148
void begin();
163149
void end();
164-
void setColor(RGBColors color);
165-
void setColor(uint8_t blue, uint8_t green, uint8_t red);
150+
151+
void on();
152+
void off();
153+
166154
uint8_t getChipID();
167155

168156

@@ -172,13 +160,9 @@ class Backlight
172160
void reset();
173161
void powerDown();
174162
void powerUp();
163+
void setColor(uint8_t blue, uint8_t green, uint8_t red);
175164
void writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
176165
uint8_t readByte(uint8_t address, uint8_t subAddress);
177-
178-
uint8_t _blue;
179-
uint8_t _green;
180-
uint8_t _red;
181-
182166
};
183167

184168
#endif

0 commit comments

Comments
 (0)