ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
HUB75Controller.cpp
Go to the documentation of this file.
1#include "HUB75Controller.h"
2
3//Macro calls from SmartMatrix library included in SmartMatrixHUB75
6
9
10HUB75Controller::HUB75Controller(CameraManager* cameras, uint8_t maxBrightness, uint8_t maxAccentBrightness) : Controller(cameras, maxBrightness, maxAccentBrightness){}
11
13 //HUB75
14 matrix.addLayer(&backgroundLayer);
15 matrix.begin();
16 matrix.setRefreshRate(240);
17
18 backgroundLayer.swapBuffers();//for ESP32 - first is ignored
19
20 //APA102
21 apamatrix.addLayer(&apaBackgroundLayer);
22 apamatrix.begin();
23 apamatrix.setRefreshRate(240);
24}
25
28
29 matrix.setBrightness(brightness);
30 apamatrix.setBrightness(accentBrightness);
31
32 IPixelGroup* camPixels = cameras->GetCameras()[0]->GetPixelGroup();
33 IPixelGroup* camSidePixelsL = cameras->GetCameras()[1]->GetPixelGroup();
34 IPixelGroup* camSidePixelsR = cameras->GetCameras()[2]->GetPixelGroup();
35
36 for (uint16_t y = 0; y < 32; y++) {
37 for (uint16_t x = 0; x < 64; x++){
38 uint16_t pixelNum = y * 64 + x;
39
40 rgb24 rgbColor = rgb24((uint16_t)camPixels->GetColor(pixelNum)->R, (uint16_t)camPixels->GetColor(pixelNum)->G, (uint16_t)camPixels->GetColor(pixelNum)->B);
41
42 backgroundLayer.drawPixel(x, (31 - y), rgbColor);
43 backgroundLayer.drawPixel(63 - x, (31 - y) + 32, rgbColor);
44 }
45 }
46
47 backgroundLayer.swapBuffers(false);
48
49 for (uint16_t x = 0; x < kApaMatrixWidth / 2; x++){
50 rgb24 rgbColorL = rgb24((uint16_t)camSidePixelsL->GetColor(x)->R, (uint16_t)camSidePixelsL->GetColor(x)->G, (uint16_t)camSidePixelsL->GetColor(x)->B);
51 rgb24 rgbColorR = rgb24((uint16_t)camSidePixelsR->GetColor(x)->R, (uint16_t)camSidePixelsR->GetColor(x)->G, (uint16_t)camSidePixelsR->GetColor(x)->B);
52
53 apaBackgroundLayer.drawPixel(x, 0, rgbColorL);
54 apaBackgroundLayer.drawPixel(x + 88, 0, rgbColorR);
55 }
56
57 apaBackgroundLayer.swapBuffers(false);
58}
59
60void HUB75Controller::SetBrightness(uint8_t maxBrightness){
61 this->maxBrightness = maxBrightness * 25 + 5;
62
63 if(isOn){//past soft start
64 this->brightness = maxBrightness * 25 + 5;
65 }
66}
67
68void HUB75Controller::SetAccentBrightness(uint8_t maxAccentBrightness){
69 this->maxAccentBrightness = maxAccentBrightness * 12 + 5;
70
71 if(isOn){//past soft start
72 this->accentBrightness = maxAccentBrightness * 12 + 5;
73 }
74}
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions)
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions)
SMARTMATRIX_APA_ALLOCATE_BUFFERS(apamatrix, kApaMatrixWidth, kApaMatrixHeight, kApaRefreshDepth, kApaDmaBufferRows, kApaPanelType, kApaMatrixOptions)
Declares the HUB75Controller class for managing HUB75 LED matrices.
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.
const uint8_t kDmaBufferRows
Number of DMA buffer rows for HUB75 matrices.
const uint8_t kPanelType
Specifies the panel type for HUB75 matrices.
const uint8_t kBackgroundLayerOptions
Background layer options for HUB75 matrices.
const uint8_t kRefreshDepth
Specifies the tradeoff between color quality and refresh rate for HUB75 matrices.
const uint16_t kMatrixWidth
Width of the HUB75 matrix.
const uint32_t kMatrixOptions
Options for HUB75 matrices.
const uint16_t kMatrixHeight
Height of the HUB75 matrix.
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
void Initialize() override
Initializes the HUB75Controller and sets up the LED matrix.
void Display() override
Updates and displays the content on the LED matrix.
HUB75Controller(CameraManager *cameras, uint8_t maxBrightness, uint8_t maxAccentBrightness)
Constructs a HUB75Controller with specified parameters.
void SetAccentBrightness(uint8_t maxAccentBrightness) override
Sets the maximum accent brightness of the secondary display.
void SetBrightness(uint8_t maxBrightness) override
Sets the maximum brightness of the LED matrix.
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