Skip to content

Commit ff36e8f

Browse files
committed
Merge branch 'chromadeck' into daniel/chromadeck/color-select-menu
2 parents 8745335 + 404c019 commit ff36e8f

7 files changed

Lines changed: 103 additions & 39 deletions

File tree

‎Makefile‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all install build upload clean
1+
.PHONY: all install build upload clean compute_version
22

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

13-
# Fetch tags, determine version numbers based on the latest tag, and slice off the branch suffix
14-
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)
15-
VORTEX_VERSION_MINOR ?= $(shell git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1 | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2)
16-
VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count HEAD)
17-
18-
# If no tags are found, default to 0.1.0
19-
VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0)
20-
VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1)
21-
VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0)
22-
23-
# Combine into a full version number
24-
VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER)
25-
2613
DEFINES=\
2714
-D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \
2815
-D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \
@@ -50,7 +37,7 @@ install:
5037
$(ARDUINO_CLI) core install esp32:esp32 --config-file $(CONFIG_FILE)
5138
$(ARDUINO_CLI) lib install FastLED
5239

53-
build:
40+
build: compute_version
5441
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(PROJECT_NAME) \
5542
--config-file $(CONFIG_FILE) \
5643
--build-path $(BUILD_PATH) \
@@ -67,3 +54,13 @@ core-list:
6754
clean:
6855
rm -rf $(BUILD_PATH)
6956

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

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,37 @@ This branch holds the master firmware that forms the foundation for all other br
2020

2121
### Desktop (Dynamic Desktop Library)
2222
![Desktop](https://github.com/StoneOrbits/VortexEngine/actions/workflows/desktop_build.yml/badge.svg?branch=desktop)
23+
![Desktop Version](https://img.shields.io/endpoint?url=https://vortex.community/downloads/json/desktop/library?badge=true)
2324
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.
2425

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

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

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

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

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

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

4956
To access a device's firmware, simply switch to its corresponding branch.

‎VortexEngine/VortexCLI/Makefile‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SUFFIXES:
33

44
# List all make targets which are not filenames
5-
.PHONY: all tests clean wasm
5+
.PHONY: all tests clean wasm compute_version
66

77
# compiler tool definitions
88
ifdef WASM
@@ -19,9 +19,16 @@ RANLIB=ranlib
1919

2020
CFLAGS=-O2 -g -Wall
2121

22+
# The branch/tag suffix for this device
23+
BRANCH_SUFFIX=c
24+
2225
# compiler defines
2326
DEFINES=\
24-
-D VORTEX_LIB
27+
-D VORTEX_LIB \
28+
-D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \
29+
-D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \
30+
-D VORTEX_BUILD_NUMBER=$(VORTEX_BUILD_NUMBER) \
31+
-D VORTEX_VERSION_NUMBER=$(VORTEX_VERSION_NUMBER)
2532

2633
# compiler include paths
2734
INCLUDES=\
@@ -107,8 +114,8 @@ wasm: FORCE
107114
env WASM=1 $(MAKE)
108115

109116
# target for vortex lib
110-
vortex: $(DEPS)
111-
$(CC) $(CFLAGS) $^ -o $@ $(LLIBS)
117+
vortex: compute_version $(DEPS)
118+
$(CC) $(CFLAGS) $(DEPS) -o $@ $(LLIBS)
112119

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

139+
# calculate the version number of the build
140+
compute_version:
141+
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1))
142+
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
143+
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2))
144+
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
145+
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
146+
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
147+
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
148+
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))
149+
132150
# Now include our target dependency files
133151
# the hyphen means ignore non-existent files
134152
-include $(DFILES)

‎VortexEngine/VortexLib/Makefile‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SUFFIXES:
33

44
# List all make targets which are not filenames
5-
.PHONY: all tests clean wasm
5+
.PHONY: all tests clean wasm compute_version
66

77
# compiler tool definitions
88
ifdef WASM
@@ -24,17 +24,8 @@ ifndef WASM
2424
CFLAGS += -g
2525
endif
2626

27-
# Determine the current version based on Git tags
28-
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)
29-
VORTEX_VERSION_MINOR ?= $(shell git tag --list | grep -E "^[[:digit:]]+\.[[:digit:]]+\$$" | sort -V | tail -n1 | cut -d. -f2)
30-
VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count HEAD)
31-
32-
# If no tags are found, default to 0.1.0
33-
VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0)
34-
VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1)
35-
VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0)
36-
37-
VORTEX_VERSION_NUMBER ?= $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER)
27+
# The branch/tag suffix for this device
28+
BRANCH_SUFFIX=c
3829

3930
# compiler defines
4031
DEFINES=\
@@ -132,11 +123,11 @@ wasm: FORCE
132123
env WASM=1 $(MAKE)
133124

