|
@@ -58,7 +58,7 @@
|
58
|
58
|
#define PCA9632_AUTOGLO 0xC0
|
59
|
59
|
#define PCA9632_AUTOGI 0xE0
|
60
|
60
|
|
61
|
|
-// Red=LED0 Green=LED1 Blue=LED2
|
|
61
|
+// Red=LED0 Green=LED1 Blue=LED2 White=LED3
|
62
|
62
|
#ifndef PCA9632_RED
|
63
|
63
|
#define PCA9632_RED 0x00
|
64
|
64
|
#endif
|
|
@@ -68,9 +68,12 @@
|
68
|
68
|
#ifndef PCA9632_BLU
|
69
|
69
|
#define PCA9632_BLU 0x04
|
70
|
70
|
#endif
|
|
71
|
+#if HAS_WHITE_LED && !defined(PCA9632_WHT)
|
|
72
|
+ #define PCA9632_WHT 0x06
|
|
73
|
+#endif
|
71
|
74
|
|
72
|
75
|
// If any of the color indexes are greater than 0x04 they can't use auto increment
|
73
|
|
-#if !defined(PCA9632_NO_AUTO_INC) && (PCA9632_RED > 0x04 || PCA9632_GRN > 0x04 || PCA9632_BLU > 0x04)
|
|
76
|
+#if !defined(PCA9632_NO_AUTO_INC) && (PCA9632_RED > 0x04 || PCA9632_GRN > 0x04 || PCA9632_BLU > 0x04 || PCA9632_WHT > 0x04)
|
74
|
77
|
#define PCA9632_NO_AUTO_INC
|
75
|
78
|
#endif
|
76
|
79
|
|
|
@@ -89,25 +92,28 @@ static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte
|
89
|
92
|
Wire.endTransmission();
|
90
|
93
|
}
|
91
|
94
|
|
92
|
|
-static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb) {
|
|
95
|
+static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb
|
|
96
|
+ #if ENABLED(PCA9632_RGBW)
|
|
97
|
+ , const byte vw
|
|
98
|
+ #endif
|
|
99
|
+) {
|
93
|
100
|
#if DISABLED(PCA9632_NO_AUTO_INC)
|
94
|
|
- uint8_t data[4], len = 4;
|
|
101
|
+ uint8_t data[4];
|
95
|
102
|
data[0] = PCA9632_AUTO_IND | regadd;
|
96
|
103
|
data[1 + (PCA9632_RED >> 1)] = vr;
|
97
|
104
|
data[1 + (PCA9632_GRN >> 1)] = vg;
|
98
|
105
|
data[1 + (PCA9632_BLU >> 1)] = vb;
|
|
106
|
+ Wire.beginTransmission(I2C_ADDRESS(addr));
|
|
107
|
+ Wire.write(data, sizeof(data));
|
|
108
|
+ Wire.endTransmission();
|
99
|
109
|
#else
|
100
|
|
- uint8_t data[6], len = 6;
|
101
|
|
- data[0] = regadd + (PCA9632_RED >> 1);
|
102
|
|
- data[1] = vr;
|
103
|
|
- data[2] = regadd + (PCA9632_GRN >> 1);
|
104
|
|
- data[3] = vg;
|
105
|
|
- data[4] = regadd + (PCA9632_BLU >> 1);
|
106
|
|
- data[5] = vb;
|
|
110
|
+ PCA9632_WriteRegister(addr, regadd + (PCA9632_RED >> 1), vr);
|
|
111
|
+ PCA9632_WriteRegister(addr, regadd + (PCA9632_GRN >> 1), vg);
|
|
112
|
+ PCA9632_WriteRegister(addr, regadd + (PCA9632_BLU >> 1), vb);
|
|
113
|
+ #if ENABLED(PCA9632_RGBW)
|
|
114
|
+ PCA9632_WriteRegister(addr, regadd + (PCA9632_WHT >> 1), vw);
|
|
115
|
+ #endif
|
107
|
116
|
#endif
|
108
|
|
- Wire.beginTransmission(I2C_ADDRESS(addr));
|
109
|
|
- Wire.write(data, len);
|
110
|
|
- Wire.endTransmission();
|
111
|
117
|
}
|
112
|
118
|
|
113
|
119
|
#if 0
|
|
@@ -130,9 +136,17 @@ void PCA9632_set_led_color(const LEDColor &color) {
|
130
|
136
|
|
131
|
137
|
const byte LEDOUT = (color.r ? LED_PWM << PCA9632_RED : 0)
|
132
|
138
|
| (color.g ? LED_PWM << PCA9632_GRN : 0)
|
133
|
|
- | (color.b ? LED_PWM << PCA9632_BLU : 0);
|
134
|
|
-
|
135
|
|
- PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b);
|
|
139
|
+ | (color.b ? LED_PWM << PCA9632_BLU : 0)
|
|
140
|
+ #if ENABLED(PCA9632_RGBW)
|
|
141
|
+ | (color.w ? LED_PWM << PCA9632_WHT : 0)
|
|
142
|
+ #endif
|
|
143
|
+ ;
|
|
144
|
+
|
|
145
|
+ PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
|
|
146
|
+ #if ENABLED(PCA9632_RGBW)
|
|
147
|
+ , color.w
|
|
148
|
+ #endif
|
|
149
|
+ );
|
136
|
150
|
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
|
137
|
151
|
}
|
138
|
152
|
|