Exemplo n.º 1
0
void loop() {
        // Turn the LED on, then pause
        int k;
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB::Red;
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB::Green;
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB::Blue;
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB(241,117, 183);
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB(103,0, 0);
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB(255, 78, 48); //portland orang
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB(250, 196, 165); //wax flower
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB(0,106, 255);
        FastLED.show();
        delay(500);
        for (k=0; k<NUM_LEDS; k++) leds[k] = CRGB::Black;
        FastLED.show();
        delay(500);
        for (int j=0; j<NUM_BREAT; j++) breat();


}
Exemplo n.º 2
0
void LightManager::setZoneLED() {
	int currentZone = singleMan->addrMan()->getZone();

	if(currentZone == 0)
		ledstrip[3] = CRGB(255,0,0);
	else if(currentZone == 1)
		ledstrip[3] = CRGB(0,255,0);
	else if(currentZone == 2)
		ledstrip[3] = CRGB(0,0,255);
	else if(currentZone == 3)
		ledstrip[3] = CRGB(255,255,255);
	else
		ledstrip[3] = CRGB(0,0,0);
}
void FastLEDRenderer::reset(CRGB *_leds) {
    //init all pixels to black
    for(byte y=top; y<top+height; y++) {
        for(byte x=left; x<left+width; x++) {
            _leds[XY(x,y)] = CRGB(0,0,0);
        }
    }
}
Exemplo n.º 4
0
void CDrawTextTextScene::Draw( CGraphics* pGraphic )
{
	CScene::Draw(pGraphic);
	pGraphic->DrawTextW(L"吴德宏",100,300,*sFontConfig.GetFont(3));	
	CPosition pts[5];
	pts[4] = CPosition(800,900);
	pts[3] = CPosition(600,500);
	pts[2] = CPosition(200,600);
	pts[1] = CPosition(200,300);
	pts[0] = CPosition(30,200);
	int a = GetTickCount();
	pGraphic->Polygon(pts,5,CRGB(255,124,122));
	DebugTrace(Trace_Info,"Polygon Time:%d\n",GetTickCount() - a);
	wchar_t* wcs = L"这是沿线绘制吴德宏啊伍德WoodHome";
	pGraphic->DrawTextW(wcs,pts,5,*sFontConfig.GetFont(2),50.0f);
	pGraphic->LineDDA(pts[0],pts[1],0,CRGB(255,124,122));
	pGraphic->LineDDA(pts[1],pts[2],0,CRGB(255,124,122));
	pGraphic->LineDDA(pts[2],pts[3],0,CRGB(255,124,122));
	pGraphic->LineDDA(pts[3],pts[4],0,CRGB(255,124,122));
	pts[0]=CPosition(600,20);
	pts[1]=CPosition(800,550);
	pGraphic->LineDDA(pts[0], 20 ,pts[1] ,10,CRGB(124,124,122));
	a = GetTickCount();
	pGraphic->DrawTextW(L"这是不等宽线",pts,2,*sFontConfig.GetFont(1),20);
	DebugTrace(Trace_Info,"不等宽线 Time:%d\n",GetTickCount() - a);
	pts[1]=CPosition(700,20);
	pts[0]=CPosition(200,120);
	a = GetTickCount();
	pGraphic->LineDDA(pts[0] ,pts[1] ,15,CRGB(124,124,122));
	pGraphic->DrawTextW(L"这是等宽线",pts,2,*sFontConfig.GetFont(1),20);
	DebugTrace(Trace_Info,"等宽线 Time:%d\n",GetTickCount() - a);
}
Exemplo n.º 5
0
static void add_sparkles() {
	for(uint8_t i = 0; i < 30; i++){
		uint16_t index = XY(random16(WIDTH), random16(HEIGHT));

		if(leds[index] == CRGB(0,0,0)) {
			leds[index] = CRGB::White;
		}
	}
}
Exemplo n.º 6
0
void LightManager::setRadioLED() {
	int red = 0;
	if(millis() < lastRadioSend+1000)
		red = 255;

	int green = 0;
	if(millis() < lastRadioReceive+1000)
		green = 255;

	ledstrip[4] = CRGB(red,green,0);
}
Exemplo n.º 7
0
void CFastSPI_LED2::clear(boolean includeLedData) { 
	showColor(CRGB(0,0,0), 0);
	if(includeLedData) { 
		for(int i = 0; i < m_nControllers; i++) { 
			if(m_Controllers[i].pLedData != NULL) { 
				memset8((void*)m_Controllers[i].pLedData, 0, sizeof(struct CRGB) * m_Controllers[i].nLeds);
			} else {
				return;
			}
		}
	}
}
Exemplo n.º 8
0
void LightManager::setButtonLED() {

		int green = 0;
		if(singleMan->inputMan()->isButton1Pressed())
			green = 255;

		int blue = 0;
		if(singleMan->inputMan()->isButton2Pressed())
			blue = 255;

		ledstrip[5] = CRGB(0,green,blue);
}
Exemplo n.º 9
0
void LightManager::pulsePattern() {
	// 4ms per Tick, 300 ticks per fade, 6 fades
	int fullPattern = ( millis() % (4*300*6) ) / 4;

	int fadeIndex = fullPattern%300;
	if(fadeIndex > 150)
		fadeIndex = 150 - (fadeIndex-150);

	switch (fullPattern / 300)
	{
		case 0:
		case 1:
		case 2:
			ledstrip[0] = CRGB(fadeIndex,0,0);
			break;
		case 3:
		case 4:
			ledstrip[0] = CRGB(0,fadeIndex,0);
			break;
		case 5:
			ledstrip[0] = CRGB(0,0,fadeIndex);
			break;
	}
}
Exemplo n.º 10
0
void LightManager::setLightSensorLED() {
	// Analog input (value 0->1024)
	int lightSensorLevel = singleMan->inputMan()->getLightLevel() / 2;

	int lowLevel = lightSensorLevel;
	if(lowLevel > 255)
		lowLevel = 255;

	int highLevel = lightSensorLevel;
	if(highLevel < 255)
		highLevel = 0;
	else
		highLevel -= 255;

	ledstrip[1] = CRGB(highLevel,lowLevel,0);
}
Exemplo n.º 11
0
LightManager::LightManager(SingletonManager* _singleMan):
	singleMan(_singleMan) {

	// Init FastLED RGB
	FastLED.addLeds<NEOPIXEL, RGB_STRIP_PIN>(ledstrip, NUM_RGB_LEDS);
	for(int i=0; i<NUM_RGB_LEDS; i++)
		ledstrip[i] = CRGB(0,0,0);
	FastLED.show();

	// Turn on the big LED at 100%
	pinMode(BIG_LED_PIN, OUTPUT);
	byte bigLEDBrightness = 255 * 1.00;
	analogWrite(BIG_LED_PIN, bigLEDBrightness);

	singleMan->setLightMan(this);
}
Exemplo n.º 12
0
void Matrix::render(CRGB* leds)
{
  for(uint8_t y = 0; y < m_height; y++)
  {
    for(uint8_t x = 0; x < m_width; x++)
    {
      uint16_t index = y * m_width + x;
      leds[index] -= CRGB(8, 2, 8);
    }
  }
  for(uint8_t i = 0; i < 10; i++)
  {
      if(particle[i].y < m_height)
      {
        uint16_t index = particle[i].y * m_width + particle[i].x;
        leds[index] = CRGB::White;
      }
  }
}
Exemplo n.º 13
0
void UserInterface::timerAlert(void)
{
    for (uint8_t i = 0; i < NUM_LEDS; i++)
        s_leds[i] = CRGB(255, 0, 0);

    while (s_switch_state == SWITCH_STATE__NONE)
    {
        Display::done();
        FastLED.show(s_brightness);
        GPIO::set(PIN_BEEPER);

        delay(500);

        Display::blank();
        FastLED.show(0);
        GPIO::clear(PIN_BEEPER);

        delay(80);
    }

    FastLED.clear(true);
}
Exemplo n.º 14
0
void loop() {
    for (int i=0; i<NUM_LEDS/3;i++){
        leds[i] = CRGB(255-i,i,i*i);
    }
    for (int i=NUM_LEDS/3; i<2*NUM_LEDS/3;i++){
        leds[i] = CRGB(i,100+i,100+i);
    }
    for (int i=2*NUM_LEDS/3; i<NUM_LEDS;i++){
        leds[i] = CRGB(120,50,255);
    }
    FastLED.show();
    delay(1000);
    leds[6] = CRGB(255,0,0);
    leds[7] = CRGB(255,0,0);
    leds[8] = CRGB(255,0,0);
    FastLED.show();
    delay(100);
    for (int i=0; i<NUM_LEDS*100; i++){
        moveStripLeft(leds);
        FastLED.show();
        delay(sinDelay());
    }
}//
Exemplo n.º 15
0
EffectFindMe::EffectFindMe(uint8_t _mode, Config_t *_cnf) : EffectClass(_mode, _cnf) {
  _cnf->currDelay = DELAY_SLOW;
  LEDS.setBrightness(MAXBRIGHT);
  _currColor = CRGB(255,255,255);
  FINDME_WIDTH = 2;
}
Exemplo n.º 16
0
namespace plugin {

uint8_t ActiveModColorEffect::mod_keys_[MAX_MODS_PER_LAYER];
uint8_t ActiveModColorEffect::mod_key_count_;
bool ActiveModColorEffect::highlight_normal_modifiers_ = true;

cRGB ActiveModColorEffect::highlight_color = (cRGB) {
  160, 160, 160
};

cRGB ActiveModColorEffect::sticky_color = CRGB(160, 0, 0);

EventHandlerResult ActiveModColorEffect::onLayerChange() {
  if (!Kaleidoscope.has_leds)
    return EventHandlerResult::OK;

  mod_key_count_ = 0;

  for (byte r = 0; r < ROWS; r++) {
    for (byte c = 0; c < COLS; c++) {
      Key k = Layer.lookupOnActiveLayer(r, c);

      if (::OneShot.isOneShotKey(k) ||
          (highlight_normal_modifiers_ && (
             (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) ||
             (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))))) {
        uint8_t coords = r * COLS + c;
        mod_keys_[mod_key_count_++] = coords;
      }
    }
  }

