Skip to content

Commit

Permalink
Merge branch 'chromadeck' into daniel/chromadeck/color-select-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Nov 22, 2024
2 parents 8745335 + 404c019 commit ff36e8f
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 39 deletions.
27 changes: 12 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all install build upload clean
.PHONY: all install build upload clean compute_version

ARDUINO_CLI = ./bin/arduino-cli --verbose
BOARD = esp32:esp32:XIAO_ESP32C3
Expand All @@ -10,19 +10,6 @@ CONFIG_FILE = $(HOME)/.arduino15/arduino-cli.yaml
# The branch/tag suffix for this device
BRANCH_SUFFIX=c

# Fetch tags, determine version numbers based on the latest tag, and slice off the branch suffix
VORTEX_VERSION_MAJOR ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1 | cut -d. -f1)
VORTEX_VERSION_MINOR ?= $(shell git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1 | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2)
VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count HEAD)

# If no tags are found, default to 0.1.0
VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0)
VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1)
VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0)

# Combine into a full version number
VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER)

DEFINES=\
-D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \
-D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \
Expand Down Expand Up @@ -50,7 +37,7 @@ install:
$(ARDUINO_CLI) core install esp32:esp32 --config-file $(CONFIG_FILE)
$(ARDUINO_CLI) lib install FastLED

build:
build: compute_version
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(PROJECT_NAME) \
--config-file $(CONFIG_FILE) \
--build-path $(BUILD_PATH) \
Expand All @@ -67,3 +54,13 @@ core-list:
clean:
rm -rf $(BUILD_PATH)

# calculate the version number of the build
compute_version:
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1))
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2))
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,37 @@ This branch holds the master firmware that forms the foundation for all other br

### Desktop (Dynamic Desktop Library)
![Desktop](https://github.com/StoneOrbits/VortexEngine/actions/workflows/desktop_build.yml/badge.svg?branch=desktop)
![Desktop Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/desktop/library?badge=true)
This is a sophisticated enhancement of the core to turn Vortex into a powerful desktop library that can be used to design various desktop applications like the Vortex Editor.

### Orbit (Vortex Classic Orbit)
![Orbit](https://github.com/StoneOrbits/VortexEngine/actions/workflows/orbit_build.yml/badge.svg?branch=orbit)
![Orbit Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/orbit/firmware?badge=true)
The firmware specifically designed for the Vortex Classic Orbit resides here.

### Handle (Vortex Omega Handles)
![Handle](https://github.com/StoneOrbits/VortexEngine/actions/workflows/handle_build.yml/badge.svg?branch=handle)
![Handle Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/handle/firmware?badge=true)
This branch hosts the firmware designed for the Vortex Omega Handles.

### Gloves (Vortex Wired Gloveset)
![Gloves](https://github.com/StoneOrbits/VortexEngine/actions/workflows/gloves_build.yml/badge.svg?branch=gloves)
![Gloves Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/gloves/firmware?badge=true)
Here, you'll find the firmware for the Vortex Wired Gloveset.

### Duo (Vortex Duo Modular Chip)
![Duo](https://github.com/StoneOrbits/VortexEngine/actions/workflows/duo_build.yml/badge.svg?branch=duo)
![Duo Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/duo/firmware?badge=true)
This branch contains the firmware for the Vortex Duo Modular Chip.

### Chromadeck (Vortex Chromadeck Mode Bank)
![Chromadeck](https://github.com/StoneOrbits/VortexEngine/actions/workflows/chromadeck_build.yml/badge.svg?branch=chromadeck)
![Chromadeck Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/chromadeck/firmware?badge=true)
This branch contains the firmware for the Vortex Chromadeck dynamic storage and transfer tool.

### Spark (Spark Orbit and Handle)
![Spark](https://github.com/StoneOrbits/VortexEngine/actions/workflows/spark_build.yml/badge.svg?branch=spark)
![Spark Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/spark/firmware?badge=true)
This branch contains the firmware for the Vortex Spark firmware, this powers multiple devices: the Spark Orbit and Spark Handle.

To access a device's firmware, simply switch to its corresponding branch.
26 changes: 22 additions & 4 deletions VortexEngine/VortexCLI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SUFFIXES:

# List all make targets which are not filenames
.PHONY: all tests clean wasm
.PHONY: all tests clean wasm compute_version

# compiler tool definitions
ifdef WASM
Expand All @@ -19,9 +19,16 @@ RANLIB=ranlib

CFLAGS=-O2 -g -Wall

# The branch/tag suffix for this device
BRANCH_SUFFIX=c

# 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=\
Expand Down Expand Up @@ -107,8 +114,8 @@ wasm: FORCE
env WASM=1 $(MAKE)

# target for vortex lib
vortex: $(DEPS)
$(CC) $(CFLAGS) $^ -o $@ $(LLIBS)
vortex: compute_version $(DEPS)
$(CC) $(CFLAGS) $(DEPS) -o $@ $(LLIBS)

# catch-all make target to generate .o and .d files
%.o: %.cpp
Expand All @@ -129,6 +136,17 @@ clean:
@$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) vortex.wasm *.txt FlashStorage.flash
$(MAKE) -C ../VortexLib clean

# calculate the version number of the build
compute_version:
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1))
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2))
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))

