void startWebServer()
{
	server.listen(80);
	server.addPath("/", onIndex);
	server.addPath("/lcd", onLcd);
	server.addPath("/volume", onVolume);
	server.addPath("/mute", onMute);
	server.addPath("/source", onSource);
	server.addPath("/state", onState);
	server.addPath("/power", onPower);
	server.addPath("/tune", onTune);
	server.addPath("/mixing", onMixing);
	server.addPath("/enhance", onEnhance);
	
		// Web Sockets configuration
	server.enableWebSockets(true);
	server.setWebSocketConnectionHandler(wsConnected);
	server.setWebSocketMessageHandler(wsMessageReceived);
	server.setWebSocketBinaryHandler(wsBinaryReceived);
	server.setWebSocketDisconnectionHandler(wsDisconnected);

	
	server.setDefaultHandler(onFile);

	Serial.println("\r\n=== WEB SERVER STARTED ===");
	Serial.println(WifiStation.getIP());
    lcd.clear();
    lcd.setCursor(1,1);
	lcd.print(WifiStation.getIP());
}
Example #2
0
void echoSerial(){
 byte index=0;
 char outa[20];
 char outb[20];
 outb[0]='\0';
 boolean foundData=false;
 while (Serial.available() > 0){
   foundData=true;
   if(index < 19){
     outa[index]=Serial.read();
     index++;
     outa[index]= '\0'; 
   }else{ 
     if(index < 39){
       outb[index-20]=Serial.read();
       index++;
       outb[index-20]= '\0';
     }
   }
 }
 if(foundData){
   lcd.clear();
   lcd.home();
   lcd.print(outa);
   lcd.setCursor ( 0, 1 );
   lcd.print(outb);
 }
}
// The loop function is called in an endless loop
void loop() {
	delay(SENSOR_CHANGE_TRIGGER_TIME);
	unsigned long unchangedTime = millis() - lastMotionDetected;
	if (unchangedTime < MAX_ON_TIME) {
		lcd.display();
		lcd.backlight();
		switch (sensor) {
		case TEMPERATURE_SENSOR_NUM:
			setTemperature();
			break;
		case HUMIDITY_SENSOR_NUM:
			setHumidity();
			break;
		case SOIL_SENSOR_NUM:
			setSoilHumidity();
			break;
		case PRESSURE_SENSOR_NUM:
			setPressure();
			break;
		}
	} else {
		lcd.noDisplay();
		lcd.noBacklight();
	}
	delay(500);
}
Example #4
0
void WeatherStation::processButton()
{
    #define GOTOSLEEP_TIME 2 //s

    setCurrentDate();
    buttonPressHours = runHours;
    buttonPressMinute = currentMinute;

    if ( DISPLAY_STATE_INIT == displayMgt.state )
    {
        lcd.backlight();

        lcd.setCursor(0,0);
        lcd.print("Weather Station");  //16
        lcd.setCursor(0,1);
        lcd.print("*** DFRobot ***");  //16

        addAction(ACTION_SAMPLE_DATA);
    }

    addAction(ACTION_DISPLAY);


    overTime = SLEEP_OVERTIME;
    /**to avoid RTC interrupt when goto sleep **/
    if ( (59 == currentMinute) && ( (currentSecond + overTime + GOTOSLEEP_TIME) >= 60 ))
    {
        overTime += (GOTOSLEEP_TIME + 1);
    }


}
void setPressure() {
	lcd.clear();
	lcd.print("Baromethric");
	lcd.setCursor(0, 1);
	lcd.print("10000");
	lcd.print(" kPa");
}
void setTemperature() {
	float newTemperature = dht.readTemperature(false);
	lcd.clear();
	lcd.print("Temperature");
	lcd.setCursor(0, 1);
	lcd.print(newTemperature);
	lcd.print(" C");
}
void printDigits(int digits, char separator)
{
  if (separator != NULL)
    lcd.print(separator);
  if(digits < 10)
    lcd.print('0');
  lcd.print(digits);
}
void setHumidity() {
	float newHumidity = dht.readHumidity();
	lcd.clear();
	lcd.print("Humidity");
	lcd.setCursor(0, 1);
	lcd.print(newHumidity);
	lcd.print(" %");
}
Example #9
0
void setup_display(void)
{
	// Switch on the backlight
	//pinMode ( BACKLIGHT_PIN, OUTPUT );
	//digitalWrite ( BACKLIGHT_PIN, HIGH );
	
	lcd.begin(16,2);               // initialize the lcd
	lcd.home();

}
Example #10
0
LCD::LCD(Cooler *cooler, CheeseDHT *dhtUp, CheeseDHT *dhtDown, CheeseLog* logger) {
  this->cooler = cooler;
  this->logger = logger;
  this->dhtUp = dhtUp;
  this->dhtDown = dhtDown;
  Wire.begin(4, 5);
  currentLCD.init();
  currentLCD.backlight();
  counter = 0;
}
Example #11
0
void navigationReturnHome()
{
  navigationSounds->play( soundUhoh );
  currentNavigationDestination = currentNavigationHome;
  lcd.clear();
  lcd.print( "Returning home!" );

  lcd.setCursor(0, 2); lcd.print( "Next stop:" );
  lcd.setCursor(0, 3); lcd.print( destinationList[currentNavigationHome] );
}
Example #12
0
void setup() {
	lcd.print("LOADING");

	lcd.begin(20, 4);
	sensorManager.init();
	initButtons();
	Serial.begin(9600);
	setSyncProvider(RTC.get);

	EEPROM_readAnything(0, altitude);
}
void setPower(int state){
	power = state;
	lcd.setCursor(0,1);
	if(state==1){
		lcd.print("   Power ON     ");	
		lcd.backlight();
	}else{
		lcd.print("   Power OFF    ");	
		lcd.noBacklight();
	}

}
void setup() {
  Serial.begin(9600);
  pinMode(SOILSENSOR, INPUT);
  pinMode(PUMPPIN, OUTPUT);
  
  // initialize the LCD
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Initializing...");

  dht.begin();
}
Example #15
0
void flashx3() {
// ------- Quick 3 blinks of backlight  -------------
for (int i = 0; i < 3; i++)
{
  lcd.backlight();
  delay(2000);
  lcd.noBacklight();
  delay(2000);
}
lcd.backlight(); // finish with backlight on

//-------- Initialise display ----------------
}
Example #16
0
void init()
{
	spiffs_mount(); // Mount file system, in order to work with files

	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(false); // Debug output to serial

	ActiveConfig = loadConfig();

	// Select control line
	pinMode(CONTROL_PIN, OUTPUT);

	// DHT sensor start
	dht.begin();

	lcd.begin(16, 2);
	lcd.backlight();
	lcd.createChar(1, icon_termometer);
	lcd.createChar(2, icon_water);
	lcd.createChar(3, celsius);
	lcd.createChar(4, icon_retarrow);
	lcd.createChar(5, icon_clock);
	lcd.createChar(6, icon_cross);
	lcd.createChar(7, icon_check);

	WifiStation.config(ActiveConfig.NetworkSSID, ActiveConfig.NetworkPassword);
	WifiStation.enable(true);
	WifiAccessPoint.enable(false);

	WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start

	procTimer.initializeMs(5000, process).start();
	process();
}
Example #17
0
void LCD::Update() {
  if ((++counter) % 2 != 0) {
    logger->Info("LCD update - data");

    currentLCD.setCursor(0, 0);
    String line1 = BriefTemp(dhtUp, "U") + BriefTemp(dhtDown, "D");
    currentLCD.print(line1);

    String line2 = "COOLER: " + String(cooler->IsWorking() ? "ON" : "OFF");
    while (line2.length() < 16)
      line2 += " ";
    currentLCD.setCursor(0, 1);
    currentLCD.print(line2);
  } else {
    logger->Info("LCD update - time");

    String line1 = CheeseTime::DayOfWeek();
    while (line1.length() < 16)
      line1 += " ";
    currentLCD.setCursor(0, 0);
    currentLCD.print(line1);

    String line2 = CheeseTime::Current();
    while (line2.length() < 16)
      line2 += " ";
    currentLCD.setCursor(0, 1);
    currentLCD.print(line2);
  }
}
Example #18
0
void MyDisplay::begin()
{
    byte error;

    Wire.lock();

#if DISPLAY_TYPE == DISPLAY_TYPE_SSD1306
    Wire.beginTransmission(0x3c);
    error = Wire.endTransmission();

    if (error == 0)
    {
        displayFound = TRUE;
        Debug.printf("Found OLED at %x\n", 0x3c);
        // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)`
        // initialize with the I2C addr 0x3D (for the 128x64)
        // bool:reset set to TRUE or FALSE depending on you display
        display.begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS, FALSE);
        // display.begin(SSD1306_SWITCHCAPVCC);
        display.display();
    }
