diff --git a/VortexEngine/src/Leds/LedTypes.h b/VortexEngine/src/Leds/LedTypes.h index 9a71f3a000..6239a40287 100644 --- a/VortexEngine/src/Leds/LedTypes.h +++ b/VortexEngine/src/Leds/LedTypes.h @@ -222,13 +222,27 @@ inline LedPos ledmapGetNextLed(LedMap map, LedPos pos) #define MAP_LINE_4 (MAP_LED(LED_3) | MAP_LED(LED_13) | MAP_LED(LED_18) | MAP_LED(LED_8)) #define MAP_LINE_5 (MAP_LED(LED_4) | MAP_LED(LED_14) | MAP_LED(LED_19) | MAP_LED(LED_9)) -//Chromadeck bitmap #define MAP_OPPOSITES_1 (MAP_LED(LED_0) | MAP_LED(LED_5) | MAP_LED(LED_10) | MAP_LED(LED_15)) #define MAP_OPPOSITES_2 (MAP_LED(LED_1) | MAP_LED(LED_6) | MAP_LED(LED_11) | MAP_LED(LED_16)) #define MAP_OPPOSITES_3 (MAP_LED(LED_2) | MAP_LED(LED_7) | MAP_LED(LED_12) | MAP_LED(LED_17)) #define MAP_OPPOSITES_4 (MAP_LED(LED_3) | MAP_LED(LED_8) | MAP_LED(LED_13) | MAP_LED(LED_18)) #define MAP_OPPOSITES_5 (MAP_LED(LED_4) | MAP_LED(LED_9) | MAP_LED(LED_14) | MAP_LED(LED_19)) +// radial led maps around the chromadeck +#define MAP_RADIAL_OUTER(n) (MAP_LED(LED_0 + ((n) % LED_10))) +#define MAP_RADIAL_INNER(n) (MAP_LED(LED_10 + ((n) % LED_10))) +#define MAP_RADIAL(n) (MAP_RADIAL_INNER(n) | MAP_RADIAL_OUTER(n)) +#define MAP_RADIAL_0 MAP_RADIAL(0) +#define MAP_RADIAL_1 MAP_RADIAL(1) +#define MAP_RADIAL_2 MAP_RADIAL(2) +#define MAP_RADIAL_3 MAP_RADIAL(3) +#define MAP_RADIAL_4 MAP_RADIAL(4) +#define MAP_RADIAL_5 MAP_RADIAL(5) +#define MAP_RADIAL_6 MAP_RADIAL(6) +#define MAP_RADIAL_7 MAP_RADIAL(7) +#define MAP_RADIAL_8 MAP_RADIAL(8) +#define MAP_RADIAL_9 MAP_RADIAL(9) + // set a single led inline void ledmapSetLed(LedMap &map, LedPos pos) { diff --git a/VortexEngine/src/Leds/Leds.cpp b/VortexEngine/src/Leds/Leds.cpp index 43b92a975b..47f4ff4581 100644 --- a/VortexEngine/src/Leds/Leds.cpp +++ b/VortexEngine/src/Leds/Leds.cpp @@ -88,6 +88,16 @@ void Leds::setRadials(Radial first, Radial last, RGBColor col) } } +void Leds::setRadialProgress(uint32_t progress, uint32_t total, RGBColor col) +{ + HSVColor hsvCol = col; + float ratio = (float)(progress * 100.0) / (float)(total * 100.0); + Radial last = (Radial)((ratio + 0.05) * RADIAL_COUNT); + uint32_t variance = Time::getCurtime() / 10; + uint32_t magnitude = 10; + setRadials(RADIAL_0, last, col); +} + void Leds::setRangeEvens(Pair first, Pair last, RGBColor col) { for (Pair pos = first; pos <= last; pos++) { diff --git a/VortexEngine/src/Leds/Leds.h b/VortexEngine/src/Leds/Leds.h index 3eecd1b328..c2ed97fe8c 100644 --- a/VortexEngine/src/Leds/Leds.h +++ b/VortexEngine/src/Leds/Leds.h @@ -41,6 +41,9 @@ class Leds static void setRadial(Radial radial, RGBColor col); static void setRadials(Radial first, Radial last, RGBColor col); + // draw a progress meter based on a ratio of progress to total + static void setRadialProgress(uint32_t progress, uint32_t total, RGBColor col); + // Turn off both LEDs on a pair, these are appropriate for use in internal pattern logic static void clearRadial(Radial radial) { setRadial(radial, RGB_OFF); } static void clearRadials(Radial first, Radial last) { setRadials(first, last, RGB_OFF); } diff --git a/VortexEngine/src/Menus/MenuList/ColorSelect.cpp b/VortexEngine/src/Menus/MenuList/ColorSelect.cpp index e1ce189e96..780aa4d06d 100644 --- a/VortexEngine/src/Menus/MenuList/ColorSelect.cpp +++ b/VortexEngine/src/Menus/MenuList/ColorSelect.cpp @@ -180,31 +180,52 @@ void ColorSelect::onLongClickM() void ColorSelect::showSlotSelection() { - uint8_t exitIndex = m_colorset.numColors(); - uint32_t holdDur = g_pButtonM->holdDuration(); - bool withinNumColors = m_curSelection < exitIndex; - bool holdDurationCheck = g_pButtonM->isPressed() && holdDur >= DELETE_THRESHOLD_TICKS; - bool holdDurationModCheck = (holdDur % (DELETE_CYCLE_TICKS * 2)) > DELETE_CYCLE_TICKS; - const RGBColor &col = m_colorset[m_curSelection]; - if (withinNumColors && holdDurationCheck && holdDurationModCheck) { - // breath red for delete slot - Leds::breatheIndex(LED_ALL, 0, holdDur); - } else if (withinNumColors) { - if (col.empty()) { - Leds::setAll(RGB_WHITE0); - } - // blink the selected slot color - Leds::blinkAll(150, 650, col); - } else if (exitIndex < MAX_COLOR_SLOTS) { - if (m_curSelection == exitIndex) { - // blink both leds and blink faster to indicate 'add' new color - Leds::blinkAll(100, 150, RGB_WHITE2); + // Render the colors on radial indices 0-7 + for (uint8_t i = 0; i < 8; ++i) { + RGBColor col; + if (m_colorset.numColors() <= i) { + Leds::setMap(MAP_RADIAL_INNER(i), RGB_WHITE0); + //Leds::blinkMap(MAP_RADIAL(i + 8)); + } else { + Leds::setMap(MAP_RADIAL_OUTER(i), m_colorset.get(i)); + Leds::setMap(MAP_RADIAL_INNER(i), RGB_WHITE2); } - exitIndex++; - } - if (m_curSelection == exitIndex) { - showFullSet(50, 100); } + + // Radial index 8: Exit + Leds::setMap(MAP_RADIAL_INNER(8), RGB_WHITE1); + Leds::setMap(MAP_RADIAL_OUTER(8), RGB_RED3); + + //Leds::setMap(MAP_RADIAL_INNER(7), HSVColor(Time::getCurtime() / 10, 255, 255)); + //Leds::setMap(MAP_RADIAL_OUTER(7), RGB_WHITE4); + //Leds::blinkMap(MAP_RADIAL(6)); + + + //uint8_t exitIndex = m_colorset.numColors(); + //uint32_t holdDur = g_pButtonM->holdDuration(); + //bool withinNumColors = m_curSelection < exitIndex; + //bool holdDurationCheck = g_pButtonM->isPressed() && holdDur >= DELETE_THRESHOLD_TICKS; + //bool holdDurationModCheck = (holdDur % (DELETE_CYCLE_TICKS * 2)) > DELETE_CYCLE_TICKS; + //const RGBColor &col = m_colorset[m_curSelection]; + //if (withinNumColors && holdDurationCheck && holdDurationModCheck) { + // // breath red for delete slot + // Leds::breatheIndex(LED_ALL, 0, holdDur); + //} else if (withinNumColors) { + // if (col.empty()) { + // Leds::setAll(RGB_WHITE0); + // } + // // blink the selected slot color + // Leds::blinkAll(150, 650, col); + //} else if (exitIndex < MAX_COLOR_SLOTS) { + // if (m_curSelection == exitIndex) { + // // blink both leds and blink faster to indicate 'add' new color + // Leds::blinkAll(100, 150, RGB_WHITE2); + // } + // exitIndex++; + //} + //if (m_curSelection == exitIndex) { + // showFullSet(50, 100); + //} } void ColorSelect::showSelection(ColorSelectState mode) diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp index 1bdf60df12..49a2a80139 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp @@ -19,6 +19,7 @@ #include #define FIRMWARE_TRANSFER_BLOCK_SIZE 512 +#define NUM_DUO_MODES 9 EditorConnection::EditorConnection(const RGBColor &col, bool advanced) : Menu(col, advanced), @@ -31,7 +32,8 @@ EditorConnection::EditorConnection(const RGBColor &col, bool advanced) : m_curStep(0), m_firmwareSize(0), m_firmwareOffset(0), - m_backupModes(true) + m_backupModes(true), + m_backupModeNum(0) { } @@ -550,15 +552,14 @@ bool EditorConnection::pullModeChromalink() // try to receive the mode index uint8_t modeIdx = 0; bool success = false; - // only 9 modes on duo, maybe this should be a macro or something - if (receiveModeIdx(modeIdx) && modeIdx < 9) { + if (receiveModeIdx(modeIdx) && modeIdx < NUM_DUO_MODES) { ByteStream modeBuffer; // same doesn't matter if this fails still need to send success = UPDI::readMode(modeIdx, modeBuffer); UPDI::reset(); UPDI::disable(); - // lol just use the mode index as the radial to set - Leds::setRadial((Radial)modeIdx, success ? RGB_GREEN4 : RGB_RED4); + // just use the mode index as the radial progress + Leds::setRadialProgress(modeIdx, NUM_DUO_MODES, success ? RGB_GREEN4 : RGB_RED4); if (!success) { // just send back a 0 if it failed modeBuffer.init(1); @@ -573,8 +574,8 @@ bool EditorConnection::pullModeChromalink() bool EditorConnection::pushModeChromalink() { - // lol just use the mode index as the radial to set - Leds::setRadials(RADIAL_0, (Radial)m_chromaModeIdx, RGB_GREEN4); + // just use the mode index as the radial progress + Leds::setRadialProgress(m_chromaModeIdx + 1, NUM_DUO_MODES, RGB_GREEN4); // wait for the mode then write it via updi ByteStream buf; if (!receiveBuffer(buf)) { @@ -591,7 +592,7 @@ bool EditorConnection::pushModeChromalink() bool EditorConnection::backupDuoModes() { - if (m_backupModeNum == 9) { + if (m_backupModeNum == NUM_DUO_MODES) { // reset counter for the restore step later m_backupModeNum = 0; // done @@ -627,16 +628,16 @@ bool EditorConnection::backupDuoModes() if (useDefault) { m_modeBackups[m_backupModeNum].init(duo_default_sizes[m_backupModeNum], duo_default_modes[m_backupModeNum]); } - Leds::setRadials(RADIAL_0, (Radial)m_backupModeNum, useDefault ? RGB_CYAN0 : RGB_PURPLE); // go to next mode m_backupModeNum++; + // show progress + Leds::setRadialProgress(m_backupModeNum, NUM_DUO_MODES, useDefault ? RGB_CYAN0 : RGB_PURPLE); return false; } bool EditorConnection::restoreDuoModes() { - Leds::setRadials(RADIAL_0, (Radial)m_backupModeNum, RGB_CYAN4); - if (m_backupModeNum == 9) { + if (m_backupModeNum == NUM_DUO_MODES) { // reset counter for the restore step later m_backupModeNum = 0; // done @@ -646,14 +647,15 @@ bool EditorConnection::restoreDuoModes() UPDI::writeMode(m_backupModeNum, m_modeBackups[m_backupModeNum]); // go to next mode m_backupModeNum++; + // show progress + Leds::setRadialProgress(m_backupModeNum, NUM_DUO_MODES, RGB_CYAN4); return false; } bool EditorConnection::writeDuoFirmware() { // render some progress, do it before updating the offset so it starts at 0 - Leds::setAll(RGB_YELLOW3); - Leds::setRadials(RADIAL_0, (Radial)((m_firmwareOffset / (float)m_firmwareSize) * RADIAL_COUNT), RGB_GREEN3); + Leds::setRadialProgress(m_firmwareOffset, m_firmwareSize, RGB_GREEN4); // first pass and backup modes is enabled if (m_firmwareOffset >= m_firmwareSize) { // done diff --git a/VortexEngine/src/Modes/DuoDefaultModes.cpp b/VortexEngine/src/Modes/DuoDefaultModes.cpp index 9143d0da9a..099e9a4586 100644 --- a/VortexEngine/src/Modes/DuoDefaultModes.cpp +++ b/VortexEngine/src/Modes/DuoDefaultModes.cpp @@ -1,60 +1,43 @@ #include "DuoDefaultModes.h" -// 14 0 0 0 0 0 0 0 -// 51 31 69 110 2 6 6 3 -// 255 0 0 0 255 0 0 0 -// 255 0 const uint8_t duo_mode1[] = { - 0x02, 0x06, 0x06, 0x03, - 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, - 0xFF, 0x00 + 0x02, 0x06, 0x06, 0x03, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, + 0x00 }; const uint8_t duo_mode2[] = { - 0x02, 0x02, 0x1C, 0x03, - 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, - 0xFF, 0x00, 0x19, 0x03, 0xFF, 0x00, 0x00, 0x00, - 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00 + 0x02, 0x02, 0x1C, 0x03, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x19, 0x03, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00 }; const uint8_t duo_mode3[] = { - 0x02, 0x02, 0x00, 0x01, - 0x97, 0x70, 0x9F, 0x00, 0x07, 0x01, 0x4D, 0x00, - 0xB2, 0x00 + 0x02, 0x02, 0x00, 0x01, 0x97, 0x70, 0x9F, 0x00, 0x07, 0x01, 0x4D, 0x00, 0xB2, + 0x00 }; const uint8_t duo_mode4[] = { - 0x02, 0x02, 0x00, 0x06, - 0xC4, 0x70, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x17, 0x00, 0x00, 0x3B, 0x00, 0x00, 0xE9, - 0x4E, 0x00, 0x00, 0x03, 0x03, 0xC4, 0x4D, 0x00, - 0x00, 0x00, 0x17, 0x3B, 0xB2, 0xE9, 0x00 + 0x02, 0x02, 0x00, 0x06, 0xC4, 0x70, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x3B, 0x00, 0x00, 0xE9, 0x4E, 0x00, 0x00, 0x03, 0x03, 0xC4, + 0x4D, 0x00, 0x00, 0x00, 0x17, 0x3B, 0xB2, 0xE9, 0x00 }; const uint8_t duo_mode5[] = { - 0x02, 0x06, 0x0E, 0x07, - 0xFF, 0x23, 0x00, 0x00, 0x06, 0x48, 0xFF, 0xC6, - 0x55, 0xFF, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x66, 0x55, 0xFF, 0x55, 0x57, 0x00 + 0x02, 0x06, 0x0E, 0x07, 0xFF, 0x23, 0x00, 0x00, 0x06, 0x48, 0xFF, 0xC6, 0x55, + 0xFF, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x55, 0xFF, 0x55, 0x57, 0x00 }; const uint8_t duo_mode6[] = { - 0x02, 0x06, 0x0D, 0x05, - 0x9F, 0x00, 0x00, 0x5A, 0xFF, 0xFF, 0xFF, 0x9F, - 0x00, 0x00, 0x00, 0x66, 0xFF, 0xFF, 0x9F, 0x00 + 0x02, 0x06, 0x0D, 0x05, 0x9F, 0x00, 0x00, 0x5A, 0xFF, 0xFF, 0xFF, 0x9F, 0x00, + 0x00, 0x00, 0x66, 0xFF, 0xFF, 0x9F, 0x00 }; const uint8_t duo_mode7[] = { - 0x02, 0x06, 0x05, 0x05, - 0x00, 0x00, 0x30, 0xFF, 0x54, 0xAA, 0xB1, 0x00, - 0x00, 0x1B, 0x90, 0xFF, 0x55, 0x2D, 0x00, 0x00 + 0x02, 0x06, 0x05, 0x05, 0x00, 0x00, 0x30, 0xFF, 0x54, 0xAA, 0xB1, 0x00, 0x00, + 0x1B, 0x90, 0xFF, 0x55, 0x2D, 0x00, 0x00 }; const uint8_t duo_mode8[] = { - 0x02, 0x02, 0x08, 0x05, - 0x00, 0x40, 0x54, 0x52, 0x26, 0x00, 0x00, 0x00, - 0x54, 0xAA, 0xFF, 0x55, 0x0B, 0x00, 0x00, 0x00, - 0x08, 0x07, 0xFF, 0x23, 0x00, 0x00, 0x06, 0x48, - 0xFF, 0xC6, 0x55, 0xFF, 0x43, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x55, 0xFF, 0x55, 0x57, 0x00 + 0x02, 0x02, 0x08, 0x05, 0x00, 0x40, 0x54, 0x52, 0x26, 0x00, 0x00, 0x00, 0x54, + 0xAA, 0xFF, 0x55, 0x0B, 0x00, 0x00, 0x00, 0x08, 0x07, 0xFF, 0x23, 0x00, 0x00, + 0x06, 0x48, 0xFF, 0xC6, 0x55, 0xFF, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, + 0x55, 0xFF, 0x55, 0x57, 0x00 }; const uint8_t duo_mode9[] = { - 0x02, 0x02, 0x04, 0x02, - 0xFF, 0x00, 0xF6, 0x08, 0x00, 0x80, 0x00, 0x01, - 0x02, 0xFF, 0x00, 0xF6, 0x08, 0x00, 0x80, 0x00 + 0x02, 0x02, 0x04, 0x02, 0xFF, 0x00, 0xF6, 0x08, 0x00, 0x80, 0x00, 0x01, 0x02, + 0xFF, 0x00, 0xF6, 0x08, 0x00, 0x80, 0x00 }; const uint8_t *duo_default_modes[9] = {