void applyQuadrantColor(const uint8_t ledIndex, const ledConfig_t *ledConfig, const quadrant_e quadrant, const hsvColor_t *color) { switch (quadrant) { case QUADRANT_NORTH_EAST: if (GET_LED_Y(ledConfig) <= highestYValueForNorth && GET_LED_X(ledConfig) >= lowestXValueForEast) { setLedHsv(ledIndex, color); } return; case QUADRANT_SOUTH_EAST: if (GET_LED_Y(ledConfig) >= lowestYValueForSouth && GET_LED_X(ledConfig) >= lowestXValueForEast) { setLedHsv(ledIndex, color); } return; case QUADRANT_SOUTH_WEST: if (GET_LED_Y(ledConfig) >= lowestYValueForSouth && GET_LED_X(ledConfig) <= highestXValueForWest) { setLedHsv(ledIndex, color); } return; case QUADRANT_NORTH_WEST: if (GET_LED_Y(ledConfig) <= highestYValueForNorth && GET_LED_X(ledConfig) <= highestXValueForWest) { setLedHsv(ledIndex, color); } return; } }
void applyDirectionalModeColor(const uint8_t ledIndex, const ledConfig_t *ledConfig, const modeColorIndexes_t *modeColors) { // apply up/down colors regardless of quadrant. if ((ledConfig->flags & LED_DIRECTION_UP)) { setLedHsv(ledIndex, &colors[modeColors->up]); } if ((ledConfig->flags & LED_DIRECTION_DOWN)) { setLedHsv(ledIndex, &colors[modeColors->down]); } // override with n/e/s/w colors to each n/s e/w half - bail at first match. if ((ledConfig->flags & LED_DIRECTION_WEST) && GET_LED_X(ledConfig) <= highestXValueForWest) { setLedHsv(ledIndex, &colors[modeColors->west]); } if ((ledConfig->flags & LED_DIRECTION_EAST) && GET_LED_X(ledConfig) >= lowestXValueForEast) { setLedHsv(ledIndex, &colors[modeColors->east]); } if ((ledConfig->flags & LED_DIRECTION_NORTH) && GET_LED_Y(ledConfig) <= highestYValueForNorth) { setLedHsv(ledIndex, &colors[modeColors->north]); } if ((ledConfig->flags & LED_DIRECTION_SOUTH) && GET_LED_Y(ledConfig) >= lowestYValueForSouth) { setLedHsv(ledIndex, &colors[modeColors->south]); } }
void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSize) { char functions[FUNCTION_COUNT]; char directions[DIRECTION_COUNT]; uint8_t index; uint8_t mappingIndex; ledConfig_t *ledConfig = &ledConfigs[ledIndex]; memset(ledConfigBuffer, 0, bufferSize); memset(&functions, 0, sizeof(functions)); memset(&directions, 0, sizeof(directions)); for (mappingIndex = 0, index = 0; mappingIndex < FUNCTION_COUNT; mappingIndex++) { if (ledConfig->flags & functionMappings[mappingIndex]) { functions[index++] = functionCodes[mappingIndex]; } } for (mappingIndex = 0, index = 0; mappingIndex < DIRECTION_COUNT; mappingIndex++) { if (ledConfig->flags & directionMappings[mappingIndex]) { directions[index++] = directionCodes[mappingIndex]; } } sprintf(ledConfigBuffer, "%u,%u:%s:%s:%u", GET_LED_X(ledConfig), GET_LED_Y(ledConfig), directions, functions, ledConfig->color); }
void determineLedStripDimensions(void) { ledGridWidth = 0; ledGridHeight = 0; uint8_t ledIndex; const ledConfig_t *ledConfig; for (ledIndex = 0; ledIndex < ledCount; ledIndex++) { ledConfig = &ledConfigs[ledIndex]; if (GET_LED_X(ledConfig) >= ledGridWidth) { ledGridWidth = GET_LED_X(ledConfig) + 1; } if (GET_LED_Y(ledConfig) >= ledGridHeight) { ledGridHeight = GET_LED_Y(ledConfig) + 1; } } }
static void applyLedAnimationLayer(void) { const ledConfig_t *ledConfig; if (ARMING_FLAG(ARMED)) { return; } uint8_t ledIndex; for (ledIndex = 0; ledIndex < ledCount; ledIndex++) { ledConfig = &ledConfigs[ledIndex]; if (GET_LED_Y(ledConfig) == previousRow) { setLedHsv(ledIndex, &white); setLedBrightness(ledIndex, 50); } else if (GET_LED_Y(ledConfig) == currentRow) { setLedHsv(ledIndex, &white); } else if (GET_LED_Y(ledConfig) == nextRow) { setLedBrightness(ledIndex, 50); } } }