MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / dotstarSend_16LE

Function dotstarSend_16LE

modules/drivers/dotstar/modDotstar.c:221–254  ·  view source on GitHub ↗

caller provides little-endian pixels @@ could double buffer "buffer" to get some aysnc sending in this loop

Source from the content-addressed store, hash-verified

219// caller provides little-endian pixels
220//@@ could double buffer "buffer" to get some aysnc sending in this loop
221void dotstarSend_16LE(PocoPixel *pixels, int byteLength, void *refcon)
222{
223 spiDisplay sd = refcon;
224 uint8_t *brightness = sd->brightness;
225
226 if (byteLength < 0) byteLength = -byteLength;
227 while (byteLength > 0) {
228 uint8_t buffer[16 * 4];
229 uint8_t *bgr = buffer;
230 uint16_t count = (byteLength >= 32) ? 32 : byteLength;
231 uint16_t counter = count >> 1;
232
233 while (counter--) {
234 PocoPixel pixel = *pixels++;
235 uint8_t t;
236
237 *bgr++ = 0xff;
238
239 t = pixel & 0x1F;
240 *bgr++ = brightness[(t << 3) | (t >> 3)];
241
242 t = (pixel >> 5) & 0x3F;
243 *bgr++ = brightness[(t << 2) | (t >> 4)];
244
245 t = pixel >> 11;
246 *bgr++ = brightness[(t << 3) | (t >> 3)];
247 }
248
249 modSPITx(&sd->spiConfig, (void *)buffer, count << 1);
250 modSPIFlush();
251
252 byteLength -= count;
253 }
254}
255
256void dotstarChipSelect(uint8_t active, modSPIConfiguration config)
257{

Callers

nothing calls this directly

Calls 2

modSPITxFunction · 0.50
modSPIFlushFunction · 0.50

Tested by

no test coverage detected