Corrige erro de cor e brilho da matriz de LEDs RGB aplicando a reversão de byte #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Conforme levantado nas discussões no Discord, o LED RGB WS2818 recebe os bytes RGB do MSB -> LSB.
Do jeito que a biblioteca está escrita, o envio é feito do LSB -> MSB. Por consequência, os comandos para mudança de cor e/ou diminuição de brilho ficam não intuitivos (O brilho aumenta conforme o número diminui, as cores ficam esmaecidas, etc.).
É possível solucionar o problema aplicando uma lógica de reversão de byte antes de enviá-lo para o WS2818. Assim, o usuário envia os valores RGB de forma intuitiva e, internamente, a biblioteca aplica a reversão e envia o valor tratado à matriz de LEDs.
Esse PR implementa uma função para a reversão de bytes
uint8_t reverse_byte(uint8_t b)bem como integra-o no código já existente, na funçãovoid npSetLED(const uint index, const uint8_t r, const uint8_t g, const uint8_t b).Essas modificações tornam o controle de brilho mais intuitivo, onde 0 e 255 significam mínimo e máximo brilho, respectivamente.