예제 #1
0
/*
 * This method is non-blocking unless an existing LED update is in progress.
 * it does not wait until all the LEDs have been updated, that happens in the background.
 */
void ws2811UpdateStrip(void)
{
    static uint32_t waitCounter = 0;
    static rgbColor24bpp_t *rgb24;

    // wait until previous transfer completes
    while(ws2811LedDataTransferInProgress) {
        waitCounter++;
    }

    dmaBufferOffset = 0;                // reset buffer memory index
    ledIndex = 0;                       // reset led index

    // fill transmit buffer with correct compare values to achieve
    // correct pulse widths according to color values
    while (ledIndex < WS2811_LED_STRIP_LENGTH)
    {
        rgb24 = hsvToRgb24(&ledColorBuffer[ledIndex]);

#ifdef USE_FAST_DMA_BUFFER_IMPL
        fastUpdateLEDDMABuffer(rgb24);
#else
        updateLEDDMABuffer(rgb24->rgb.g);
        updateLEDDMABuffer(rgb24->rgb.r);
        updateLEDDMABuffer(rgb24->rgb.b);
#endif

        ledIndex++;
    }

    ws2811LedDataTransferInProgress = 1;
    ws2811LedStripDMAEnable();
}
예제 #2
0
/*
 * This method is non-blocking unless an existing LED update is in progress.
 * it does not wait until all the LEDs have been updated, that happens in the background.
 */
void ws2811UpdateStrip(void)
{
    static rgbColor24bpp_t *rgb24;

    // don't wait - risk of infinite block, just get an update next time round
    if (ws2811LedDataTransferInProgress) {
        return;
    }

    dmaBufferOffset = 0;                // reset buffer memory index
    ledIndex = 0;                       // reset led index

    // fill transmit buffer with correct compare values to achieve
    // correct pulse widths according to color values
    while (ledIndex < WS2811_LED_STRIP_LENGTH)
    {
        rgb24 = hsvToRgb24(&ledColorBuffer[ledIndex]);

#ifdef USE_FAST_DMA_BUFFER_IMPL
        fastUpdateLEDDMABuffer(rgb24);
#else
        updateLEDDMABuffer(rgb24->rgb.g);
        updateLEDDMABuffer(rgb24->rgb.r);
        updateLEDDMABuffer(rgb24->rgb.b);
#endif

        ledIndex++;
    }

    ws2811LedDataTransferInProgress = 1;
    ws2811LedStripDMAEnable();
}
예제 #3
0
/*
 * This method is non-blocking unless an existing LED update is in progress.
 * it does not wait until all the LEDs have been updated, that happens in the background.
 */
void ws2811UpdateStrip(void)
{
    // wait until previous transfer completes
    while(ws2811LedDataTransferInProgress);

    uint8_t *dst = ledStripDMABuffer;               // reset buffer memory index

    // fill transmit buffer with correct compare values to achieve
    // correct pulse widths according to color values
    for (int ledIndex = 0; ledIndex < WS2811_LED_STRIP_LENGTH; ledIndex++) {
        rgbColor24bpp_t rgb24 = hsvToRgb24(&ledColorBuffer[ledIndex]);

        fastUpdateLEDDMABuffer(&dst, rgb24);
    }

    ws2811LedDataTransferInProgress = 1;
    ws2811LedStripDMAEnable();
}