134125
# target for vortex lib
135-
vortex.a: $(DEPS)
136-
$(AR) $@ $^
126+
vortex.a: compute_version $(DEPS)
127+
$(AR) $@ $(DEPS)
137128

138-
VortexLib.js: $(DEPS)
139-
$(CC) $(LDFLAGS) $^ -o $@ $(LLIBS)
129+
VortexLib.js: compute_version $(DEPS)
130+
$(CC) $(LDFLAGS) $(DEPS) -o $@ $(LLIBS)
140131

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

150+
# calculate the version number of the build
151+
compute_version:
152+
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1))
153+
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
154+
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2))
155+
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
156+
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
157+
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
158+
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
159+
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))
160+
159161
# Now include our target dependency files
160162
# the hyphen means ignore non-existent files
161163
-include $(DFILES)

‎VortexEngine/src/Modes/Modes.cpp‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,36 @@ bool Modes::setFlag(uint8_t flag, bool enable, bool save)
713713
m_globalFlags &= ~flag;
714714
}
715715
DEBUG_LOGF("Toggled instant on/off to %s", enable ? "on" : "off");
716-
return !save || saveHeader();
716+
if (!save) {
717+
// if save is not requested then just return here
718+
return true;
719+
}
720+
// otherwise need to update the global flags field of the save header in storage
721+
ByteStream headerBuffer;
722+
// read out the storage header so we can update the flag field
723+
if (!Storage::read(0, headerBuffer) || !headerBuffer.size()) {
724+
// if cannot read the save header then just save it normally
725+
return saveHeader();
726+
}
727+
// layout of the save header, this struct is never really used anywhere else
728+
// except here the actual layout of the save header is dictated by
729+
// saveHeader() and serializeSaveHeader()
730+
struct SaveHeader {
731+
uint8_t vMajor;
732+
uint8_t vMinor;
733+
uint8_t globalFlags;
734+
uint8_t brightness;
735+
uint8_t numModes;
736+
};
737+
// data cannot be NULL since size is non zero
738+
SaveHeader *pHeader = (SaveHeader *)headerBuffer.data();
739+
// update the global flags field in the header
740+
pHeader->globalFlags = m_globalFlags;
741+
// need to force the crc to recalc since we modified the data, just mark the
742+
// CRC as dirty and Storage::write() will re-calculate the CRC if it's dirty
743+
headerBuffer.setCRCDirty();
744+
// write the save header back to storage
745+
return Storage::write(0, headerBuffer);
717746
}
718747

719748
#ifdef VORTEX_LIB

‎VortexEngine/src/Serial/ByteStream.cpp‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ bool ByteStream::isCRCDirty() const
338338
return (m_pData && (m_pData->flags & BUFFER_FLAG_DIRTY) != 0);
339339
}
340340

341+
void ByteStream::setCRCDirty()
342+
{
343+
if (!m_pData) {
344+
return;
345+
}
346+
// set the dirty flag
347+
m_pData->flags |= BUFFER_FLAG_DIRTY;
348+
}
349+
341350
bool ByteStream::serialize8(uint8_t byte)
342351
{
343352
//DEBUG_LOGF("Serialize8(): %u", byte);
@@ -350,7 +359,7 @@ bool ByteStream::serialize8(uint8_t byte)
350359
// walk forward
351360
m_pData->size += sizeof(uint8_t);
352361
// dirty the crc
353-
m_pData->flags |= BUFFER_FLAG_DIRTY;
362+
setCRCDirty();
354363
return true;
355364
}
356365

@@ -366,7 +375,7 @@ bool ByteStream::serialize16(uint16_t bytes)
366375
// walk forward
367376
m_pData->size += sizeof(uint16_t);
368377
// dirty the crc
369-
m_pData->flags |= BUFFER_FLAG_DIRTY;
378+
setCRCDirty();
370379
return true;
371380
}
372381

@@ -382,7 +391,7 @@ bool ByteStream::serialize32(uint32_t bytes)
382391
// walk forward
383392
m_pData->size += sizeof(uint32_t);
384393
// dirty the crc
385-
m_pData->flags |= BUFFER_FLAG_DIRTY;
394+
setCRCDirty();
386395
return true;
387396
}
388397

‎VortexEngine/src/Serial/ByteStream.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class ByteStream
7676
// check whether the data in the buffer has changed since the
7777
// crc has been re-calculated, if it is dirty, call recalcCRC
7878
bool isCRCDirty() const;
79+
// mark the CRC as dirty (manually modified the buffer or something)
80+
void setCRCDirty();
7981

8082
// serialize a byte into the buffer
8183
bool serialize8(uint8_t byte);

0 commit comments

Comments
 (0)