Initial commit

This commit is contained in:
2024-02-09 21:33:45 -05:00
commit 87d17bc0d1
25 changed files with 1146 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#include "ColorManager.h"
void ColorManager::Update(){
if(!(this->enabled)){
return;
}
// go through our colors and have them fade from r->g->b->r
for(uint8_t i = 0; i < 9; i++){
for(uint8_t j = 0; j < 3; j++){
Color * color = this->colors[i][j];
// fade from red to green
if(color->red > 0 && color->green >= 0 && color->blue == 0){
color->red--;
color->green++;
}
// fade from green to blue
else if(color->green > 0 && color->blue >= 0 && color->red == 0){
color->green--;
color->blue++;
}
// fade from blue to red
else if(color->blue > 0 && color->red >= 0 && color->green == 0){
color->blue--;
color->red++;
}
}
}
// set the colors
for(uint8_t i = 0; i < 9; i++){
Color temp_colors[3] = {*(this->colors[i][0]), *(this->colors[i][1]), *(this->colors[i][2])};
this->board->SetStackColors(i, temp_colors);
}
}
void ColorManager::Enable(bool enable){
this->enabled = enable;
if(this->enabled == false){
// set all the colors to black
Color black(0, 0, 0);
Color temp_colors[3] = {black, black, black};
// set the colors
for(uint8_t i = 0; i < 9; i++){
this->board->SetStackColors(i, temp_colors);
}
}
}

View File

@@ -0,0 +1,44 @@
/**
* @file ColorManager.h
* @brief Generate pretty colors for the board and make it do something when unity isn't controlling it
*/
#pragma once
#include "BoardLayout.h"
#include "Color.h"
class ColorManager{
public:
ColorManager(BoardLayout * board) :
board(board)
{}
/**
* @brief Allows the color manager to update the board colors
*/
void Update();
/**
* @brief Enables or disables the color manager
* @param enable true to enable, false to disable
*/
void Enable(bool enable);
private:
BoardLayout * board;
bool enabled{true};
Color * colors[9][3] = {
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)},
{new Color(255, 0, 0), new Color(0, 255, 0), new Color(0, 0, 255)}
};
};