Fade To Red

Siyah yerine kırmızıya dönsün istiyordum. Bunu denerken şans eseri istediğim bir

ADD SPEC: Yukarı doğru zıplayan bir renkli palet.

i çözdüm.

//TGAN SIFIRLAMA DUGMESI
#DEFINE USE_GET_MILLISECOND_TIMER 1
//TGAN SIFIRLAMA DUGMESI

/* COLORPAL_BEAT TURGAN 01

BY: ANDREW TULINE

DATE: JULY, 2015

THIS ROUTINE USES FASTLED BEATS AND COLOUR PALETTES WITH GRADUAL PALETTE CROSS FADING. IT DOESN'T REQUIRE TIMERS/DELAYS EXCEPT TO CHANGE/FADE BETWEEN PALETTES ON OCCASION.

*/
#INCLUDE "FASTLED.H"

#IF FASTLED_VERSION < 3001000
#ERROR "REQUIRES FASTLED 3.1 OR LATER; CHECK GITHUB FOR LATEST CODE."
#ENDIF
#DEFINE LED_DT 2
//#DEFINE LED_CK 11
#DEFINE NUM_LEDS 300
#DEFINE LED_TYPE WS2812B
#DEFINE COLOR_ORDER GRB

// TGAN POTENTIOMETER VALUE
INT POTPIN = A0;
INT POTVALUE = 0;
INT POTMAPPEDOUTPUTVALUE = 30;
// TGAN POTENTIOMETER

//TGAN SIFIRLAMA DUGMESI
CONST INT BUTTONPIN = 50;
INT BUTTONSTATE = 0;
//TGAN SIFIRLAMA DUGMESI

//TGAN SIFIRLAMA DUGMESI
UINT32_T RESETTIME;
//TGAN SIFIRLAMA DUGMESI

CRGB LEDS[NUM_LEDS];

UINT8_T BRIGHTNESS = 128;

CRGBPALETTE16 CURRENTPALETTE;
CRGBPALETTE16 TARGETPALETTE;
UINT8_T MAXCHANGES = 24;
TBLENDTYPE CURRENTBLENDING;
VOID SETUP() {
//TGAN SIFIRLAMA DUGMESI
PINMODE(BUTTONPIN, INPUT);
//TGAN SIFIRLAMA DUGMESI

DELAY(3000); // POWER-UP SAFETY DELAY

FASTLED.ADDLEDS<LED_TYPE, LED_DT, COLOR_ORDER>(LEDS, NUM_LEDS); // WS2812B
// FASTLED.ADDLEDS<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(LEDS, NUM_LEDS); // WS2801 OR APA102

FASTLED.SETBRIGHTNESS(BRIGHTNESS);
SET_MAX_POWER_IN_VOLTS_AND_MILLIAMPS(5, 500); // FASTLED POWER MANAGEMENT SET AT 5V, 500MA.

CURRENTPALETTE = RAINBOWCOLORS_P; // RAINBOWCOLORS_P; CLOUDCOLORS_P; PARTYCOLORS_P; LAVACOLORS_P; HEATCOLORS_P;
TARGETPALETTE = LAVACOLORS_P; // RAINBOWCOLORS_P; CLOUDCOLORS_P; PARTYCOLORS_P; LAVACOLORS_P; HEATCOLORS_P;
CURRENTBLENDING = LINEARBLEND;

} //SETUP()

//TGAN SIFIRLAMA DUGMESI
UINT32_T GET_MILLISECOND_TIMER()
{
RETURN MILLIS()-RESETTIME ;
}
//TGAN SIFIRLAMA DUGMESI

VOID LOOP() {
//TGAN SIFIRLAMA DUGMESI
BUTTONSTATE = DIGITALREAD(BUTTONPIN);
IF (BUTTONSTATE == HIGH) {
RESETTIME = MILLIS() ;
} ;
//TGAN SIFIRLAMA DUGMESI

// TGAN POTENTIOMETER
POTVALUE = ANALOGREAD(POTPIN);
POTMAPPEDOUTPUTVALUE = MAP(POTVALUE, 0, 1023, 40, 145);
// TGAN POTENTIOMETER

UINT8_T BEATA = BEATSIN8(POTMAPPEDOUTPUTVALUE, 0, 255); // STARTING HUE
FILLLEDSFROMPALETTECOLORS(BEATA);
SHOW_AT_MAX_BRIGHTNESS_FOR_POWER(); // POWER MANAGED DISPLAY.

EVERY_N_MILLISECONDS(100) { // FASTLED BASED TIMER TO UPDATE/DISPLAY THE SEQUENCE EVERY 5 SECONDS.
NBLENDPALETTETOWARDPALETTE( CURRENTPALETTE, TARGETPALETTE, MAXCHANGES);
}

EVERY_N_MILLISECONDS(5000) { // FASTLED BASED TIMER TO UPDATE/DISPLAY THE SEQUENCE EVERY 5 SECONDS.
SETUPRANDOMPALETTE();
}
} //LOOP()
VOID FILLLEDSFROMPALETTECOLORS(UINT8_T COLORINDEX) {
UINT8_T BEATB = BEATSIN8(15, 10, 20); // DELTA HUE BETWEEN LED'S
FOR (INT I = 0; I < NUM_LEDS; I++) {
LEDS[I] = COLORFROMPALETTE(CURRENTPALETTE, COLORINDEX, 255, CURRENTBLENDING);
COLORINDEX += BEATB;
}
} //FILLLEDSFROMPALETTECOLORS()
VOID SETUPRANDOMPALETTE() {
TARGETPALETTE = CRGBPALETTE16(CHSV(RANDOM8(), 255, 32), CHSV(RANDOM8(), RANDOM8(64)+192, 255), CHSV(RANDOM8(), 255, 32), CHSV(RANDOM8(), 255, 255));
} // SETUPRANDOMPALETTE()

 

Leave a Reply