  return EventHandlerResult::OK;
}

EventHandlerResult ActiveModColorEffect::beforeReportingState() {
  if (mod_key_count_ == 0) {
    onLayerChange();
  }

  for (uint8_t i = 0; i < mod_key_count_; i++) {
    uint8_t coords = mod_keys_[i];
    byte c = coords % COLS;
    byte r = (coords - c) / COLS;

    Key k = Layer.lookupOnActiveLayer(r, c);

    if (::OneShot.isOneShotKey(k)) {
      if (::OneShot.isSticky(k))
        ::LEDControl.setCrgbAt(r, c, sticky_color);
      else if (::OneShot.isActive(k))
        ::LEDControl.setCrgbAt(r, c, highlight_color);
      else
        ::LEDControl.refreshAt(r, c);
    } else if (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) {
      if (hid::isModifierKeyActive(k))
        ::LEDControl.setCrgbAt(r, c, highlight_color);
      else
        ::LEDControl.refreshAt(r, c);
    } else if (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP)) {
      uint8_t layer = k.keyCode;
      if (layer >= LAYER_SHIFT_OFFSET)
        layer -= LAYER_SHIFT_OFFSET;

      if (Layer.isActive(layer))
        ::LEDControl.setCrgbAt(r, c, highlight_color);
      else
        ::LEDControl.refreshAt(r, c);
    }
  }

  return EventHandlerResult::OK;
}

}
Exemplo n.º 17
0
void CFastLED::clear(boolean writeData) {
	if(writeData) {
		showColor(CRGB(0,0,0), 0);
	}
    clearData();
}
Exemplo n.º 18
0
void gameoflife::run(byte res) {

    static word current[15];  //current 16x16 playing fied
    static word next[15];     //next 16x16 playing field
    static byte emptycount;
    static byte Reset;        //internal reset flag
    static byte frameOffset = 0;    //offset for drawing frame
    static byte frameCount  = 0;
    static byte genCount    = 0;
    static byte resetFade   = gameOfLifeResetFade - 1;

    byte xMod, yMod, alive, fadecount;
    CRGB fadeInColor, fadeOutColor, onColor;
    byte fadeInVal, fadeOutVal;


    if((Reset == 1) | (res == 1)) {   //if reset flag is thrown

        resetFade++;
        if(resetFade != gameOfLifeResetFade) {  //take time to fade colors

            fadeOutVal    = 250 - (resetFade * 5);
            fadeOutColor  = CRGB(fadeOutVal * gameOfLifeR, fadeOutVal * gameOfLifeG, fadeOutVal * gameOfLifeB);

            for(byte y = 0; y<10; y++) {     //draw the current frame window
                for(byte x = 0; x<10; x++) {
                    if( (bitRead(current[y], GOL_BUFFER_WRAP(x))==1) ) {   //keep on all the way if the colonly isnt changing
                        disp[CORDINATE(x,y)] = fadeOutColor;
                    }
                }
                //Serial.println(fadeOutVal);
            }
        }

        else {
            for(byte i = 0; i< 15; i++) {
                current[i] = 0;      //ramdomly populate playing field
                next[i] = random(0xFFFF);
            }
            Reset = 0;        //set reset flag back to 0;
            emptycount = 0;   //if the reset flag was thrown internally by a stagnated game reset stagnant frame count
            genCount = 0;
            resetFade =  0;
        }

        //Serial.println(resetFade);
        return;
    }

    //check each cell to update for next generation generation
    if(frameCount == 0) {
        for(byte y = 0; y<16; y++) {        //check each row
            for(byte x = 0; x <16; x++) {   //Check each column
                xMod =(15-((x + 15) % 15));    //flip x
                yMod = (y + 15) % 15;

                alive = 0;
                alive += bitRead(current[yMod+1], xMod);      //right
                alive += bitRead(current[yMod+1], xMod+1);    //down + right
                alive += bitRead(current[yMod+1], xMod-1);    //down + left

                alive += bitRead(current[yMod-1], xMod-1);    //up + right
                alive += bitRead(current[yMod-1], xMod);      //up
                alive += bitRead(current[yMod-1], xMod+1);    //up + right

                alive += bitRead(current[yMod], xMod+1);      //left
                alive += bitRead(current[yMod], xMod-1);      // down

                if (bitRead(current[yMod], xMod) == 1) {                    //check to see if cell lives or dies
                    if ((alive < 2) || (alive > 3))
                        bitWrite(next[yMod], xMod, 0);                //dies
                    else
                        bitWrite(next[yMod], xMod, 1);                //lives
                }
                else {
                    if (alive == 3)
                        bitWrite(next[yMod], xMod, 1);                  //stays alive
                }

            }
        }    //finish generation */
    }


    fadeInVal     = (frameCount * gameOfLifeNLFactor) ;   //uncomment for non-linear brightness
    fadeOutVal    = 250 - fadeInVal;
    // fadeInVal     = linearPWM(frameCount * gameOfLifeLFactor);                            //uncomment for linear brightness
    // fadeOutVal    = linearPWM((gameOfLifeTime - frameCount) * gameOfLifeLFactor);
    fadeInColor   = CRGB(fadeInVal * gameOfLifeR, fadeInVal * gameOfLifeG, fadeInVal * gameOfLifeB);
    fadeOutColor  = CRGB(fadeOutVal * gameOfLifeR, fadeOutVal * gameOfLifeG, fadeOutVal * gameOfLifeB);
    onColor       =  CRGB(255 * gameOfLifeR, 255 * gameOfLifeG, 255 * gameOfLifeB);

    for(byte y = 0; y<10; y++) {     //draw the current frame window
        for(byte x = 0; x<10; x++) {
            if( (bitRead(current[y], GOL_BUFFER_WRAP(x))==0) && (bitRead(next[y], GOL_BUFFER_WRAP(x))==0)) {   //keep on all the way if the colonly isnt changing
                disp[CORDINATE(x,y)] = CRGB::Black;
            }

            else if( (bitRead(current[y], GOL_BUFFER_WRAP(x))==1) && (bitRead(next[y], GOL_BUFFER_WRAP(x))==1) ) {   //keep on all the way if the colonly isnt changing
                disp[CORDINATE(x,y)] = onColor;
            }
            else if( (bitRead(current[y], GOL_BUFFER_WRAP(x)) == 1) && (bitRead(next[y], GOL_BUFFER_WRAP(x))==0) ) {        //fade current out
                disp[CORDINATE(x,y)] = fadeOutColor;
            }

            else {        //fade next color in
                disp[CORDINATE(x,y)] = fadeInColor;
            }

        }
    }

    fadecount = 0;      //seagnation variable

    if(frameCount == gameOfLifeTime) {  //copy over and check for game stagnation
        frameCount = 0;
        genCount++;

        for(byte i = 0; i<16; i++) {     //copy new frame to current frame
            if(((unsigned int)(next[i]) == ((unsigned int)(current[i]))) && (i < 10))
                fadecount++;

            current[i] = next[i];
        } //end for loop

        if(fadecount > 5)    //if most of the frame has not moved
            emptycount++;     //add 1 to emptycount
        else
            emptycount = 0;         //reset emptycount to 0 to prevent false positives

        if((emptycount>5) || (genCount > gameOfLifeMaxGen))        //if game had been mostly stagnant for 15 frames in a row, throw internal reset
            Reset = 1;
    }
    else
        frameCount++;



    return;
}
Exemplo n.º 19
0
void LightManager::setMotionSensorLED() {
	if(singleMan->inputMan()->isMotionDetected())
		ledstrip[2] = CRGB(0,255,0);
	else
		ledstrip[2] = CRGB(255,0,0);
}
Exemplo n.º 20
0
#define MATRIX_TYPE    HORIZONTAL_MATRIX

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;


