ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
APA102Controller.cpp
Go to the documentation of this file.
1#include "APA102Controller.h"
2
3//Macro calls from SmartMatrix library included in SmartMatrixAPA102
6
7APA102Controller::APA102Controller(CameraManager* cameras, uint8_t maxBrightness, uint8_t maxAccentBrightness) : Controller(cameras, maxBrightness, maxAccentBrightness){}
8
10 //APA102
11 apamatrix.addLayer(&apaBackgroundLayer);
12 apamatrix.begin();
13 apamatrix.setRefreshRate(240);
14}
15
18
19 apamatrix.setBrightness(brightness);
20
21 IPixelGroup* camSidePixelsL = cameras->GetCameras()[0]->GetPixelGroup();
22 IPixelGroup* camSidePixelsR = cameras->GetCameras()[1]->GetPixelGroup();
23
24 for (uint16_t x = 0; x < kApaMatrixWidth / 2; x++){
25 rgb24 rgbColorL = rgb24((uint16_t)camSidePixelsL->GetColor(x)->R, (uint16_t)camSidePixelsL->GetColor(x)->G, (uint16_t)camSidePixelsL->GetColor(x)->B);
26 rgb24 rgbColorR = rgb24((uint16_t)camSidePixelsR->GetColor(x)->R, (uint16_t)camSidePixelsR->GetColor(x)->G, (uint16_t)camSidePixelsR->GetColor(x)->B);
27
28 apaBackgroundLayer.drawPixel(x, 0, rgbColorL);
29 apaBackgroundLayer.drawPixel(x + 88, 0, rgbColorR);
30 }
31
32 apaBackgroundLayer.swapBuffers(false);
33}
34
35void APA102Controller::SetBrightness(uint8_t maxBrightness){
36 this->maxBrightness = maxBrightness * 25 + 5;
37
38 if(isOn){//past soft start
39 this->brightness = maxBrightness * 25 + 5;
40 }
41}
42
43void APA102Controller::SetAccentBrightness(uint8_t maxAccentBrightness){
44 this->maxAccentBrightness = maxAccentBrightness * 12 + 5;
45
46 if(isOn){//past soft start
47 this->accentBrightness = maxAccentBrightness * 12 + 5;
48 }
49}
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(apaBackgroundLayer, kApaMatrixWidth, kApaMatrixHeight, COLOR_DEPTH, kApaBackgroundLayerOptions)
SMARTMATRIX_APA_ALLOCATE_BUFFERS(apamatrix, kApaMatrixWidth, kApaMatrixHeight, kApaRefreshDepth, kApaDmaBufferRows, kApaPanelType, kApaMatrixOptions)
Declares the APA102Controller class for managing APA102 LED strips.
const uint8_t kApaBackgroundLayerOptions
Background layer options for APA matrices.
const uint16_t kApaMatrixWidth
Width of the APA matrix or strip.
#define COLOR_DEPTH
Specifies the color depth used for storing pixels in the layers.
const uint32_t kApaMatrixOptions
Options for APA matrices, including color order.
const uint8_t kApaDmaBufferRows
Not currently used for APA matrices.
const uint8_t kApaPanelType
Not currently used for APA matrices.
const uint16_t kApaMatrixHeight
Height of the APA matrix. Set to 1 for strips.
const uint8_t kApaRefreshDepth
Not currently used for APA matrices.
void Initialize() override
Initializes the APA102Controller and sets up the LED strip.
void Display() override
Updates and displays the content on the LED strip.
APA102Controller(CameraManager *cameras, uint8_t maxBrightness, uint8_t maxAccentBrightness)
Constructs an APA102Controller with specified parameters.
void SetAccentBrightness(uint8_t maxAccentBrightness) override
Sets the maximum accent brightness of the LED strip.
void SetBrightness(uint8_t maxBrightness) override
Sets the maximum brightness of the LED strip.
virtual IPixelGroup * GetPixelGroup()=0
Retrieves the associated pixel group.
Manages multiple CameraBase objects.
CameraBase ** GetCameras()
Retrieves the array of CameraBase objects.
Base class for managing brightness and display operations of lighting controllers.
Definition Controller.h:25
uint8_t maxAccentBrightness
Maximum allowed accent brightness level.
Definition Controller.h:35
uint8_t accentBrightness
Current accent brightness level.
Definition Controller.h:33
uint8_t brightness
Current brightness level.
Definition Controller.h:32
uint8_t maxBrightness
Maximum allowed brightness level.
Definition Controller.h:34
CameraManager * cameras
Pointer to the CameraManager for managing camera data.
Definition Controller.h:31
void UpdateBrightness()
Updates the brightness based on internal logic.
Definition Controller.cpp:9
bool isOn
Indicates if the controller is active.
Definition Controller.h:36
Interface for managing and interacting with a collection of pixels.
Definition IPixelGroup.h:25
virtual RGBColor * GetColor(uint16_t count)=0
Retrieves the color of a specific pixel.
uint8_t B
Blue component of the color (0-255).
Definition RGBColor.h:27
uint8_t G
Green component of the color (0-255).
Definition RGBColor.h:26
uint8_t R
Red component of the color (0-255).
Definition RGBColor.h:25