diff --git a/README.md b/README.md index 10dc64f..c6cfea9 100644 --- a/README.md +++ b/README.md @@ -127,55 +127,6 @@ Format Example `!3;` Description: This command will tell the ESP32 to re-enable its idle animation. It will respond with a `!3;` when it recieves this command. -**HERE IS A GUIDE TO GET YOU STARTED ON YOUR [MAYBE] FIRST REPOSITORY**: - - - -Obviously, this is not what your README should say on-submission. Change it. Yes, the whole thing. - -This is where a description of your project will go. README.md files support [Markdown syntax](https://www.markdownguide.org/basic-syntax/). - -## Setup - -**Oh yeah, by the way, don't forget to set up `git lfs` on your machine.** - -Tell everyone what your project needs in order to run. This might involve many components or software. Maybe some cool libraries? - -### Hardware Required - -- Some polyphonic headset on OS version `3.14159265358979323846233832795028841971` with room-temperature hyperconductors -- Some macrocontroller with specific hardware revision `4.2` - - With tank wheels -- Some computer with a holoported underdisplay cap -- Some fancy smart device that is worn and knows your favorite toothpaste - -### Software Dependencies - -- Division Game Engine version `2024.1.26` -- Michaelsoft Binbows `XD` - -## Run - -1. Open the thing - - You know, that thing over there - - No, not that one - - Go back - - Yes, that one -2. Click the button and type the following text: - -```shell -# install the sotware -sudo apt install -y cmatrix -# run the trap -cmatrix -``` - -3. After the process completes and you don't even see the code, anymore, you are ready. Here is what it looks like: - -```js -"b" + "a" + +"a" + "a"; // 'baNaNa' -``` - ## Shout-Outs - Thank you to all the organizers at Reality Hack and the Hardware track. - Lucas De Bonet for creating `the Singularity` which allowed us to connect the board to Quest headsets. diff --git a/lib/Board/BoardManager.h b/lib/Board/BoardManager.h index 54624d3..dccdd70 100644 --- a/lib/Board/BoardManager.h +++ b/lib/Board/BoardManager.h @@ -133,7 +133,10 @@ void BoardManager::Update(){ // create a cube slice array buffer BOARD_TYPES::Cube* sliceBuffer[BOARD_DIMS.z]; // have the board slice get read into our buffer - this->board.SliceBoard(sliceVector, sliceBuffer); + uint32_t sliceSize = this->board.SliceBoard(sliceVector, sliceBuffer); + if(sliceSize < BOARD_DIMS.z){ + return; + } // send the board slice to the driver to update its LED colors this->driver.UpdateStackLEDs(stackIndex, sliceBuffer, BOARD_DIMS.z); } @@ -146,9 +149,14 @@ void BoardManager::updateStackColors(const V3D &column){ V3D sliceVector{column.x, column.y, BOARD_TYPES::Z}; // create a buffer for slice board to write the cube slice into BOARD_TYPES::Cube * cubeSlice[BOARD_DIMS.z]; - this->board.SliceBoard(column, cubeSlice); + uint32_t sliceSize = this->board.SliceBoard(column, cubeSlice); uint32_t numCubes{this->getColumnHeight(static_cast(column.z))}; + + if(sliceSize < numCubes){ + return; + } + this->driver.UpdateStackLEDs(BOARD_DIMS.x, cubeSlice, numCubes); } @@ -168,6 +176,11 @@ void BoardManager::SetColumnColors(const V3D &column, cons uint32_t sliceLength{this->board.SliceBoard(column, slicedBoard)}; uint32_t maxIndex{std::min(numColors, columnHeight)}; + + if(sliceLength < maxIndex){ + return; + } + for(uint32_t i = 0; i < maxIndex; i++){ slicedBoard[i]->color = color[i]; } diff --git a/src/main.cpp b/src/main.cpp index 35150d1..20d8fb9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,21 +85,30 @@ void printBoardState(){ } void SetStackColor(uint32_t * args, uint32_t argsLength){ - uint32_t stackNum = args[1]; + uint32_t stackNum = args[0]; uint32_t X_COORD{stackNum}; while(X_COORD > BOARD_DIMENSIONS.x - 1){ X_COORD -= BOARD_DIMENSIONS.x; } uint32_t Y_COORD{(stackNum - X_COORD) / BOARD_DIMENSIONS.y}; + Serial.println("StackNum: " + String(stackNum)); + Serial.println("X: " + String(X_COORD) + " Y: " + String(Y_COORD)); + uint32_t numColors = (argsLength - 1) / 3; - uint32_t numColors = (argsLength - 2) / 3; + // nothing to do if no colors were given + if(numColors == 0){ + return; + } + + Serial.println("Num Colors: " + String(numColors)); V3D colors[numColors]; for(int i = 0; i < numColors; i++){ - uint32_t red = args[2 + (i * 3)]; - uint32_t green = args[3 + (i * 3)]; - uint32_t blue = args[4 + (i * 3)]; + uint32_t red = args[1 + (i * 3)]; + uint32_t green = args[2 + (i * 3)]; + uint32_t blue = args[3 + (i * 3)]; colors[i] = V3D{red, green, blue}; + Serial.println("Color: " + String(red) + "," + String(green) + "," + String(blue)); } boardManager.SetColumnColors(V3D{X_COORD, Y_COORD, BOARD_TYPES::PLANE_NORMAL::Z}, colors, numColors); } @@ -120,7 +129,7 @@ CommandHandler::CommandStatus SetColorCommandHandler(uint32_t * args, uint32_t a animator.isEnabled = false; V3D black{}; boardManager.FillColor(black); - SetStackColor(reinterpret_cast(args), argsLength); + SetStackColor(args, argsLength); return CommandHandler::CommandStatus::SUCCESS; }