/* Cycles a rainbow over the entire string of LEDs.  */
static int ws2812_effects_mode_rainbow_cycle(int repeat_count)
/* Cycles a rainbow over the entire string of LEDs.  */
static int ws2812_effects_mode_rainbow_cycle(int repeat_count)
{
    uint16_t wheel_index = (i * 360 / buffer->npix * repeat_count) % 360;
    uint32_t color = color_wheel(wheel_index);
    uint8_t r = ((color & 0x00FF0000) >> 16) * state->brightness / BRIGHTNESS_MAX;
    uint8_t g = ((color & 0x0000FF00) >>  8) * state->brightness / BRIGHTNESS_MAX;
    uint8_t b = ((color & 0x000000FF) >>  0) * state->brightness / BRIGHTNESS_MAX;
    *p++ = g;
    *p++ = r;
    *p++ = b;
    for (j = 3; j < pixbuf_channels(buffer); j++)
    {
      *p++ = 0;
    }
  }
  return 0;
}