diff --git a/PrinterMonitor_LDR.png b/PrinterMonitor_LDR.png new file mode 100644 index 0000000..031fc33 Binary files /dev/null and b/PrinterMonitor_LDR.png differ diff --git a/printermonitor/Settings.h b/printermonitor/Settings.h index a149b82..994b877 100644 --- a/printermonitor/Settings.h +++ b/printermonitor/Settings.h @@ -92,7 +92,7 @@ boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = // Display Settings const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d) const int SDA_PIN = D2; -const int SCL_PIN = D5; // original code D5 -- Monitor Easy Board use D1 +const int SCL_PIN = D3; // original code D5 -- Monitor Easy Board use D1 boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at the bottom //#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common @@ -100,6 +100,9 @@ boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at the bott const int externalLight = LED_BUILTIN; // LED will always flash on bootup or Wifi Errors boolean USE_FLASH = true; // true = System LED will Flash on Service Calls; false = disabled LED flashing +//Light Dependant Resistor (LDR) Port +const int ldrPin = A0; + // PSU Control boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index 8849850..bdd5763 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -84,6 +84,9 @@ String lastSecond = "xx"; String lastReportStatus = ""; boolean displayOn = true; +//LDR Status +int ldrStatus =0; + // Printer Client #if defined(USE_REPETIER_CLIENT) RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); @@ -394,7 +397,7 @@ void loop() { } checkDisplay(); // Check to see if the printer is on or offline and change display. - + lightOn(); //Check if the lights are on ui.update(); if (WEBSERVER_ENABLED) { @@ -405,6 +408,20 @@ void loop() { } } +void lightOn() { //Check LDR status + ldrStatus = analogRead(ldrPin); + if(ldrStatus>=250){ //Change this value to change the sensitivity of the LDR + Serial.print("LDR value will turn on screen"); + DISPLAYCLOCK = true; + //enableDisplay(true); + } + else{ + Serial.print("LDR will NOT turn on screen"); + DISPLAYCLOCK = false; + // enableDisplay(false); + } +} + void getUpdateTime() { ledOnOff(true); // turn on the LED Serial.println();