Files
wordclock/code/main/platform/inc/prgm_ledstrip.h
2024-03-22 17:33:53 +01:00

125 lines
4.2 KiB
C++

// --------------------------------------------------------------------------------------------------------------------
/// \file prgm_ledstrip.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_
#define MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_
/**
* prgm_ledstrip implementation
* \defgroup prgm_ledstrip
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h"
#include "led_strip.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class prgm_ledstrip
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
struct pixel
{
uint32_t index;
union
{
struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
} rgb;
struct
{
uint16_t hue;
uint8_t saturation;
uint8_t value;
} hsv;
};
};
// Class Constructor
prgm_ledstrip(uint32_t numberOfLEDs, uint32_t gpio);
// Set and clear functions only update the pixel value(s) locally but do not push the values to the strip
FunctionStatus setPixelRGB(struct pixel& pixel);
FunctionStatus setPixelHSV(struct pixel& pixel);
FunctionStatus clearAll(void);
// Clears all pixels locally and automatically pushes the values to the strip
FunctionStatus clearAndUpdate(void);
// Push the latest pixel values to the strip
FunctionStatus update(void);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
uint32_t numberOfLEDs;
uint32_t gpio;
led_strip_handle_t led_strip;
led_strip_config_t strip_config;
led_strip_rmt_config_t rmt_config;
};
/** @} */
#endif /* MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_ */