# Now include our target dependency files
# the hyphen means ignore non-existent files
-include $(DFILES)
34 changes: 18 additions & 16 deletions VortexEngine/VortexLib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SUFFIXES:

# List all make targets which are not filenames
.PHONY: all tests clean wasm
.PHONY: all tests clean wasm compute_version

# compiler tool definitions
ifdef WASM
Expand All @@ -24,17 +24,8 @@ ifndef WASM
CFLAGS += -g
endif

# Determine the current version based on Git tags
VORTEX_VERSION_MAJOR ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list | grep -E "^[[:digit:]]+\.[[:digit:]]+\$$" | sort -V | tail -n1 | cut -d. -f1)
VORTEX_VERSION_MINOR ?= $(shell git tag --list | grep -E "^[[:digit:]]+\.[[:digit:]]+\$$" | sort -V | tail -n1 | cut -d. -f2)
VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count HEAD)

# If no tags are found, default to 0.1.0
VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0)
VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1)
VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0)

VORTEX_VERSION_NUMBER ?= $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER)
# The branch/tag suffix for this device
BRANCH_SUFFIX=c

# compiler defines
DEFINES=\
Expand Down Expand Up @@ -132,11 +123,11 @@ wasm: FORCE
env WASM=1 $(MAKE)

# target for vortex lib
vortex.a: $(DEPS)
$(AR) $@ $^
vortex.a: compute_version $(DEPS)
$(AR) $@ $(DEPS)

VortexLib.js: $(DEPS)
$(CC) $(LDFLAGS) $^ -o $@ $(LLIBS)
VortexLib.js: compute_version $(DEPS)
$(CC) $(LDFLAGS) $(DEPS) -o $@ $(LLIBS)

# catch-all make target to generate .o and .d files
%.o: %.cpp
Expand All @@ -156,6 +147,17 @@ FORCE:
clean:
@$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) VortexLib.js vortex.wasm

# calculate the version number of the build
compute_version:
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1))
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2))
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))

# Now include our target dependency files
# the hyphen means ignore non-existent files
-include $(DFILES)
31 changes: 30 additions & 1 deletion VortexEngine/src/Modes/Modes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,36 @@ bool Modes::setFlag(uint8_t flag, bool enable, bool save)
m_globalFlags &= ~flag;
}
DEBUG_LOGF("Toggled instant on/off to %s", enable ? "on" : "off");
return !save || saveHeader();
if (!save) {
// if save is not requested then just return here
return true;
}
// otherwise need to update the global flags field of the save header in storage
ByteStream headerBuffer;
// read out the storage header so we can update the flag field
if (!Storage::read(0, headerBuffer) || !headerBuffer.size()) {
// if cannot read the save header then just save it normally
return saveHeader();
}
// layout of the save header, this struct is never really used anywhere else
// except here the actual layout of the save header is dictated by
// saveHeader() and serializeSaveHeader()
struct SaveHeader {
uint8_t vMajor;
uint8_t vMinor;
uint8_t globalFlags;
uint8_t brightness;
uint8_t numModes;
};
// data cannot be NULL since size is non zero
SaveHeader *pHeader = (SaveHeader *)headerBuffer.data();
// update the global flags field in the header
pHeader->globalFlags = m_globalFlags;
// need to force the crc to recalc since we modified the data, just mark the
// CRC as dirty and Storage::write() will re-calculate the CRC if it's dirty
headerBuffer.setCRCDirty();
// write the save header back to storage
return Storage::write(0, headerBuffer);
}

#ifdef VORTEX_LIB
Expand Down
15 changes: 12 additions & 3 deletions VortexEngine/src/Serial/ByteStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ bool ByteStream::isCRCDirty() const
return (m_pData && (m_pData->flags & BUFFER_FLAG_DIRTY) != 0);
}

void ByteStream::setCRCDirty()
{
if (!m_pData) {
return;
}
// set the dirty flag
m_pData->flags |= BUFFER_FLAG_DIRTY;
}

bool ByteStream::serialize8(uint8_t byte)
{
//DEBUG_LOGF("Serialize8(): %u", byte);
Expand All @@ -350,7 +359,7 @@ bool ByteStream::serialize8(uint8_t byte)
// walk forward
m_pData->size += sizeof(uint8_t);
// dirty the crc
m_pData->flags |= BUFFER_FLAG_DIRTY;
setCRCDirty();
return true;
}

Expand All @@ -366,7 +375,7 @@ bool ByteStream::serialize16(uint16_t bytes)
// walk forward
m_pData->size += sizeof(uint16_t);
// dirty the crc
m_pData->flags |= BUFFER_FLAG_DIRTY;
setCRCDirty();
return true;
}

Expand All @@ -382,7 +391,7 @@ bool ByteStream::serialize32(uint32_t bytes)
// walk forward
m_pData->size += sizeof(uint32_t);
// dirty the crc
m_pData->flags |= BUFFER_FLAG_DIRTY;
setCRCDirty();
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions VortexEngine/src/Serial/ByteStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class ByteStream
// check whether the data in the buffer has changed since the
// crc has been re-calculated, if it is dirty, call recalcCRC
bool isCRCDirty() const;
// mark the CRC as dirty (manually modified the buffer or something)
void setCRCDirty();

// serialize a byte into the buffer
bool serialize8(uint8_t byte);
Expand Down

0 comments on commit ff36e8f

Please sign in to comment.