abacon118 2023-05-29 20:41:02 -04:00 committed by GitHub
commit 1b19232a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

BIN
PrinterMonitor_LDR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -92,7 +92,7 @@ boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false =
// Display Settings // Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d) const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
const int SDA_PIN = D2; 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 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 //#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 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 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 // PSU Control
boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use

View File

@ -84,6 +84,9 @@ String lastSecond = "xx";
String lastReportStatus = ""; String lastReportStatus = "";
boolean displayOn = true; boolean displayOn = true;
//LDR Status
int ldrStatus =0;
// Printer Client // Printer Client
#if defined(USE_REPETIER_CLIENT) #if defined(USE_REPETIER_CLIENT)
RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); 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. checkDisplay(); // Check to see if the printer is on or offline and change display.
lightOn(); //Check if the lights are on
ui.update(); ui.update();
if (WEBSERVER_ENABLED) { 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() { void getUpdateTime() {
ledOnOff(true); // turn on the LED ledOnOff(true); // turn on the LED
Serial.println(); Serial.println();