APA102 protocol fix (#1352) (#1361)

* Fix APA102 protocoll

* Minor clean-ups

* Revert updates
This commit is contained in:
LordGrey
2021-10-28 18:54:54 +01:00
committed by GitHub
parent ba32b875ab
commit 954112a88e
7 changed files with 65 additions and 28 deletions

View File

@@ -4,6 +4,9 @@
// hyperion includes
#include "ProviderSpi.h"
/// The maximal level supported by the APA brightness control field, 31
const int APA102_BRIGHTNESS_MAX_LEVEL = 31;
///
/// Implementation of the LedDevice interface for writing to APA102 led device.
///
@@ -43,6 +46,18 @@ private:
/// @return Zero on success, else negative
///
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Writes the RGB-Color values to the SPI Tx buffer setting considering a given brightness level
///
/// @param[in,out] txBuf The packed spi transfer buffer of the LED's color values
/// @param[in] ledValues The RGB-color per LED
/// @param[in] brightness The current brightness level 1 .. 31
///
void bufferWithBrightness(std::vector<uint8_t> &txBuf, const std::vector<ColorRgb> & ledValues, const int brightness = APA102_BRIGHTNESS_MAX_LEVEL);
/// The brighness level. Possibile values 1 .. 31.
int _brightnessControlMaxLevel;
};
#endif // LEDEVICEAPA102_H