Skip to content

Commit

Permalink
Merge branch 'chromadeck' into daniel/chromadeck/updi_start
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Sep 6, 2024
2 parents 78b3bca + 252d78e commit 3a3553e
Show file tree
Hide file tree
Showing 9 changed files with 379 additions and 66 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/chromadeck_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ jobs:
working-directory: VortexEngine/VortexLib

docs:
needs: [setup, test, embedded, wasm]
#todo: fix the depends to be setup, test, embedded, wasm
needs: [setup, test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/chromadeck'
steps:
Expand All @@ -143,14 +144,16 @@ jobs:
- name: Checkout doxygen-awesome
run: git clone https://github.com/jothepro/doxygen-awesome-css.git doxygen-awesome-css
- name: Generate Documentation
run: doxygen Doxyfile
- name: Commit and Push Documentation
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add docs
git commit -m "Update Doxygen documentation"
git push -f origin HEAD:chromadeck-docs
mkdir -p docs/chromadeck
doxygen Doxyfile
echo "Listing contents of docs/chromadeck:"
ls -R docs/chromadeck || echo "No files found in docs/chromadeck"
- name: Upload Doxygen Documentation as Artifact
uses: actions/upload-artifact@v3
with:
name: doxygen-docs-chromadeck
path: docs/chromadeck

deploy:
needs: [setup, test, embedded, wasm, docs]
Expand Down
4 changes: 2 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = docs
OUTPUT_DIRECTORY = docs/chromadeck

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -864,7 +864,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = VortexEngine/src/
INPUT = VortexEngine/src/ VortexEngine/VortexLib/ VortexEngine/VortexCLI/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
20 changes: 10 additions & 10 deletions VortexEngine/src/Colors/ColorConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@
#define RGB_CYAN8 (uint32_t)0x00E0E0 // 0 224 224
#define RGB_CYAN9 (uint32_t)0x00FCFC // 0 252 252

#define RGB_PURPLE0 (uint32_t)0x090310 // 9 3 16
#define RGB_PURPLE1 (uint32_t)0x1C001C // 28 0 28
#define RGB_PURPLE2 (uint32_t)0x380038 // 56 0 56
#define RGB_PURPLE3 (uint32_t)0x540054 // 84 0 84
#define RGB_PURPLE4 (uint32_t)0x700070 // 112 0 112
#define RGB_PURPLE5 (uint32_t)0x8C008C // 140 0 140
#define RGB_PURPLE6 (uint32_t)0xA800A8 // 168 0 168
#define RGB_PURPLE7 (uint32_t)0xC400C4 // 196 0 196
#define RGB_PURPLE8 (uint32_t)0xE000E0 // 224 0 224
#define RGB_PURPLE9 (uint32_t)0xFC00FC // 252 0 252
#define RGB_MAGENTA0 (uint32_t)0x100010 // 16 0 16
#define RGB_MAGENTA1 (uint32_t)0x1C001C // 28 0 28
#define RGB_MAGENTA2 (uint32_t)0x380038 // 56 0 56
#define RGB_MAGENTA3 (uint32_t)0x540054 // 84 0 84
#define RGB_MAGENTA4 (uint32_t)0x700070 // 112 0 112
#define RGB_MAGENTA5 (uint32_t)0x8C008C // 140 0 140
#define RGB_MAGENTA6 (uint32_t)0xA800A8 // 168 0 168
#define RGB_MAGENTA7 (uint32_t)0xC400C4 // 196 0 196
#define RGB_MAGENTA8 (uint32_t)0xE000E0 // 224 0 224
#define RGB_MAGENTA9 (uint32_t)0xFC00FC // 252 0 252

#define RGB_ORANGE0 (uint32_t)0x100800 // 16 8 0
#define RGB_ORANGE1 (uint32_t)0x1C0E00 // 28 14 0
Expand Down
8 changes: 3 additions & 5 deletions VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,14 @@ void Menu::showBulbSelection()
LedPos pos = (LedPos)((Time::getCurtime() / 30) % LED_COUNT);
for (int dots = 0; dots < 4; ++dots) {
LedPos dotPos = (LedPos)((pos + (dots * (LED_COUNT / 4))) % LED_COUNT);
Leds::blinkIndexOffset(dotPos, dotPos * 10, 50, 500, m_menuColor);
Leds::blinkIndexOffset(dotPos, dotPos * 10, 50, 500, RGB_MAGENTA1);
}
} else {
Leds::setMap(m_targetLeds, RGB_ORANGE);
Leds::blinkMap(ledPermutations[m_ledSelection], BULB_SELECT_OFF_MS, BULB_SELECT_ON_MS, m_menuColor);
Leds::blinkMap(ledPermutations[m_ledSelection], BULB_SELECT_OFF_MS, BULB_SELECT_ON_MS, RGB_MAGENTA1);
}
// blink when selecting
Menus::showSelection(RGBColor(m_menuColor.red << 3,
m_menuColor.green << 3,
m_menuColor.blue << 3));
Menus::showSelection(RGB_MAGENTA1);
}

