diff --git a/.github/workflows/handle_build.yml b/.github/workflows/handle_build.yml index c02c12ebe5..7b5824243c 100644 --- a/.github/workflows/handle_build.yml +++ b/.github/workflows/handle_build.yml @@ -11,7 +11,10 @@ jobs: setup: runs-on: ubuntu-latest outputs: - version: ${{ steps.set_version.outputs.version }} + vortex_version_major: ${{ steps.set_version.outputs.vortex_version_major }} + vortex_version_minor: ${{ steps.set_version.outputs.vortex_version_minor }} + vortex_build_number: ${{ steps.set_version.outputs.vortex_build_number }} + vortex_version_number: ${{ steps.set_version.outputs.vortex_version_number }} steps: - uses: actions/checkout@v4 with: @@ -26,18 +29,25 @@ jobs: LATEST_TAG=$(git tag --list "*${BRANCH_SUFFIX}" | sort -V | tail -n1) if [ -z "$LATEST_TAG" ]; then echo "No matching tags found. Setting default version." - VERSION_NUMBER="0.1" + VERSION_MAJOR="0" + VERSION_MINOR="1" BUILD_NUMBER="0" else echo "Found latest tag: $LATEST_TAG" VERSION_NUMBER=$(echo $LATEST_TAG | sed "s/${BRANCH_SUFFIX}//g") + VERSION_MAJOR=$(echo $VERSION_NUMBER | cut -d. -f1) + VERSION_MINOR=$(echo $VERSION_NUMBER | cut -d. -f2) BUILD_NUMBER=$(git rev-list --count $LATEST_TAG..HEAD) fi - FULL_VERSION="$VERSION_NUMBER.$BUILD_NUMBER" - echo "version=$FULL_VERSION" >> $GITHUB_OUTPUT + FULL_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$BUILD_NUMBER" + echo "vortex_version_major=$VERSION_MAJOR" >> $GITHUB_OUTPUT + echo "vortex_version_minor=$VERSION_MINOR" >> $GITHUB_OUTPUT + echo "vortex_build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT + echo "vortex_version_number=$FULL_VERSION" >> $GITHUB_OUTPUT echo "Version Number: $FULL_VERSION" test: + needs: setup runs-on: ubuntu-latest steps: - name: Checkout current repository @@ -47,7 +57,12 @@ jobs: - name: Install Dependencies run: sudo apt-get install valgrind g++ make --fix-missing - name: Build - run: make -j + run: | + export VORTEX_VERSION_MAJOR=${{ needs.setup.outputs.vortex_version_major }} + export VORTEX_VERSION_MINOR=${{ needs.setup.outputs.vortex_version_minor }} + export VORTEX_BUILD_NUMBER=${{ needs.setup.outputs.vortex_build_number }} + export VORTEX_VERSION_NUMBER=${{ needs.setup.outputs.vortex_version_number }} + make -j working-directory: VortexEngine - name: Set execute permissions for test script run: chmod +x ./runtests.sh @@ -57,7 +72,7 @@ jobs: working-directory: VortexEngine/tests embedded: - needs: test + needs: [setup, test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -68,7 +83,12 @@ jobs: - name: Install Dependencies run: make install - name: Build Binary - run: make build + run: | + export VORTEX_VERSION_MAJOR=${{ needs.setup.outputs.vortex_version_major }} + export VORTEX_VERSION_MINOR=${{ needs.setup.outputs.vortex_version_minor }} + export VORTEX_BUILD_NUMBER=${{ needs.setup.outputs.vortex_build_number }} + export VORTEX_VERSION_NUMBER=${{ needs.setup.outputs.vortex_version_number }} + make build - name: Archive production artifacts uses: actions/upload-artifact@v4 with: @@ -86,7 +106,7 @@ jobs: path: build/VortexEngine.ino.uf2 wasm: - needs: embedded + needs: [setup, test, embedded] runs-on: ubuntu-latest steps: - name: Checkout current repository @@ -104,11 +124,15 @@ jobs: - name: Build Webassembly run: | source ./emsdk/emsdk_env.sh + export VORTEX_VERSION_MAJOR=${{ needs.setup.outputs.vortex_version_major }} + export VORTEX_VERSION_MINOR=${{ needs.setup.outputs.vortex_version_minor }} + export VORTEX_BUILD_NUMBER=${{ needs.setup.outputs.vortex_build_number }} + export VORTEX_VERSION_NUMBER=${{ needs.setup.outputs.vortex_version_number }} make -j wasm working-directory: VortexEngine/VortexLib docs: - needs: wasm + needs: [setup, test, embedded, wasm] runs-on: ubuntu-latest if: github.ref == 'refs/heads/handle' steps: @@ -131,7 +155,7 @@ jobs: git push -f origin HEAD:handle-docs deploy: - needs: [embedded, setup] + needs: [setup, test, embedded, wasm, docs] runs-on: ubuntu-latest if: github.ref == 'refs/heads/handle' steps: @@ -143,14 +167,15 @@ jobs: - name: Rename and Deploy Firmware run: | DEVICE_TYPE="handle" - VERSIONED_FILENAME="VortexEngine-${DEVICE_TYPE}-${{ needs.setup.outputs.version }}.uf2" + VERSIONED_FILENAME="VortexEngine-${DEVICE_TYPE}-${{ needs.setup.outputs.vortex_version_number }}.uf2" mv build/VortexEngine.ino.uf2 build/$VERSIONED_FILENAME - echo "Version is ${{ needs.setup.outputs.version }}" + echo "Version is ${{ needs.setup.outputs.vortex_version_number }}" echo "Filename is is $VERSIONED_FILENAME" curl -X POST \ -F "file=@build/$VERSIONED_FILENAME" \ -F "device=$DEVICE_TYPE" \ - -F "version=${{ needs.setup.outputs.version }}" \ + -F "version=${{ needs.setup.outputs.vortex_version_number }}" \ -F "category=firmware" \ -F "clientApiKey=${{ secrets.VORTEX_COMMUNITY_API_KEY }}" \ https://vortex.community/firmware/upload + diff --git a/VortexEngine/VortexLib/Makefile b/VortexEngine/VortexLib/Makefile index 5a7c38e96f..c136b665bd 100644 --- a/VortexEngine/VortexLib/Makefile +++ b/VortexEngine/VortexLib/Makefile @@ -26,7 +26,11 @@ endif # compiler defines DEFINES=\ - -D VORTEX_LIB + -D VORTEX_LIB \ + -D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \ + -D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \ + -D VORTEX_BUILD_NUMBER=$(VORTEX_BUILD_NUMBER) \ + -D VORTEX_VERSION_NUMBER=$(VORTEX_VERSION_NUMBER) # compiler include paths INCLUDES=\ diff --git a/VortexEngine/src/Log/ErrorBlinker.cpp b/VortexEngine/src/Log/ErrorBlinker.cpp deleted file mode 100644 index bf6ea1f3f5..0000000000 --- a/VortexEngine/src/Log/ErrorBlinker.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "ErrorBlinker.h" - -#if VORTEX_ERROR_BLINK == 1 - -#include "../Leds/Leds.h" - -#include - -static uint16_t g_error = ERROR_NONE; - -void setError(uint16_t err) -{ - if (g_error != ERROR_NONE) { - // do not overwrite errors, the first error gets precedent - return; - } - g_error = err; -} - -uint16_t getError() -{ - return g_error; -} - -void blinkError() -{ - // this is so bad ugh it blinks r -> g -> b for the error code like - // error 231 is 2 reds, 3 greens, 1 blue - if (g_error == ERROR_NONE) { - return; - } - uint8_t errOnes = (g_error % 10); - uint8_t errTens = ((g_error - errOnes) % 100) / 10; - uint8_t errHunds = (g_error - (errTens + errOnes)) / 100; - Leds::setIndex(LED_1, RGBColor(40, 40, 40)); - const uint8_t msWait = 500; - for (uint8_t i = 0; i < errHunds; ++i) { - Leds::setIndex(LED_0, RGBColor(255, 0, 0)); Leds::update(); delay(msWait); - Leds::clearIndex(LED_0); Leds::update(); delay(msWait); - } - for (uint8_t i = 0; i < errTens; ++i) { - Leds::setIndex(LED_0, RGBColor(0, 255, 0)); Leds::update(); delay(msWait); - Leds::clearIndex(LED_0); Leds::update(); delay(msWait); - } - for (uint8_t i = 0; i < errOnes; ++i) { - Leds::setIndex(LED_0, RGBColor(0, 0, 255)); Leds::update(); delay(msWait); - Leds::clearIndex(LED_0); Leds::update(); delay(msWait); - } - delay(msWait); -} - -#endif diff --git a/VortexEngine/src/Log/ErrorBlinker.h b/VortexEngine/src/Log/ErrorBlinker.h deleted file mode 100644 index 164099c0e8..0000000000 --- a/VortexEngine/src/Log/ErrorBlinker.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include - -#include "../VortexConfig.h" - -// These error codes follow a pattern when blinked -// The hundreds column is the number of r blinks -// The tens column is the number of g blinks -// The ones column is the number of b blinks -// There is a gray space after each round of blinks -#define ERROR_NONE 0 - - // For example this would just be 'B' (1 blink) -#define ERROR_EXAMPLE1 1 - // this would be "R R G G G B" -#define ERROR_EXAMPLE2 231 - -#if VORTEX_ERROR_BLINK == 0 - -// normal builds don't do anything -#define FATAL_ERROR(err) - -#else - -// set an error code and blink it -#define FATAL_ERROR(err) setError(err); - -// set an error code -void setError(uint16_t err); -// fetch the current error code -uint16_t getError(); -// blink the current error -void blinkError(); - -#endif diff --git a/VortexEngine/src/Log/Log.h b/VortexEngine/src/Log/Log.h index 5977ec8442..52bb5f7786 100644 --- a/VortexEngine/src/Log/Log.h +++ b/VortexEngine/src/Log/Log.h @@ -5,10 +5,6 @@ #include "../VortexConfig.h" -// just self-inclode the error blinker so that anybody who includes log has -// access to the error blinker since it's only enabled in debug builds -#include "../Log/ErrorBlinker.h" - #if LOGGING_LEVEL > 0 #define INFO_LOG(msg) InfoMsg(msg) #define INFO_LOGF(msg, ...) InfoMsg(msg, __VA_ARGS__) diff --git a/VortexEngine/src/Modes/Modes.cpp b/VortexEngine/src/Modes/Modes.cpp index 7d6b41f1ae..35ccea1751 100644 --- a/VortexEngine/src/Modes/Modes.cpp +++ b/VortexEngine/src/Modes/Modes.cpp @@ -387,35 +387,12 @@ bool Modes::unserialize(ByteStream &modesBuffer) bool Modes::setDefaults() { clearModes(); -#if DEMO_ALL_PATTERNS == 1 - // RGB_RED, RGB_YELLOW, RGB_GREEN, RGB_CYAN, RGB_BLUE, RGB_PURPLE - PatternID default_start = PATTERN_FIRST; - PatternID default_end = PATTERN_LAST; - // add 65 randomized modes - for (int i = 0; i < 65; ++i) { - Mode tmpMode; - for (LedPos led = LED_FIRST; led < LED_COUNT; ++led) { - // create a random pattern ID from all patterns - PatternID randomPattern = (PatternID)random(PATTERN_SINGLE_FIRST, PATTERN_SINGLE_LAST); - Colorset randSet; - randSet.randomize(8); - tmpMode.setPatternAt(led, randomPattern, nullptr, &randSet); - } - // add another mode with the given pattern and colorset - if (!addMode(&tmpMode)) { - ERROR_LOG("Failed to add mode"); - // return false? - } - } - DEBUG_LOGF("Added default patterns %u through %u", default_start, default_end); -#else // add each default mode with each of the given colors for (uint8_t i = 0; i < num_default_modes; ++i) { const default_mode_entry &def = default_modes[i]; Colorset set(def.numColors, def.cols); addMode(def.patternID, nullptr, &set); } -#endif return true; } diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index 72654df7c5..9424aade08 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -7,19 +7,31 @@ // The engine major version indicates the state of the save file, // if any changes to the save format occur then the major version // must increment so that the savefiles will not be loaded +#ifndef VORTEX_VERSION_MAJOR #define VORTEX_VERSION_MAJOR 1 +#endif // A minor version simply indicates a bugfix or minor change that // will not effect the save files produces by the engine. This means // a savefile produced by 1.1 should be loadable by an engine on 1.2 // and vice versa. But an engine on 2.0 cannot share savefiles with // either of the engines on version 1.1 or 1.2 +#ifndef VORTEX_VERSION_MINOR #define VORTEX_VERSION_MINOR 1 +#endif + +// The build or patch number based on the major.minor version, this is +// set by the build system using the number of commits since last version +#ifndef VORTEX_BUILD_NUMBER +#define VORTEX_BUILD_NUMBER 0 +#endif // produces a number like 1.0 -#define VORTEX_VERSION_NUMBER VORTEX_VERSION_MAJOR.VORTEX_VERSION_MINOR +#ifndef VORTEX_VERSION_NUMBER +#define VORTEX_VERSION_NUMBER VORTEX_VERSION_MAJOR.VORTEX_VERSION_MINOR.VORTEX_BUILD_NUMBER +#endif -// produces a string like "1.0" +// produces a string like "1.1.0" #define ADD_QUOTES(str) #str #define EXPAND_AND_QUOTE(str) ADD_QUOTES(str) #define VORTEX_VERSION EXPAND_AND_QUOTE(VORTEX_VERSION_NUMBER) @@ -30,7 +42,7 @@ // the full name of this build for ex: // Vortex Engine v1.0 'Igneous' (built Tue Jan 31 19:03:55 2023) -#define VORTEX_FULL_NAME "Vortex Engine v" VORTEX_VERSION " '" VORTEX_NAME "' ( built " __TIMESTAMP__ ")" +#define VORTEX_FULL_NAME "Vortex Engine v" VORTEX_VERSION " '" VORTEX_NAME "' (built " __TIMESTAMP__ ")" // Vortex Slim // @@ -307,23 +319,6 @@ // =================================================================== // Boolean Configurations (0 or 1) -// Fill From Thumb -// -// The ring menu will fill from the thumb if this is present, otherwise -// it will fill from the pinkie. -// -// The logic is cleaner for fill from pinkie but fill from thumb is preferred -#define FILL_FROM_THUMB 1 - -// Demo All Patterns -// -// The default modes that are set on the gloveset will be dynamically -// generated with one mode per pattern in the patterns list -// -// This can be used to quickly demo all possible patterns, mostly useful -// for testing and development -#define DEMO_ALL_PATTERNS 0 - // Debug Allocations // // Tracks all memory allocations and logs them, useful for finding leaks @@ -349,25 +344,6 @@ // the final build? I'm not sure. #define VARIABLE_TICKRATE 0 -// Error Blinker System -// -// This toggles the vortex error blinker system, this system reports -// fatal errors as a series of blinks. If an error is encountered the -// chip will only blink out the error code from there forward. -// -// Note that enabling this system takes a non-negligible amount -// of space for all of the code, it really should only be used -// for debug settings or given tiers like logging level. -// -// This is mainly useful for tracking down issues on devices that don't -// have a serial connection like the attiny. Use FATAL_ERROR(code) to -// set the error code and then the device will blink out the error -// -// for ex: red red green blue blue blue is code 213 -// -// See Log/ErrorBlinker.h for details on the error codes -#define VORTEX_ERROR_BLINK 0 - // Fixed LED Count // // Do not allow the Mode loader to dynamically load however many modes @@ -592,11 +568,8 @@ #endif // VortexEditor -// When running in the test framework with demo all patterns enabled -// we should change the max patterns to the total pattern count because -// the test framework can handle the memory usage and we can't demo -// all the patterns without the increased limit -#if DEMO_ALL_PATTERNS == 1 || SERIALIZATION_TEST == 1 || COMPRESSION_TEST == 1 +// When running various tests lift the max mode limit and enable logging +#if SERIALIZATION_TEST == 1 || COMPRESSION_TEST == 1 #undef MAX_MODES #include "Patterns/Patterns.h" #define MAX_MODES 0