started optimizing code

This commit is contained in:
Lexzach 2022-10-08 22:18:30 -04:00
parent c9fa689235
commit 18702567c3
Signed by: Lexzach
GPG Key ID: B574880929E6F1F0
2 changed files with 194 additions and 276 deletions

View File

@ -23,13 +23,12 @@ int EEPROMBuild = 4;
//----------------------------------------------------------------------------- RUNTIME VARIABLES //----------------------------------------------------------------------------- RUNTIME VARIABLES
bool fullAlarm = false; //bool to control if this is a full alarm that requres a panel reset to clear bool fullAlarm = false; //bool to control if this is a full alarm that requres a panel reset to clear
bool silenced = false; bool silenced = false;
bool keyInserted = false; //if the control panel has a key inserted bool panelUnlocked = false; //if the control panel has a key inserted
bool readyLedStatus = false; //ready led status (this variable is for the trouble response code)
bool horn = false; //bool to control if the horns are active bool horn = false; //bool to control if the horns are active
bool strobe = false; //bool to control if the strobes are active bool strobe = false; //bool to control if the strobes are active
bool trouble = false; //bool to control if the panel is in trouble bool trouble = false; //bool to control if the panel is in trouble
bool troubleAck = false; //bool to control if the trouble is acknowledged bool troubleAcked = false; //bool to control if the trouble is acknowledged
bool configMenu = false; //determine if the control panel is in the configuration menu bool inConfigMenu = false; //determine if the control panel is in the configuration menu
//---------------------------- Variables that are *always* true if a button is held down at all //---------------------------- Variables that are *always* true if a button is held down at all
bool resetPressed = false; bool resetPressed = false;
@ -43,7 +42,7 @@ bool silenceStillPressed = false;
bool drillStillPressed = false; bool drillStillPressed = false;
//---------------------------- //----------------------------
bool possibleAlarm = false; //panel receieved 0 from pull station ciruit and is now investigating bool runVerification = false; //panel receieved 0 from pull station ciruit and is now investigating
bool walkTest = false; //is the system in walk test bool walkTest = false; //is the system in walk test
bool silentWalkTest = false; bool silentWalkTest = false;
bool backlightOn = true; bool backlightOn = true;
@ -55,8 +54,8 @@ bool secondStage = false; //if the panel is in second stage
int characters[] = {32,45,46,47,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90}; //characters allowed on name int characters[] = {32,45,46,47,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90}; //characters allowed on name
int panelNameList[16]; int panelNameList[16];
int clearTimer = 0; //timer for keeping track of button holding for clearing character in the name editor int clearTimer = 0; //timer for keeping track of button holding for clearing character in the name editor
int verification = 0; //number to keep track of ms for verification int verificationTimer = 0; //number to keep track of ms for verification
int drill = 0; //number to keep track of ms for drill int drillTimer = 0; //number to keep track of ms for drill
int buttonCheckTimer = 0; //add a slight delay to avoid double-clicking buttons int buttonCheckTimer = 0; //add a slight delay to avoid double-clicking buttons
int keyCheckTimer = 0; int keyCheckTimer = 0;
int troubleTimer = 0; //ms for trouble int troubleTimer = 0; //ms for trouble
@ -77,13 +76,13 @@ String configBottom;
String currentConfigTop; //configuration menu strings for current lcd display String currentConfigTop; //configuration menu strings for current lcd display
String currentConfigBottom; String currentConfigBottom;
bool keyRequired = false; //determine if key switch is required to operate buttons bool keyRequired = false; //determine if key switch is required to operate buttons
bool isVerification = true; //is verification turned on bool verificationEnabled = true; //is verification turned on
bool eolResistor = true; //is the EOL resistor enabled bool eolResistor = true; //is the EOL resistor enabled
bool preAlarm = false; //use pre-alarm? bool preAlarm = false; //use pre-alarm?
bool smokeDetectorVerification = false; //should smoke detectors activate first stage bool smokeDetectorVerification = false; //should smoke detectors activate first stage
bool smokeDetectorCurrentlyInVerification = false; //Is a smoke detector currently in verification? bool smokeDetectorCurrentlyInVerification = false; //Is a smoke detector currently in verification?
bool audibleSilence = true; bool audibleSilence = true;
bool twoWire = false; //does the panel use 2 wire for alarms bool useTwoWire = false; //does the panel use 2 wire for alarms
int twoWireTimer = 0; //timer for 2 wire alarms int twoWireTimer = 0; //timer for 2 wire alarms
int smokeDetectorTimeout = 60000; //how long to wait before toggling smoke detectors back on int smokeDetectorTimeout = 60000; //how long to wait before toggling smoke detectors back on
int smokeDetectorPostRestartTimer = 0; //variable to keep track of the 60 seconds post-power up that the panel watches the smoke detector int smokeDetectorPostRestartTimer = 0; //variable to keep track of the 60 seconds post-power up that the panel watches the smoke detector
@ -93,7 +92,7 @@ int firstStageTime = 300000; //time in minutes that first stage should last
int firstStageTimer = 0; //timer to keep track of current first stage int firstStageTimer = 0; //timer to keep track of current first stage
int codeWheel = 0; //which alarm pattern to use, code-3 default int codeWheel = 0; //which alarm pattern to use, code-3 default
int strobeSync = 0; //strobe sync is not on by default 0 - none | 1 - System Sensor | 2 - Wheelock | 3 - Gentex | 4 - Simplex int strobeSync = 0; //strobe sync is not on by default 0 - none | 1 - System Sensor | 2 - Wheelock | 3 - Gentex | 4 - Simplex
int strobeSyncTiming = 0; //strobe sync timer int strobeSyncTimer = 0; //strobe sync timer
float verificationTime = 2500; float verificationTime = 2500;
int panelHomescreen = 0; int panelHomescreen = 0;
int lcdTimeout = 0; int lcdTimeout = 0;
@ -362,9 +361,9 @@ void setup() {
} }
//----------------------------- Panel security variable //----------------------------- Panel security variable
if (EEPROM.read(9) == 1){ if (EEPROM.read(9) == 1){
isVerification = true; verificationEnabled = true;
} else { } else {
isVerification = false; verificationEnabled = false;
} }
if (EEPROM.read(73) == 1){ if (EEPROM.read(73) == 1){
eolResistor = true; eolResistor = true;
@ -392,9 +391,9 @@ void setup() {
keylessSilence = false; keylessSilence = false;
} }
if (EEPROM.read(30) == 1){ if (EEPROM.read(30) == 1){
twoWire = true; useTwoWire = true;
} else { } else {
twoWire = false; useTwoWire = false;
} }
smokeDetectorTimeout = EEPROM.read(77)*5000; smokeDetectorTimeout = EEPROM.read(77)*5000;
smokeDetectorPostRestartVerificationTime = EEPROM.read(28)*5000; smokeDetectorPostRestartVerificationTime = EEPROM.read(28)*5000;
@ -420,12 +419,11 @@ void setup() {
delay(100); delay(100);
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
readyLedStatus = true;
updateLockStatus = true; updateLockStatus = true;
if (digitalRead(keySwitchPin) == HIGH and keyRequired == true){ //check the key status on startup if (digitalRead(keySwitchPin) == HIGH and keyRequired == true){ //check the key status on startup
keyInserted = true; panelUnlocked = true;
} else { } else {
keyInserted = false; panelUnlocked = false;
} }
digitalWrite(silenceLed, LOW); digitalWrite(silenceLed, LOW);
digitalWrite(alarmLed, LOW); digitalWrite(alarmLed, LOW);
@ -445,7 +443,6 @@ void setup() {
lcd.setCursor(0,1); lcd.setCursor(0,1);
lcd.print("SYSTEM NORMAL"); lcd.print("SYSTEM NORMAL");
digitalWrite(readyLed, HIGH); digitalWrite(readyLed, HIGH);
readyLedStatus = true;
digitalWrite(smokeDetectorRelay, LOW); //turn on smoke relay digitalWrite(smokeDetectorRelay, LOW); //turn on smoke relay
} }
lastPulse = millis(); //start last pulse lastPulse = millis(); //start last pulse
@ -492,7 +489,7 @@ void activateNAC(){
strobe = true; strobe = true;
fullAlarm = true; fullAlarm = true;
silenced = false; silenced = false;
configMenu = false; inConfigMenu = false;
codeWheelTimer = 0; codeWheelTimer = 0;
if (zoneAlarm == 4 or preAlarm == false){ if (zoneAlarm == 4 or preAlarm == false){
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
@ -501,27 +498,26 @@ void activateNAC(){
} }
tone(); tone();
digitalWrite(readyLed, HIGH); digitalWrite(readyLed, HIGH);
readyLedStatus = true;
digitalWrite(alarmLed, HIGH); digitalWrite(alarmLed, HIGH);
digitalWrite(silenceLed, LOW); digitalWrite(silenceLed, LOW);
} }
void checkKey(){ void checkKey(){
if (digitalRead(keySwitchPin) == HIGH){ if (digitalRead(keySwitchPin) == HIGH){
if (keyInserted == false and keyRequired == true){ if (panelUnlocked == false and keyRequired == true){
keyInserted = true; panelUnlocked = true;
updateLockStatus = true; updateLockStatus = true;
} }
} else { } else {
if (keyInserted == true and keyRequired == true){ if (panelUnlocked == true and keyRequired == true){
keyInserted = 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
resetPressed=false; resetPressed=false;
drillStillPressed=false; drillStillPressed=false;
resetStillPressed=false; resetStillPressed=false;
silenceStillPressed=false; silenceStillPressed=false;
drill = 0; drillTimer = 0;
updateLockStatus = true; updateLockStatus = true;
} }
} }
@ -530,12 +526,12 @@ void checkKey(){
//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!] //----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!]
void checkDevices(){ void checkDevices(){
if (walkTest == false){ if (walkTest == false){
if (possibleAlarm == false and fullAlarm == false and (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0)){ //reading a single zero flags as a possible alarm if (runVerification == false and fullAlarm == false and (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0)){ //reading a single zero flags as a possible alarm
possibleAlarm = true; runVerification = true;
} }
if (possibleAlarm == true and fullAlarm == false){ //only execute if the panel flags a possible alarm and there isn't currently a full alarm if (runVerification == true and fullAlarm == false){ //only execute if the panel flags a possible alarm and there isn't currently a full alarm
if (verification >= verificationTime or isVerification == false){ //execute the following code if verification surpasses the configured verification time OR verification is disabled if (verificationTimer >= verificationTime or verificationEnabled == false){ //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 (smokeDetectorVerification == false or smokeDetectorCurrentlyInVerification == true){ //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
@ -546,8 +542,8 @@ void checkDevices(){
zoneAlarm = 1; //z1 zoneAlarm = 1; //z1
} }
activateNAC(); activateNAC();
possibleAlarm = false; //dismiss the possible alarm after activating the NACs runVerification = false; //dismiss the possible alarm after activating the NACs
verification = 0; verificationTimer = 0;
} else if (smokeDetectorVerification == true and smokeDetectorCurrentlyInVerification == false){ //if smoke detector verifcaion is turned on, run this instead } else if (smokeDetectorVerification == true and smokeDetectorCurrentlyInVerification == false){ //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
@ -561,24 +557,24 @@ void checkDevices(){
} }
activateNAC(); activateNAC();
smokeDetectorOn(true); //re-enable the smoke detector relay after determining that a pull station was pulled. smokeDetectorOn(true); //re-enable the smoke detector relay after determining that a pull station was pulled.
possibleAlarm = false; runVerification = false;
verification = 0; verificationTimer = 0;
} else { //if the signal *does not* persists after disabling the smoke detector relay, it was a smoke detector, run verification. } else { //if the signal *does not* persists after disabling the smoke detector relay, it was a smoke detector, run verification.
smokeDetectorPostRestartTimer = 0; smokeDetectorPostRestartTimer = 0;
smokeDetectorCurrentlyInVerification = true; //tell the smokeDetector() function to run code smokeDetectorCurrentlyInVerification = true; //tell the smokeDetector() function to run code
smokeDetectorTimer = 0; //reset the smoke detector timer smokeDetectorTimer = 0; //reset the smoke detector timer
currentScreen = -1; //update the screen to allow the displaying of smoke detector verification currentScreen = -1; //update the screen to allow the displaying of smoke detector verification
digitalWrite(alarmLed, HIGH); //LED indicator digitalWrite(alarmLed, HIGH); //LED indicator
possibleAlarm = false; runVerification = false;
verification = 0; verificationTimer = 0;
} }
} }
} else { //if no zeros are read after verification, dismiss possible alarm } else { //if no zeros are read after verification, dismiss possible alarm
possibleAlarm = false; runVerification = false;
verification = 0; verificationTimer = 0;
} }
} else { } else {
verification++; verificationTimer++;
} }
} }
} else if (walkTest == true){ } else if (walkTest == true){
@ -653,18 +649,16 @@ void checkDevices(){
//----------------------------------------------------------------------------- TROUBLE RESPONSE //----------------------------------------------------------------------------- TROUBLE RESPONSE
void troubleCheck(){ void troubleCheck(){
if (trouble == true and fullAlarm == false and walkTest == false){ if (trouble and not fullAlarm and not walkTest){
if (troubleLedTimer >= 200){ if (troubleLedTimer >= 200){
if (readyLedStatus == true){ if (digitalRead(readyLed)){
digitalWrite(readyLed, LOW); digitalWrite(readyLed, LOW);
readyLedStatus = false; if (not troubleAcked){
if (troubleAck==false){
noTone(); noTone();
} }
} else { } else {
digitalWrite(readyLed, HIGH); digitalWrite(readyLed, HIGH);
readyLedStatus = true; if (not troubleAcked){
if (troubleAck==false){
tone(); tone();
} }
} }
@ -711,22 +705,21 @@ void checkButtons(){
} }
if (digitalRead(silenceButtonPin) == HIGH){ //---------------------------------------------------------SILENCE BUTTON if (digitalRead(silenceButtonPin) == HIGH){ //---------------------------------------------------------SILENCE BUTTON
if (horn == true){ //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);
digitalWrite(readyLed, LOW); digitalWrite(readyLed, LOW);
readyLedStatus = false;
horn = false; horn = false;
if (audibleSilence == false){ if (not audibleSilence){
strobe = false; strobe = false;
} }
silenced=true; silenced=true;
noTone(); noTone();
} else if (horn == false and strobe == false and trouble == true and silencePressed == false and troubleAck==false){ } else if (not fullAlarm and trouble and not silencePressed and not troubleAcked){
troubleAck = true; troubleAcked = true;
noTone(); noTone();
} else if (horn == false and strobe == false and fullAlarm == false and silencePressed == false and configMenu == false){ } else if (not fullAlarm and not silencePressed and not inConfigMenu){
configMenu = true; inConfigMenu = true;
resetStillPressed = true; //make sure the menu doesn't close out as soon as someone opens it resetStillPressed = true; //make sure the menu doesn't close out as soon as someone opens it
silenceStillPressed = true; silenceStillPressed = true;
drillStillPressed = true; drillStillPressed = true;
@ -743,19 +736,19 @@ void checkButtons(){
silencePressed = false; silencePressed = false;
} }
if (digitalRead(drillButtonPin) == HIGH and horn != true and silenced != true and fullAlarm == false){ //------------------------------------------DRILL BUTTON if (digitalRead(drillButtonPin) == HIGH and not horn and not silenced and not fullAlarm){ //------------------------------------------DRILL BUTTON
if (drill >= 237){ if (drillTimer >= 237){
zoneAlarm = 4; zoneAlarm = 4;
activateNAC(); activateNAC();
} else { } else {
drill++; drillTimer++;
} }
drillPressed = true; drillPressed = true;
} else { } else {
drill = 0; drillTimer = 0;
drillPressed = false; drillPressed = false;
} }
if (digitalRead(drillButtonPin) == HIGH and fullAlarm == true and secondStage == false){ if (digitalRead(drillButtonPin) == HIGH and not fullAlarm and not secondStage){
secondStage = true; secondStage = true;
currentScreen = -1; currentScreen = -1;
} }
@ -769,21 +762,21 @@ void alarm(){
if (strobeSync == 0){ if (strobeSync == 0){
strobeOn(true); strobeOn(true);
} else if (strobeSync == 1 or strobeSync == 2){ } else if (strobeSync == 1 or strobeSync == 2){
if (strobeSyncTiming >= 1000){ if (strobeSyncTimer >= 1000){
strobeSyncTiming=0; strobeSyncTimer=0;
} else if (strobeSyncTiming >= 975){ } else if (strobeSyncTimer >= 975){
strobeOn(false); strobeOn(false);
} else if (strobeSyncTiming <= 10){ } else if (strobeSyncTimer <= 10){
strobeOn(true); strobeOn(true);
} }
strobeSyncTiming++; strobeSyncTimer++;
} }
}else{ }else{
strobeOn(false); strobeOn(false);
strobeSyncTiming = 0; strobeSyncTimer = 0;
} }
if (horn == true and twoWire == false){ if (horn and not useTwoWire){
if (preAlarm == false or secondStage == true){ //yes, preAlarm == false is redundant but in the case that second stage == false, but pre-alarm is off, the full alarm will still sound if (not preAlarm or secondStage){ //yes, preAlarm == false is redundant but in the case that second stage == false, but pre-alarm is off, the full alarm will still sound
if (codeWheel == 0){ if (codeWheel == 0){
if (codeWheelTimer == 0){ //---------- temporal code 3 if (codeWheelTimer == 0){ //---------- temporal code 3
@ -875,7 +868,7 @@ void alarm(){
} }
codeWheelTimer++; codeWheelTimer++;
} else if (preAlarm == true and secondStage == false){ } else if (preAlarm and not secondStage){
if (codeWheelTimer == 0){ if (codeWheelTimer == 0){
hornOn(true); hornOn(true);
} else if (codeWheelTimer == 75){ } else if (codeWheelTimer == 75){
@ -892,8 +885,8 @@ void alarm(){
currentScreen = -1; currentScreen = -1;
} }
} }
} else if (twoWire == true){ //-------------------------------- DO MORE TESTING WITH THIS!!!! } else if (useTwoWire){ //-------------------------------- DO MORE TESTING WITH THIS!!!!
if (horn == true and (preAlarm == false or secondStage == true)){ if (horn and (not preAlarm or secondStage)){
if (twoWireTimer >= 1000){ if (twoWireTimer >= 1000){
twoWireTimer = 0; twoWireTimer = 0;
} else if (twoWireTimer >= 975){ } else if (twoWireTimer >= 975){
@ -902,7 +895,7 @@ void alarm(){
hornOn(true); hornOn(true);
} }
twoWireTimer++; twoWireTimer++;
} else if (horn == false and silenced == true){ } else if (not horn and silenced and audibleSilence){
if (twoWireTimer >= 1000){ if (twoWireTimer >= 1000){
twoWireTimer = 0; twoWireTimer = 0;
} else if (twoWireTimer >= 965){ } else if (twoWireTimer >= 965){
@ -911,7 +904,7 @@ void alarm(){
hornOn(true); hornOn(true);
} }
twoWireTimer++; twoWireTimer++;
} else if (preAlarm == true and secondStage == false){ } else if (horn and preAlarm and not secondStage){
if (codeWheelTimer == 0){ if (codeWheelTimer == 0){
hornOn(true); hornOn(true);
} else if (codeWheelTimer == 75){ } else if (codeWheelTimer == 75){
@ -933,16 +926,16 @@ void alarm(){
codeWheelTimer = 0; codeWheelTimer = 0;
twoWireTimer = 0; twoWireTimer = 0;
} }
if (fullAlarm == true){ if (fullAlarm){
alarmLedTimer++; alarmLedTimer++;
if (alarmLedTimer >= 750){ if (alarmLedTimer >= 750){
if (digitalRead(alarmLed) == false){ if (not digitalRead(alarmLed)){
if (silenced == true){ if (silenced){
tone(); tone();
} }
digitalWrite(alarmLed, HIGH); digitalWrite(alarmLed, HIGH);
} else { } else {
if (silenced == true){ if (silenced){
noTone(); noTone();
} }
digitalWrite(alarmLed, LOW); digitalWrite(alarmLed, LOW);
@ -954,11 +947,11 @@ void alarm(){
//----------------------------------------------------------------------------- NAC ACTIVATION //----------------------------------------------------------------------------- NAC ACTIVATION
void lcdUpdate(){ void lcdUpdate(){
if (trouble==false and fullAlarm==false and horn==false and strobe==false and walkTest == false and currentScreen != 0 and drill == 0){ if (not trouble and not fullAlarm and not walkTest and currentScreen != 0 and drillTimer == 0){
lcd.noAutoscroll(); lcd.noAutoscroll();
lcd.clear(); lcd.clear();
lcd.setCursor(2,0); lcd.setCursor(2,0);
if (smokeDetectorCurrentlyInVerification == true){ if (smokeDetectorCurrentlyInVerification){
lcd.print("Smoke Verif."); lcd.print("Smoke Verif.");
} else { } else {
lcd.print("System Normal"); lcd.print("System Normal");
@ -971,10 +964,10 @@ void lcdUpdate(){
} }
currentScreen = 0; currentScreen = 0;
updateLockStatus = true; updateLockStatus = true;
} else if (fullAlarm == true and silenced == false and currentScreen != 3){ } else if (fullAlarm and not silenced and currentScreen != 3){
lcd.clear(); lcd.clear();
lcd.setCursor(1,0); lcd.setCursor(1,0);
if (secondStage == true){ //print pre-alarm if it is first stage if (secondStage){ //print pre-alarm if it is first stage
lcd.print("* FIRE ALARM *"); lcd.print("* FIRE ALARM *");
} else { } else {
lcd.print("* PRE ALARM *"); lcd.print("* PRE ALARM *");
@ -991,7 +984,7 @@ void lcdUpdate(){
} }
currentScreen = 3; currentScreen = 3;
updateLockStatus = true; updateLockStatus = true;
} else if (silenced == true and currentScreen != 4){ } else if (silenced and currentScreen != 4){
lcd.clear(); lcd.clear();
lcd.setCursor(1,0); lcd.setCursor(1,0);
lcd.print("-- SILENCED --"); lcd.print("-- SILENCED --");
@ -1005,11 +998,9 @@ void lcdUpdate(){
} else if (zoneAlarm == 4){ } else if (zoneAlarm == 4){
lcd.print("Fire Drill"); lcd.print("Fire Drill");
} }
// lcd.setCursor(2,1);
// lcd.print("Zone 1");
currentScreen = 4; currentScreen = 4;
updateLockStatus = true; updateLockStatus = true;
} else if (walkTest == true and currentScreen != 5) { } else if (walkTest and currentScreen != 5) {
lcd.clear(); lcd.clear();
lcd.setCursor(1,0); lcd.setCursor(1,0);
lcd.print("* Supervisory *"); lcd.print("* Supervisory *");
@ -1018,15 +1009,14 @@ void lcdUpdate(){
currentScreen = 5; currentScreen = 5;
updateLockStatus = true; updateLockStatus = true;
digitalWrite(readyLed, LOW); //ready led off for walk test digitalWrite(readyLed, LOW); //ready led off for walk test
readyLedStatus = false; } else if (drillPressed and not fullAlarm and not walkTest and currentScreen != 6) {
} else if (drillPressed == true and fullAlarm == false and horn == false and strobe == false and walkTest == false and currentScreen != 6) {
lcd.clear(); lcd.clear();
lcd.setCursor(0,0); lcd.setCursor(0,0);
lcd.print("CONTINUE HOLDING"); lcd.print("CONTINUE HOLDING");
lcd.setCursor(1,1); lcd.setCursor(1,1);
lcd.print("TO START DRILL"); lcd.print("TO START DRILL");
currentScreen = 6; currentScreen = 6;
} else if (trouble==true and fullAlarm == false and drillPressed == false and walkTest == false and currentScreen != 1){ } else if (trouble and not fullAlarm and not drillPressed and not walkTest and currentScreen != 1){
lcd.clear(); lcd.clear();
lcd.setCursor(2,0); lcd.setCursor(2,0);
lcd.print("* Trouble *"); lcd.print("* Trouble *");
@ -1046,16 +1036,32 @@ void lcdUpdate(){
currentScreen = 1; currentScreen = 1;
updateLockStatus = true; updateLockStatus = true;
} }
if (updateLockStatus == true and configMenu == false and keyRequired == true){ if (updateLockStatus and not inConfigMenu and keyRequired){
lcd.setCursor(0,0); lcd.setCursor(0,0);
if (keyInserted == false){ if (panelUnlocked){
lcd.write(byte(0));
} else {
lcd.print(" "); lcd.print(" ");
} else {
lcd.write(byte(0));
} }
updateLockStatus = false; updateLockStatus = false;
} }
} }
void configLCDUpdate(int cursor, String top, String bottom, bool replaceTop = false, bool replaceBottom = false){ // new cursor position, top lcd text, bottom lcd text, does the top text need a check or cross, does the bottom text need a check or cross
configTop = top;
configBottom = bottom;
cursorPosition = cursor;
if (replaceTop == true){
configTop.replace("1","*");
configTop.replace("0","$");
}
if (replaceBottom == true){
configBottom.replace("1","*");
configBottom.replace("0","$");
}
}
void config(){ void config(){
char *main[] = {"Testing","Settings"}; //menu 0 char *main[] = {"Testing","Settings"}; //menu 0
char *mainTesting[] = {"Walk Test","Silent Wlk Test","Strobe Test"}; //menu 1 char *mainTesting[] = {"Walk Test","Silent Wlk Test","Strobe Test"}; //menu 1
@ -1090,66 +1096,49 @@ void config(){
} }
//----------------------------------------------------------------------------- MAIN MENU //----------------------------------------------------------------------------- MAIN MENU
if (configPage == 0){ if (configPage == 0){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ //main screen if (cursorPosition == 0){ //main screen
cursorPosition = 1; configLCDUpdate(1, (String)main[1], (String)main[0]);
configTop = (String)main[1];
configBottom = (String)main[0];
} else if (cursorPosition == 1){ } else if (cursorPosition == 1){
cursorPosition = 0; configLCDUpdate(0, (String)main[0], (String)main[1]);
configTop = (String)main[0];
configBottom = (String)main[1];
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
silencePressed = true; silencePressed = true;
configMenu = false; inConfigMenu = false;
currentScreen=-1; currentScreen=-1;
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed and not drillStillPressed){
if (cursorPosition == 0){ //cursor over testing if (cursorPosition == 0){ //cursor over testing
configPage = 1; //change screen to testing configPage = 1; //change screen to testing
cursorPosition = 0; configLCDUpdate(0, (String)mainTesting[0], (String)mainTesting[1]);
configTop = (String)mainTesting[0];
configBottom = (String)mainTesting[1];
} else if (cursorPosition == 1){ //cursor over settings } else if (cursorPosition == 1){ //cursor over settings
configPage = 2; //change screen to settings configPage = 2; //change screen to settings
cursorPosition = 0; configLCDUpdate(0, (String)mainSettings[0], (String)mainSettings[1]);
configTop = (String)mainSettings[0];
configBottom = (String)mainSettings[1];
} }
} }
//----------------------------------------------------------------------------- MAIN MENU //----------------------------------------------------------------------------- MAIN MENU
//----------------------------------------------------------------------------- TESTING //----------------------------------------------------------------------------- TESTING
} else if (configPage == 1){ } else if (configPage == 1){
if (resetPressed == true and resetStillPressed == false and strobe != true){ if (resetPressed and not resetStillPressed and not strobe){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; configLCDUpdate(1, (String)mainTesting[1], (String)mainTesting[2]);
configTop = (String)mainTesting[1];
configBottom = (String)mainTesting[2];
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2; configLCDUpdate(2, (String)mainTesting[2], (String)mainTesting[0]);
configTop = (String)mainTesting[2];
configBottom = (String)mainTesting[0];
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 0; configLCDUpdate(0, (String)mainTesting[0], (String)mainTesting[1]);
configTop = (String)mainTesting[0];
configBottom = (String)mainTesting[1];
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 0; configPage = 0;
cursorPosition = 0; configLCDUpdate(0, (String)main[0], (String)main[1]);
configTop = (String)main[0];
configBottom = (String)main[1];
strobe = false; strobe = false;
smokeDetectorOn(true); smokeDetectorOn(true);
digitalWrite(readyLed,HIGH); digitalWrite(readyLed,HIGH);
readyLedStatus = true; } else if (drillPressed == true and not drillStillPressed){
} else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
walkTest = true; walkTest = true;
silentWalkTest = false; silentWalkTest = false;
silencePressed = true; silencePressed = true;
configMenu = false; inConfigMenu = false;
currentScreen=-1; currentScreen=-1;
zone1Count = 0; zone1Count = 0;
zone2Count = 0; zone2Count = 0;
@ -1157,23 +1146,21 @@ void config(){
walkTest = true; walkTest = true;
silentWalkTest = true; silentWalkTest = true;
silencePressed = true; silencePressed = true;
configMenu = false; inConfigMenu = false;
currentScreen=-1; currentScreen=-1;
zone1Count = 0; zone1Count = 0;
zone2Count = 0; zone2Count = 0;
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
if (strobe == false){ if (not strobe){
strobe = true; strobe = true;
smokeDetectorOn(false); //prevent (specifically cheap IR) smoke detectors from tripping from the strobe smokeDetectorOn(false); //prevent (specifically cheap IR) smoke detectors from tripping from the strobe
digitalWrite(readyLed,LOW); digitalWrite(readyLed,LOW);
readyLedStatus = false; configLCDUpdate(2, (String)mainTesting[2]+" *", (String)mainTesting[0]);
configTop = (String)mainTesting[2]+" *";
} else { } else {
strobe = false; strobe = false;
smokeDetectorOn(true); smokeDetectorOn(true);
digitalWrite(readyLed,HIGH); digitalWrite(readyLed,HIGH);
readyLedStatus = true; configLCDUpdate(2, (String)mainTesting[2], (String)mainTesting[0]);
configTop = (String)mainTesting[2];
} }
} }
} }
@ -1181,144 +1168,93 @@ void config(){
//----------------------------------------------------------------------------- SETTINGS //----------------------------------------------------------------------------- SETTINGS
} else if (configPage == 2){ } else if (configPage == 2){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ //main screen if (cursorPosition == 0){ //main screen
cursorPosition = 1; configLCDUpdate(1, (String)mainSettings[1], (String)mainSettings[0]);
configTop = (String)mainSettings[1];
configBottom = (String)mainSettings[0];
} else if (cursorPosition == 1){ } else if (cursorPosition == 1){
cursorPosition = 0; configLCDUpdate(0, (String)mainSettings[0], (String)mainSettings[1]);
configTop = (String)mainSettings[0];
configBottom = (String)mainSettings[1];
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed == true and silenceStillPressed == false){
configPage = 0; configPage = 0;
cursorPosition = 1; configLCDUpdate(1, (String)main[1], (String)main[0]);
configTop = (String)main[1]; } else if (drillPressed and not drillStillPressed){
configBottom = (String)main[0];
} else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
configPage = 3; //change screen to facp settings configPage = 3; //change screen to facp settings
cursorPosition = 0; if (useTwoWire){
if (twoWire == false){ configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0] + " off", (String)mainSettingsFireAlarmSettings[1]);
configTop = (String)mainSettingsFireAlarmSettings[0];
} else { } else {
configTop = (String)mainSettingsFireAlarmSettings[0] + " off"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0], (String)mainSettingsFireAlarmSettings[1]);
} }
configBottom = (String)mainSettingsFireAlarmSettings[1];
} else if (cursorPosition == 1){ } else if (cursorPosition == 1){
configPage = 8; //change screen to facp settings configPage = 8; //change screen to facp settings
cursorPosition = 0; configLCDUpdate(0, (String)mainPanelSettings[0], (String)mainPanelSettings[1]);
configTop = (String)mainPanelSettings[0];
configBottom = (String)mainPanelSettings[1];
} }
} }
//----------------------------------------------------------------------------- SETTINGS //----------------------------------------------------------------------------- SETTINGS
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM
} else if (configPage == 3){ } else if (configPage == 3){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed and not resetStillPressed){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; configLCDUpdate(1, (String)mainSettingsFireAlarmSettings[1], (String)mainSettingsFireAlarmSettings[2]);
configTop = (String)mainSettingsFireAlarmSettings[1];
configBottom = (String)mainSettingsFireAlarmSettings[2];
} else if (cursorPosition == 1) { } else if (cursorPosition == 1) {
cursorPosition = 2; configLCDUpdate(2, (String)mainSettingsFireAlarmSettings[2], (String)mainSettingsFireAlarmSettings[3]+audibleSilence, false, true);
configTop = (String)mainSettingsFireAlarmSettings[2];
configBottom = (String)mainSettingsFireAlarmSettings[3]+audibleSilence;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
cursorPosition = 3; if (keyRequiredVisual){
configTop = (String)mainSettingsFireAlarmSettings[3]+audibleSilence; configLCDUpdate(3, (String)mainSettingsFireAlarmSettings[3]+audibleSilence, (String)mainSettingsFireAlarmSettings[4]+keylessSilence, true, true);
if (keyRequiredVisual == true){
configBottom = (String)mainSettingsFireAlarmSettings[4]+keylessSilence;
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettings[4]+"off"; configLCDUpdate(3, (String)mainSettingsFireAlarmSettings[3]+audibleSilence, (String)mainSettingsFireAlarmSettings[4]+keylessSilence+"off", true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 3){ } else if (cursorPosition == 3){
cursorPosition = 4; if (keyRequiredVisual){
if (keyRequiredVisual == true){ configLCDUpdate(4, (String)mainSettingsFireAlarmSettings[4]+keylessSilence, (String)mainSettingsFireAlarmSettings[5], true, false);
configTop = (String)mainSettingsFireAlarmSettings[4]+keylessSilence;
} else { } else {
configTop = (String)mainSettingsFireAlarmSettings[4]+"off"; configLCDUpdate(4, (String)mainSettingsFireAlarmSettings[4]+"off", (String)mainSettingsFireAlarmSettings[5], false, false);
} }
configBottom = (String)mainSettingsFireAlarmSettings[5];
configTop.replace("1","*");
configTop.replace("0","$");
} else if (cursorPosition == 4) { } else if (cursorPosition == 4) {
cursorPosition = 5; configLCDUpdate(5, (String)mainSettingsFireAlarmSettings[5], (String)mainSettingsFireAlarmSettings[6]+useTwoWire, false, true);
configTop = (String)mainSettingsFireAlarmSettings[5];
configBottom = (String)mainSettingsFireAlarmSettings[6]+twoWire;
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 5){ } else if (cursorPosition == 5){
cursorPosition = 6; if (useTwoWire){
configTop = (String)mainSettingsFireAlarmSettings[6]+twoWire; configLCDUpdate(6, (String)mainSettingsFireAlarmSettings[6]+useTwoWire, (String)mainSettingsFireAlarmSettings[0]+"off", true, false);
if (twoWire == false){
configBottom = (String)mainSettingsFireAlarmSettings[0];
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettings[0] + " off"; configLCDUpdate(6, (String)mainSettingsFireAlarmSettings[6]+useTwoWire, (String)mainSettingsFireAlarmSettings[0], true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} else if (cursorPosition == 6){ } else if (cursorPosition == 6){
cursorPosition = 0; if (useTwoWire){
if (twoWire == false){ configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0] + " off", (String)mainSettingsFireAlarmSettings[1]);
configTop = (String)mainSettingsFireAlarmSettings[0];
} else { } else {
configTop = (String)mainSettingsFireAlarmSettings[0] + " off"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettings[0], (String)mainSettingsFireAlarmSettings[1]);
} }
configBottom = (String)mainSettingsFireAlarmSettings[1];
} }
} else if (silencePressed == true and silenceStillPressed == false){ } else if (silencePressed and not silenceStillPressed){
configPage = 2; configPage = 2;
cursorPosition = 0; configLCDUpdate(0, (String)mainSettings[0], (String)mainSettings[1]);
configTop = (String)mainSettings[0]; } else if (drillPressed and not drillStillPressed){
configBottom = (String)mainSettings[1]; if (cursorPosition == 0 and not useTwoWire){
} else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0 and twoWire == false){
configPage = 5; configPage = 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 (cursorPosition == 1) { } else if (cursorPosition == 1) {
configPage = 4; configPage = 4;
cursorPosition = 0; if (verificationEnabled){
configTop = (String)mainSettingsVerificationSettings[0] + isVerification; configLCDUpdate(0, (String)mainSettingsVerificationSettings[0] + verificationEnabled, (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s", true, false);
if (isVerification == false){
configBottom = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configLCDUpdate(0, (String)mainSettingsVerificationSettings[0] + verificationEnabled, (String)mainSettingsVerificationSettings[1] + "off", true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} else if (cursorPosition == 2) { } else if (cursorPosition == 2) {
configPage = 6; configPage = 6;
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 (cursorPosition == 3) { } else if (cursorPosition == 3) {
if (audibleSilence == true){ if (audibleSilence){
audibleSilence = false; audibleSilence = false;
EEPROM.write(79,0); EEPROM.write(79,0);
} else { } else {
@ -1326,18 +1262,13 @@ void config(){
EEPROM.write(79,1); EEPROM.write(79,1);
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettings[3]+audibleSilence; if (keyRequiredVisual){
if (keyRequiredVisual == true){ configLCDUpdate(3, (String)mainSettingsFireAlarmSettings[3]+audibleSilence, (String)mainSettingsFireAlarmSettings[4]+keylessSilence, true, true);
configBottom = (String)mainSettingsFireAlarmSettings[4]+keylessSilence;
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettings[4]+"off"; configLCDUpdate(3, (String)mainSettingsFireAlarmSettings[3]+audibleSilence, (String)mainSettingsFireAlarmSettings[4]+"off", true, false);
} }
configTop.replace("1","*"); } else if (cursorPosition == 4 and keyRequiredVisual){
configTop.replace("0","$"); if (keylessSilence){
configBottom.replace("1","*");
configBottom.replace("0","$");
} else if (cursorPosition == 4 and keyRequiredVisual == true){
if (keylessSilence == true){
keylessSilence = false; keylessSilence = false;
EEPROM.write(27,0); EEPROM.write(27,0);
} else { } else {
@ -1345,41 +1276,31 @@ void config(){
EEPROM.write(27,1); EEPROM.write(27,1);
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettings[4]+keylessSilence; configLCDUpdate(4, (String)mainSettingsFireAlarmSettings[4]+keylessSilence, (String)mainSettingsFireAlarmSettings[5], true, false);
configBottom = (String)mainSettingsFireAlarmSettings[5];
configTop.replace("1","*");
configTop.replace("0","$");
} else if (cursorPosition == 5){ } else if (cursorPosition == 5){
configPage = 11; configPage = 11;
cursorPosition = 0;
if (strobeSync == 0){ if (strobeSync == 0){
configTop = (String)mainSettingsFireAlarmSettingsStrobeSync[0] + "*"; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsStrobeSync[0] + "*", (String)mainSettingsFireAlarmSettingsStrobeSync[1]);
} else if (strobeSync == 1){
configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsStrobeSync[0], (String)mainSettingsFireAlarmSettingsStrobeSync[1] + "*");
} else { } else {
configTop = (String)mainSettingsFireAlarmSettingsStrobeSync[0]; configLCDUpdate(0, (String)mainSettingsFireAlarmSettingsStrobeSync[0], (String)mainSettingsFireAlarmSettingsStrobeSync[1]);
}
if (strobeSync == 1){
configBottom = (String)mainSettingsFireAlarmSettingsStrobeSync[1] + "*";
} else {
configBottom = (String)mainSettingsFireAlarmSettingsStrobeSync[1];
} }
} else if (cursorPosition == 6){ } else if (cursorPosition == 6){
if (twoWire == true){ if (useTwoWire){
twoWire = false; useTwoWire = false;
EEPROM.write(30,0); EEPROM.write(30,0);
} else { } else {
twoWire = true; useTwoWire = true;
EEPROM.write(30,1); EEPROM.write(30,1);
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsFireAlarmSettings[6]+twoWire; configTop = (String)mainSettingsFireAlarmSettings[6]+useTwoWire;
if (twoWire == false){ if (useTwoWire){
configBottom = (String)mainSettingsFireAlarmSettings[0]; configLCDUpdate(6, (String)mainSettingsFireAlarmSettings[6]+useTwoWire, (String)mainSettingsFireAlarmSettings[0] + " off", true, false);
} else { } else {
configBottom = (String)mainSettingsFireAlarmSettings[0] + " off"; configLCDUpdate(6, (String)mainSettingsFireAlarmSettings[6]+useTwoWire, (String)mainSettingsFireAlarmSettings[0], true, false);
} }
configTop.replace("1","*");
configTop.replace("0","$");
} }
} }
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM
@ -1644,10 +1565,10 @@ void config(){
} 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; cursorPosition = 0;
if (twoWire == false){ if (useTwoWire){
configTop = (String)mainSettingsFireAlarmSettings[0];
} else {
configTop = (String)mainSettingsFireAlarmSettings[0] + " off"; configTop = (String)mainSettingsFireAlarmSettings[0] + " off";
} else {
configTop = (String)mainSettingsFireAlarmSettings[0];
} }
configBottom = (String)mainSettingsFireAlarmSettings[1]; configBottom = (String)mainSettingsFireAlarmSettings[1];
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed == true and drillStillPressed == false){
@ -1668,7 +1589,7 @@ void config(){
if (resetPressed == true and resetStillPressed == false){ if (resetPressed == true and resetStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
cursorPosition = 1; cursorPosition = 1;
if (isVerification == false){ if (verificationEnabled == false){
configTop = (String)mainSettingsVerificationSettings[1] + "off"; configTop = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s";
@ -1721,13 +1642,13 @@ void config(){
} else { } else {
configTop = (String)mainSettingsVerificationSettings[4] + "off"; configTop = (String)mainSettingsVerificationSettings[4] + "off";
} }
configBottom = (String)mainSettingsVerificationSettings[0] + isVerification; configBottom = (String)mainSettingsVerificationSettings[0] + verificationEnabled;
configBottom.replace("1","*"); configBottom.replace("1","*");
configBottom.replace("0","$"); configBottom.replace("0","$");
} else if (cursorPosition == 4) { } else if (cursorPosition == 4) {
cursorPosition = 0; cursorPosition = 0;
configTop = (String)mainSettingsVerificationSettings[0] + isVerification; configTop = (String)mainSettingsVerificationSettings[0] + verificationEnabled;
if (isVerification == false){ if (verificationEnabled == false){
configBottom = (String)mainSettingsVerificationSettings[1] + "off"; configBottom = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s";
@ -1742,23 +1663,23 @@ void config(){
configBottom = (String)mainSettingsFireAlarmSettings[2]; configBottom = (String)mainSettingsFireAlarmSettings[2];
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed == true and drillStillPressed == false){
if (cursorPosition == 0){ if (cursorPosition == 0){
if (isVerification == true){ if (verificationEnabled == true){
isVerification = false; verificationEnabled = false;
EEPROM.write(9,0); EEPROM.write(9,0);
} else { } else {
isVerification = true; verificationEnabled = true;
EEPROM.write(9,1); EEPROM.write(9,1);
} }
EEPROM.commit(); EEPROM.commit();
configTop = (String)mainSettingsVerificationSettings[0]+isVerification; configTop = (String)mainSettingsVerificationSettings[0]+verificationEnabled;
if (isVerification == false){ if (verificationEnabled == false){
configBottom = (String)mainSettingsVerificationSettings[1] + "off"; configBottom = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s";
} }
configTop.replace("1","*"); configTop.replace("1","*");
configTop.replace("0","$"); configTop.replace("0","$");
} else if (cursorPosition == 1 and isVerification == true) { } 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);
@ -1779,7 +1700,7 @@ void config(){
EEPROM.write(10,5); EEPROM.write(10,5);
} }
EEPROM.commit(); EEPROM.commit();
if (isVerification == false){ if (verificationEnabled == false){
configTop = (String)mainSettingsVerificationSettings[1] + "off"; configTop = (String)mainSettingsVerificationSettings[1] + "off";
} else { } else {
configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s";
@ -1886,7 +1807,7 @@ void config(){
} else { } else {
configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m"; configTop = (String)mainSettingsVerificationSettings[4] + (smokeDetectorPostRestartVerificationTime/60000) + "m";
} }
configBottom = (String)mainSettingsVerificationSettings[0] + isVerification; configBottom = (String)mainSettingsVerificationSettings[0] + verificationEnabled;
configBottom.replace("1","*"); configBottom.replace("1","*");
configBottom.replace("0","$"); configBottom.replace("0","$");
} }
@ -2123,7 +2044,7 @@ void config(){
configPage = 3; //change screen to facp settings configPage = 3; //change screen to facp settings
cursorPosition = 5; cursorPosition = 5;
configTop = (String)mainSettingsFireAlarmSettings[5]; configTop = (String)mainSettingsFireAlarmSettings[5];
configBottom = (String)mainSettingsFireAlarmSettings[6]+twoWire; configBottom = (String)mainSettingsFireAlarmSettings[6]+useTwoWire;
configBottom.replace("1","*"); configBottom.replace("1","*");
configBottom.replace("0","$"); configBottom.replace("0","$");
} else if (drillPressed == true and drillStillPressed == false){ } else if (drillPressed == true and drillStillPressed == false){
@ -2205,7 +2126,7 @@ void lcdBacklight(){
} else if (backlightOn == true) { } else if (backlightOn == true) {
lcdTimeoutTimer++; lcdTimeoutTimer++;
} }
if (drillPressed == true or silencePressed == true or resetPressed == true or fullAlarm == true or trouble == true or (keyInserted == true and keyRequired == true) or smokeDetectorCurrentlyInVerification == true){ if (drillPressed == true or silencePressed == true or resetPressed == true or fullAlarm == true or trouble == true or (panelUnlocked == true and keyRequired == true) or smokeDetectorCurrentlyInVerification == true){
lcdTimeoutTimer = 0; lcdTimeoutTimer = 0;
if (backlightOn == false){ if (backlightOn == false){
lcd.backlight(); lcd.backlight();
@ -2264,12 +2185,10 @@ void failsafe(){ //--------------------------------------------- FAILSAFE MODE I
ESP.restart(); ESP.restart();
} }
if (troubleLedTimer >= 2000){ if (troubleLedTimer >= 2000){
if (readyLedStatus == true){ if (digitalRead(readyLed)){
digitalWrite(readyLed, LOW); digitalWrite(readyLed, LOW);
readyLedStatus = false;
} else { } else {
digitalWrite(readyLed, HIGH); digitalWrite(readyLed, HIGH);
readyLedStatus = true;
} }
troubleLedTimer = 0; troubleLedTimer = 0;
} else { } else {
@ -2302,15 +2221,14 @@ void loop() {
} }
if (buttonCheckTimer >= 20){ if (buttonCheckTimer >= 20){
if (configMenu==false){ if (not inConfigMenu){
if ((keyInserted == true and keyRequired == true) or (keyRequired==false)){ if ((panelUnlocked == true and keyRequired == true) or (keyRequired==false)){
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){
digitalWrite(silenceLed, HIGH); digitalWrite(silenceLed, HIGH);
digitalWrite(alarmLed, LOW); digitalWrite(alarmLed, LOW);
digitalWrite(readyLed, LOW); digitalWrite(readyLed, LOW);
readyLedStatus = false;
horn = false; horn = false;
if (audibleSilence == false){ if (audibleSilence == false){
strobe = false; strobe = false;
@ -2321,8 +2239,8 @@ void loop() {
} }
lcdUpdate(); //------------------------------------------------------ UPDATE LCD DISPLAY lcdUpdate(); //------------------------------------------------------ UPDATE LCD DISPLAY
} else if (configMenu==true) { } else if (inConfigMenu) {
if ((keyInserted == true and keyRequired == true) or (keyInserted==false and keyRequired==false)){ if ((panelUnlocked == true and keyRequired == true) or (panelUnlocked==false and keyRequired==false)){
config(); config();
} }
} }