Example #1
0
void setup() {
  Serial.begin(9600);
  Serial.println("$CLS#Setup()");
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  LcdInit();

  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    PulseLed(RED, 2, 10, 10);
    PulseLed(BLUE, 2, 10, 10);
    PulseLed(GREEN, 2, 10, 10);

    Serial.print(".");
    LcdPrint(".");
  }
  Udp.begin(localPort);
  setSyncInterval(300);
  setSyncProvider(getNtpTime);

  // Turn on the backlight.
  LcdClear();
  LcdnoBacklight();
  delay(2000);
  LcdBacklight();
}
Example #2
0
void digitalClockDisplayLCD() {
  // digital clock display of the time
  // Serial /w Debug
  sprintf(buffer, "$FT,Y0,X0#%04d-%02d-%02d ", year(), month(), day());
  Serial.print(buffer);
  sprintf(buffer, "$FT,Y1,X0#%s W%02d D%03d", dow2String(weekday()), WN, DN);
  Serial.print(buffer);
  sprintf(buffer, "$Y5,X0#%02d:%02d:", hour(), minute());
  Serial.print(buffer);
  sprintf(buffer, "$FN,Y5,X35#%02d", second());
  Serial.print(buffer);
  Serial.print(F("$FT#"));
  // I2C LCD
  LcdSetCursor(0, 0);
  sprintf(buffer, "%04d-%02d-%02d %s", year(), month(), day(),
          dow2String(weekday()));
  LcdPrint(buffer);
  sprintf(buffer, "%02d:%02d:%02d W%02d %03d", hour(), minute(), second(), WN,
          DN);
  LcdSetCursor(0, 1);
  LcdPrint(buffer);
}
void ScaleEvents::OnScaleChanged(const ScaleEventData *evt)
{
	
	pLcd->clear();
  pLcd->home();
  pLcd->setCursor(0,0);
	
	if( evt->reportID != 3 ) {
		
		const char inv_report[]="Invalid report!";
		
		Serial.println(inv_report);
		LcdPrint(inv_report);
		
		return;
		
	}//if( evt->reportID != 3...
	
	switch( evt->status ) {
		
		case REPORT_FAULT: 
			Serial.println(F("Report fault"));
			break;
			
		case ZEROED:
			Serial.println(F("Scale zero set"));
			break;
			
		case WEIGHING: {
			
			const char progress[] = "Weighing...";
			Serial.println(progress);
			LcdPrint(progress);
			break;
		}
		
		case WEIGHT_VALID: {
			
			char buf[10];
      double weight = evt->weight * pow( 10, evt->exp );
      
      	
                        
      	Serial.print(F("Weight: "));
				Serial.print( weight );
				Serial.print(F(" "));
				Serial.println( UNITS[ evt->unit ]);
				
				LcdPrint("Weight: ");
				dtostrf( weight, 4, 2, buf );
				LcdPrint( buf ); 
				LcdPrint( UNITS[ evt->unit ]);
			
			break;
			
		}//case WEIGHT_VALID...
			
		case WEIGHT_NEGATIVE: {
			
			const char negweight[] = "Negative weight";
			Serial.println(negweight);
			LcdPrint(negweight);
			break;
		}
			
		case OVERWEIGHT: {
		
			const char overweight[] = "Max.weight reached";
			Serial.println(overweight);
			LcdPrint( overweight );
			break;
		}
		
		case CALIBRATE_ME:
			
			Serial.println(F("Scale calibration required"));
			break;
			
		case ZERO_ME:
			
			Serial.println(F("Scale zeroing required"));
			break;
			
		default:
			
			Serial.print(F("Undefined status code: "));
			Serial.println( evt->status );
			break;	
			
	}//switch( evt->status...

}