void Menu::showExit()
Expand Down
229 changes: 228 additions & 1 deletion VortexEngine/src/Menus/MenuList/EditorConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
EditorConnection::EditorConnection(const RGBColor &col, bool advanced) :
Menu(col, advanced),
m_state(STATE_DISCONNECTED),
m_timeOutStartTime(0)
m_timeOutStartTime(0),
m_chromaModeIdx(0),
m_allowReset(true),
m_previousModeIndex(0),
m_numModesToReceive(0)
{
}

Expand All @@ -41,6 +45,39 @@ bool EditorConnection::init()
return true;
}

bool EditorConnection::receiveMessage(const char *message)
{
size_t len = strlen(message);
uint8_t byte = 0;
// wait for the editor to ack the idle
if (m_receiveBuffer.size() < len) {
return false;
}
if (memcmp(m_receiveBuffer.frontUnserializer(), message, len) != 0) {
return false;
}
for (size_t i = 0; i < len; ++i) {
if (!m_receiveBuffer.unserialize8(&byte)) {
return false;
}
}
// if everything was read out, reset
if (m_receiveBuffer.unserializerAtEnd()) {
m_receiveBuffer.clear();
}
// we have now received at least one command, do not allow resetting
m_allowReset = false;
return true;
}

void EditorConnection::clearDemo()
{
Colorset set(RGB_WHITE0);
PatternArgs args(1, 0, 0);
m_previewMode.setPattern(PATTERN_STROBE, LED_ALL, &args, &set);
m_previewMode.init();
}

Menu::MenuAction EditorConnection::run()
{
MenuAction result = Menu::run();
Expand Down Expand Up @@ -74,6 +111,11 @@ Menu::MenuAction EditorConnection::run()
case STATE_IDLE:
// parse the receive buffer for any commands from the editor
handleCommand();
// watch for disconnects
if (!SerialComs::isConnected()) {
Leds::holdAll(RGB_GREEN);
leaveMenu(true);
}
break;
case STATE_PULL_MODES:
// editor requested pull modes, send the modes
Expand Down Expand Up @@ -259,6 +301,89 @@ Menu::MenuAction EditorConnection::run()
SerialComs::write(EDITOR_VERB_PUSH_CHROMA_MODE_ACK);
m_state = STATE_IDLE;
break;
case STATE_PULL_EACH_MODE:
// editor requested pull modes, send the modes
m_receiveBuffer.clear();
sendModeCount();
m_state = STATE_PULL_EACH_MODE_COUNT;
break;
case STATE_PULL_EACH_MODE_COUNT:
if (receiveMessage(EDITOR_VERB_PULL_EACH_MODE_ACK)) {
if (Modes::numModes() == 0) {
m_state = STATE_PULL_EACH_MODE_DONE;
} else {
m_previousModeIndex = Modes::curModeIndex();
m_state = STATE_PULL_EACH_MODE_SEND;
}
}
break;
case STATE_PULL_EACH_MODE_SEND:
m_receiveBuffer.clear();
// send the current mode
sendCurMode();
// wait for the ack
m_state = STATE_PULL_EACH_MODE_WAIT;
break;
case STATE_PULL_EACH_MODE_WAIT:
// recive the ack from the editor to send next mode
if (receiveMessage(EDITOR_VERB_PULL_EACH_MODE_ACK)) {
// if there is still more modes
if (Modes::curModeIndex() < (Modes::numModes() - 1)) {
// then iterate to the next mode and send
Modes::nextMode();
m_state = STATE_PULL_EACH_MODE_SEND;
} else {
// otherwise done sending modes
m_state = STATE_PULL_EACH_MODE_DONE;
}
}
break;
case STATE_PULL_EACH_MODE_DONE:
m_receiveBuffer.clear();
// send our acknowledgement that the modes were sent
SerialComs::write(EDITOR_VERB_PULL_EACH_MODE_DONE);
// switch back to the previous mode
Modes::setCurMode(m_previousModeIndex);
// go idle
m_state = STATE_IDLE;
break;
case STATE_PUSH_EACH_MODE:
// editor requested to push modes, find out how many
m_receiveBuffer.clear();
// ack the command and wait for the amount of modes
SerialComs::write(EDITOR_VERB_PUSH_EACH_MODE_ACK);
m_state = STATE_PUSH_EACH_MODE_COUNT;
break;
case STATE_PUSH_EACH_MODE_COUNT:
if (receiveModeCount()) {
// clear modes and start receiving
Modes::clearModes();
// write out an ack
m_receiveBuffer.clear();
SerialComs::write(EDITOR_VERB_PUSH_EACH_MODE_ACK);
// ready to receive a mode
m_state = STATE_PUSH_EACH_MODE_RECEIVE;
}
break;
case STATE_PUSH_EACH_MODE_RECEIVE:
// receive the modes into the receive buffer
if (receiveMode()) {
m_receiveBuffer.clear();
SerialComs::write(EDITOR_VERB_PUSH_EACH_MODE_ACK);
if (m_numModesToReceive > 0) {
m_numModesToReceive--;
}
if (!m_numModesToReceive) {
// success modes were received send the done
m_state = STATE_PUSH_EACH_MODE_DONE;
}
}
break;
case STATE_PUSH_EACH_MODE_DONE:
// did originally receive/send a DONE message here but it wasn't working
// on lightshow.lol so just skip to IDLE
m_state = STATE_IDLE;
break;
}
return MENU_CONTINUE;
}
Expand Down Expand Up @@ -320,10 +445,16 @@ bool EditorConnection::pushModeChromalink()

