void init() { Serial.begin(SERIAL_BAUD_RATE); Serial.systemDebugOutput(true); // Allow debug print to serial Serial.println("Sming. Let's do smart things!"); Wire.pins(2, 0); lcd.begin(16, 2); lcd.backlight(); lcd.clear(); lcd.setCursor(0, 0); lcd.print("DATE: 00/00/0000"); lcd.setCursor(0, 1); lcd.print("TIME: 00:00"); // Station - WiFi client WifiStation.enable(true); WifiStation.config(WIFI_SSID, WIFI_PWD); // Put you SSID and Password here // set timezone hourly difference to UTC SystemClock.setTimeZone(7); // Run our method when station was connected to AP (or not connected) WifiStation.waitConnection(connectOk, 30, connectFail); // We recommend 20+ seconds at start }
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 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); } }
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 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; }
void changeStopLedState() { lcd.setCursor(0,0); lcd.print("Stop light time :"); lcd.setCursor(0,1); digitalClockDisplay(led.getStopTime()); lcd.setCursor(0,2); lcd.print("^"); lcd.setCursor(0,3); lcd.print("Back : #"); }
void changeHourState() { lcd.setCursor(0,0); lcd.print("Type the time :"); lcd.setCursor(0,1); digitalClockDisplay(now()); lcd.setCursor(0,2); lcd.print("^"); lcd.setCursor(0,3); lcd.print("Back : #"); }
void changeFadeOutState() { lcd.setCursor(0,0); lcd.print("Fade out light time :"); lcd.setCursor(0,1); digitalClockDisplay(led.getFadeOutTime()); lcd.setCursor(0,2); lcd.print("^"); lcd.setCursor(0,3); lcd.print("Back : #"); }
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")); }
void printWaitScreen() { lcd.setCursor(0,0); digitalClockDisplay(now()); lcd.setCursor(0,1); lcd.print("Output : "); lcd.print(percent); lcd.print("%"); lcd.setCursor(0,3); lcd.print("Menu : #"); }
void loop() { int sensorValue = analogRead(SOILSENSOR); Serial.print(sensorValue); Serial.print(" - "); if(sensorValue <= DRYNESS) { // if the soil is too dry start watering for 1.5 seconds then // wait for seconds before monitoring again Serial.println("Soil dry start watering"); digitalWrite(PUMPPIN, HIGH); delay(WATERDELAY); digitalWrite(PUMPPIN, LOW); delay(WATERPOSTDELAY); } float h = dht.readHumidity(); float f = dht.readTemperature(true); // Fahrenheit if (isnan(h) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(f, 1); // print only one decimal digit due to limited space lcd.print("\337F"); lcd.setCursor(0, 1); lcd.print("SoilMoisture:"); lcd.print(sensorValue); // lcd.setCursor(0,1); // lcd.print("Humidity: "); // lcd.print(h, 1); // lcd.print("%"); // Serial.print("Temp: "); // Serial.print(f); // // Serial.print("Humidity: "); // Serial.print(h); //Serial.print("Soil Moisture: "); //Serial.print(sensorValue); delay(5000); }
void setPressure() { lcd.clear(); lcd.print("Baromethric"); lcd.setCursor(0, 1); lcd.print("10000"); lcd.print(" kPa"); }
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); } }
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()); }
void setSource(int sourc){ source = sourc; int sourceID = 0; lcd.home(); // go home lcd.setCursor(0,1); if( source == 0){ sourceID = 0xC7; lcd.print(" 5.1 "); }else if( source == 1){ sourceID = 0xCB; lcd.print(" FM Radio "); }else if( source == 2){ sourceID = 0xCA; lcd.print(" AUX 2 "); }else if( source == 3){ sourceID = 0xC9; lcd.print(" AUX 3 "); }else if( source == 4){ sourceID = 0xC8; lcd.print(" AUX 4 "); } if(sourceID){ Wire.beginTransmission(PT2323_ADDRESS); Wire.write(DEVICE_REG_MODE1); Wire.write(sourceID); Wire.endTransmission(); } }
void setHumidity() { float newHumidity = dht.readHumidity(); lcd.clear(); lcd.print("Humidity"); lcd.setCursor(0, 1); lcd.print(newHumidity); lcd.print(" %"); }
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; } } }
void DisplayClass::goSleep() { lcd.clear(); lcd.home(); lcd.print(F("Low Power Mode")); lcd.setCursor(0, 1); lcd.print(F("Going to sleep in:")); lcd.setCursor(0, 2); lcd.print(F("3")); DELAY_FUNC(333); for (uint8_t i = 0; i < 3; i++) { lcd.print(F(".")); DELAY_FUNC(333); } lcd.print(F("2")); DELAY_FUNC(333); for (uint8_t i = 0; i < 3; i++) { lcd.print(F(".")); DELAY_FUNC(333); } lcd.print(F("1")); DELAY_FUNC(333); for (uint8_t i = 0; i < 3; i++) { lcd.print(F(".")); DELAY_FUNC(333); } lcd.print(F("0!")); DELAY_FUNC(333); for (uint8_t i = 0; i < 3; i++) { noBacklight(); DELAY_FUNC(500); backlight(); DELAY_FUNC(500); } }
void setTemperature() { float newTemperature = dht.readTemperature(false); lcd.clear(); lcd.print("Temperature"); lcd.setCursor(0, 1); lcd.print(newTemperature); lcd.print(" C"); }
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] ); }
void altitudeSet() { if(digitalRead(upButtonPin)==LOW) altitude += 10; if(digitalRead(downButtonPin)==LOW) altitude -= 10; if(digitalRead(selectButtonPin) == LOW) EEPROM_writeAnything(0, altitude); lcd.setCursor(0,0); lcd.print("Ustaw wysokosc"); lcd.setCursor(0,1); lcd.print("nad poziomem morza"); lcd.setCursor(0,2); lcd.print(altitude); lcd.setCursor(0, 3); lcd.print("SELECT - zapisz"); }
void connectFail() { debugf("connection FAILED"); WifiAccessPoint.config("MeteoConfig", "", AUTH_OPEN); WifiAccessPoint.enable(true); // Stop main screen output procTimer.stop(); displayTimer.stop(); lcd.clear(); lcd.setCursor(0,0); lcd.print("WiFi MeteoConfig"); lcd.setCursor(0,1); lcd.print(" "); lcd.print(WifiAccessPoint.getIP()); startWebServer(); WifiStation.waitConnection(connectOk); // Wait connection }
void loop() { /* Runs the non RT controller */ controller.run(); // Serial.print(" Temperature milieu: "); // Serial.print(humidTempSensor.getTemp()); // Serial.print(" Humidite milieu: "); // Serial.print(humidTempSensor.getHumidity()); // Serial.print(" Temperature Bas: "); // Serial.println(lowSensor.getAverageValue()); // Serial.println(); // lcd.cursor(); // lcd.clear(); lcd.setCursor(7,0); digitalClockDisplay(now()); lcd.setCursor(0,1); lcd.print("Up : "); lcd.print(highSensor.getTemp()); lcd.print((char)223); lcd.print('C'); // lcd.setCursor(0,2); // lcd.print("Mid : "); // lcd.print(humidTempSensor.getTemp()); // lcd.print((char)223); // lcd.print('C'); lcd.setCursor(0,2); lcd.print("Down : "); lcd.print(lowSensor.getTemp()); lcd.print((char)223); lcd.print('C'); // fogRelay.on(); // lightRelay.on(); // // heatRelay.on(); // delay(5000); // fogRelay.off(); // lightRelay.off(); // // heatRelay.off(); lcd.setCursor(0,1); Alarm.delay(1000); }
void init() { spiffs_mount(); Serial.begin(230400); // 115200 by default Serial.systemDebugOutput(false); // Enable debug output to serial Wire.begin(); lcd.begin(16,2); // initialize the lcd for(int i = 0; i< 3; i++) { lcd.backlight(); delay(150); lcd.noBacklight(); delay(250); } lcd.backlight(); lcd.setCursor(0,0); lcd.clear(); lcd.print(" Music Box "); lcd.setCursor(0,1); lcd.print(" Geek Labs "); SystemClock.setTimeZone(3); printTimer.initializeMs(1000*60, onPrintSystemTime).start(); Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(true); // Enable debug output to serial WifiStation.enable(true); WifiStation.config(WIFI_SSID, WIFI_PWD); WifiAccessPoint.enable(false); Wire.beginTransmission(PT2258_ADDRESS); Wire.write(0xC0); Wire.endTransmission(); // Run our method when station was connected to AP WifiStation.waitConnection(connectOk, 30, connectFail); }
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 overviewPage() { lcd.home(); lcd.print(getTime(tm) + " " + getDate(tm)); lcd.setCursor(0,1); lcd.print("Temp: "); lcd.print(temperature); lcd.print("C"); lcd.setCursor(0, 2); lcd.print("Swiatlo: "); lcd.print(lightLevel); lcd.print(" lx"); lcd.setCursor(0, 3); lcd.print("Cisn: "); lcd.print(pressure); lcd.print("hPa"); }
void menuState() { menuItem tempItem; for (int i = 0; i < NUMBER_OF_MENU_LINES; i++) { tempItem = menuItems.pop(); if (tempItem.message != NULL) { lcd.setCursor(0,i); lcd.print(i+1); lcd.print(tempItem.message); } menuItems.push(tempItem); } lcd.setCursor(0,3); if (menuItems.count() > NUMBER_OF_MENU_LINES) { lcd.print("Next : * Back : 0"); } else{ lcd.print("Back : #"); } }
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(); }
void setup() { Serial.begin(115200); //Setup Channel A pinMode(X_DIR_PIN, OUTPUT); //Initiates Motor Channel A pin pinMode(Y_DIR_PIN, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin pinMode(A0,INPUT); pinMode(X_MIN_PIN,INPUT_PULLUP); pinMode(X_MAX_PIN,INPUT_PULLUP); pinMode(X_JOY_LEFT,INPUT_PULLUP); pinMode(X_JOY_RIGHT,INPUT_PULLUP); pinMode(Y_JOY_DOWN,INPUT_PULLUP); pinMode(Y_JOY_UP,INPUT_PULLUP); // Quadrature encoders // X encoder pinMode(c_XEncoderPinA, INPUT); // sets pin A as input digitalWrite(c_XEncoderPinA, LOW); // turn on pullup resistors pinMode(c_XEncoderPinB, INPUT); // sets pin B as input digitalWrite(c_XEncoderPinB, LOW); // turn on pullup resistors attachInterrupt(c_XEncoderInterrupt, HandleLeftMotorInterruptA, RISING); // Y encoder pinMode(c_YEncoderPinA, INPUT); // sets pin A as input digitalWrite(c_YEncoderPinA, LOW); // turn on pullup resistors pinMode(c_YEncoderPinB, INPUT); // sets pin B as input digitalWrite(c_YEncoderPinB, LOW); // turn on pullup resistors attachInterrupt(c_YEncoderInterrupt, HandleRightMotorInterruptA, RISING); lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight // ------- Quick 3 blinks of backlight ------------- for(int i = 0; i< 3; i++) { lcd.backlight(); delay(150); lcd.noBacklight(); delay(150); } lcd.backlight(); // finish with backlight on //-------- Write characters on the display ------------------ // NOTE: Cursor Position: Lines and Characters start at 0 lcd.setCursor(3,0); //Start at character 4 on line 0 lcd.print("Hello, world!"); }/*--(end setup )---*/
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); } }