#define SHAPE_WIDTH    5
#define SHAPE_HEIGHT   5
const uint8_t ShapeData[] =
{
  B8_1BIT(00100000),
  B8_1BIT(01110000),
  B8_1BIT(11111000),
  B8_1BIT(01110000),
  B8_1BIT(00100000),
};
struct CRGB ColTable[1] = { CRGB(64, 128, 255) };
cLEDSprites Sprites(&leds);
cSprite Shape(SHAPE_WIDTH, SHAPE_HEIGHT, ShapeData, 1, _1BIT, ColTable, ShapeData);


void setup()
{
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
  FastLED.setBrightness(64);
  FastLED.clear(true);
  delay(500);
  FastLED.showColor(CRGB::Red);
  delay(1000);
  FastLED.showColor(CRGB::Lime);
  delay(1000);
  FastLED.showColor(CRGB::Blue);
Exemplo n.º 21
0
void GreenPattern::draw(CRGB *frameBuffer)
{
    fill_gradient_RGB(frameBuffer, NUM_LEDS, CRGB(16, 16, 0), CRGB(0, 16, 0));
}
Exemplo n.º 22
0
void PixelUtil::setPixelRGB(uint16_t led, byte r, byte g, byte b)
{
  leds[led] = CRGB(r, g, b);
}
#ifdef __AVR__
..snipped

#elif defined(__arm__)

#if defined(__MK20DX128__) || defined(__MK20DX256__) // Teensy 3.0 & 3.1
#define CYCLES_800_T0H  (F_CPU / 2500000) // corbin: .35us on, .8us off
#define CYCLES_800_T1H  (F_CPU / 1250000) // 0.7us on, .6us off ??
#define CYCLES_800      (F_CPU /  800000)
#define CYCLES_400_T0H  (F_CPU / 2000000)
#define CYCLES_400_T1H  (F_CPU /  833333)
#define CYCLES_400      (F_CPU /  400000)

    
    // TODO: test dithering??
    CRGB scale = CRGB(m_brightness, m_brightness, m_brightness); // corbin, fix m_brightness to not mess w/stuff
    // corbin...figure out how to do the template based on the type
    PixelController<GRB> pixelController(m_pixels, numLEDs, scale, DISABLE_DITHER);

    pixelController.preStepFirstByteDithering();
    
    volatile uint8_t *set = portSetRegister(pin);
    volatile uint8_t *clr = portClearRegister(pin);
    
    // Get access to the clock
    ARM_DEMCR    |= ARM_DEMCR_TRCENA; // what is this set for??
    ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
    ARM_DWT_CYCCNT = 0;
    
#ifdef NEO_KHZ400
    if((type & NEO_SPDMASK) == NEO_KHZ800) { // 800 KHz bitstream
Exemplo n.º 24
0
void PixelUtil::setAllRGB(byte r, byte g, byte b)
{
  for (uint16_t led = 0; led < numPixels(); led++) {
    leds[led] = CRGB(r, g, b);
  }
}
Exemplo n.º 25
0
	int end;
} bounds_t;

bounds_t teams[NUM_TEAMS] = {
	{5, 13}, //Team 1
	{18, 26}, //Team 2
	{31, 39}, //Team 3
	{44, 52}, //Team 4
	{57, 65}, //Team 5
	{70, 78}, //Team 6
	{83, 91}, //Team 7
	{94, 98}, //Team 8
};

CRGB teamcol[NUM_TEAMS] = {
	CRGB(255,   0,   0), //Team 1 (red)
	CRGB(  0, 255,   0), //Team 2 (green)
	CRGB(  0,   0, 255), //Team 3 (blue)
	CRGB(255, 255,   0), //Team 4 (yellow)
	CRGB(255,   0, 255), //Team 5 (magenta)
	CRGB(  0, 255, 255), //Team 6 (cyan)
	CRGB(128,   0, 255), //Team 7 (purple)
	CRGB(255, 255, 255), //Team 8 (white)
};

#define NUM_FRAMES 100
#define FRAME_DELAY 1
#define SWOOP_TEAM_COLS 1
#define SWOOP_FADE_SPEED 8
#define POST_SWOOP_FADE_SPEED 5