Esempio n. 1
0
File: delay.cpp Progetto: Eih3/v0.83
void setup()
{
	initBoard();
	colorLED(GREEN);
	Delay(1);
	colorLED(RED);
	Delay(2);
	colorLED(BLACK);
}
Esempio n. 2
0
// set the global color variables AND simple set to this color
void Visualight::setColor(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _w){ 
  _red = _r;
  _green = _g;
  _blue = _b;
  _white = _w;

  colorLED(_r,_g,_b,_w);
}
Esempio n. 3
0
void Visualight::alert(){

  long elapsedBlinkTime = millis(); 

  if ( elapsedBlinkTime - alertBeginTimeStamp >= _durationTime){
  	if(isServer){
  		//wifly.setJoin(WIFLY_WLAN_JOIN_AUTO);
			//wifly.save();
			wifly.reboot();
	  	fadeOn();
	  	VPRINTLN(F("SERVER TIMEOUT")); //TIMEOUT??
		}else{
    	colorLED(_red, _green, _blue, _white);
    }
    alerting = false;
    blinkState=100;
    //return;
  } 

  else {  // update the current blink
    blinkState -= _frequency;
		if (blinkState <= 1 || blinkState >= 100) _frequency *= -1;
    
    switch(_blinkType){
      case 0: //FADING blink
        colorLED( int((blinkState*_Ared)/100), int((blinkState*_Agreen)/100), int((blinkState*_Ablue)/100), int((blinkState*_Awhite)/100));
				break;

      case 1: //HARD blink
        if(_frequency > 0 ){
          colorLED(_Ared, _Agreen, _Ablue, _Awhite);
        } else {
          colorLED(0, 0, 0, 0);
        }
				break;

      default:
      	break;
    }
  }
  delay(1);
}
Esempio n. 4
0
// turns all LEDs on to startColor
void Visualight::fadeOn(){
	_red = EEPROM.read(1);
	_green = EEPROM.read(2);
	_blue = EEPROM.read(3);
	_white = EEPROM.read(4);
  VPRINTLN(F("fadeOn"));
  for(int fadeValue = 1; fadeValue <=100; fadeValue +=5) { 
    colorLED((fadeValue*_red)/100, (fadeValue*_green)/100, (fadeValue*_blue)/100, (fadeValue*_white)/100);
    delay(10);            
  }
}
Esempio n. 5
0
void Visualight::wifiReset(){
  wifly.close();
  VPRINTLN(F("-WIFIRESET-"));
  colorLED(0,255,0,0); // THIS IS RELEASE DEPENDENT MAKE BETTER!!
  isServer = true;
  EEPROM.write(0, 1);
  setWiFlyLeds(1, false); //turn on, reboot
  wifly.reboot();
  wifly.setSoftAP();
  setAlert(0, 600000, 1, 0, 0, 255, 0);
}
Esempio n. 6
0
boolean Visualight::factoryRestore(){ 
  pinMode(resetButton, INPUT);
  pinMode(resetPin,OUTPUT);
  digitalWrite(resetButton, HIGH);
  digitalWrite(resetPin, HIGH);  
  pinMode(_red,OUTPUT);
  pinMode(_green, OUTPUT);
  pinMode(_blue, OUTPUT);
  
  #if DEBUG
    Serial.begin(115200);
    while(!Serial){
      ;
    }
  #endif
  colorLED(255, 0, 0,0);

  Serial1.begin(9600);
  if (!wifly.begin(&Serial1,&Serial)) {
    VPRINTLN(F("Failed to start wifly"));
  }

  // FACTORY RESTORE WIFLY UNIT
  if(wifly.factoryRestore()){
    wifly.setDeviceID("WiFly");
    wifly.save();
    VPRINTLN(F("WiFly Factory Restored. Rebooting.."));
    wifly.reboot();
    //reset visualight eeprom
    EEPROM.write(0, 1); 
    VPRINTLN(F("Visualight Factory Reset Complete !"));

    setAlert(0, 90000, 1, 0, 255, 0, 0);

    // setWiFlyLeds(1); // 1 = enable, 0 = disable green and red (GPIO 4 and 6)

    return true;
  } else {
    VPRINTLN(F("Failed to factoryRestore wifly"));
    return false;
  }
}