void flickerDim(uint16_t position) {
  if(chanceOneIn(50)){
    setLedColor(position, brighten8(getLedColor(position), 1));
  } else {
    setLedColor(position, dim256(getLedColor(position), 4));
  }
}
bool checkForCollision(uint16_t position) {
  if(getLedColor(position) == RED && getLedColor(position+1) != BLACK) {
    return true;
  } else if(getLedColor(position) == BLUE && getLedColor(position-1) != BLACK) {
    return true;
  } else {
    return false;
  }
}
uint16_t twinkleTwinkle(uint16_t tick, uint32_t color, uint8_t cycles) {
  for (uint16_t i=0; i<NUM_LEDS; i++) {
    if(getLedColor(i) > BLACK) {
      setLedColor(i, dim256(getLedColor(i), map(cycles, NUM_CYCLES, 0, 10, 100)));
    } else if (chanceOneIn(map(cycles, NUM_CYCLES, 0, 500, 10))) {
      setLedColor(i, getRandomColor());
    }
  }

  return 1;
}
void moveAllPixelsBackward(uint32_t color) {
  for (int i = 0; i < NUM_LEDS; i++) {
    if (getLedColor(i) == color) {
      movePixel(i, -1);
    }
  }
}
void moveAllPixelsForward(uint32_t color) {
  for (int i = NUM_LEDS-1; i >= 0; i--) {
    if (getLedColor(i) == color) {
      movePixel(i, 1);
    }
  }
}
uint16_t competitivePixels(uint16_t tick, uint32_t color) {
  uint8_t speed;

  for (uint16_t i=0; i<NUM_LEDS; i++) {
    if(getLedColor(i) > BLACK) {
      speed = getLedColor(i) % 5;
      setLedColor(i + speed, getLedColor(i));
      setLedColor(i, BLACK);
      i = i + speed;
    } else if(i == 0 && chanceOneIn(100)) {
      setLedColor(i, getRandomColor());
    }
  }

  return 1;
}
void movePixel(int position, int moveBy) {
  int targetPosition = position + moveBy;

  if(targetPosition >= 0 && targetPosition < NUM_LEDS) {
    setLedColor(targetPosition, getLedColor(position));
  }

  setLedColor(position, BLACK);
}
Beispiel #8
0
void osdOpenMenu(void)
{
    if (inMenu)
        return;

    if (feature(FEATURE_LED_STRIP))
        featureLedstrip = 1;

    if (feature(FEATURE_BLACKBOX))
        featureBlackbox = 1;

#if defined(VTX) || defined(USE_RTC6705)
    if (feature(FEATURE_VTX))
        featureVtx = 1;
#endif // VTX || USE_RTC6705

#ifdef VTX
    vtxBand = masterConfig.vtxBand;
    vtxChannel = masterConfig.vtx_channel + 1;
#endif // VTX

#ifdef USE_RTC6705
    vtxBand = masterConfig.vtx_channel / 8;
    vtxChannel = masterConfig.vtx_channel % 8 + 1;
#endif // USE_RTC6705

    osdRows = max7456GetRowsCount();
    inMenu = true;
    refreshTimeout = 0;
    max7456ClearScreen();
    currentMenu = &menuMain[0];
    osdResetAlarms();
    osdChangeScreen(currentMenu);
#ifdef LED_STRIP
    getLedColor();
#endif // LED_STRIP
}
uint16_t tinyExplosions(uint16_t tick, uint32_t color) {

  for (uint16_t i=0; i<NUM_LEDS; i++) {
    if (isDimmedMagenta(getLedColor(i))) {
      flickerDim(i);
    }
  }

  drawAllCollisions();
  moveAllPixelsForward(RED);
  drawAllCollisions();
  moveAllPixelsBackward(BLUE);

  // put in new pixels at the end of the strip
  if(chanceOneIn(300)) {
    setLedColor(0, RED);
  }

  if(chanceOneIn(300)) {
    setLedColor(NUM_LEDS-1, BLUE);
  }

  return 1;
}