void EditorConnection::onShortClick()
{
// if the device has received any commands do not reset!
if (!m_allowReset) {
return;
}
// reset, this won't actually disconnect the com port
m_state = STATE_DISCONNECTED;
// clear the demo
clearDemo();
// sent a reset, do not allow another
m_allowReset = false;
}

void EditorConnection::onLongClick()
Expand All @@ -348,6 +479,10 @@ void EditorConnection::handleCommand()
m_state = STATE_DEMO_MODE;
} else if (receiveMessage(EDITOR_VERB_CLEAR_DEMO)) {
m_state = STATE_CLEAR_DEMO;
} else if (receiveMessage(EDITOR_VERB_PULL_EACH_MODE)) {
m_state = STATE_PULL_EACH_MODE;
} else if (receiveMessage(EDITOR_VERB_PUSH_EACH_MODE)) {
m_state = STATE_PUSH_EACH_MODE;
} else if (receiveMessage(EDITOR_VERB_TRANSMIT_VL)) {
sendCurModeVL();
} else if (receiveMessage(EDITOR_VERB_LISTEN_VL)) {
Expand Down Expand Up @@ -394,6 +529,28 @@ void EditorConnection::sendModes()
SerialComs::write(modesBuffer);
}

void EditorConnection::sendModeCount()
{
ByteStream buffer;
buffer.serialize8(Modes::numModes());
SerialComs::write(buffer);
}

void EditorConnection::sendCurMode()
{
ByteStream modeBuffer;
Mode *cur = Modes::curMode();
if (!cur) {
// ??
return;
}
if (!cur->saveToBuffer(modeBuffer)) {
// ??
return;
}
SerialComs::write(modeBuffer);
}

bool EditorConnection::receiveBuffer(ByteStream &buffer)
{
// need at least the buffer size first
Expand Down Expand Up @@ -436,6 +593,76 @@ bool EditorConnection::receiveModes()
return true;
}

bool EditorConnection::receiveModeCount()
{
// need at least the buffer size first
uint32_t size = 0;
if (m_receiveBuffer.size() < sizeof(size)) {
// wait, not enough data available yet
return false;
}
// grab the size out of the start
m_receiveBuffer.resetUnserializer();
size = m_receiveBuffer.peek32();
if (m_receiveBuffer.size() < (size + sizeof(size))) {
// don't unserialize yet, not ready
return false;
}
// okay unserialize now, first unserialize the size
if (!m_receiveBuffer.unserialize32(&size)) {
return false;
}
// create a new ByteStream that will hold the full buffer of data
ByteStream buf(m_receiveBuffer.rawSize());
// then copy everything from the receive buffer into the rawdata
// which is going to overwrite the crc/size/flags of the ByteStream
memcpy(buf.rawData(), m_receiveBuffer.data() + sizeof(size),
m_receiveBuffer.size() - sizeof(size));
// unserialize the mode count
if (!buf.unserialize8(&m_numModesToReceive)) {
return false;
}
if (m_numModesToReceive > MAX_MODES) {
return false;
}
// good mode count
return true;
}

bool EditorConnection::receiveMode()
{
// need at least the buffer size first
uint32_t size = 0;
if (m_receiveBuffer.size() < sizeof(size)) {
// wait, not enough data available yet
return false;
}
// grab the size out of the start
m_receiveBuffer.resetUnserializer();
size = m_receiveBuffer.peek32();
if (m_receiveBuffer.size() < (size + sizeof(size))) {
// don't unserialize yet, not ready
return false;
}
// okay unserialize now, first unserialize the size
if (!m_receiveBuffer.unserialize32(&size)) {
return false;
}
// create a new ByteStream that will hold the full buffer of data
ByteStream buf(m_receiveBuffer.rawSize());
// then copy everything from the receive buffer into the rawdata
// which is going to overwrite the crc/size/flags of the ByteStream
memcpy(buf.rawData(), m_receiveBuffer.data() + sizeof(size),
m_receiveBuffer.size() - sizeof(size));
// clear the receive buffer
m_receiveBuffer.clear();
// unserialize the mode into the demo mode
if (!Modes::addModeFromBuffer(buf)) {
// error
}
return true;
}

bool EditorConnection::receiveDemoMode()
{
// create a new ByteStream that will hold the full buffer of data
Expand Down
Loading

0 comments on commit 3a3553e

Please sign in to comment.