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 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 setup_display(void) { // Switch on the backlight //pinMode ( BACKLIGHT_PIN, OUTPUT ); //digitalWrite ( BACKLIGHT_PIN, HIGH ); lcd.begin(16,2); // initialize the lcd lcd.home(); }
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 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 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 setup() { Serial.begin(9600); // Switch on the backlight pinMode ( BACKLIGHT_PIN, OUTPUT ); digitalWrite ( BACKLIGHT_PIN, HIGH ); lcd.begin(16,2); // initialize the lcd sen1.begin(); sen2.begin(); sen3.begin(); sen4.begin(); sen5.begin(); lcd.home (); // go home lcd.print(" getting temps "); lcd.setCursor ( 0, 1 ); // go to the next line lcd.print (" init serial "); delay ( 1000 ); digitalWrite ( BACKLIGHT_PIN, LOW); }
// The loop function is called in an endless loop void loop() { switch(b.getState()) { case Button::pressed: // if press and hold is allowed, the pressed state should not be used break; case Button::released: Serial1.println("Released condition"); b.resetState(); Store.Advance(); break; case Button::press_hold: Serial1.println("Press and hold condition"); ForceADCReadout = true; switch( Store.getItemState(Store.mIndex) ) { case Item::normal: Serial1.println("normal->forced_off"); Store.setItemState(Store.mIndex, Item::forced_off); break; case Item::forced_off: Serial1.println("forced_off->forced_on"); Store.setItemState(Store.mIndex, Item::forced_on); break; case Item::forced_on: Serial1.println("forced_on->normal"); Store.setItemState(Store.mIndex, Item::normal); break; } b.resetState(); break; default:; } // ADC sampling for(int i = 0; i < CHANNEL_COUNT; i++ ) { AdcChannel * ch = &ADCs[i]; if( ch->isActive() && ( ForceADCReadout || ch->isDue() )) { Store.temperatureReading(i, ch->getTemperature()); } } ForceADCReadout = false; // update LCD display if necessary if( Store.isAnyActiveChannel() == true ) { if(CurrentIndex != Store.mIndex || Store.getDirty(Store.mIndex)) { CurrentIndex = Store.mIndex; lcd.home (); // set cursor to 0,0 char buf[32]; float t = Store.getTemperature(Store.mIndex); int intPart = t; unsigned int fractPart = abs((t - (float)intPart)*10.0); sprintf( buf, "CH%d %d.%01dC %s", CurrentIndex + 1, intPart, fractPart, Store.getIsOn(Store.mIndex) ? "ON " : "OFF "); Store.setDirty(Store.mIndex, false); lcd.print( buf ); lcd.setCursor (0,1); // go to start of 2nd line if( Store.getItemState(Store.mIndex) == Item::forced_off || Store.getItemState(Store.mIndex) == Item::forced_on ) { lcd.print( "FORCED " ); } else { lcd.print( Store.getLow(Store.mIndex) ); lcd.print(".."); lcd.print( Store.getHigh(Store.mIndex) ); lcd.print("C "); } // list controlled actuators lcd.print("A:"); for( int i = 0; i < CHANNEL_COUNT; i++ ) { if( Store.getActuators(Store.mIndex) & (1 << i) ) { lcd.print((char)(i + '1')); } } lcd.print(" "); } } else { lcd.home (); // set cursor to 0,0 lcd.print("ALL CHANNELS"); lcd.setCursor (0,1); // go to start of 2nd line lcd.print("INACTIVE"); } // log the data if time comes. Protect against wrap around unsigned long ms = millis(); if( ms < notTooOftenCounter || notTooOftenCounter + 60000 < ms ) { notTooOftenCounter = millis(); DateTime now = rtc.now(); if( !Store.LogIfDue( now ) ) { Serial1.println("No logging. The write attempt failed. Is the SD inserted? Insert and reset!"); digitalWrite( ALARM_LED_PIN, HIGH ); } } }
void loop() { sen1.requestTemperatures(); sen2.requestTemperatures(); sen3.requestTemperatures(); sen4.requestTemperatures(); sen5.requestTemperatures(); echoSerial(); delay(1000); echoSerial(); delay(1000); digitalWrite ( BACKLIGHT_PIN, HIGH ); if(sen1.getTempCByIndex(0) < 80){ tmp1=sen1.getTempCByIndex(0); } if(sen2.getTempCByIndex(0) < 80){ tmp2=sen2.getTempCByIndex(0); } if(sen3.getTempCByIndex(0) < 80){ tmp3=sen3.getTempCByIndex(0); } if(sen4.getTempCByIndex(0) < 80){ tmp4=sen4.getTempCByIndex(0); } if(sen5.getTempCByIndex(0) < 80){ tmp5=sen5.getTempCByIndex(0); } lcd.home (); // go home lcd.print("T1="); lcd.print(tmp1); lcd.print(" T2="); lcd.print(tmp2); lcd.setCursor ( 0, 1 ); // go to the next line lcd.print("T3="); lcd.print(tmp3); lcd.print(" T4="); lcd.print(tmp4); Serial.print(tmp1); Serial.print("|"); Serial.print(tmp2); Serial.print("|"); Serial.print(tmp3); Serial.print("|"); Serial.print(tmp4); Serial.print("|"); Serial.print(tmp5); Serial.println(";"); for(int i=0;i<5;i++){ echoSerial(); delay(1000); } digitalWrite ( BACKLIGHT_PIN, LOW ); }