Completed the board manager rewrite

This commit is contained in:
2024-08-22 21:07:32 -04:00
parent 48f83eee38
commit 3e4f0124db
17 changed files with 666 additions and 408 deletions

View File

@@ -4,32 +4,60 @@
*/
#pragma once
#include <cstdint>
#include <array>
#include "PINOUT.h"
#include "CubeStack.h"
#include "BoardDriverTypes.h"
// define the physical dimensions of the board
#define BOARD_WIDTH 3
#define BOARD_LENGTH 3
#define BOARD_HEIGHT 3
static constexpr uint32_t BOARD_WIDTH{3};
static constexpr uint32_t BOARD_LENGTH{3};
static constexpr uint32_t BOARD_HEIGHT{3};
// define the number of stacks
#define NUMBER_STACKS BOARD_WIDTH * BOARD_LENGTH
static constexpr uint32_t NUMBER_STACKS{BOARD_WIDTH * BOARD_LENGTH};
// define the CubeStacks
CubeStack stack1(STACK1_ADC_PIN, STACK1_LED_PIN, BOARD_HEIGHT);
CubeStack stack2(STACK2_ADC_PIN, STACK2_LED_PIN, BOARD_HEIGHT);
CubeStack stack3(STACK3_ADC_PIN, STACK3_LED_PIN, BOARD_HEIGHT);
CubeStack stack4(STACK4_ADC_PIN, STACK4_LED_PIN, BOARD_HEIGHT);
CubeStack stack5(STACK5_ADC_PIN, STACK5_LED_PIN, BOARD_HEIGHT);
CubeStack stack6(STACK6_ADC_PIN, STACK6_LED_PIN, BOARD_HEIGHT);
CubeStack stack7(STACK7_ADC_PIN, STACK7_LED_PIN, BOARD_HEIGHT);
CubeStack stack8(STACK8_ADC_PIN, STACK8_LED_PIN, BOARD_HEIGHT);
CubeStack stack9(STACK9_ADC_PIN, STACK9_LED_PIN, BOARD_HEIGHT);
static BoardDriverTypes::CubeStack stack1{
.adcPin=STACK1_ADC_PIN,
.ledPin=STACK1_LED_PIN
};
static BoardDriverTypes::CubeStack stack2{
.adcPin=STACK2_ADC_PIN,
.ledPin=STACK2_LED_PIN
};
static BoardDriverTypes::CubeStack stack3{
.adcPin=STACK3_ADC_PIN,
.ledPin=STACK3_LED_PIN
};
static BoardDriverTypes::CubeStack stack4{
.adcPin=STACK4_ADC_PIN,
.ledPin=STACK4_LED_PIN
};
static BoardDriverTypes::CubeStack stack5{
.adcPin=STACK5_ADC_PIN,
.ledPin=STACK5_LED_PIN
};
static BoardDriverTypes::CubeStack stack6{
.adcPin=STACK6_ADC_PIN,
.ledPin=STACK6_LED_PIN
};
static BoardDriverTypes::CubeStack stack7{
.adcPin=STACK7_ADC_PIN,
.ledPin=STACK7_LED_PIN
};
static BoardDriverTypes::CubeStack stack8{
.adcPin=STACK8_ADC_PIN,
.ledPin=STACK8_LED_PIN
};
static BoardDriverTypes::CubeStack stack9{
.adcPin=STACK9_ADC_PIN,
.ledPin=STACK9_LED_PIN
};
// define the array of stacks
CubeStack * stacks[] = {
&stack1, &stack2, &stack3,
&stack4, &stack5, &stack6,
&stack7, &stack8, &stack9
static std::array<BoardDriverTypes::CubeStack, NUMBER_STACKS> stacks{
stack1, stack2, stack3,
stack4, stack5, stack6,
stack7, stack8, stack9
};

54
include/Vector3D.h Normal file
View File

@@ -0,0 +1,54 @@
#pragma once
#include <cstdint>
#include <cmath>
class V3D{
public:
V3D(uint32_t x=0, uint32_t y=0, uint32_t z=0):
x(x),
y(y),
z(z){}
V3D& operator=(const V3D &other){
this->x = other.x;
this->y = other.y;
this->z = other.z;
return *this;
}
V3D& operator+(const V3D &other){
V3D vector{};
vector.x = this->x + other.x;
vector.y = this->y + other.y;
vector.z = this->z + other.z;
return vector;
}
V3D& operator-(const V3D &other){
V3D vector{};
vector.x = this->x - other.x;
vector.y = this->y - other.y;
vector.z = this->z - other.z;
return vector;
}
V3D operator/(const uint32_t scalar){
V3D vector{};
vector.x = this->x / scalar;
vector.y = this->y / scalar;
vector.z = this->z / scalar;
return vector;
}
bool operator==(const V3D &other){
return this->x == other.x && this->y == other.y && this->z == other.z;
}
float magnitude(){
return std::sqrt(this->x * this->x + this->y * this->y + this->z * this-> z);
}
uint32_t x;
uint32_t y;
uint32_t z;
};