## 2 Materials and Methods
### CSK Modulation  
Color-shift keying is a VLC modulation scheme involving multiple LEDs, in which the average emitted optical color and the total optical power are kept constant. It is included in the IEEE 802.15.7 standard for short-range optical wireless communications as part of the PHY III mode of the VLC physical layer, which is used for high-data-rate applications in indoor environments [11]. A CSK-based system consists of three RGB LEDs, each transmitting a primary color, red, green, or blue, and three PDs with optical filters that let through one of the primary colors each. CSK symbols are defined in the CIE 1931 \(xy\) color space. The center-of-band wavelengths of the three LEDs \(\lambda_{r}\), \(\lambda_{g}\), \(\lambda_{b}\) are expressed in CIE 1931 \(xy\) space coordinates by  
\[\mathbf{s}_{r}= \begin{bmatrix}x_{r}\\ y_{r}\end{bmatrix} ,\quad\mathbf{s}_{g}= \begin{bmatrix}x_{g}\\ y_{g}\end{bmatrix} ,\quad\mathbf{s}_{b}= \begin{bmatrix}x_{b}\\ y_{b}\end{bmatrix} , \tag{7}\]  
respectively. \(\mathbf{s}_{r},\mathbf{s}_{g}\), and \(\mathbf{s}_{b}\) are known as the center-of-band symbols. All colors that can be reproduced by the three LEDs via additive mixing form a triangle in the CIE \(xy\) space, with \(\mathbf{s}_{r},\mathbf{s}_{g}\), and \(\mathbf{s}_{b}\) being the vertices. The set of all the colors reproducible by the three LEDs is known as the gamut of the system and can be expressed mathematically as the convex combination of the center of band symbols in the CIE \(xy\) space, as in  
\[G=\{\alpha_{1}\mathbf{s}_{r}+\alpha_{2}\mathbf{s}_{g}+\alpha_{3}\mathbf{s}_{ b}\in\mathbb{R}^{2}\ |\ \alpha_{1}+\alpha_{2}+\alpha_{3}=1,\quad\alpha_{1},\alpha_{2},\alpha_{3}\geq 0 \}\,, \tag{8}\]where \(G\) is the gamut of the system. The CSK scheme encodes \(k\) bits per symbol, employing a constellation \(\mathcal{A}\) of \(M=2^{k}\) symbols, with \(\mathcal{A}=\{\mathbf{s}_{1},\ldots,\mathbf{s}_{M}\}\), which is known as \(M\)-CSK modulation. Each \(n\)th symbol for \(n=1\ldots,M\) is a CIE 1931 \(xy\) space coordinate inside gamut \(G\), i.e.,  
\[\mathbf{s}_{n}= \begin{bmatrix}x_{n}\\ y_{n}\end{bmatrix} \in G,\quad\forall n=1,\ldots,M\,. \tag{9}\]  
In theory, an infinite number of gamuts and constellations can be defined in the system. However, the IEEE 802.15.7 standard considers only fourteen possible system gamuts and establishes a set of rules to construct symbol constellations given the number of symbols \(M\) and the system gamut \(G\). The ruleset for constellation construction is laid out in [11]. All possible gamuts and system constellations for 4-CSK, 8-CSK, and 16-CSK, together with their corresponding data mapping, as defined by the IEEE 802.15.7 standard, are presented in [26]. Consider a CSK RGB luminary whose average transmitted optical power must not exceed \(P_{\text{avg}}\). In order to transmit symbol \(\mathbf{s}_{n}=[x_{n},y_{n}]^{\text{T}}\in G\), it must be converted into an optical power triplet \([P_{1,n},P_{2,n},P_{3,n}]^{\text{T}}\) such that  
\[P_{1,n}+P_{2,n}+P_{3,n}=P_{\text{avg}} \tag{10}\]  
where \(P_{1,n},P_{2,n}\), and \(P_{3,n}\) are the transmitted optical powers of the red, green, and blue LEDs, respectively, when symbol \(\mathbf{s}_{n}\) is transmitted. As in [11], the triplet can be found by solving the following system of equations:  
\[ \begin{split} x_{n}&=\overline{P}_{1}x_{r}+\overline{ P}_{2}x_{g}+\overline{P}_{3}x_{b}\\ y_{n}&=\overline{P}_{1}y_{r}+\overline{P}_{2}y_{g}+ \overline{P}_{3}y_{b}\\ 1&=\overline{P}_{1}+\overline{P}_{2}+\overline{P}_{3}\,. \end{split}  \tag{11}\]  
Consider \(\overline{P}_{1,n},\overline{P}_{2,n}\), and \(\overline{P}_{3,n}\) to be the solution to Equation (11). Then, the desired optical power triplet for symbol \(\mathbf{s}_{n}\) is given by  
\[ \begin{bmatrix}P_{1,n}\\ P_{2,n}\\ P_{3,n}\end{bmatrix} =P_{\text{avg}} \begin{bmatrix}\overline{P}_{1,n}\\ \overline{P}_{2,n}\\ \overline{P}_{3,n}\end{bmatrix} .