#elif DISPLAY_TYPE == DISPLAY_TYPE_20X4
    Wire.beginTransmission(I2C_LCD_ADDR);
    error = Wire.endTransmission();

    if (error == 0)
    {
        displayFound = TRUE;
        Debug.printf("Found LCD at %x\n", I2C_LCD_ADDR);
        lcd.begin(20, 4);
        lcd.setCursor(0, 0);
        lcd.print((char *)"MySensors gateway   ");
    }
    else
    {
        Debug.printf("LCD not found at %x\n", I2C_LCD_ADDR);
    }        
#else
    Debug.println("No display available");
    error = 0xff;
#endif

    Wire.unlock();

    if (displayFound)
    {
        displayTimer.initializeMs(1000, TimerDelegate(&MyDisplay::update, this)).start(true);
    }
}
Example #19
0
void setup()/*----( SETUP: RUNS ONCE )----*/
{
  lcd.begin(20, 4);        // initialize the lcd for 20 chars 4 lines and turn on backlight
  
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // --- button setup

  pinMode(RunBtn, INPUT);
  pinMode(ChangeScanBtn, INPUT);

  digitalWrite(RunBtn, HIGH);
  digitalWrite(ChangeScanBtn, HIGH);


  pinMode(clampPin, OUTPUT);      // sets the digital pin as OUTPUT to drive FET clamp)

  pinMode(5, OUTPUT);      // sets the digital pin as output
  pinMode(6, OUTPUT);      // sets the digital pin as output
  pinMode(7, OUTPUT);      // sets the digital pin as output
  pinMode(11, OUTPUT);     // pin11= PWM  output / frequency output //Will Turner - This could go to pin 5 from 11.  CHANGED TO 9 AS IT WOULDNT REACH OTHERS


  // ------- Quick 3 blinks of backlight  -------------
  for (int i = 0; i < 3; i++)
  {
    lcd.backlight();
    delay(20);
    lcd.noBacklight();
    delay(20);
  }
  lcd.backlight(); // finish with backlight on

  //-------- Initialise display ----------------
  // NOTE: Cursor Position: CHAR, LINE) start at 0
  lcd.setCursor(0, 0); //Start at character 0 on line 0
  lcd.print("Tension Tester v1.5 "); // sets up the screen for the wire number and layer number being recorded
  lcd.setCursor(0, 2);
  lcd.print("     Press Run      ");

  Setup_timer2();

  // disable interrupts to avoid timing distortion
  cbi (TIMSK0, TOIE0);             // disable Timer0 !!! delay() is now not available
  sbi (TIMSK2, TOIE2);             // enable Timer2 Interrupt

  dfreq = 1000.0;                  // initial output frequency = 1000.o Hz
  tword_m = pow(2, 32) * dfreq / refclk; // calulate DDS new tuning word

  // setup start and end frequencies of sweep

  // setup initial values for loop
  adcflag = false;

  analogval = 0;
  digitalWrite(clampPin, HIGH);    // sets the pin high to short out large signals before amp (using a FET as clamp)
  avgcnt = 0.0;
}
Example #20
0
time_t computeUserInput(uint8_t index, uint8_t number)
{
  static time_t time;
  uint8_t numberPosition = index;
  uint8_t nextPosition = index + 1;

  switch (index)
  {
    case 0:
      if (number > 2)
        number = 0;
      time = 0;
      time = hoursToTime_t(number * 10);
      break;
    case 1:
      nextPosition = 3;
      if (hour(time) >= 20 && number > 3)
        number = 0;
      time += hoursToTime_t(number);
      break;
    case 2:
      numberPosition = 3;
      nextPosition = 4;
      if (number > 5)
        number = 0;
      time += minutesToTime_t(number * 10);
      break;
    case 3:
      numberPosition = 4;
      nextPosition = 6;
      time += minutesToTime_t(number);
      break;
    case 4:
      numberPosition = 6;
      nextPosition = 7;
      if (number > 5)
        number = 0;
      time += number * 10;
      break;
    case 5:
      time += number;
      numberPosition = 7;
      nextPosition = 0;
      lcd.setCursor(10,3);
      lcd.print("OK : *");
      break;
    default:
      return time;
  }

  lcd.setCursor(numberPosition,1);
  lcd.print(number);
  lcd.setCursor(numberPosition,2);
  lcd.print(" ");
  lcd.setCursor(nextPosition,2);
  lcd.print("^");

  return time;
}
void printDigits(int digits, char separator)
{
    if (separator != NULL)
    {
        lcd.print(separator);
        Serial.print(separator);
    }
    if(digits < 10)
    {
        lcd.print('0');
        Serial.print('0');
    }
    lcd.print(digits);
    Serial.print(digits);
}
void onPrintSystemTime() {
	lcd.setCursor(0,0);
	lcd.print(SystemClock.getSystemTimeString());	
	
	if(!WifiStation.isConnected()){
		if(connectTimeout>2){
			lcd.print(" Restarting...  ");	
			System.restart();
			connectTimeout = 0;
		}else{
			lcd.print("    Offline     ");	
			
		}
	}
}
Example #23
0
void navigationInit(PiezoEffects * mySounds)
{
  navigationSounds = mySounds;

  //lcd buttons
  pinMode(LCD_UP_PIN, INPUT_PULLUP);
  pinMode(LCD_DOWN_PIN, INPUT_PULLUP);
  pinMode(LCD_PLAY_PIN, INPUT_PULLUP);
  pinMode(LCD_STOP_PIN, INPUT_PULLUP);

  // initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.print("Geekbot Navigator");
}
Example #24
0
void DisplayClass::init()
{
	lcd.begin(20, 4);               // initialize the lcd 
	lcd.home();                   // go home
	lcd.print(F("  WATER DISPENSER"));
	lcd.setCursor(0, 1);
	lcd.print(F("    Version: "VERSION""));
	lcd.setCursor(0, 2);
	lcd.print(F("   INITALIZING..."));
	lcd.setCursor(0, 3);
	lcd.print(F("  Tiago Conceicao"));
}
Example #25
0
void WeatherStation::enableAfterSleep()
{
    uint8_t i;
    volatile uint8_t *out, *ddr;
    uint16_t diffMinutes;

    //enable power
    digitalWrite( PALETTE_PIN_MVCC, LOW );
    pinMode( PALETTE_PIN_MVCC, OUTPUT );
    delay(50);  //waiting power stable

    /**recovery ports**/
    for( i = 0; i < PALETTE_PORT_NUM; i++ )
    {
        ddr = portModeRegister(ioPort[i]);
        out = portOutputRegister(ioPort[i]);

        *ddr = ioPreDDRValue[i];
        *out = ioPrePORTValue[i];
    }


    sensorMgt.start();
    lcd.init();  //need sometimes

    if ( EVENT_STATE_SET == eventButtonState )
    {
        lcd.backlight();

        setCurrentDate();

        diffMinutes = (uint16_t)(runHours - buttonPressHours) * 60 + currentMinute - buttonPressMinute;

        if ( (!displayMgt.statisticFlag) || (diffMinutes >= RESTART_DISPLAY_OVERTIME) )
        {
            clrDisplayMgt();
        }
    }


    for ( i = 0; i < ACTION_NUMBER; i++ )
    {
        a_actionList[i].state = STATE_INIT;
    }

    startTime = (uint8_t)(millis()/1000);

}
Example #26
0
void WeatherStation::disableBeforeSleep()
{
    volatile uint8_t *out, *ddr;
    uint8_t i;

    setCurrentDate();

    lcd.noBacklight();

    sensorMgt.stop();

    overTime = 0;

    delay(100);

    /**close ports**/
    for( i = 0; i < PALETTE_PORT_NUM; i++ )
    {
        ddr = portModeRegister(ioPort[i]);
        out = portOutputRegister(ioPort[i]);

        ioPreDDRValue[i] = *ddr;
        ioPrePORTValue[i] = *out;

        (*ddr) &= ioDisableMask[i];
        (*out) &= ioDisableMask[i];
    }


}
Example #27
0
int step1()
{
    //Wait for GPS
    lcd.clear();
    lcd.println(F("Looking for GPS"));
    lcd.setCursor(0, 1);
    char str[32];
    sprintf(str,"view:%2d  fix:%2d", sats_view, sats_fix);
    lcd.print(str);

    delay(1000);

    if(millis() > sleep_time + 300000) digitalWrite(ON_PIN, 0);
    if(gps_fix == 3) return 1;
    else return 0;
}
void setMixing(int mixin){
	mixing = mixin;
	lcd.setCursor(0,1);
	if(mixing){
		lcd.print("   Mixed ON     ");	
		Wire.beginTransmission(PT2323_ADDRESS); 
		Wire.write(DEVICE_REG_MODE1);
		Wire.write(0x90);
		Wire.endTransmission();
	}else{
		lcd.print("   Mixed OFF    ");	
		Wire.beginTransmission(PT2323_ADDRESS); 
		Wire.write(DEVICE_REG_MODE1);
		Wire.write(0x91);
		Wire.endTransmission();
	}
}
void setMmute(int mut){
	mute=mut;
	lcd.setCursor(0,1);
	if(mut==1){
		lcd.print("     Mute       ");	
	    Wire.beginTransmission(PT2323_ADDRESS);
	  	Wire.write(DEVICE_REG_MODE1);
	  	Wire.write(0xFF);
	  	Wire.endTransmission();
	}else{
		lcd.print("   Un Mute      ");	
	    Wire.beginTransmission(PT2323_ADDRESS);
	  	Wire.write(DEVICE_REG_MODE1);
	  	Wire.write(0xFE);
	  	Wire.endTransmission();
	}
}
Example #30
0
void lcdSelectDestination()
{
  uint8_t currentPrintItem = lcdCurrentSelection;

  lcd.setCursor(0, 1);
  lcd.print('>');

  for ( int i = 0; i < 3; ++i )
  {
    lcd.print( destinationList[currentPrintItem] );
    lcd.setCursor(0, 2 + i);
    if ( ++currentPrintItem == MAP_LOCATION_COUNT )
    {
      currentPrintItem = 0;
    }
  }
}