15#include "sylib/env.hpp"
16#include "sylib/system.hpp"
17#include "sylib/sylib_apitypes.hpp"
45 static const std::vector<uint32_t> off_buffer;
46 const std::uint8_t smart_port;
47 const std::uint8_t adi_port;
48 const std::uint8_t strip_length;
49 std::vector<uint32_t> buffer;
50 std::vector<uint32_t> template_buffer;
51 std::vector<uint32_t> rotation_buffer;
52 std::vector<uint32_t> buffer_saved;
53 static std::vector<sylib::Addrled*>& getAllAddrleds();
54 const V5_DeviceT device;
55 static void setAddrledUpdateCycles(
int count);
57 double controlSpeed = 1;
58 double pulseSpeed = 1;
59 int cyclePixelsShifted = 0;
61 bool pulseControlReversed =
false;
62 bool cycleControlReversed =
false;
64 int pulseStartMovementTime = 0;
65 int cycleStartMovementTime = 0;
66 bool sendingPulse =
false;
67 int controlPulseWidth = 1;
71 int pulsePixelsShifted = 0;
86 Addrled(
const std::uint8_t smart_port,
const std::uint8_t adi_port,
87 const std::uint8_t strip_length,
88 const std::vector<std::uint32_t> colors = std::vector<std::uint32_t>());
113 void set_pixel(std::uint32_t color, std::uint8_t index);
172 void pulse(std::uint32_t color,
int pulse_width,
int speed = 1,
int start_pos = 0,
173 bool reverse =
false,
int end_pixel = -1);
198 void gradient(std::uint32_t start_color, std::uint32_t end_color,
int fade_width = 0,
199 int start_pos = 0,
bool reverse =
false,
bool hsv_mode =
false);
219 void cycle(std::vector<uint32_t> pattern,
int speed = 1,
int start_pos = 0,
220 bool reverse =
false);
231 void rotate(
int pixels = 0,
bool reverse =
false);
306 static std::uint32_t
interpolate_hsv(std::uint32_t start_color, std::uint32_t end_color,
307 int step,
int fade_width);
328 static std::uint32_t
interpolate_rgb(std::uint32_t start_color, std::uint32_t end_color,
329 int step,
int fade_width);
WS2812B Addressable LED Strip Controller.
Definition: addrled.hpp:43
void set_pixel(std::uint32_t color, std::uint8_t index)
Sets a specific pixel to a specific color.
void cycle(std::vector< uint32_t > pattern, int speed=1, int start_pos=0, bool reverse=false)
Automatically rotates the colors of a provided buffer through the light strip periodically.
void turn_on()
Sets the light control mode to MANUAL without changing the saved buffer.
static rgb hex_to_rgb(std::uint32_t color)
Converts an RGB hex code to RGB values.
std::vector< uint32_t > & operator*()
Operator overload to retrieve the current saved buffer.
static std::uint32_t rgb_to_hex(int r, int g, int b)
Converts RGB values to an RGB hex code.
void gradient(std::uint32_t start_color, std::uint32_t end_color, int fade_width=0, int start_pos=0, bool reverse=false, bool hsv_mode=false)
Sets the strip to a static color gradient.
static std::uint32_t interpolate_rgb(std::uint32_t start_color, std::uint32_t end_color, int step, int fade_width)
Finds a color between two provided color values.
void rotate(int pixels=0, bool reverse=false)
Rotates pixel colors up or down the strip.
void turn_off()
Sets the light control mode to OFF without changing the saved buffer.
void clear()
Resets the buffer.
void update() override
Addrled update loop.
uint32_t & operator[](std::uint32_t index)
Operator overload to retrieve a pixel color.
void color_shift(int red, int green, int blue)
Adds the provided red, green, and blue values to the colors sent to the lights.
static std::uint32_t hsv_to_rgb(hsv in)
Converts an HSV color to an RGB hex code.
void set_all(std::uint32_t color)
Sets every pixel to a single color.
static std::uint32_t interpolate_hsv(std::uint32_t start_color, std::uint32_t end_color, int step, int fade_width)
Finds a color between two provided color values.
void set_buffer(std::vector< uint32_t > colors)
Sets the entire light strip to the provided vector of hex codes.
void pulse(std::uint32_t color, int pulse_width, int speed=1, int start_pos=0, bool reverse=false, int end_pixel=-1)
Sends a single pulse of color down the strip.
int get_smart_port()
Gets smart port number used by the ADI expander for the light strip.
Addrled(const std::uint8_t smart_port, const std::uint8_t adi_port, const std::uint8_t strip_length, const std::vector< std::uint32_t > colors=std::vector< std::uint32_t >())
Creates an Addrled object for the given port and specifications.
static hsv rgb_to_hsv(std::uint32_t in)
Converts RGB values to an HSV color.
int get_adi_port()
Gets adi port number used by the light strip.
static bool addrled_enabled
A flag that when set to false turns off all lights on all addrled objects.
Definition: addrled.hpp:95
sylib::SylibAddrledControlMode getControlMode()
Gets which control mode the light is using.
Device Parent Class.
Definition: system.hpp:238
Definition: addrled.hpp:20
SylibAddrledControlMode
Definition: sylib_apitypes.hpp:25
HSV Color.
Definition: addrled.hpp:34
double s
Definition: addrled.hpp:36
double v
Definition: addrled.hpp:37
double h
Definition: addrled.hpp:35
RGB Color.
Definition: addrled.hpp:25
double r
Definition: addrled.hpp:26
double g
Definition: addrled.hpp:27
double b
Definition: addrled.hpp:28