MCPcopy Create free account
hub / github.com/HomeSpan/HomeSpan / pixelEncodeCallback

Method pixelEncodeCallback

src/src/extras/Pixel.cpp:38–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36////////////////////////////////////////////
37
38IRAM_ATTR size_t Pixel::pixelEncodeCallback(const void *colors, size_t symbolsTotal,
39 size_t symbolsWritten, size_t symbolsFree,
40 rmt_symbol_word_t *symbols, bool *done, void *arg) {
41
42 if(symbolsWritten==symbolsTotal){ // all symbols have been written
43 *done=true;
44 return(0);
45 } else {
46 *done=false;
47 }
48
49 callbackArgs_t *callbackArgs=(callbackArgs_t *)arg;
50
51 if(symbolsFree < callbackArgs->pixel->symbolsPerPixel) // not enough space to write an entire pixel
52 return(0);
53
54 Color *color = (Color *)colors + (callbackArgs->multiColor ? (symbolsWritten / callbackArgs->pixel->symbolsPerPixel) : 0);
55
56 for(auto i=0; i<callbackArgs->pixel->bytesPerPixel; i++){
57 uint8_t colorByte = color->col[callbackArgs->pixel->map[i]];
58 for(auto j = 7; j >= 0; j--)
59 *symbols++ = (colorByte & (1 << j)) ? callbackArgs->pixel->bit1 : callbackArgs->pixel->bit0;
60 }
61
62 return(callbackArgs->pixel->symbolsPerPixel);
63};
64
65///////////////////
66

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected