diff options
Diffstat (limited to 'drivers/chibios/ws2812_pwm.c')
-rw-r--r-- | drivers/chibios/ws2812_pwm.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c index bfb44ce4a..14be0a9ed 100644 --- a/drivers/chibios/ws2812_pwm.c +++ b/drivers/chibios/ws2812_pwm.c | |||
@@ -107,6 +107,7 @@ | |||
107 | */ | 107 | */ |
108 | #define WS2812_BIT(led, byte, bit) (24 * (led) + 8 * (byte) + (7 - (bit))) | 108 | #define WS2812_BIT(led, byte, bit) (24 * (led) + 8 * (byte) + (7 - (bit))) |
109 | 109 | ||
110 | #if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) | ||
110 | /** | 111 | /** |
111 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given red bit | 112 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given red bit |
112 | * | 113 | * |
@@ -117,7 +118,7 @@ | |||
117 | * | 118 | * |
118 | * @return The bit index | 119 | * @return The bit index |
119 | */ | 120 | */ |
120 | #define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 1, (bit)) | 121 | # define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 1, (bit)) |
121 | 122 | ||
122 | /** | 123 | /** |
123 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given green bit | 124 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given green bit |
@@ -129,7 +130,7 @@ | |||
129 | * | 130 | * |
130 | * @return The bit index | 131 | * @return The bit index |
131 | */ | 132 | */ |
132 | #define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 0, (bit)) | 133 | # define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 0, (bit)) |
133 | 134 | ||
134 | /** | 135 | /** |
135 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given blue bit | 136 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given blue bit |
@@ -141,7 +142,45 @@ | |||
141 | * | 142 | * |
142 | * @return The bit index | 143 | * @return The bit index |
143 | */ | 144 | */ |
144 | #define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit)) | 145 | # define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit)) |
146 | |||
147 | #elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB) | ||
148 | /** | ||
149 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given red bit | ||
150 | * | ||
151 | * @note The red byte is the middle byte in the color packet | ||
152 | * | ||
153 | * @param[in] led: The led index [0, @ref RGBLED_NUM) | ||
154 | * @param[in] bit: The bit number [0, 7] | ||
155 | * | ||
156 | * @return The bit index | ||
157 | */ | ||
158 | # define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 0, (bit)) | ||
159 | |||
160 | /** | ||
161 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given green bit | ||
162 | * | ||
163 | * @note The red byte is the first byte in the color packet | ||
164 | * | ||
165 | * @param[in] led: The led index [0, @ref RGBLED_NUM) | ||
166 | * @param[in] bit: The bit number [0, 7] | ||
167 | * | ||
168 | * @return The bit index | ||
169 | */ | ||
170 | # define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 1, (bit)) | ||
171 | |||
172 | /** | ||
173 | * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given blue bit | ||
174 | * | ||
175 | * @note The red byte is the last byte in the color packet | ||
176 | * | ||
177 | * @param[in] led: The led index [0, @ref RGBLED_NUM) | ||
178 | * @param[in] bit: The bit index [0, 7] | ||
179 | * | ||
180 | * @return The bit index | ||
181 | */ | ||
182 | # define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit)) | ||
183 | #endif | ||
145 | 184 | ||
146 | /* --- PRIVATE VARIABLES ---------------------------------------------------- */ | 185 | /* --- PRIVATE VARIABLES ---------------------------------------------------- */ |
147 | 186 | ||