more optimization

This commit is contained in:
Lexzach 2022-10-15 13:52:08 -04:00
parent 18702567c3
commit 1b41a2da82
Signed by: Lexzach
GPG Key ID: B574880929E6F1F0

View File

@ -224,9 +224,6 @@ void setup() {
//----------------------------------------------------------------------------- SETUP PINS //----------------------------------------------------------------------------- SETUP PINS
pinMode(resetButtonPin, INPUT); //reset switch pinMode(resetButtonPin, INPUT); //reset switch
if (digitalRead(resetButtonPin) == HIGH){
failsafeMode = true;
}
pinMode(hornRelay, OUTPUT); //horn pinMode(hornRelay, OUTPUT); //horn
pinMode(strobeRelay, OUTPUT); //strobe pinMode(strobeRelay, OUTPUT); //strobe
pinMode(smokeDetectorRelay, OUTPUT); //smoke relay pinMode(smokeDetectorRelay, OUTPUT); //smoke relay
@ -236,6 +233,9 @@ void setup() {
pinMode(keySwitchPin, INPUT); //key switch pinMode(keySwitchPin, INPUT); //key switch
pinMode(silenceButtonPin, INPUT); //silence switch pinMode(silenceButtonPin, INPUT); //silence switch
pinMode(drillButtonPin, INPUT); //drill switch pinMode(drillButtonPin, INPUT); //drill switch
if (digitalRead(resetButtonPin) and not digitalRead(silenceButtonPin) and not digitalRead(drillButtonPin)){
failsafeMode = true;
}
pinMode(zone1Pin, INPUT); //zone 1 pinMode(zone1Pin, INPUT); //zone 1
pinMode(zone2Pin, INPUT); //zone 2 pinMode(zone2Pin, INPUT); //zone 2
@ -259,7 +259,7 @@ void setup() {
lcd.backlight(); lcd.backlight();
//----------------------------------------------------------------------------- EEPROM RESET BUTTONS //----------------------------------------------------------------------------- EEPROM RESET BUTTONS
if (digitalRead(resetButtonPin)==HIGH and digitalRead(silenceButtonPin)==HIGH and digitalRead(drillButtonPin)==HIGH and failsafeMode == false){ //reset EEPROM if all buttons are pressed if (digitalRead(resetButtonPin) and digitalRead(silenceButtonPin) and digitalRead(drillButtonPin) and failsafeMode == false){ //reset EEPROM if all buttons are pressed
for(int i=5; i!=0; i--){ for(int i=5; i!=0; i--){
lcd.clear(); lcd.clear();
lcd.setCursor(0,0); lcd.setCursor(0,0);
@ -268,7 +268,7 @@ void setup() {
lcd.print((String)"HOLD BUTTONS - "+i); lcd.print((String)"HOLD BUTTONS - "+i);
delay(1000); delay(1000);
} }
if (digitalRead(resetButtonPin)==HIGH and digitalRead(silenceButtonPin)==HIGH and digitalRead(drillButtonPin)==HIGH){ if (digitalRead(resetButtonPin) and digitalRead(silenceButtonPin) and digitalRead(drillButtonPin)){
lcd.clear(); lcd.clear();
lcd.setCursor(0,0); lcd.setCursor(0,0);
lcd.print("RESETTING TO"); lcd.print("RESETTING TO");
@ -316,19 +316,19 @@ void setup() {
} }
lcd.setCursor(0,1); lcd.setCursor(0,1);
lcd.print("check manual"); lcd.print("check manual");
while(digitalRead(resetButtonPin) == LOW and digitalRead(drillButtonPin) == LOW){ //wait until button is pressed while(not digitalRead(resetButtonPin) and not digitalRead(drillButtonPin)){ //wait until button is pressed
delay(1); delay(1);
} }
if(digitalRead(resetButtonPin) == HIGH){ if(digitalRead(resetButtonPin)){
failsafeMode = true; // ----- ENTER FAILSAFE MODE failsafeMode = true; // ----- ENTER FAILSAFE MODE
} else if (digitalRead(drillButtonPin) == HIGH){ } else if (digitalRead(drillButtonPin)){
resetEEPROM(); resetEEPROM();
} }
} else { } else {
Serial.println("EEPROM integrity verified"); Serial.println("EEPROM integrity verified");
} }
//----------------------------------------------------------------------------- EEPROM INTEGRETY //----------------------------------------------------------------------------- EEPROM INTEGRETY
if (failsafeMode == false){ //continue loading if failsafe mode is not enabled if (not failsafeMode){ //continue loading if failsafe mode is not enabled
lcd.clear(); lcd.clear();
lcd.setCursor(4,0); lcd.setCursor(4,0);
lcd.print("BOOTING..."); lcd.print("BOOTING...");
@ -420,7 +420,7 @@ void setup() {
Serial.println("Config loaded"); Serial.println("Config loaded");
digitalWrite(readyLed, HIGH); //power on ready LED on startup digitalWrite(readyLed, HIGH); //power on ready LED on startup
updateLockStatus = true; updateLockStatus = true;
if (digitalRead(keySwitchPin) == HIGH and keyRequired == true){ //check the key status on startup if (digitalRead(keySwitchPin) and keyRequired){ //check the key status on startup
panelUnlocked = true; panelUnlocked = true;
} else { } else {
panelUnlocked = false; panelUnlocked = false;
@ -461,14 +461,14 @@ void noTone() {
ledcWriteTone(0, 0); // stop tone ledcWriteTone(0, 0); // stop tone
} }
void hornOn(bool on){ void hornOn(bool on){
if (on == true){ if (on){
digitalWrite(hornRelay, LOW); //turn on horn relay digitalWrite(hornRelay, LOW); //turn on horn relay
} else { } else {
digitalWrite(hornRelay, HIGH); //turn off horn relay digitalWrite(hornRelay, HIGH); //turn off horn relay
} }
} }
void strobeOn(bool on){ void strobeOn(bool on){
if (on == true){ if (on){
digitalWrite(strobeRelay, LOW); //turn on strobe relay without strobe sync digitalWrite(strobeRelay, LOW); //turn on strobe relay without strobe sync
} else { } else {
digitalWrite(strobeRelay, HIGH); //turn off strobe relay digitalWrite(strobeRelay, HIGH); //turn off strobe relay
@ -476,7 +476,7 @@ void strobeOn(bool on){
} }
void smokeDetectorOn(bool on){ void smokeDetectorOn(bool on){
if (on == true){ if (on){
digitalWrite(smokeDetectorRelay, LOW); //turn on smoke relay digitalWrite(smokeDetectorRelay, LOW); //turn on smoke relay
} else { } else {
digitalWrite(smokeDetectorRelay, HIGH); //turn off smoke relay digitalWrite(smokeDetectorRelay, HIGH); //turn off smoke relay
@ -491,7 +491,7 @@ void activateNAC(){
silenced = false; silenced = false;
inConfigMenu = false; inConfigMenu = false;
codeWheelTimer = 0; codeWheelTimer = 0;
if (zoneAlarm == 4 or preAlarm == false){ if (zoneAlarm == 4 or not preAlarm){
secondStage = true; //entirely skip first stage if it is a drill or if prealarm is turned off secondStage = true; //entirely skip first stage if it is a drill or if prealarm is turned off
} else { } else {
secondStage = false; secondStage = false;
@ -503,13 +503,13 @@ void activateNAC(){
} }
void checkKey(){ void checkKey(){
if (digitalRead(keySwitchPin) == HIGH){ if (digitalRead(keySwitchPin)){
if (panelUnlocked == false and keyRequired == true){ if (not panelUnlocked and keyRequired){
panelUnlocked = true; panelUnlocked = true;
updateLockStatus = true; updateLockStatus = true;
} }
} else { } else {
if (panelUnlocked == true and keyRequired == true){ if (panelUnlocked and keyRequired){
panelUnlocked = false; panelUnlocked = false;
drillPressed=false; drillPressed=false;
silencePressed=false; //make sure all buttons are registered as depressed after key is removed silencePressed=false; //make sure all buttons are registered as depressed after key is removed
@ -525,15 +525,15 @@ void checkKey(){
//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!] //----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!]
void checkDevices(){ void checkDevices(){
if (walkTest == false){ if (not walkTest){
if (runVerification == false and fullAlarm == false and (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0)){ //reading a single zero flags as a possible alarm if (not runVerification and not fullAlarm and (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0)){ //reading a single zero flags as a possible alarm
runVerification = true; runVerification = true;
} }
if (runVerification == true and fullAlarm == false){ //only execute if the panel flags a possible alarm and there isn't currently a full alarm if (runVerification and not fullAlarm){ //only execute if the panel flags a possible alarm and there isn't currently a full alarm
if (verificationTimer >= verificationTime or verificationEnabled == false){ //execute the following code if verification surpasses the configured verification time OR verification is disabled if (verificationTimer >= verificationTime or not verificationEnabled){ //execute the following code if verification surpasses the configured verification time OR verification is disabled
if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){ //check once again if any zeros are read if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){ //check once again if any zeros are read
if (smokeDetectorVerification == false or smokeDetectorCurrentlyInVerification == true){ //if smoke detector verification is disabled, or a smoke detector has tripped *after* verification, activate NACs if (not smokeDetectorVerification or smokeDetectorCurrentlyInVerification){ //if smoke detector verification is disabled, or a smoke detector has tripped *after* verification, activate NACs
if (analogRead(zone1Pin) == 0 and analogRead(zone2Pin) == 0){ //read the pins once more to check which zone is in alarm if (analogRead(zone1Pin) == 0 and analogRead(zone2Pin) == 0){ //read the pins once more to check which zone is in alarm
zoneAlarm = 3; //both zoneAlarm = 3; //both
} else if (analogRead(zone2Pin) == 0){ } else if (analogRead(zone2Pin) == 0){
@ -544,7 +544,7 @@ void checkDevices(){
activateNAC(); activateNAC();
runVerification = false; //dismiss the possible alarm after activating the NACs runVerification = false; //dismiss the possible alarm after activating the NACs
verificationTimer = 0; verificationTimer = 0;
} else if (smokeDetectorVerification == true and smokeDetectorCurrentlyInVerification == false){ //if smoke detector verifcaion is turned on, run this instead } else if (smokeDetectorVerification and not smokeDetectorCurrentlyInVerification){ //if smoke detector verifcaion is turned on, run this instead
smokeDetectorOn(false); //turn off the smoke detector relay smokeDetectorOn(false); //turn off the smoke detector relay
delay(100); //wait for 100 ms delay(100); //wait for 100 ms
if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){ // if the alarm signal persists after turning off the smoke detectors, it is a pull station, activate the nacs if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){ // if the alarm signal persists after turning off the smoke detectors, it is a pull station, activate the nacs
@ -577,7 +577,7 @@ void checkDevices(){
verificationTimer++; verificationTimer++;
} }
} }
} else if (walkTest == true){ } else if (walkTest){
if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){// or analogRead(zone2Pin) == 0){ if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){// or analogRead(zone2Pin) == 0){
if (analogRead(zone1Pin) == 0){ if (analogRead(zone1Pin) == 0){
zone1Count++; zone1Count++;
@ -585,16 +585,17 @@ void checkDevices(){
strobeOn(true); strobeOn(true);
delay(500); delay(500);
digitalWrite(alarmLed, HIGH); digitalWrite(alarmLed, HIGH);
if (silentWalkTest == false){ if (not silentWalkTest){
hornOn(true); hornOn(true);
}
delay(500); delay(500);
if (silentWalkTest == false){
hornOn(false); hornOn(false);
} else {
delay(500);
} }
delay(3000); delay(3000);
digitalWrite(alarmLed, LOW); digitalWrite(alarmLed, LOW);
strobeOn(false); strobeOn(false);
delay(4000);
smokeDetectorOn(true); smokeDetectorOn(true);
} else if (analogRead(zone2Pin) == 0){ } else if (analogRead(zone2Pin) == 0){
zone2Count++; zone2Count++;
@ -602,31 +603,28 @@ void checkDevices(){
strobeOn(true); strobeOn(true);
delay(500); delay(500);
digitalWrite(alarmLed, HIGH); digitalWrite(alarmLed, HIGH);
if (silentWalkTest == false){ if (not silentWalkTest){
hornOn(true); hornOn(true);
}
delay(500); delay(500);
if (silentWalkTest == false){
hornOn(false); hornOn(false);
}
delay(500); delay(500);
if (silentWalkTest == false){
hornOn(true); hornOn(true);
}
delay(500); delay(500);
if (silentWalkTest == false){
hornOn(false); hornOn(false);
} else {
delay(1500);
} }
digitalWrite(alarmLed, LOW);
delay(3000); delay(3000);
digitalWrite(alarmLed, LOW);
strobeOn(false); strobeOn(false);
delay(4000);
smokeDetectorOn(true); smokeDetectorOn(true);
} }
currentScreen = -1; currentScreen = -1;
} }
} }
if ((analogRead(zone1Pin) == 4095 or analogRead(zone2Pin) == 4095) and eolResistor == true) { if ((analogRead(zone1Pin) == 4095 or analogRead(zone2Pin) == 4095) and eolResistor) {
if (troubleTimer >= 1000){ if (troubleTimer >= 1000){
trouble = true; trouble = true;
troubleType=1; troubleType=1;
@ -700,11 +698,11 @@ void reboot(){
//----------------------------------------------------------------------------- BUTTON CHECK //----------------------------------------------------------------------------- BUTTON CHECK
void checkButtons(){ void checkButtons(){
if (digitalRead(resetButtonPin) == HIGH){ //-----------------------------------------------------------RESET BUTTON if (digitalRead(resetButtonPin)){ //-----------------------------------------------------------RESET BUTTON
reboot(); reboot();
} }
if (digitalRead(silenceButtonPin) == HIGH){ //---------------------------------------------------------SILENCE BUTTON if (digitalRead(silenceButtonPin)){ //---------------------------------------------------------SILENCE BUTTON
if (horn){ //if horns are not silenced, silence the horns if (horn){ //if horns are not silenced, silence the horns
digitalWrite(silenceLed, HIGH); digitalWrite(silenceLed, HIGH);
digitalWrite(alarmLed, LOW); digitalWrite(alarmLed, LOW);
@ -736,7 +734,7 @@ void checkButtons(){
silencePressed = false; silencePressed = false;
} }
if (digitalRead(drillButtonPin) == HIGH and not horn and not silenced and not fullAlarm){ //------------------------------------------DRILL BUTTON if (digitalRead(drillButtonPin) and not horn and not silenced and not fullAlarm){ //------------------------------------------DRILL BUTTON
if (drillTimer >= 237){ if (drillTimer >= 237){
zoneAlarm = 4; zoneAlarm = 4;
activateNAC(); activateNAC();
@ -748,7 +746,7 @@ void checkButtons(){
drillTimer = 0; drillTimer = 0;
drillPressed = false; drillPressed = false;
} }
if (digitalRead(drillButtonPin) == HIGH and not fullAlarm and not secondStage){ if (digitalRead(drillButtonPin) and not fullAlarm and not secondStage){
secondStage = true; secondStage = true;
currentScreen = -1; currentScreen = -1;
} }
@ -758,7 +756,7 @@ void checkButtons(){
//----------------------------------------------------------------------------- NAC ACTIVATION //----------------------------------------------------------------------------- NAC ACTIVATION
void alarm(){ void alarm(){
if (strobe == true){ if (strobe){
if (strobeSync == 0){ if (strobeSync == 0){
strobeOn(true); strobeOn(true);
} else if (strobeSync == 1 or strobeSync == 2){ } else if (strobeSync == 1 or strobeSync == 2){
@ -1052,11 +1050,11 @@ void configLCDUpdate(int cursor, String top, String bottom, bool replaceTop = fa
configBottom = bottom; configBottom = bottom;
cursorPosition = cursor; cursorPosition = cursor;
if (replaceTop == true){ if (replaceTop){
configTop.replace("1","*"); configTop.replace("1","*");
configTop.replace("0","$"); configTop.replace("0","$");
} }
if (replaceBottom == true){ if (replaceBottom){
configBottom.replace("1","*"); configBottom.replace("1","*");
configBottom.replace("0","$"); configBottom.replace("0","$");
} }
@ -1076,19 +1074,19 @@ void config(){
char *mainSettingsFireAlarmSettingsStrobeSync[] = {"None","System Sensor","Wheelock","Gentex","Simplex"}; //menu 11 char *mainSettingsFireAlarmSettingsStrobeSync[] = {"None","System Sensor","Wheelock","Gentex","Simplex"}; //menu 11
char *mainPanelSettingsAbout[] = {"Antigneous FACP","Firmware: ","by Lexzach"}; //menu 12 char *mainPanelSettingsAbout[] = {"Antigneous FACP","Firmware: ","by Lexzach"}; //menu 12
if (digitalRead(resetButtonPin) == HIGH){ //RESET BUTTON if (digitalRead(resetButtonPin)){ //RESET BUTTON
resetPressed = true; resetPressed = true;
} else { } else {
resetPressed = false; resetPressed = false;
resetStillPressed = false; resetStillPressed = false;
} }
if (digitalRead(silenceButtonPin) == HIGH){ //SILENCE BUTTON if (digitalRead(silenceButtonPin)){ //SILENCE BUTTON
silencePressed = true; silencePressed = true;
} else { } else {
silencePressed = false; silencePressed = false;
silenceStillPressed = false; silenceStillPressed = false;
} }
if (digitalRead(drillButtonPin) == HIGH){ //DRILL BUTTON if (digitalRead(drillButtonPin)){ //DRILL BUTTON
drillPressed = true; drillPressed = true;
} else { } else {
drillPressed = false; drillPressed = false;
@ -1133,7 +1131,7 @@ void config(){
strobe = false; strobe = false;
smokeDetectorOn(true); smokeDetectorOn(true);
digitalWrite(readyLed,HIGH); digitalWrite(readyLed,HIGH);
} else if (drillPressed == true and not drillStillPressed){ } else if (drillPressed and not drillStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
walkTest = true; walkTest = true;
silentWalkTest = false; silentWalkTest = false;
@ -1174,7 +1172,7 @@ void config(){
} else if (cursorPosition == 1){ } else if (cursorPosition == 1){
configLCDUpdate(0, (String)mainSettings[0], (String)mainSettings[1]); configLCDUpdate(0, (String)mainSettings[0], (String)mainSettings[1]);
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 0; configPage = 0;
configLCDUpdate(1, (String)main[1], (String)main[0]); configLCDUpdate(1, (String)main[1], (String)main[0]);
} else if (drillPressed and not drillStillPressed){ } else if (drillPressed and not drillStillPressed){
@ -1309,61 +1307,45 @@ void config(){
} else if (configPage == 8){ } else if (configPage == 8){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed == true and resetStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1;
configTop = (String)mainPanelSettings[1];
if (lcdTimeout == 0){ if (lcdTimeout == 0){
configBottom = (String)mainPanelSettings[2] + "off"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + "off");
} else if (lcdTimeout<=30000) { } else if (lcdTimeout<=30000) {
configBottom = (String)mainPanelSettings[2] + lcdTimeout/1000+"s"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + lcdTimeout/1000+"s");
} else { } else {
configBottom = (String)mainPanelSettings[2] + lcdTimeout/60000+"m"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + lcdTimeout/60000+"m");
} }
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2; cursorPosition = 2;
if (lcdTimeout == 0){ if (lcdTimeout == 0){
configTop = (String)mainPanelSettings[2] + "off"; configLCDUpdate(2, (String)mainPanelSettings[2] + "off", (String)mainPanelSettings[3]);
} else if (lcdTimeout<=30000) { } else if (lcdTimeout<=30000) {
configTop = (String)mainPanelSettings[2] + lcdTimeout/1000+"s"; configLCDUpdate(2, (String)mainPanelSettings[2] + lcdTimeout/1000+"s", (String)mainPanelSettings[3]);
} else { } else {
configTop = (String)mainPanelSettings[2] + lcdTimeout/60000+"m"; configLCDUpdate(2, (String)mainPanelSettings[2] + lcdTimeout/60000+"m", (String)mainPanelSettings[3]);
} }
configBottom = (String)mainPanelSettings[3];
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 3; configLCDUpdate(3, (String)mainPanelSettings[3], (String)mainPanelSettings[4]);
configTop = (String)mainPanelSettings[3];
configBottom = (String)mainPanelSettings[4];
} else if (cursorPosition == 3) { } else if (cursorPosition == 3) {
cursorPosition = 4; configLCDUpdate(4, (String)mainPanelSettings[4], (String)mainPanelSettings[0]);
configTop = (String)mainPanelSettings[4];
configBottom = (String)mainPanelSettings[0];
} else if (cursorPosition == 4) { } else if (cursorPosition == 4) {
cursorPosition = 0; configLCDUpdate(0, (String)mainPanelSettings[0], (String)mainPanelSettings[1]);
configTop = (String)mainPanelSettings[0];
configBottom = (String)mainPanelSettings[1];
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed == true and silenceStillPressed == false){
configPage = 2; configPage = 2;
cursorPosition = 1; configLCDUpdate(1, (String)mainSettings[1], (String)mainSettings[0]);
configTop = (String)mainSettings[1];
configBottom = (String)mainSettings[0];
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
configPage = 10; configPage = 10;
cursorPosition = 0; configLCDUpdate(0, "Enter Name:", (String)panelName);
configTop = "Enter Name:";
configBottom = (String)panelName;
lcd.blink_on(); lcd.blink_on();
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
configPage = 9; configPage = 9;
cursorPosition = 0;
if (keyRequiredVisual == true){ if (keyRequiredVisual == true){
configTop = (String)mainPanelSettingsPanelSecurity[0]; configLCDUpdate(0, (String)mainPanelSettingsPanelSecurity[0], (String)mainPanelSettingsPanelSecurity[1]+"*");
configBottom = (String)mainPanelSettingsPanelSecurity[1]+"*";
} else { } else {
configTop = (String)mainPanelSettingsPanelSecurity[0]+"*"; configLCDUpdate(0, (String)mainPanelSettingsPanelSecurity[0]+"*", (String)mainPanelSettingsPanelSecurity[1]);
configBottom = (String)mainPanelSettingsPanelSecurity[1];
} }
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
if (lcdTimeout == 0){ if (lcdTimeout == 0){
@ -1387,21 +1369,18 @@ void config(){
} }
EEPROM.commit(); EEPROM.commit();
if (lcdTimeout == 0){ if (lcdTimeout == 0){
configTop = (String)mainPanelSettings[2] + "off"; configLCDUpdate(2, (String)mainPanelSettings[2] + "off", (String)mainPanelSettings[3]);
} else if (lcdTimeout<=30000) { } else if (lcdTimeout<=30000) {
configTop = (String)mainPanelSettings[2] + lcdTimeout/1000+"s"; configLCDUpdate(2, (String)mainPanelSettings[2] + lcdTimeout/1000+"s", (String)mainPanelSettings[3]);
} else { } else {
configTop = (String)mainPanelSettings[2] + lcdTimeout/60000+"m"; configLCDUpdate(2, (String)mainPanelSettings[2] + lcdTimeout/60000+"m", (String)mainPanelSettings[3]);
} }
} else if (cursorPosition == 3){ } else if (cursorPosition == 3){
configBottom = "drill = yes"; configLCDUpdate(3, "reset = yes", "silence = no");
configTop = "silence = no";
configPage = -1; configPage = -1;
} else if (cursorPosition == 4){ } else if (cursorPosition == 4){
configPage = 12; configPage = 12;
cursorPosition = 0; configLCDUpdate(0, (String)mainPanelSettingsAbout[0], (String)mainPanelSettingsAbout[1] + firmwareRev);
configTop = (String)mainPanelSettingsAbout[0];
configBottom = (String)mainPanelSettingsAbout[1] + firmwareRev;
} }
} }
//----------------------------------------------------------------------------- SETTINGS > PANEL //----------------------------------------------------------------------------- SETTINGS > PANEL
@ -1436,9 +1415,7 @@ void config(){
lcd.blink_off(); lcd.blink_off();
EEPROM.commit(); EEPROM.commit();
configPage = 8; configPage = 8;
cursorPosition = 0; configLCDUpdate(0, (String)mainPanelSettings[0], (String)mainPanelSettings[1]);
configTop = (String)mainPanelSettings[0];
configBottom = (String)mainPanelSettings[1];
x=0; x=0;
panelName = ""; panelName = "";
for (int i=11; i<=26; i++){ //read panel name for (int i=11; i<=26; i++){ //read panel name
@ -1466,14 +1443,10 @@ void config(){
//----------------------------------------------------------------------------- SETTINGS > PANEL > FACTORY RESET //----------------------------------------------------------------------------- SETTINGS > PANEL > FACTORY RESET
} else if (configPage == -1){ } else if (configPage == -1){
configBottom = "drill = yes"; if (silencePressed and not silenceStillPressed){
configTop = "silence = no";
if (silencePressed == true and silenceStillPressed == false){
configPage = 8; configPage = 8;
cursorPosition = 3; configLCDUpdate(3, (String)mainPanelSettings[3], (String)mainPanelSettings[4]);
configTop = (String)mainPanelSettings[3]; } else if (resetPressed and not resetStillPressed){
configBottom = (String)mainPanelSettings[4];
} else if (drillPressed == true and drillStillPressed == false){
digitalWrite(readyLed, LOW); //ready LED digitalWrite(readyLed, LOW); //ready LED
lcd.clear(); lcd.clear();
lcd.setCursor(0,0); lcd.setCursor(0,0);
@ -1490,95 +1463,68 @@ void config(){
} else if (configPage == 5){ } else if (configPage == 5){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed == true and resetStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1;
if (codeWheel == 1){ if (codeWheel == 1){
configTop = (String)mainSettingsFireAlarmSettingsCoding[1]+"*"; configLCDUpdate(1, (String)mainSettingsFireAlarmSettingsCoding[1]+"*", (String)mainSettingsFireAlarmSettingsCoding[2]);
} else if (codeWheel == 2){
configLCDUpdate(1, (String)mainSettingsFireAlarmSettingsCoding[1], (String)mainSettingsFireAlarmSettingsCoding[2]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[1]; configLCDUpdate(1, (String)mainSettingsFireAlarmSettingsCoding[1], (String)mainSettingsFireAlarmSettingsCoding[2]);
}
if (codeWheel == 2){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[2]+"*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[2];
} }
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2;
if (codeWheel == 2){ if (codeWheel == 2){
configTop = (String)mainSettingsFireAlarmSettingsCoding[2]+"*"; configLCDUpdate(2, (String)mainSettingsFireAlarmSettingsCoding[2]+"*", (String)mainSettingsFireAlarmSettingsCoding[3]);
} else if (codeWheel == 3){
configLCDUpdate(2, (String)mainSettingsFireAlarmSettingsCoding[2], (String)mainSettingsFireAlarmSettingsCoding[3]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[2]; configLCDUpdate(2, (String)mainSettingsFireAlarmSettingsCoding[2], (String)mainSettingsFireAlarmSettingsCoding[3]);
}
if (codeWheel == 3){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[3]+"*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[3];
} }
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 3;
if (codeWheel == 3){ if (codeWheel == 3){
configTop = (String)mainSettingsFireAlarmSettingsCoding[3]+"*"; configLCDUpdate(3, (String)mainSettingsFireAlarmSettingsCoding[3]+"*", (String)mainSettingsFireAlarmSettingsCoding[4]);
} else if (codeWheel == 4){
configLCDUpdate(3, (String)mainSettingsFireAlarmSettingsCoding[3], (String)mainSettingsFireAlarmSettingsCoding[4]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[3]; configLCDUpdate(3, (String)mainSettingsFireAlarmSettingsCoding[3], (String)mainSettingsFireAlarmSettingsCoding[4]);
}
if (codeWheel == 4){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[4]+"*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[4];
} }
} else if (cursorPosition == 3) { } else if (cursorPosition == 3) {
cursorPosition = 4;
if (codeWheel == 4){ if (codeWheel == 4){
configTop = (String)mainSettingsFireAlarmSettingsCoding[4]+"*"; configLCDUpdate(4, (String)mainSettingsFireAlarmSettingsCoding[4]+"*", (String)mainSettingsFireAlarmSettingsCoding[5]);
} else if (codeWheel == 5){
configLCDUpdate(4, (String)mainSettingsFireAlarmSettingsCoding[4], (String)mainSettingsFireAlarmSettingsCoding[5]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[4]; configLCDUpdate(4, (String)mainSettingsFireAlarmSettingsCoding[4], (String)mainSettingsFireAlarmSettingsCoding[5]);
}
if (codeWheel == 5){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[5]+"*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[5];
} }
} else if (cursorPosition == 4) { } else if (cursorPosition == 4) {
cursorPosition = 5;
if (codeWheel == 5){ if (codeWheel == 5){
configTop = (String)mainSettingsFireAlarmSettingsCoding[5]+"*"; configLCDUpdate(5, (String)mainSettingsFireAlarmSettingsCoding[5]+"*", (String)mainSettingsFireAlarmSettingsCoding[0]);
} else if (codeWheel == 0){
configLCDUpdate(5, (String)mainSettingsFireAlarmSettingsCoding[5], (String)mainSettingsFireAlarmSettingsCoding[0]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[5]; configLCDUpdate(5, (String)mainSettingsFireAlarmSettingsCoding[5], (String)mainSettingsFireAlarmSettingsCoding[0]);
}
if (codeWheel == 0){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[0]+"*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[0];
} }
} else if (cursorPosition == 5) { } else if (cursorPosition == 5) {
cursorPosition = 0;
if (codeWheel == 0){ if (codeWheel == 0){
configTop = (String)mainSettingsFireAlarmSettingsCoding[0]+"*"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsCoding[0]+"*", (String)mainSettingsFireAlarmSettingsCoding[1]);
} else if (codeWheel == 1){
configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsCoding[0], (String)mainSettingsFireAlarmSettingsCoding[1]+"*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsCoding[0]; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsCoding[0], (String)mainSettingsFireAlarmSettingsCoding[1]);
}
if (codeWheel == 1){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[1]+"*";
} else{
configBottom = (String)mainSettingsFireAlarmSettingsCoding[1];
} }
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed == true and silenceStillPressed == false){
configPage = 3; //change screen to facp settings configPage = 3; //change screen to facp settings
cursorPosition = 0;
if (useTwoWire){ if (useTwoWire){
configTop = (String)mainSettingsFireAlarmSettings[0] + " off"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0] + " off", (String)mainSettingsFireAlarmSettings[1]);
} else { } else {
configTop = (String)mainSettingsFireAlarmSettings[0]; configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0], (String)mainSettingsFireAlarmSettings[1]);
} }
configBottom = (String)mainSettingsFireAlarmSettings[1];
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed == true and drillStillPressed == false){
EEPROM.write(7,cursorPosition); //write the new codewheel settings to eeprom EEPROM.write(7,cursorPosition); //write the new codewheel settings to eeprom
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettingsCoding[cursorPosition]+"*";
if (cursorPosition == 5){ if (cursorPosition == 5){
configBottom = (String)mainSettingsFireAlarmSettingsCoding[0]; configLCDUpdate(cursorPosition, (String)mainSettingsFireAlarmSettingsCoding[cursorPosition]+"*", (String)mainSettingsFireAlarmSettingsCoding[0]);
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettingsCoding[cursorPosition+1]; configLCDUpdate(cursorPosition, (String)mainSettingsFireAlarmSettingsCoding[cursorPosition]+"*", (String)mainSettingsFireAlarmSettingsCoding[cursorPosition+1]);
} }
codeWheel = EEPROM.read(7); //codeWheel setting address codeWheel = EEPROM.read(7); //codeWheel setting address
} }
@ -1586,34 +1532,25 @@ void config(){
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION
} else if (configPage == 4){ } else if (configPage == 4){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; if (not verificationEnabled){
if (verificationEnabled == false){ configLCDUpdate(1, (String)mainSettingsVerificationSettings[1] + "off", (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, false, true);
configTop = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configLCDUpdate(1, (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s", (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, false, true);
} }
configBottom = (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2; if (smokeDetectorVerification){
configTop = (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification;
if (smokeDetectorVerification == true){
if (smokeDetectorTimeout<60000){ if (smokeDetectorTimeout<60000){
configBottom = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s"; configLCDUpdate(2, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s", true, false);
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m"; configLCDUpdate(2, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m", true, false);
} }
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[3] + "off"; configLCDUpdate(2, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + "off", true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 3; if (smokeDetectorVerification){
if (smokeDetectorVerification == true){
if (smokeDetectorTimeout<60000){ if (smokeDetectorTimeout<60000){
configTop = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s"; configTop = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s";
} else { } else {
@ -1622,48 +1559,38 @@ void config(){
} else { } else {
configTop = (String)mainSettingsVerificationSettings[3] + "off"; configTop = (String)mainSettingsVerificationSettings[3] + "off";
} }
if (smokeDetectorVerification == true){ if (smokeDetectorVerification){
if (smokeDetectorPostRestartVerificationTime<60000){ if (smokeDetectorPostRestartVerificationTime<60000){
configBottom = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s"; configLCDUpdate(3, configTop, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s");
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m"; configLCDUpdate(3, configTop, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m");
} }
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[4] + "off"; configLCDUpdate(3, configTop, (String)mainSettingsVerificationSettings[4] + "off");
} }
} else if (cursorPosition == 3) { } else if (cursorPosition == 3) {
cursorPosition = 4; if (smokeDetectorVerification){
if (smokeDetectorVerification == true){
if (smokeDetectorPostRestartVerificationTime<60000){ if (smokeDetectorPostRestartVerificationTime<60000){
configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s"; configLCDUpdate(4, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s", (String)mainSettingsVerificationSettings[0] + verificationEnabled, false, true);
} else { } else {
configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m"; configLCDUpdate(4, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m", (String)mainSettingsVerificationSettings[0] + verificationEnabled, false, true);
} }
} else { } else {
configTop = (String)mainSettingsVerificationSettings[4] + "off"; configLCDUpdate(4, (String)mainSettingsVerificationSettings[4] + "off", (String)mainSettingsVerificationSettings[0] + verificationEnabled, false, true);
} }
configBottom = (String)mainSettingsVerificationSettings[0] + verificationEnabled;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 4) { } else if (cursorPosition == 4) {
cursorPosition = 0; if (not verificationEnabled){
configTop = (String)mainSettingsVerificationSettings[0] + verificationEnabled; configLCDUpdate(0, (String)mainSettingsVerificationSettings[0] + verificationEnabled, (String)mainSettingsVerificationSettings[1] + "off", true, false);
if (verificationEnabled == false){
configBottom = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configLCDUpdate(0, (String)mainSettingsVerificationSettings[0] + verificationEnabled, (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s", true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 3; configPage = 3;
cursorPosition = 1; configLCDUpdate(1, (String)mainSettingsFireAlarmSettings[1], (String)mainSettingsFireAlarmSettings[2]);
configTop = (String)mainSettingsFireAlarmSettings[1]; } else if (drillPressed and not drillStillPressed){
configBottom = (String)mainSettingsFireAlarmSettings[2];
} else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
if (verificationEnabled == true){ if (verificationEnabled){
verificationEnabled = false; verificationEnabled = false;
EEPROM.write(9,0); EEPROM.write(9,0);
} else { } else {
@ -1671,15 +1598,12 @@ void config(){
EEPROM.write(9,1); EEPROM.write(9,1);
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsVerificationSettings[0]+verificationEnabled; if (not verificationEnabled){
if (verificationEnabled == false){ configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[0]+verificationEnabled, (String)mainSettingsVerificationSettings[1] + "off", true, false);
configBottom = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[0]+verificationEnabled, (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s", true, false);
} }
configTop.replace("1","*"); } else if (cursorPosition == 1 and verificationEnabled) {
configTop.replace("0","$");
} else if (cursorPosition == 1 and verificationEnabled == true) {
if (verificationTime == 500){ if (verificationTime == 500){
verificationTime = 1000; verificationTime = 1000;
EEPROM.write(10,10); EEPROM.write(10,10);
@ -1700,16 +1624,13 @@ void config(){
EEPROM.write(10,5); EEPROM.write(10,5);
} }
EEPROM.commit(); EEPROM.commit();
if (verificationEnabled == false){ if (not verificationEnabled){
configTop = (String)mainSettingsVerificationSettings[1] + "off"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[1] + "off", (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, false, true);
} else { } else {
configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s", (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, false, true);
} }
configBottom = (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 2){ } else if (cursorPosition == 2){
if (smokeDetectorVerification == false){ if (not smokeDetectorVerification){
EEPROM.write(76,1); //enable pre-alarm EEPROM.write(76,1); //enable pre-alarm
smokeDetectorVerification = true; smokeDetectorVerification = true;
} else { } else {
@ -1722,19 +1643,16 @@ void config(){
smokeDetectorTimer=0; smokeDetectorTimer=0;
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification; if (smokeDetectorVerification){
if (smokeDetectorVerification == true){
if (smokeDetectorTimeout<60000){ if (smokeDetectorTimeout<60000){
configBottom = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/1000) + "s", true, false);
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m", true, false);
} }
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[3] + "off"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[2] + smokeDetectorVerification, (String)mainSettingsVerificationSettings[3] + "off", true, false);
} }
configTop.replace("1","*"); } else if (cursorPosition == 3 and smokeDetectorVerification) {
configTop.replace("0","$");
} else if (cursorPosition == 3 and smokeDetectorVerification == true) {
if (smokeDetectorTimeout == 5000){ if (smokeDetectorTimeout == 5000){
EEPROM.write(77,2); EEPROM.write(77,2);
smokeDetectorTimeout = 10000; smokeDetectorTimeout = 10000;
@ -1772,16 +1690,16 @@ void config(){
} else { } else {
configTop = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m"; configTop = (String)mainSettingsVerificationSettings[3] + (smokeDetectorTimeout/60000) + "m";
} }
if (smokeDetectorVerification == true){ if (smokeDetectorVerification){
if (smokeDetectorPostRestartVerificationTime<60000){ if (smokeDetectorPostRestartVerificationTime<60000){
configBottom = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s"; configLCDUpdate(cursorPosition, configTop, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s");
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m"; configLCDUpdate(cursorPosition, configTop, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m");
} }
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[4] + "off"; configLCDUpdate(cursorPosition, configTop, (String)mainSettingsVerificationSettings[4] + "off");
} }
} else if (cursorPosition == 4 and smokeDetectorVerification == true) { } else if (cursorPosition == 4 and smokeDetectorVerification) {
if (smokeDetectorPostRestartVerificationTime == 60000){ if (smokeDetectorPostRestartVerificationTime == 60000){
EEPROM.write(28,24); EEPROM.write(28,24);
smokeDetectorPostRestartVerificationTime = 120000; smokeDetectorPostRestartVerificationTime = 120000;
@ -1795,7 +1713,7 @@ void config(){
EEPROM.write(28,60); EEPROM.write(28,60);
smokeDetectorPostRestartVerificationTime = 300000; smokeDetectorPostRestartVerificationTime = 300000;
} else if (smokeDetectorPostRestartVerificationTime == 300000){ } else if (smokeDetectorPostRestartVerificationTime == 300000){
EEPROM.write(28,60); EEPROM.write(28,120);
smokeDetectorPostRestartVerificationTime = 600000; smokeDetectorPostRestartVerificationTime = 600000;
} else if (smokeDetectorPostRestartVerificationTime == 600000){ } else if (smokeDetectorPostRestartVerificationTime == 600000){
EEPROM.write(28,12); EEPROM.write(28,12);
@ -1803,126 +1721,93 @@ void config(){
} }
EEPROM.commit(); EEPROM.commit();
if (smokeDetectorPostRestartVerificationTime<60000){ if (smokeDetectorPostRestartVerificationTime<60000){
configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/1000) + "s", (String)mainSettingsVerificationSettings[0] + verificationEnabled, false, true);
} else { } else {
configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m"; configLCDUpdate(cursorPosition, (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m", (String)mainSettingsVerificationSettings[0] + verificationEnabled, false, true);
} }
configBottom = (String)mainSettingsVerificationSettings[0] + verificationEnabled;
configBottom.replace("1","*");
configBottom.replace("0","$");
} }
} }
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY //----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY
} else if (configPage == 9){ } else if (configPage == 9){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; if (keyRequiredVisual){
if (keyRequiredVisual == true){ configLCDUpdate(1, (String)mainPanelSettingsPanelSecurity[1]+"*", (String)mainPanelSettingsPanelSecurity[0]);
configTop = (String)mainPanelSettingsPanelSecurity[1]+"*";
configBottom = (String)mainPanelSettingsPanelSecurity[0];
} else { } else {
configTop = (String)mainPanelSettingsPanelSecurity[1]; configLCDUpdate(1, (String)mainPanelSettingsPanelSecurity[1], (String)mainPanelSettingsPanelSecurity[0]+"*");
configBottom = (String)mainPanelSettingsPanelSecurity[0]+"*";
} }
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 0; if (keyRequiredVisual){
if (keyRequiredVisual == true){ configLCDUpdate(0, (String)mainPanelSettingsPanelSecurity[0], (String)mainPanelSettingsPanelSecurity[1]+"*");
configTop = (String)mainPanelSettingsPanelSecurity[0];
configBottom = (String)mainPanelSettingsPanelSecurity[1]+"*";
} else { } else {
configTop = (String)mainPanelSettingsPanelSecurity[0]+"*"; configLCDUpdate(0, (String)mainPanelSettingsPanelSecurity[0]+"*", (String)mainPanelSettingsPanelSecurity[1]);
configBottom = (String)mainPanelSettingsPanelSecurity[1];
} }
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 8; configPage = 8;
cursorPosition = 1;
configTop = (String)mainPanelSettings[1];
if (lcdTimeout == 0){ if (lcdTimeout == 0){
configBottom = (String)mainPanelSettings[2] + "off"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + "off");
} else if (lcdTimeout<=30000) { } else if (lcdTimeout<=30000) {
configBottom = (String)mainPanelSettings[2] + lcdTimeout/1000+"s"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + lcdTimeout/1000+"s");
} else { } else {
configBottom = (String)mainPanelSettings[2] + lcdTimeout/60000+"m"; configLCDUpdate(1, (String)mainPanelSettings[1], (String)mainPanelSettings[2] + lcdTimeout/60000+"m");
} }
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed and not drillStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
EEPROM.write(8,0); //write the new keyswitch settings to eeprom EEPROM.write(8,0); //write the new keyswitch settings to eeprom
EEPROM.commit(); EEPROM.commit();
keyRequiredVisual = false; keyRequiredVisual = false;
configTop = (String)mainPanelSettingsPanelSecurity[0]+"*"; configLCDUpdate(cursorPosition, (String)mainPanelSettingsPanelSecurity[0]+"*", (String)mainPanelSettingsPanelSecurity[1]);
configBottom = (String)mainPanelSettingsPanelSecurity[1];
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
EEPROM.write(8,1); //write the new keyswitch settings to eeprom EEPROM.write(8,1); //write the new keyswitch settings to eeprom
EEPROM.commit(); EEPROM.commit();
keyRequiredVisual = true; keyRequiredVisual = true;
configTop = (String)mainPanelSettingsPanelSecurity[1]+"*"; configLCDUpdate(cursorPosition, (String)mainPanelSettingsPanelSecurity[1]+"*", (String)mainPanelSettingsPanelSecurity[0]);
configBottom = (String)mainPanelSettingsPanelSecurity[0];
} }
} }
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY //----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY
//----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT //----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT
} else if (configPage == 12){ } else if (configPage == 12){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; configLCDUpdate(1, (String)mainPanelSettingsAbout[1]+firmwareRev, (String)mainPanelSettingsAbout[2]);
configTop = (String)mainPanelSettingsAbout[1]+firmwareRev;
configBottom = (String)mainPanelSettingsAbout[2];
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2; configLCDUpdate(2, (String)mainPanelSettingsAbout[2], (String)mainPanelSettingsAbout[0]);
configTop = (String)mainPanelSettingsAbout[2];
configBottom = (String)mainPanelSettingsAbout[0];
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 0; configLCDUpdate(0, (String)mainPanelSettingsAbout[0], (String)mainPanelSettingsAbout[1]+firmwareRev);
configTop = (String)mainPanelSettingsAbout[0];
configBottom = (String)mainPanelSettingsAbout[1]+firmwareRev;
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 8; configPage = 8;
cursorPosition = 4; configLCDUpdate(4, (String)mainPanelSettings[4], (String)mainPanelSettings[0]);
configTop = (String)mainPanelSettings[4];
configBottom = (String)mainPanelSettings[0];
} }
//----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT //----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM
} else if (configPage == 6){ } else if (configPage == 6){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; if (preAlarm){
if (preAlarm == true){ configLCDUpdate(1, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m", (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0] + preAlarm, false, true);
configTop = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m";
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off"; configLCDUpdate(1, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off", (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0] + preAlarm, false, true);
} }
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0] + preAlarm;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 1){ } else if (cursorPosition == 1){
cursorPosition = 0; if (preAlarm){
configTop = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m", true, false);
if (preAlarm == true){
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m";
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off", true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 3; configPage = 3;
cursorPosition = 2; configLCDUpdate(2, (String)mainSettingsFireAlarmSettings[2], (String)mainSettingsFireAlarmSettings[3]+audibleSilence, false, true);
configTop = (String)mainSettingsFireAlarmSettings[2]; } else if (drillPressed and not drillStillPressed){
configBottom = (String)mainSettingsFireAlarmSettings[3]+audibleSilence;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
if (preAlarm == false){ if (not preAlarm){
EEPROM.write(74,1); //enable pre-alarm EEPROM.write(74,1); //enable pre-alarm
preAlarm = true; preAlarm = true;
} else { } else {
@ -1930,15 +1815,12 @@ void config(){
preAlarm = false; preAlarm = false;
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm; if (preAlarm){
if (preAlarm == true){ configLCDUpdate(cursorPosition, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m", true, false);
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m";
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off"; configLCDUpdate(cursorPosition, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0]+preAlarm, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + "off", true, false);
} }
configTop.replace("1","*"); } else if (cursorPosition == 1 and preAlarm) {
configTop.replace("0","$");
} else if (cursorPosition == 1 and preAlarm == true) {
if (firstStageTime == 60000){ if (firstStageTime == 60000){
EEPROM.write(75,2); EEPROM.write(75,2);
firstStageTime = 120000; firstStageTime = 120000;
@ -1968,10 +1850,7 @@ void config(){
firstStageTime = 60000; firstStageTime = 60000;
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m"; configLCDUpdate(cursorPosition, (String)mainSettingsFireAlarmSettingsPreAlarmSettings[1] + (firstStageTime/60000) + "m", (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0] + preAlarm, false, true);
configBottom = (String)mainSettingsFireAlarmSettingsPreAlarmSettings[0] + preAlarm;
configBottom.replace("1","*");
configBottom.replace("0","$");
} }
} }
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM
@ -2153,7 +2032,7 @@ void smokeDetector(){
} }
void failsafe(){ //--------------------------------------------- FAILSAFE MODE IN CASE PANEL CANT BOOT NORMALLY void failsafe(){ //--------------------------------------------- FAILSAFE MODE IN CASE PANEL CANT BOOT NORMALLY
if ((analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0) and fullAlarm == false){ if ((analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0) and not fullAlarm){
fullAlarm = true; fullAlarm = true;
silenced = false; silenced = false;
digitalWrite(alarmLed, HIGH); digitalWrite(alarmLed, HIGH);
@ -2165,7 +2044,7 @@ void failsafe(){ //--------------------------------------------- FAILSAFE MODE I
lcd.setCursor(0,1); lcd.setCursor(0,1);
lcd.print("FIRE ALARM"); lcd.print("FIRE ALARM");
} }
if (digitalRead(silenceButtonPin) == HIGH and silenced == false and fullAlarm == true){ if (digitalRead(silenceButtonPin) == HIGH and not silenced and fullAlarm){
silenced = true; silenced = true;
digitalWrite(hornRelay, HIGH); digitalWrite(hornRelay, HIGH);
digitalWrite(silenceLed,HIGH); digitalWrite(silenceLed,HIGH);
@ -2200,7 +2079,7 @@ void failsafe(){ //--------------------------------------------- FAILSAFE MODE I
void loop() { void loop() {
systemClock = millis(); //-------------------- SYSTEM CLOCK systemClock = millis(); //-------------------- SYSTEM CLOCK
if (systemClock-lastPulse >= 1){ if (systemClock-lastPulse >= 1){
if (failsafeMode == false){ if (not failsafeMode){
lcdBacklight(); //------------------------------------------------------ CHECK LCD BACKLIGHT lcdBacklight(); //------------------------------------------------------ CHECK LCD BACKLIGHT
checkDevices(); //------------------------------------------------------ CHECK ACTIVATING DEVICES checkDevices(); //------------------------------------------------------ CHECK ACTIVATING DEVICES
@ -2209,7 +2088,7 @@ void loop() {
alarm(); //------------------------------------------------------------- ALARM CODEWHEEL alarm(); //------------------------------------------------------------- ALARM CODEWHEEL
if (smokeDetectorCurrentlyInVerification == true and fullAlarm == false){ //if a smoke detector is in verification, execute this function if (smokeDetectorCurrentlyInVerification and not fullAlarm){ //if a smoke detector is in verification, execute this function
smokeDetector(); smokeDetector();
} }
@ -2222,7 +2101,7 @@ void loop() {
if (buttonCheckTimer >= 20){ if (buttonCheckTimer >= 20){
if (not inConfigMenu){ if (not inConfigMenu){
if ((panelUnlocked == true and keyRequired == true) or (keyRequired==false)){ if ((panelUnlocked and keyRequired) or (not keyRequired)){
checkButtons(); //check if certain buttons are pressed checkButtons(); //check if certain buttons are pressed
} else if (keylessSilence == true and fullAlarm == true and silenced == false){ } else if (keylessSilence == true and fullAlarm == true and silenced == false){
if (digitalRead(silenceButtonPin) == HIGH){ if (digitalRead(silenceButtonPin) == HIGH){
@ -2240,7 +2119,7 @@ void loop() {
lcdUpdate(); //------------------------------------------------------ UPDATE LCD DISPLAY lcdUpdate(); //------------------------------------------------------ UPDATE LCD DISPLAY
} else if (inConfigMenu) { } else if (inConfigMenu) {
if ((panelUnlocked == true and keyRequired == true) or (panelUnlocked==false and keyRequired==false)){ if ((panelUnlocked and keyRequired) or (not panelUnlocked and not keyRequired)){
config(); config();
} }
} }