2022-07-04 18:07:36 -04:00
# include <Arduino.h>
# include <EEPROM.h>
# include <LiquidCrystal_I2C.h>
# include <string.h>
2023-03-25 23:51:21 -04:00
bool invertRelay = false ; //------------------IF YOUR RELAYS OPERATE THE OPPOSITE OF HOW YOU EXPECT, CHANGE THIS TO 'TRUE'
2022-09-27 22:31:38 -04:00
unsigned long systemClock ; //-----------------SYSTEM CLOCK [VERY IMPORTANT]
unsigned long lastPulse ; //-------------------LAST void loop() PULSE
2022-10-03 23:05:16 -04:00
bool failsafeMode = false ; // If panel fails to boot, you can enter a reduced-feature down panel that is guaranteed to work
2022-09-27 22:31:38 -04:00
2023-03-26 21:20:11 -04:00
char * firmwareRev = " v1.5 " ; //VERSION
2022-07-04 19:28:48 -04:00
int EEPROMVersion = 1 ; //version control to rewrite eeprom after update
2023-03-26 21:20:11 -04:00
int EEPROMBuild = 5 ;
2022-10-06 22:49:08 -04:00
//patents
// https://patents.google.com/patent/US5559492 - simplex
// https://patents.google.com/patent/US6281789 - simplex smartsync
// https://patents.google.com/patent/US6194994 - wheelock
// https://patents.google.com/patent/US5659287A/en - gentex strobe sync
// https://patents.google.com/patent/US5959528 - gentex smartsync
// https://patents.google.com/patent/US8928191B2/en - potter weird universal sync
2022-07-04 19:28:48 -04:00
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- RUNTIME VARIABLES
2022-07-04 18:07:36 -04:00
bool fullAlarm = false ; //bool to control if this is a full alarm that requres a panel reset to clear
bool silenced = false ;
2022-10-08 22:18:30 -04:00
bool panelUnlocked = false ; //if the control panel has a key inserted
2022-07-04 18:07:36 -04:00
bool horn = false ; //bool to control if the horns 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
2022-10-08 22:18:30 -04:00
bool troubleAcked = false ; //bool to control if the trouble is acknowledged
bool inConfigMenu = false ; //determine if the control panel is in the configuration menu
2022-10-02 22:28:59 -04:00
//---------------------------- Variables that are *always* true if a button is held down at all
2022-07-04 18:07:36 -04:00
bool resetPressed = false ;
2022-10-02 22:28:59 -04:00
bool silencePressed = false ;
2022-07-04 18:07:36 -04:00
bool drillPressed = false ;
2022-10-02 22:28:59 -04:00
//----------------------------
//---------------------------- Variables that are false the *first* iteration through, caused by the variables above being true, this is handy for detecting single button presses, and not repeating code every loop
2022-07-04 18:07:36 -04:00
bool resetStillPressed = false ;
2022-10-02 22:28:59 -04:00
bool silenceStillPressed = false ;
2022-07-04 18:07:36 -04:00
bool drillStillPressed = false ;
2022-10-02 22:28:59 -04:00
//----------------------------
2022-10-08 22:18:30 -04:00
bool runVerification = false ; //panel receieved 0 from pull station ciruit and is now investigating
2022-07-04 18:07:36 -04:00
bool walkTest = false ; //is the system in walk test
bool silentWalkTest = false ;
bool backlightOn = true ;
2022-10-06 22:49:08 -04:00
bool keyRequiredVisual ; //this variable makes it so the user can change the security settings, exit, return, and the setting they changed persists, but it won't apply until panel restart
2022-09-30 23:02:37 -04:00
bool keylessSilence = false ; //can the panel be silenced without a key
2022-09-25 13:24:30 -04:00
bool debug = false ;
2022-10-01 17:22:12 -04:00
bool updateLockStatus = false ; //if the screen needs to be updated for the lock/unlock icon
2022-10-02 22:28:59 -04:00
bool secondStage = false ; //if the panel is in second stage
2022-07-04 18:07:36 -04:00
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 clearTimer = 0 ; //timer for keeping track of button holding for clearing character in the name editor
2022-10-08 22:18:30 -04:00
int verificationTimer = 0 ; //number to keep track of ms for verification
int drillTimer = 0 ; //number to keep track of ms for drill
2022-09-27 22:31:38 -04:00
int buttonCheckTimer = 0 ; //add a slight delay to avoid double-clicking buttons
2022-09-30 23:02:37 -04:00
int keyCheckTimer = 0 ;
2022-07-04 18:07:36 -04:00
int troubleTimer = 0 ; //ms for trouble
int codeWheelTimer = 0 ; //code wheel timing variable
int troubleLedTimer = 0 ; //number to keep track of ms for trouble light
int alarmLedTimer = 0 ; //alarm led timer
int troubleType = 0 ; //trouble type 0 - general, 1 - eol resistor
int lcdTimeoutTimer = 0 ; //timer to keep track of how long until lcd off
int currentScreen = - 1 ; //update display if previous screen is not the same
int configPage = 0 ; //config page for the config menu
int cursorPosition = 0 ; //which menu item the cursor is over
2022-09-29 17:39:07 -04:00
int zone1Count = 0 ; //walk test variables
int zone2Count = 0 ;
int zoneAlarm = 0 ; //which zone is in alarm 0 - none | 1 - zone 1 | 2 - zone 2 | 3 - zone 1 & 2 | 4 - drill
2022-10-01 17:22:12 -04:00
int zoneTrouble = 0 ; //which zone is in trouble 0 - none | 1 - zone 1 | 2 - zone 2 | 3 - zone 1 & 2
2023-03-26 21:20:11 -04:00
int powerOnHours = 0 ;
2022-07-04 18:07:36 -04:00
String configTop ; //configuration menu strings for lcd
String configBottom ;
String currentConfigTop ; //configuration menu strings for current lcd display
String currentConfigBottom ;
2022-10-02 22:28:59 -04:00
bool keyRequired = false ; //determine if key switch is required to operate buttons
2022-10-08 22:18:30 -04:00
bool verificationEnabled = true ; //is verification turned on
2022-10-02 22:28:59 -04:00
bool eolResistor = true ; //is the EOL resistor enabled
bool preAlarm = false ; //use pre-alarm?
bool smokeDetectorVerification = false ; //should smoke detectors activate first stage
bool smokeDetectorCurrentlyInVerification = false ; //Is a smoke detector currently in verification?
bool audibleSilence = true ;
2022-10-08 22:18:30 -04:00
bool useTwoWire = false ; //does the panel use 2 wire for alarms
2022-10-06 22:49:08 -04:00
int twoWireTimer = 0 ; //timer for 2 wire alarms
2022-10-03 23:05:16 -04:00
int smokeDetectorTimeout = 60000 ; //how long to wait before toggling smoke detectors back on
2022-10-02 22:28:59 -04:00
int smokeDetectorPostRestartTimer = 0 ; //variable to keep track of the 60 seconds post-power up that the panel watches the smoke detector
2022-10-03 23:05:16 -04:00
int smokeDetectorPostRestartVerificationTime = 120000 ; //time in ms that the smoke detector should be monitored
2022-10-02 22:28:59 -04:00
int smokeDetectorTimer = 0 ; //timer to keep track of the current smoke detector timeout progress
int firstStageTime = 300000 ; //time in minutes that first stage should last
int firstStageTimer = 0 ; //timer to keep track of current first stage
int codeWheel = 0 ; //which alarm pattern to use, code-3 default
2022-10-06 22:49:08 -04:00
int strobeSync = 0 ; //strobe sync is not on by default 0 - none | 1 - System Sensor | 2 - Wheelock | 3 - Gentex | 4 - Simplex
2022-10-08 22:18:30 -04:00
int strobeSyncTimer = 0 ; //strobe sync timer
2022-10-02 22:28:59 -04:00
float verificationTime = 2500 ;
int panelHomescreen = 0 ;
int lcdTimeout = 0 ;
String panelName = " " ;
LiquidCrystal_I2C lcd ( 0x27 , 16 , 2 ) ;
2022-09-30 19:07:30 -04:00
//---------------------------------------- CUSTOM LCD CHARACTERS
2022-09-25 23:54:40 -04:00
byte lock [ ] = { //lock icon
B01110 ,
B10001 ,
B10001 ,
B11111 ,
B11011 ,
B11011 ,
B11111 ,
B00000
} ;
2022-07-04 18:07:36 -04:00
2022-09-27 22:31:38 -04:00
byte check [ ] = { //check mark icon
B00000 ,
B00001 ,
B00011 ,
B10110 ,
B11100 ,
B01000 ,
B00000 ,
B00000
} ;
2022-09-30 19:07:30 -04:00
byte cross [ ] = { //x mark
B00000 ,
B11011 ,
B01110 ,
B00100 ,
B01110 ,
B11011 ,
B00000 ,
B00000
} ;
//---------------------------------------- CUSTOM LCD CHARACTERS
2023-03-22 14:12:48 -04:00
//PIN DEFINITIONS
2022-07-04 18:07:36 -04:00
int zone1Pin = 15 ;
2023-03-25 21:54:38 -04:00
int zone2Pin = 39 ; //TESTING is set to 15 but is normally 39.
2022-09-21 21:57:02 -04:00
int hornRelay = 13 ;
2022-07-04 18:07:36 -04:00
int buzzerPin = 4 ;
2022-09-21 21:57:02 -04:00
int strobeRelay = 18 ;
int smokeDetectorRelay = 14 ;
int readyLed = 27 ;
int silenceLed = 26 ;
int alarmLed = 25 ;
2022-07-04 19:28:48 -04:00
int keySwitchPin = 33 ;
2022-09-19 20:46:43 -04:00
int resetButtonPin = 32 ;
int silenceButtonPin = 35 ;
int drillButtonPin = 34 ;
2022-07-04 19:28:48 -04:00
int sclPin = 22 ;
int sdaPin = 21 ;
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- RUNTIME VARIABLES
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- EEPROM RESET
2022-07-04 18:07:36 -04:00
void resetEEPROM ( ) {
2023-03-26 21:20:11 -04:00
for ( int i = 0 ; i < = 512 ; i + + ) { //write all 255's from 0-1024 address
2022-07-04 18:07:36 -04:00
EEPROM . write ( i , 255 ) ;
2022-09-19 20:46:43 -04:00
}
Serial . println ( " Erased EEPROM " ) ;
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
EEPROM . write ( 0 , 76 ) ; EEPROM . write ( 1 , 101 ) ; EEPROM . write ( 2 , 120 ) ; EEPROM . write ( 3 , 122 ) ; EEPROM . write ( 4 , 97 ) ; EEPROM . write ( 5 , 99 ) ; EEPROM . write ( 6 , 104 ) ; //write Lexzach to addresses 0-6
Serial . println ( " Wrote LEXZACH header " ) ;
EEPROM . write ( 7 , 0 ) ; //code-3 default
Serial . println ( " Configured Code-3 " ) ;
EEPROM . write ( 8 , 0 ) ; //key not required by default
Serial . println ( " Disabled key " ) ;
EEPROM . write ( 9 , 1 ) ; //verification is turned on by default
Serial . println ( " Turned on verification " ) ;
EEPROM . write ( 10 , 25 ) ; //default verification time of 2.5 seconds
Serial . println ( " Set verification time of 2.5 seconds " ) ;
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
//system name "ANTIGNEOUS"
EEPROM . write ( 11 , 65 ) ; EEPROM . write ( 12 , 78 ) ; EEPROM . write ( 13 , 84 ) ; EEPROM . write ( 14 , 73 ) ; EEPROM . write ( 15 , 71 ) ; EEPROM . write ( 16 , 78 ) ; EEPROM . write ( 17 , 69 ) ; EEPROM . write ( 18 , 79 ) ; EEPROM . write ( 19 , 85 ) ; EEPROM . write ( 20 , 83 ) ;
Serial . println ( " Wrote system name 'ANTIGNEOUS' " ) ;
for ( int i = 21 ; i < = 26 ; i + + ) { //write all 0's from 21-26 address
EEPROM . write ( i , 32 ) ;
}
Serial . println ( " Wrote 6 blank spaces " ) ;
2022-07-04 19:28:48 -04:00
2022-10-06 22:49:08 -04:00
EEPROM . write ( 27 , 0 ) ; //write keyless silence
2022-09-30 23:02:37 -04:00
Serial . println ( " Disabled keyless silence " ) ;
2022-10-06 22:49:08 -04:00
EEPROM . write ( 28 , 24 ) ; //post restart smoke detector verification time
2022-10-03 23:05:16 -04:00
Serial . println ( " Set smoke detector verification to 120 seconds " ) ;
2022-10-06 22:49:08 -04:00
EEPROM . write ( 29 , 0 ) ; //strobe sync
Serial . println ( " Disable strobe sync by default " ) ;
EEPROM . write ( 30 , 0 ) ; //2 wire
Serial . println ( " Disabled 2 wire alarms by default " ) ;
2022-09-19 20:46:43 -04:00
EEPROM . write ( 50 , EEPROMVersion ) ; //write current version and build
EEPROM . write ( 51 , EEPROMBuild ) ;
Serial . println ( " Wrote EEPROM version and build " ) ;
2022-09-25 13:24:30 -04:00
//EEPROM.write(72,125); //EOL lenience 500 by default (take the value stored and multiply by 4 to get actual value)
//Serial.println("Set EOL lenience to 500");
2022-09-19 20:46:43 -04:00
EEPROM . write ( 73 , 1 ) ; //EOL resistor is enabled by default
Serial . println ( " Enabled EOL resistor " ) ;
EEPROM . write ( 74 , 0 ) ; //pre-alarm disabled by default
Serial . println ( " Disabled pre-alarm " ) ;
2022-10-02 22:28:59 -04:00
EEPROM . write ( 75 , 5 ) ; //pre-alarm first-stage is 1 minute by default
Serial . println ( " Set pre-alarm first stage to 5 minutes " ) ;
EEPROM . write ( 76 , 0 ) ; //smoke detector verification is disable by default
Serial . println ( " Disabled smoke detector verification " ) ;
EEPROM . write ( 77 , 12 ) ; //smoke detector verification is 1 minute by default
Serial . println ( " Set smoke detector verification to 1 minute " ) ;
2022-09-19 20:46:43 -04:00
EEPROM . write ( 78 , 0 ) ; //homescreen is panel name by default
Serial . println ( " Set panel name as homescreen " ) ;
EEPROM . write ( 79 , 1 ) ; //audible silence is enabled by default
Serial . println ( " Enabled audible silence " ) ;
EEPROM . write ( 80 , 0 ) ; //lcd timeout is disabled by default (time in MS found by taking value and multiplying it by 15000)
Serial . println ( " Disabled LCD timeout " ) ;
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
EEPROM . commit ( ) ;
Serial . println ( " Wrote changes to EEPROM " ) ;
2022-07-04 18:07:36 -04:00
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- EEPROM RESET
2022-07-04 18:07:36 -04:00
void setup ( ) {
2023-03-26 21:20:11 -04:00
EEPROM . begin ( 512 ) ; //allocate memory address 0-1024 for EEPROM
Serial . println ( " Configured EEPROM for addresses 0-512 " ) ;
2022-07-04 18:07:36 -04:00
Serial . begin ( 115200 ) ; //begin serial
2023-03-26 21:20:11 -04:00
Serial . println ( " Lexzach's Low-Cost FACP v1.5 " ) ;
2022-07-04 18:07:36 -04:00
Serial . println ( " Booting... " ) ;
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETUP PINS
2022-10-03 23:05:16 -04:00
pinMode ( resetButtonPin , INPUT ) ; //reset switch
2022-09-21 21:57:02 -04:00
pinMode ( hornRelay , OUTPUT ) ; //horn
pinMode ( strobeRelay , OUTPUT ) ; //strobe
pinMode ( smokeDetectorRelay , OUTPUT ) ; //smoke relay
pinMode ( readyLed , OUTPUT ) ; //ready LED
pinMode ( silenceLed , OUTPUT ) ; //silence LED
pinMode ( alarmLed , OUTPUT ) ; //alarm LED
2022-07-04 19:28:48 -04:00
pinMode ( keySwitchPin , INPUT ) ; //key switch
2022-09-19 20:46:43 -04:00
pinMode ( silenceButtonPin , INPUT ) ; //silence switch
pinMode ( drillButtonPin , INPUT ) ; //drill switch
2022-10-15 13:52:08 -04:00
if ( digitalRead ( resetButtonPin ) and not digitalRead ( silenceButtonPin ) and not digitalRead ( drillButtonPin ) ) {
failsafeMode = true ;
}
2022-07-04 18:07:36 -04:00
pinMode ( zone1Pin , INPUT ) ; //zone 1
pinMode ( zone2Pin , INPUT ) ; //zone 2
2022-07-04 19:28:48 -04:00
pinMode ( buzzerPin , OUTPUT ) ; //buzzer
2023-03-25 23:51:21 -04:00
if ( not invertRelay ) {
digitalWrite ( hornRelay , HIGH ) ; //horn
digitalWrite ( strobeRelay , HIGH ) ; //strobe
digitalWrite ( smokeDetectorRelay , HIGH ) ; //smoke relay
} else {
digitalWrite ( hornRelay , LOW ) ; //horn
digitalWrite ( strobeRelay , LOW ) ; //strobe
digitalWrite ( smokeDetectorRelay , LOW ) ; //smoke relay
}
2022-07-04 18:07:36 -04:00
2022-07-04 19:28:48 -04:00
pinMode ( sclPin , OUTPUT ) ; //scl
pinMode ( sdaPin , OUTPUT ) ; //sda
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETUP PINS
2022-07-04 18:07:36 -04:00
Serial . println ( " Initializing LCD... " ) ;
lcd . init ( ) ; //initialize LCD
2022-09-25 23:54:40 -04:00
lcd . createChar ( 0 , lock ) ; //create the lock character
2022-09-27 22:31:38 -04:00
lcd . createChar ( 1 , check ) ; //create the lock character
2022-09-30 19:07:30 -04:00
lcd . createChar ( 2 , cross ) ; //create the lock character
2022-09-27 22:31:38 -04:00
2022-09-30 19:07:30 -04:00
2022-07-04 18:07:36 -04:00
lcd . backlight ( ) ;
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- EEPROM RESET BUTTONS
2022-10-15 14:32:14 -04:00
if ( digitalRead ( resetButtonPin ) and digitalRead ( silenceButtonPin ) and digitalRead ( drillButtonPin ) and not failsafeMode ) { //reset EEPROM if all buttons are pressed
2022-09-19 20:46:43 -04:00
for ( int i = 5 ; i ! = 0 ; i - - ) {
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
2022-09-19 21:52:52 -04:00
lcd . print ( " TO FACTORY RESET " ) ;
2022-09-19 20:46:43 -04:00
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( ( String ) " HOLD BUTTONS - " + i ) ;
delay ( 1000 ) ;
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( resetButtonPin ) and digitalRead ( silenceButtonPin ) and digitalRead ( drillButtonPin ) ) {
2022-09-19 20:46:43 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " RESETTING TO " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " FACTORY SETTINGS " ) ;
resetEEPROM ( ) ;
delay ( 4000 ) ;
ESP . restart ( ) ;
} else {
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
2022-09-19 21:52:52 -04:00
lcd . print ( " FACTORY RESET " ) ;
2022-09-19 20:46:43 -04:00
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " CANCELLED " ) ;
delay ( 3000 ) ;
}
}
//----------------------------------------------------------------------------- EEPROM RESET BUTTONS
2022-10-03 23:05:16 -04:00
// if (digitalRead(silenceButtonPin)==HIGH){ //debug code
// debug = true;
// }
2022-09-25 13:24:30 -04:00
2022-07-04 18:07:36 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 4 , 0 ) ;
2022-09-19 21:52:52 -04:00
lcd . print ( " BOOTING... " ) ;
lcd . setCursor ( 0 , 1 ) ;
2022-09-30 23:02:37 -04:00
lcd . print ( " IO " ) ;
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
Serial . println ( " Configured all pins " ) ;
2022-07-04 18:07:36 -04:00
2022-09-19 20:46:43 -04:00
//EEPROM.write(0,255); //-------------------------------------------------------UNCOMMENT TO INVALIDATE EEPROM AND REFLASH IT AFTER EVERY RESTART
//EEPROM.commit();
2022-07-04 18:07:36 -04:00
Serial . println ( " Verifying EEPROM configuration integrity... " ) ;
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- EEPROM INTEGRETY
2022-10-15 14:32:14 -04:00
if ( ( EEPROM . read ( 0 ) ! = 76 or EEPROM . read ( 6 ) ! = 104 or EEPROM . read ( 7 ) > 5 or EEPROM . read ( 8 ) > 1 or EEPROM . read ( 50 ) ! = EEPROMVersion or EEPROM . read ( 51 ) ! = EEPROMBuild ) and not failsafeMode ) { //completely skip eeprom verification if booting into failsafe
2022-09-19 20:46:43 -04:00
Serial . println ( " EEPROM verification failed. " ) ;
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
2022-10-03 23:05:16 -04:00
if ( EEPROM . read ( 50 ) ! = EEPROMVersion or EEPROM . read ( 51 ) ! = EEPROMBuild ) { //display error 2 if the firmware is different
2022-09-30 23:02:37 -04:00
lcd . print ( " ERROR 2 " ) ;
} else {
lcd . print ( " ERROR 1 " ) ;
}
2022-09-19 20:46:43 -04:00
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " check manual " ) ;
2022-10-15 13:52:08 -04:00
while ( not digitalRead ( resetButtonPin ) and not digitalRead ( drillButtonPin ) ) { //wait until button is pressed
2022-09-19 20:46:43 -04:00
delay ( 1 ) ;
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( resetButtonPin ) ) {
2022-10-03 23:05:16 -04:00
failsafeMode = true ; // ----- ENTER FAILSAFE MODE
2022-10-15 13:52:08 -04:00
} else if ( digitalRead ( drillButtonPin ) ) {
2022-09-19 20:46:43 -04:00
resetEEPROM ( ) ;
}
2022-07-04 18:07:36 -04:00
} else {
2022-09-19 21:52:52 -04:00
Serial . println ( " EEPROM integrity verified " ) ;
2022-07-04 18:07:36 -04:00
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- EEPROM INTEGRETY
2022-10-15 13:52:08 -04:00
if ( not failsafeMode ) { //continue loading if failsafe mode is not enabled
2022-10-03 23:05:16 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 4 , 0 ) ;
lcd . print ( " BOOTING... " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " IO-SLFTST " ) ;
Serial . println ( " Current EEPROM dump: " ) ; //dump EEPROM into serial monitor
for ( int i = 0 ; i < = 1024 ; i + + ) {
Serial . print ( i ) ;
Serial . print ( " : " ) ;
Serial . print ( EEPROM . read ( i ) ) ;
Serial . print ( " " ) ;
}
Serial . println ( ) ;
2022-07-04 18:07:36 -04:00
2022-10-03 23:05:16 -04:00
//CONFIG LOADING ROUTINE
Serial . println ( " Loading config from EEPROM... " ) ;
codeWheel = EEPROM . read ( 7 ) ; //codeWheel setting address
2022-10-15 14:32:14 -04:00
//----------------------------- Panel security variables
keyRequired = EEPROM . read ( 8 ) = = 1 ? true : false ;
keyRequiredVisual = keyRequired ? true : false ;
//----------------------------- Panel security variables
verificationEnabled = EEPROM . read ( 9 ) = = 1 ? true : false ;
eolResistor = EEPROM . read ( 73 ) = = 1 ? true : false ;
preAlarm = EEPROM . read ( 74 ) = = 1 ? true : false ;
smokeDetectorVerification = EEPROM . read ( 76 ) = = 1 ? true : false ;
audibleSilence = EEPROM . read ( 79 ) = = 1 ? true : false ;
keylessSilence = EEPROM . read ( 27 ) = = 1 ? true : false ;
useTwoWire = EEPROM . read ( 30 ) = = 1 ? true : false ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = EEPROM . read ( 77 ) * 5000 ;
smokeDetectorPostRestartVerificationTime = EEPROM . read ( 28 ) * 5000 ;
firstStageTime = EEPROM . read ( 75 ) * 60000 ;
verificationTime = EEPROM . read ( 10 ) * 100 ;
//resistorLenience = EEPROM.read(72)*4; DEPRECATED
panelHomescreen = EEPROM . read ( 78 ) ;
lcdTimeout = EEPROM . read ( 80 ) * 15000 ;
2022-10-06 22:49:08 -04:00
strobeSync = EEPROM . read ( 29 ) ;
2022-10-03 23:05:16 -04:00
int x = 0 ;
for ( int i = 11 ; i < = 26 ; i + + ) { //read panel name
if ( EEPROM . read ( i ) ! = 0 ) {
panelName = panelName + ( char ) EEPROM . read ( i ) ;
panelNameList [ x ] = EEPROM . read ( i ) ;
x + + ;
}
}
lcd . clear ( ) ;
lcd . setCursor ( 4 , 0 ) ;
lcd . print ( " BOOTING... " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " IO-SLFTST-CONFIG " ) ;
delay ( 100 ) ;
Serial . println ( " Config loaded " ) ;
digitalWrite ( readyLed , HIGH ) ; //power on ready LED on startup
updateLockStatus = true ;
2022-10-15 14:32:14 -04:00
panelUnlocked = ( digitalRead ( keySwitchPin ) and keyRequired ) ? true : false ; //check the key status on startup
2022-10-03 23:05:16 -04:00
digitalWrite ( silenceLed , LOW ) ;
digitalWrite ( alarmLed , LOW ) ;
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( smokeDetectorRelay , HIGH ) ; //turn on smoke relay
} else {
digitalWrite ( smokeDetectorRelay , LOW ) ; //turn on smoke relay
}
2022-10-03 23:05:16 -04:00
Serial . println ( " -=- STARTUP COMPLETE -=- " ) ;
2022-10-01 17:22:12 -04:00
} else {
2022-10-03 23:05:16 -04:00
Serial . println ( " -=- ENTERING FAILSAFE MODE -=- " ) ;
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " ENTERING " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " FAILSAFE... " ) ;
delay ( 3000 ) ;
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " FAILSAFE MODE " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " SYSTEM NORMAL " ) ;
digitalWrite ( readyLed , HIGH ) ;
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( smokeDetectorRelay , HIGH ) ; //turn on smoke relay
} else {
digitalWrite ( smokeDetectorRelay , LOW ) ; //turn on smoke relay
}
2022-10-01 17:22:12 -04:00
}
2022-09-27 22:31:38 -04:00
lastPulse = millis ( ) ; //start last pulse
2022-07-04 18:07:36 -04:00
}
2022-09-29 17:39:07 -04:00
//---------------------------------------------------------------------------------------- functions for turning certain things on and off
2022-07-04 18:07:36 -04:00
void tone ( ) {
ledcSetup ( 0 , 5000 , 8 ) ; // setup beeper
ledcAttachPin ( buzzerPin , 0 ) ; // attach beeper
ledcWriteTone ( 0 , 1500 ) ; // play tone
}
void noTone ( ) {
ledcSetup ( 0 , 5000 , 8 ) ; // setup beeper
ledcAttachPin ( buzzerPin , 0 ) ; // attach beeper
ledcWriteTone ( 0 , 0 ) ; // stop tone
}
2022-09-29 17:39:07 -04:00
void hornOn ( bool on ) {
2022-10-15 13:52:08 -04:00
if ( on ) {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( hornRelay , HIGH ) ; //turn on horn relay
} else {
digitalWrite ( hornRelay , LOW ) ; //turn on horn relay
}
2022-09-29 17:39:07 -04:00
} else {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( hornRelay , LOW ) ; //turn on horn relay
} else {
digitalWrite ( hornRelay , HIGH ) ; //turn on horn relay
}
2022-09-29 17:39:07 -04:00
}
}
void strobeOn ( bool on ) {
2022-10-15 13:52:08 -04:00
if ( on ) {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( strobeRelay , HIGH ) ; //turn on strobe relay without strobe sync
} else {
digitalWrite ( strobeRelay , LOW ) ; //turn on strobe relay without strobe sync
}
2022-09-29 17:39:07 -04:00
} else {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( strobeRelay , LOW ) ; //turn on strobe relay without strobe sync
} else {
digitalWrite ( strobeRelay , HIGH ) ; //turn on strobe relay without strobe sync
}
2022-09-29 17:39:07 -04:00
}
}
2022-10-06 22:49:08 -04:00
2022-09-29 17:39:07 -04:00
void smokeDetectorOn ( bool on ) {
2022-10-15 13:52:08 -04:00
if ( on ) {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( smokeDetectorRelay , HIGH ) ; //turn on smoke relay
} else {
digitalWrite ( smokeDetectorRelay , LOW ) ; //turn on smoke relay
}
2022-09-29 17:39:07 -04:00
} else {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( smokeDetectorRelay , LOW ) ; //turn on smoke relay
} else {
digitalWrite ( smokeDetectorRelay , HIGH ) ; //turn on smoke relay
}
2022-09-29 17:39:07 -04:00
}
}
//---------------------------------------------------------------------------------------- functions for turning certain things on and off
2022-07-04 18:07:36 -04:00
void activateNAC ( ) {
horn = true ;
strobe = true ;
fullAlarm = true ;
silenced = false ;
2022-10-08 22:18:30 -04:00
inConfigMenu = false ;
2022-10-02 22:28:59 -04:00
codeWheelTimer = 0 ;
2022-12-19 23:07:12 -05:00
strobeSyncTimer = 0 ;
2022-10-15 14:32:14 -04:00
secondStage = ( zoneAlarm = = 4 or not preAlarm ) ? true : false ; //entirely skip first stage if it is a drill or if prealarm is turned off
2022-07-04 18:07:36 -04:00
tone ( ) ;
2022-10-01 17:22:12 -04:00
digitalWrite ( readyLed , HIGH ) ;
2022-09-21 21:57:02 -04:00
digitalWrite ( alarmLed , HIGH ) ;
digitalWrite ( silenceLed , LOW ) ;
2022-07-04 18:07:36 -04:00
}
void checkKey ( ) {
2022-10-15 13:52:08 -04:00
if ( digitalRead ( keySwitchPin ) ) {
if ( not panelUnlocked and keyRequired ) {
2022-10-08 22:18:30 -04:00
panelUnlocked = true ;
2022-10-01 17:22:12 -04:00
updateLockStatus = true ;
2022-09-25 23:54:40 -04:00
}
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
if ( panelUnlocked and keyRequired ) {
2022-10-08 22:18:30 -04:00
panelUnlocked = false ;
2022-09-25 23:54:40 -04:00
drillPressed = false ;
silencePressed = false ; //make sure all buttons are registered as depressed after key is removed
resetPressed = false ;
drillStillPressed = false ;
resetStillPressed = false ;
silenceStillPressed = false ;
2022-10-08 22:18:30 -04:00
drillTimer = 0 ;
2022-10-01 17:22:12 -04:00
updateLockStatus = true ;
2022-09-25 23:54:40 -04:00
}
2022-07-04 18:07:36 -04:00
}
}
2022-09-30 19:07:30 -04:00
//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!]
2022-07-04 18:07:36 -04:00
void checkDevices ( ) {
2022-10-15 13:52:08 -04:00
if ( not walkTest ) {
if ( not runVerification and not fullAlarm and ( analogRead ( zone1Pin ) = = 0 or analogRead ( zone2Pin ) = = 0 ) ) { //reading a single zero flags as a possible alarm
2022-10-08 22:18:30 -04:00
runVerification = true ;
2022-07-04 18:07:36 -04:00
}
2022-10-15 13:52:08 -04:00
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 not verificationEnabled ) { //execute the following code if verification surpasses the configured verification time OR verification is disabled
2022-10-03 23:05:16 -04:00
if ( analogRead ( zone1Pin ) = = 0 or analogRead ( zone2Pin ) = = 0 ) { //check once again if any zeros are read
2022-10-15 13:52:08 -04:00
if ( not smokeDetectorVerification or smokeDetectorCurrentlyInVerification ) { //if smoke detector verification is disabled, or a smoke detector has tripped *after* verification, activate NACs
2022-10-03 23:05:16 -04:00
if ( analogRead ( zone1Pin ) = = 0 and analogRead ( zone2Pin ) = = 0 ) { //read the pins once more to check which zone is in alarm
2022-10-02 22:28:59 -04:00
zoneAlarm = 3 ; //both
} else if ( analogRead ( zone2Pin ) = = 0 ) {
zoneAlarm = 2 ; //z2
} else {
zoneAlarm = 1 ; //z1
}
activateNAC ( ) ;
2022-10-08 22:18:30 -04:00
runVerification = false ; //dismiss the possible alarm after activating the NACs
verificationTimer = 0 ;
2022-10-15 13:52:08 -04:00
} else if ( smokeDetectorVerification and not smokeDetectorCurrentlyInVerification ) { //if smoke detector verifcaion is turned on, run this instead
2022-10-03 23:05:16 -04:00
smokeDetectorOn ( false ) ; //turn off the smoke detector relay
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
2022-10-02 22:28:59 -04:00
if ( analogRead ( zone1Pin ) = = 0 and analogRead ( zone2Pin ) = = 0 ) {
zoneAlarm = 3 ; //both
} else if ( analogRead ( zone2Pin ) = = 0 ) {
zoneAlarm = 2 ; //z2
} else {
zoneAlarm = 1 ; //z1
}
activateNAC ( ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorOn ( true ) ; //re-enable the smoke detector relay after determining that a pull station was pulled.
2022-10-08 22:18:30 -04:00
runVerification = false ;
verificationTimer = 0 ;
2022-10-03 23:05:16 -04:00
} else { //if the signal *does not* persists after disabling the smoke detector relay, it was a smoke detector, run verification.
2022-10-02 22:28:59 -04:00
smokeDetectorPostRestartTimer = 0 ;
2022-10-03 23:05:16 -04:00
smokeDetectorCurrentlyInVerification = true ; //tell the smokeDetector() function to run code
smokeDetectorTimer = 0 ; //reset the smoke detector timer
currentScreen = - 1 ; //update the screen to allow the displaying of smoke detector verification
digitalWrite ( alarmLed , HIGH ) ; //LED indicator
2022-10-08 22:18:30 -04:00
runVerification = false ;
verificationTimer = 0 ;
2022-10-02 22:28:59 -04:00
}
2022-09-29 17:39:07 -04:00
}
2022-10-03 23:05:16 -04:00
} else { //if no zeros are read after verification, dismiss possible alarm
2022-10-08 22:18:30 -04:00
runVerification = false ;
verificationTimer = 0 ;
2022-07-04 18:07:36 -04:00
}
} else {
2022-10-08 22:18:30 -04:00
verificationTimer + + ;
2022-07-04 18:07:36 -04:00
}
}
2022-10-15 13:52:08 -04:00
} else if ( walkTest ) {
2022-09-29 17:39:07 -04:00
if ( analogRead ( zone1Pin ) = = 0 or analogRead ( zone2Pin ) = = 0 ) { // or analogRead(zone2Pin) == 0){
if ( analogRead ( zone1Pin ) = = 0 ) {
zone1Count + + ;
smokeDetectorOn ( false ) ;
strobeOn ( true ) ;
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
digitalWrite ( alarmLed , HIGH ) ;
2022-10-15 13:52:08 -04:00
if ( not silentWalkTest ) {
2022-09-30 19:07:30 -04:00
hornOn ( true ) ;
2022-10-15 13:52:08 -04:00
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
hornOn ( false ) ;
2022-10-15 13:52:08 -04:00
} else {
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
}
2022-09-29 17:39:07 -04:00
delay ( 3000 ) ;
2022-09-30 19:07:30 -04:00
digitalWrite ( alarmLed , LOW ) ;
2022-09-29 17:39:07 -04:00
strobeOn ( false ) ;
2022-10-15 13:52:08 -04:00
delay ( 4000 ) ;
2022-09-29 17:39:07 -04:00
smokeDetectorOn ( true ) ;
} else if ( analogRead ( zone2Pin ) = = 0 ) {
zone2Count + + ;
smokeDetectorOn ( false ) ;
strobeOn ( true ) ;
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
digitalWrite ( alarmLed , HIGH ) ;
2022-10-15 13:52:08 -04:00
if ( not silentWalkTest ) {
2022-09-30 19:07:30 -04:00
hornOn ( true ) ;
2022-10-15 13:52:08 -04:00
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
hornOn ( false ) ;
2022-10-15 13:52:08 -04:00
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
hornOn ( true ) ;
2022-10-15 13:52:08 -04:00
delay ( 500 ) ;
2022-09-30 19:07:30 -04:00
hornOn ( false ) ;
2022-10-15 13:52:08 -04:00
} else {
delay ( 1500 ) ;
2022-09-30 19:07:30 -04:00
}
2022-09-29 17:39:07 -04:00
delay ( 3000 ) ;
2022-10-15 13:52:08 -04:00
digitalWrite ( alarmLed , LOW ) ;
2022-09-29 17:39:07 -04:00
strobeOn ( false ) ;
2022-10-15 13:52:08 -04:00
delay ( 4000 ) ;
2022-09-29 17:39:07 -04:00
smokeDetectorOn ( true ) ;
2022-07-04 18:07:36 -04:00
}
currentScreen = - 1 ;
}
}
2022-10-15 13:52:08 -04:00
if ( ( analogRead ( zone1Pin ) = = 4095 or analogRead ( zone2Pin ) = = 4095 ) and eolResistor ) {
2022-10-03 23:05:16 -04:00
if ( troubleTimer > = 1000 ) {
2022-09-30 19:07:30 -04:00
trouble = true ;
troubleType = 1 ;
2022-10-01 17:22:12 -04:00
if ( analogRead ( zone1Pin ) = = 4095 and analogRead ( zone2Pin ) = = 4095 ) {
zoneTrouble = 3 ;
} else if ( analogRead ( zone1Pin ) = = 4095 ) {
zoneTrouble = 1 ;
} else {
zoneTrouble = 2 ;
}
2022-09-30 19:07:30 -04:00
} else {
troubleTimer + + ;
}
2022-07-04 18:07:36 -04:00
} else {
troubleTimer = 0 ;
}
}
2022-09-30 19:07:30 -04:00
//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!]
2022-09-19 20:46:43 -04:00
2022-07-04 18:07:36 -04:00
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- TROUBLE RESPONSE
2022-07-04 18:07:36 -04:00
void troubleCheck ( ) {
2022-10-08 22:18:30 -04:00
if ( trouble and not fullAlarm and not walkTest ) {
2022-09-27 22:31:38 -04:00
if ( troubleLedTimer > = 200 ) {
2022-10-08 22:18:30 -04:00
if ( digitalRead ( readyLed ) ) {
2022-09-27 22:31:38 -04:00
digitalWrite ( readyLed , LOW ) ;
2022-10-08 22:18:30 -04:00
if ( not troubleAcked ) {
2022-09-27 22:31:38 -04:00
noTone ( ) ;
}
} else {
digitalWrite ( readyLed , HIGH ) ;
2022-10-08 22:18:30 -04:00
if ( not troubleAcked ) {
2022-09-27 22:31:38 -04:00
tone ( ) ;
}
2022-07-04 18:07:36 -04:00
}
2022-09-27 22:31:38 -04:00
troubleLedTimer = 0 ;
} else {
troubleLedTimer + + ;
2022-07-04 18:07:36 -04:00
}
} else {
troubleLedTimer = 0 ;
2022-10-01 17:22:12 -04:00
zoneTrouble = 0 ;
2022-07-04 18:07:36 -04:00
}
}
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- TROUBLE RESPONSE
2022-07-04 18:07:36 -04:00
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- RESET CODE
2022-09-19 20:46:43 -04:00
void reboot ( ) {
lcd . clear ( ) ;
2022-07-04 18:07:36 -04:00
lcd . setCursor ( 2 , 0 ) ;
lcd . print ( " Resetting... " ) ;
tone ( ) ;
2022-09-21 21:57:02 -04:00
digitalWrite ( readyLed , HIGH ) ; //ready LED
digitalWrite ( silenceLed , HIGH ) ; //silence LED
digitalWrite ( alarmLed , HIGH ) ; //alarm LED
2022-09-29 17:39:07 -04:00
hornOn ( false ) ; //horn
strobeOn ( false ) ; //strobe
smokeDetectorOn ( false ) ; //smoke relay
2022-09-19 21:52:52 -04:00
lcd . backlight ( ) ;
2022-07-04 18:07:36 -04:00
delay ( 2500 ) ;
noTone ( ) ;
2022-09-21 21:57:02 -04:00
digitalWrite ( readyLed , LOW ) ; //ready LED
digitalWrite ( silenceLed , LOW ) ; //silence LED
digitalWrite ( alarmLed , LOW ) ; //alarm LED
2022-07-04 18:07:36 -04:00
ESP . restart ( ) ;
2022-09-19 20:46:43 -04:00
}
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- RESET CODE
2022-09-19 20:46:43 -04:00
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- BUTTON CHECK
2022-09-19 20:46:43 -04:00
void checkButtons ( ) {
2022-10-15 13:52:08 -04:00
if ( digitalRead ( resetButtonPin ) ) { //-----------------------------------------------------------RESET BUTTON
2022-09-19 20:46:43 -04:00
reboot ( ) ;
2022-07-04 18:07:36 -04:00
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( silenceButtonPin ) ) { //---------------------------------------------------------SILENCE BUTTON
2022-10-08 22:18:30 -04:00
if ( horn ) { //if horns are not silenced, silence the horns
2022-09-21 21:57:02 -04:00
digitalWrite ( silenceLed , HIGH ) ;
digitalWrite ( alarmLed , LOW ) ;
2022-09-29 17:39:07 -04:00
digitalWrite ( readyLed , LOW ) ;
2022-07-04 18:07:36 -04:00
horn = false ;
2022-10-08 22:18:30 -04:00
if ( not audibleSilence ) {
2022-07-04 18:07:36 -04:00
strobe = false ;
}
silenced = true ;
noTone ( ) ;
2022-10-08 22:18:30 -04:00
} else if ( not fullAlarm and trouble and not silencePressed and not troubleAcked ) {
troubleAcked = true ;
2022-07-04 18:07:36 -04:00
noTone ( ) ;
2022-10-08 22:18:30 -04:00
} else if ( not fullAlarm and not silencePressed and not inConfigMenu ) {
inConfigMenu = true ;
2022-07-04 18:07:36 -04:00
resetStillPressed = true ; //make sure the menu doesn't close out as soon as someone opens it
silenceStillPressed = true ;
drillStillPressed = true ;
char * main [ ] = { " Testing " , " Settings " } ; //menu 0
configTop = ( String ) main [ 0 ] ;
configBottom = ( String ) main [ 1 ] ;
configPage = 0 ;
cursorPosition = 0 ;
currentConfigBottom = " " ;
currentConfigTop = " " ;
}
silencePressed = true ;
} else {
silencePressed = false ;
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( drillButtonPin ) and not horn and not silenced and not fullAlarm ) { //------------------------------------------DRILL BUTTON
2022-10-08 22:18:30 -04:00
if ( drillTimer > = 237 ) {
2022-09-29 17:39:07 -04:00
zoneAlarm = 4 ;
2022-07-04 18:07:36 -04:00
activateNAC ( ) ;
} else {
2022-10-08 22:18:30 -04:00
drillTimer + + ;
2022-07-04 18:07:36 -04:00
}
drillPressed = true ;
} else {
2022-10-08 22:18:30 -04:00
drillTimer = 0 ;
2022-07-04 18:07:36 -04:00
drillPressed = false ;
}
2022-10-15 14:32:14 -04:00
if ( digitalRead ( drillButtonPin ) and fullAlarm and not secondStage ) {
2022-10-02 22:28:59 -04:00
secondStage = true ;
currentScreen = - 1 ;
}
2022-07-04 18:07:36 -04:00
}
2022-09-27 22:31:38 -04:00
//----------------------------------------------------------------------------- BUTTON CHECK
2022-07-04 18:07:36 -04:00
2022-09-19 21:52:52 -04:00
//----------------------------------------------------------------------------- NAC ACTIVATION
2022-07-04 18:07:36 -04:00
void alarm ( ) {
2022-10-15 13:52:08 -04:00
if ( strobe ) {
2023-01-01 11:01:10 -05:00
if ( strobeSync ! = 1 and strobeSync ! = 2 ) { //add more strobesyncs in the future
2022-10-06 22:49:08 -04:00
strobeOn ( true ) ;
} else if ( strobeSync = = 1 or strobeSync = = 2 ) {
2022-10-08 22:18:30 -04:00
if ( strobeSyncTimer > = 1000 ) {
strobeSyncTimer = 0 ;
} else if ( strobeSyncTimer > = 975 ) {
2022-10-06 22:49:08 -04:00
strobeOn ( false ) ;
2022-10-08 22:18:30 -04:00
} else if ( strobeSyncTimer < = 10 ) {
2022-10-06 22:49:08 -04:00
strobeOn ( true ) ;
}
2022-10-08 22:18:30 -04:00
strobeSyncTimer + + ;
2022-10-06 22:49:08 -04:00
}
2022-07-04 18:07:36 -04:00
} else {
2022-09-29 17:39:07 -04:00
strobeOn ( false ) ;
2022-10-08 22:18:30 -04:00
strobeSyncTimer = 0 ;
2022-07-04 18:07:36 -04:00
}
2022-10-08 22:18:30 -04:00
if ( horn and not useTwoWire ) {
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
2022-10-02 22:28:59 -04:00
if ( codeWheel = = 0 ) {
2022-07-04 18:07:36 -04:00
2022-10-02 22:28:59 -04:00
if ( codeWheelTimer = = 0 ) { //---------- temporal code 3
hornOn ( true ) ;
} else if ( codeWheelTimer = = 500 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 1000 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 1500 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 2000 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 2500 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 4000 ) {
codeWheelTimer = - 1 ;
}
2022-07-04 18:07:36 -04:00
2022-10-02 22:28:59 -04:00
} else if ( codeWheel = = 1 ) {
2022-07-04 18:07:36 -04:00
2022-10-02 22:28:59 -04:00
if ( codeWheelTimer = = 0 ) { //---------- marchtime
hornOn ( true ) ;
} else if ( codeWheelTimer = = 250 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 500 ) {
codeWheelTimer = - 1 ;
}
} else if ( codeWheel = = 2 ) { //---------- 4-4
if ( codeWheelTimer = = 0 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 300 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 600 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 900 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 1200 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 1500 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 1800 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 2100 ) {
hornOn ( false ) ;
2022-07-04 18:07:36 -04:00
2022-10-02 22:28:59 -04:00
} else if ( codeWheelTimer = = 2850 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 3150 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 3450 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 3750 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 4050 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 4350 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer = = 4650 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 4950 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 14950 ) {
codeWheelTimer = - 1 ;
}
2022-07-04 18:07:36 -04:00
2022-10-02 22:28:59 -04:00
} else if ( codeWheel = = 3 ) { //---------- continuous
2022-09-29 17:39:07 -04:00
hornOn ( true ) ;
2022-10-02 22:28:59 -04:00
} else if ( codeWheel = = 5 ) {
if ( codeWheelTimer = = 0 ) { //---------- marchtime slower
hornOn ( true ) ;
} else if ( codeWheelTimer = = 500 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 1000 ) {
codeWheelTimer = - 1 ;
}
} else if ( codeWheel = = 4 ) {
if ( codeWheelTimer = = 0 ) { //---------- california code
hornOn ( true ) ;
} else if ( codeWheelTimer = = 10000 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 15000 ) {
codeWheelTimer = - 1 ;
}
2022-07-04 18:07:36 -04:00
}
2022-10-02 22:28:59 -04:00
codeWheelTimer + + ;
2022-10-08 22:18:30 -04:00
} else if ( preAlarm and not secondStage ) {
2022-10-02 22:28:59 -04:00
if ( codeWheelTimer = = 0 ) {
2022-09-29 17:39:07 -04:00
hornOn ( true ) ;
2022-10-02 22:28:59 -04:00
} else if ( codeWheelTimer = = 75 ) {
2022-09-29 17:39:07 -04:00
hornOn ( false ) ;
2022-10-02 22:28:59 -04:00
} else if ( codeWheelTimer > = 5075 ) {
2022-07-04 18:07:36 -04:00
codeWheelTimer = - 1 ;
}
2022-10-02 22:28:59 -04:00
2022-10-06 22:49:08 -04:00
codeWheelTimer + + ;
firstStageTimer + + ;
if ( firstStageTimer > = firstStageTime ) {
codeWheelTimer = 0 ;
secondStage = true ;
currentScreen = - 1 ;
}
}
2022-10-08 22:18:30 -04:00
} else if ( useTwoWire ) { //-------------------------------- DO MORE TESTING WITH THIS!!!!
if ( horn and ( not preAlarm or secondStage ) ) {
2022-10-06 22:49:08 -04:00
if ( twoWireTimer > = 1000 ) {
twoWireTimer = 0 ;
} else if ( twoWireTimer > = 975 ) {
hornOn ( false ) ;
} else if ( twoWireTimer < = 10 ) {
hornOn ( true ) ;
}
twoWireTimer + + ;
2022-10-08 22:18:30 -04:00
} else if ( not horn and silenced and audibleSilence ) {
2022-10-06 22:49:08 -04:00
if ( twoWireTimer > = 1000 ) {
twoWireTimer = 0 ;
} else if ( twoWireTimer > = 965 ) {
hornOn ( false ) ;
} else if ( twoWireTimer < = 10 ) {
hornOn ( true ) ;
}
twoWireTimer + + ;
2022-10-08 22:18:30 -04:00
} else if ( horn and preAlarm and not secondStage ) {
2022-10-06 22:49:08 -04:00
if ( codeWheelTimer = = 0 ) {
hornOn ( true ) ;
} else if ( codeWheelTimer = = 75 ) {
hornOn ( false ) ;
} else if ( codeWheelTimer > = 5075 ) {
codeWheelTimer = - 1 ;
}
2022-10-02 22:28:59 -04:00
codeWheelTimer + + ;
firstStageTimer + + ;
if ( firstStageTimer > = firstStageTime ) {
codeWheelTimer = 0 ;
secondStage = true ;
currentScreen = - 1 ;
}
2022-07-04 18:07:36 -04:00
}
2022-09-29 17:39:07 -04:00
} else {
hornOn ( false ) ;
codeWheelTimer = 0 ;
2022-10-06 22:49:08 -04:00
twoWireTimer = 0 ;
2022-09-29 17:39:07 -04:00
}
2022-10-08 22:18:30 -04:00
if ( fullAlarm ) {
2022-07-04 18:07:36 -04:00
alarmLedTimer + + ;
if ( alarmLedTimer > = 750 ) {
2022-10-08 22:18:30 -04:00
if ( not digitalRead ( alarmLed ) ) {
if ( silenced ) {
2022-09-29 17:39:07 -04:00
tone ( ) ;
}
2022-09-21 21:57:02 -04:00
digitalWrite ( alarmLed , HIGH ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-08 22:18:30 -04:00
if ( silenced ) {
2022-09-29 17:39:07 -04:00
noTone ( ) ;
}
2022-09-21 21:57:02 -04:00
digitalWrite ( alarmLed , LOW ) ;
2022-07-04 18:07:36 -04:00
}
2022-09-29 17:39:07 -04:00
alarmLedTimer = 0 ;
2022-07-04 18:07:36 -04:00
}
}
}
2022-09-19 21:52:52 -04:00
//----------------------------------------------------------------------------- NAC ACTIVATION
2022-07-04 18:07:36 -04:00
void lcdUpdate ( ) {
2022-10-08 22:18:30 -04:00
if ( not trouble and not fullAlarm and not walkTest and currentScreen ! = 0 and drillTimer = = 0 ) {
2022-10-02 22:28:59 -04:00
lcd . noAutoscroll ( ) ;
lcd . clear ( ) ;
lcd . setCursor ( 2 , 0 ) ;
2022-10-08 22:18:30 -04:00
if ( smokeDetectorCurrentlyInVerification ) {
2022-10-02 22:28:59 -04:00
lcd . print ( " Smoke Verif. " ) ;
} else {
2022-10-01 17:22:12 -04:00
lcd . print ( " System Normal " ) ;
2022-10-02 22:28:59 -04:00
}
lcd . setCursor ( 0 , 1 ) ;
if ( panelHomescreen = = 0 ) {
lcd . print ( panelName ) ;
} else if ( panelHomescreen = = 1 ) {
lcd . print ( analogRead ( zone1Pin ) ) ;
}
currentScreen = 0 ;
updateLockStatus = true ;
2022-10-08 22:18:30 -04:00
} else if ( fullAlarm and not silenced and currentScreen ! = 3 ) {
2022-07-04 18:07:36 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 1 , 0 ) ;
2022-10-08 22:18:30 -04:00
if ( secondStage ) { //print pre-alarm if it is first stage
2022-10-02 22:28:59 -04:00
lcd . print ( " * FIRE ALARM * " ) ;
} else {
lcd . print ( " * PRE ALARM * " ) ;
}
2022-09-29 17:39:07 -04:00
lcd . setCursor ( 0 , 1 ) ;
if ( zoneAlarm = = 1 ) {
lcd . print ( " Zone 1 " ) ;
} else if ( zoneAlarm = = 2 ) {
lcd . print ( " Zone 2 " ) ;
} else if ( zoneAlarm = = 3 ) {
lcd . print ( " Zone 1 & Zone 2 " ) ;
} else if ( zoneAlarm = = 4 ) {
lcd . print ( " Fire Drill " ) ;
}
2022-07-04 18:07:36 -04:00
currentScreen = 3 ;
2022-10-02 22:28:59 -04:00
updateLockStatus = true ;
2022-10-08 22:18:30 -04:00
} else if ( silenced and currentScreen ! = 4 ) {
2022-07-04 18:07:36 -04:00
lcd . clear ( ) ;
2022-10-01 17:22:12 -04:00
lcd . setCursor ( 1 , 0 ) ;
lcd . print ( " -- SILENCED -- " ) ;
2022-09-29 17:39:07 -04:00
lcd . setCursor ( 0 , 1 ) ;
if ( zoneAlarm = = 1 ) {
lcd . print ( " Zone 1 " ) ;
} else if ( zoneAlarm = = 2 ) {
lcd . print ( " Zone 2 " ) ;
} else if ( zoneAlarm = = 3 ) {
lcd . print ( " Zone 1 & Zone 2 " ) ;
} else if ( zoneAlarm = = 4 ) {
lcd . print ( " Fire Drill " ) ;
}
2022-07-04 18:07:36 -04:00
currentScreen = 4 ;
2022-10-02 22:28:59 -04:00
updateLockStatus = true ;
2022-10-08 22:18:30 -04:00
} else if ( walkTest and currentScreen ! = 5 ) {
2022-07-04 18:07:36 -04:00
lcd . clear ( ) ;
2022-10-01 17:22:12 -04:00
lcd . setCursor ( 1 , 0 ) ;
2022-07-04 18:07:36 -04:00
lcd . print ( " * Supervisory * " ) ;
lcd . setCursor ( 0 , 1 ) ;
2022-09-29 17:39:07 -04:00
lcd . print ( " Z1: " + ( String ) zone1Count + " Z2: " + ( String ) zone2Count ) ;
2022-07-04 18:07:36 -04:00
currentScreen = 5 ;
2022-10-02 22:28:59 -04:00
updateLockStatus = true ;
2022-09-21 21:57:02 -04:00
digitalWrite ( readyLed , LOW ) ; //ready led off for walk test
2022-10-08 22:18:30 -04:00
} else if ( drillPressed and not fullAlarm and not walkTest and currentScreen ! = 6 ) {
2022-09-25 13:24:30 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " CONTINUE HOLDING " ) ;
lcd . setCursor ( 1 , 1 ) ;
lcd . print ( " TO START DRILL " ) ;
currentScreen = 6 ;
2022-10-08 22:18:30 -04:00
} else if ( trouble and not fullAlarm and not drillPressed and not walkTest and currentScreen ! = 1 ) {
2022-10-01 17:22:12 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 2 , 0 ) ;
lcd . print ( " * Trouble * " ) ;
if ( troubleType = = 0 ) {
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " Unknown " ) ;
} else if ( troubleType = = 1 ) {
lcd . setCursor ( 0 , 1 ) ;
if ( zoneTrouble = = 3 ) {
lcd . print ( " Gnd Fault Z1&Z2 " ) ;
} else if ( zoneTrouble = = 2 ) {
lcd . print ( " Gnd Fault Z2 " ) ;
} else if ( zoneTrouble = = 1 ) {
lcd . print ( " Gnd Fault Z1 " ) ;
}
}
currentScreen = 1 ;
2022-10-02 22:28:59 -04:00
updateLockStatus = true ;
2022-10-01 17:22:12 -04:00
}
2022-10-08 22:18:30 -04:00
if ( updateLockStatus and not inConfigMenu and keyRequired ) {
2022-10-01 17:22:12 -04:00
lcd . setCursor ( 0 , 0 ) ;
2022-10-08 22:18:30 -04:00
if ( panelUnlocked ) {
2022-10-01 17:22:12 -04:00
lcd . print ( " " ) ;
2022-10-08 22:18:30 -04:00
} else {
lcd . write ( byte ( 0 ) ) ;
2022-10-01 17:22:12 -04:00
}
updateLockStatus = false ;
2022-07-04 18:07:36 -04:00
}
}
2022-10-08 22:18:30 -04:00
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 ;
2022-10-15 13:52:08 -04:00
if ( replaceTop ) {
2022-10-08 22:18:30 -04:00
configTop . replace ( " 1 " , " * " ) ;
configTop . replace ( " 0 " , " $ " ) ;
}
2022-10-15 13:52:08 -04:00
if ( replaceBottom ) {
2022-10-08 22:18:30 -04:00
configBottom . replace ( " 1 " , " * " ) ;
configBottom . replace ( " 0 " , " $ " ) ;
}
}
2022-07-04 18:07:36 -04:00
void config ( ) {
char * main [ ] = { " Testing " , " Settings " } ; //menu 0
char * mainTesting [ ] = { " Walk Test " , " Silent Wlk Test " , " Strobe Test " } ; //menu 1
char * mainSettings [ ] = { " Fire Alarm " , " Panel " } ; //menu 2
2022-10-06 22:49:08 -04:00
char * mainSettingsFireAlarmSettings [ ] = { " Coding " , " Verification " , " Pre-Alarm " , " Audible Sil.: " , " No-Key Sil.: " , " Strobe Sync " , " 2 Wire: " } ; //menu 3
2023-03-22 21:07:17 -04:00
char * mainSettingsVerificationSettings [ ] = { " Verification: " , " V.Time: " , " Det.Verif.: " , " Det.Timeout: " , " Det.Watch: " } ; //menu 4
2022-07-04 18:07:36 -04:00
char * mainSettingsFireAlarmSettingsCoding [ ] = { " Temporal Three " , " Marchtime " , " 4-4 " , " Continuous " , " California " , " Slow Marchtime " } ; //menu 5
2022-10-02 22:28:59 -04:00
char * mainSettingsFireAlarmSettingsPreAlarmSettings [ ] = { " Pre-Alarm: " , " Stage1 Time: " } ; //menu 6
2022-09-30 23:02:37 -04:00
char * mainPanelSettings [ ] = { " Panel Name " , " Panel Security " , " LCD Dim: " , " Factory Reset " , " About " } ; //menu 8
2022-07-04 18:07:36 -04:00
char * mainPanelSettingsPanelSecurity [ ] = { " None " , " Keyswitch " , " Passcode " } ; //menu 9
char * mainPanelSettingsPanelName [ ] = { " Enter Name: " } ; //menu 10
2023-01-01 11:01:10 -05:00
char * mainSettingsFireAlarmSettingsStrobeSync [ ] = { " None " , " System Sensor " , " Wheelock " , " Gentex " , " Simplex " } ; //menu 11
2022-09-27 22:31:38 -04:00
char * mainPanelSettingsAbout [ ] = { " Antigneous FACP " , " Firmware: " , " by Lexzach " } ; //menu 12
2022-09-25 13:24:30 -04:00
2022-10-15 13:52:08 -04:00
if ( digitalRead ( resetButtonPin ) ) { //RESET BUTTON
2022-07-04 18:07:36 -04:00
resetPressed = true ;
} else {
resetPressed = false ;
resetStillPressed = false ;
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( silenceButtonPin ) ) { //SILENCE BUTTON
2022-07-04 18:07:36 -04:00
silencePressed = true ;
} else {
silencePressed = false ;
silenceStillPressed = false ;
}
2022-10-15 13:52:08 -04:00
if ( digitalRead ( drillButtonPin ) ) { //DRILL BUTTON
2022-07-04 18:07:36 -04:00
drillPressed = true ;
} else {
drillPressed = false ;
drillStillPressed = false ;
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- MAIN MENU
2022-07-04 18:07:36 -04:00
if ( configPage = = 0 ) {
2022-10-08 22:18:30 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) { //main screen
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 1 , ( String ) main [ 1 ] , ( String ) main [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) main [ 0 ] , ( String ) main [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
2022-10-08 22:18:30 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
silencePressed = true ;
2022-10-08 22:18:30 -04:00
inConfigMenu = false ;
2022-07-04 18:07:36 -04:00
currentScreen = - 1 ;
2022-10-08 22:18:30 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) { //cursor over testing
configPage = 1 ; //change screen to testing
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainTesting [ 0 ] , ( String ) mainTesting [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) { //cursor over settings
configPage = 2 ; //change screen to settings
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettings [ 0 ] , ( String ) mainSettings [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- MAIN MENU
//----------------------------------------------------------------------------- TESTING
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 1 ) {
2022-10-08 22:18:30 -04:00
if ( resetPressed and not resetStillPressed and not strobe ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 1 , ( String ) mainTesting [ 1 ] , ( String ) mainTesting [ 2 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 2 , ( String ) mainTesting [ 2 ] , ( String ) mainTesting [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 2 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainTesting [ 0 ] , ( String ) mainTesting [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
2022-10-08 22:18:30 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
configPage = 0 ;
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) main [ 0 ] , ( String ) main [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
strobe = false ;
2022-09-30 19:07:30 -04:00
smokeDetectorOn ( true ) ;
2022-10-15 13:52:08 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
walkTest = true ;
silentWalkTest = false ;
silencePressed = true ;
2022-10-08 22:18:30 -04:00
inConfigMenu = false ;
2022-07-04 18:07:36 -04:00
currentScreen = - 1 ;
2022-09-29 17:39:07 -04:00
zone1Count = 0 ;
zone2Count = 0 ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
walkTest = true ;
silentWalkTest = true ;
silencePressed = true ;
2022-10-08 22:18:30 -04:00
inConfigMenu = false ;
2022-07-04 18:07:36 -04:00
currentScreen = - 1 ;
2022-09-29 17:39:07 -04:00
zone1Count = 0 ;
zone2Count = 0 ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 2 ) {
2022-10-08 22:18:30 -04:00
if ( not strobe ) {
2022-07-04 18:07:36 -04:00
strobe = true ;
2022-09-30 19:07:30 -04:00
smokeDetectorOn ( false ) ; //prevent (specifically cheap IR) smoke detectors from tripping from the strobe
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 2 , ( String ) mainTesting [ 2 ] + " * " , ( String ) mainTesting [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
} else {
strobe = false ;
2022-09-30 19:07:30 -04:00
smokeDetectorOn ( true ) ;
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 2 , ( String ) mainTesting [ 2 ] , ( String ) mainTesting [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
}
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- TESTING
//----------------------------------------------------------------------------- SETTINGS
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 2 ) {
2022-10-08 22:18:30 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) { //main screen
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 1 , ( String ) mainSettings [ 1 ] , ( String ) mainSettings [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettings [ 0 ] , ( String ) mainSettings [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
configPage = 0 ;
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 1 , ( String ) main [ 1 ] , ( String ) main [ 0 ] ) ;
} else if ( drillPressed and not drillStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
configPage = 3 ; //change screen to facp settings
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] + " off " , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
configPage = 8 ; //change screen to facp settings
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettings [ 0 ] , ( String ) mainPanelSettings [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETTINGS
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 3 ) {
2022-10-08 22:18:30 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettings [ 1 ] , ( String ) mainSettingsFireAlarmSettings [ 2 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettings [ 2 ] , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , false , true ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 2 ) {
2022-10-08 22:18:30 -04:00
if ( keyRequiredVisual ) {
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , ( String ) mainSettingsFireAlarmSettings [ 4 ] + keylessSilence , true , true ) ;
2022-10-02 22:28:59 -04:00
} else {
2023-03-26 00:03:19 -04:00
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , ( String ) mainSettingsFireAlarmSettings [ 4 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
2022-09-30 23:02:37 -04:00
} else if ( cursorPosition = = 3 ) {
2022-10-08 22:18:30 -04:00
if ( keyRequiredVisual ) {
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettings [ 4 ] + keylessSilence , ( String ) mainSettingsFireAlarmSettings [ 5 ] , true , false ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettings [ 4 ] + " off " , ( String ) mainSettingsFireAlarmSettings [ 5 ] , false , false ) ;
2022-10-02 22:28:59 -04:00
}
2022-09-30 23:02:37 -04:00
} else if ( cursorPosition = = 4 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 5 , ( String ) mainSettingsFireAlarmSettings [ 5 ] , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , false , true ) ;
2022-10-06 22:49:08 -04:00
} else if ( cursorPosition = = 5 ) {
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
configLCDUpdate ( 6 , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , ( String ) mainSettingsFireAlarmSettings [ 0 ] + " off " , true , false ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 6 , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , ( String ) mainSettingsFireAlarmSettings [ 0 ] , true , false ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 6 ) {
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] + " off " , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
2022-07-04 18:07:36 -04:00
}
2022-10-08 22:18:30 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
configPage = 2 ;
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettings [ 0 ] , ( String ) mainSettings [ 1 ] ) ;
} else if ( drillPressed and not drillStillPressed ) {
if ( cursorPosition = = 0 and not useTwoWire ) {
2022-07-04 18:07:36 -04:00
configPage = 5 ;
if ( codeWheel = = 0 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] ) ;
} else if ( codeWheel = = 1 ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 1 ) {
configPage = 4 ;
2022-10-08 22:18:30 -04:00
if ( verificationEnabled ) {
configLCDUpdate ( 0 , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + ( verificationTime / 1000 ) + " s " , true , false ) ;
2022-09-30 19:07:30 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + " off " , true , false ) ;
2022-09-30 19:07:30 -04:00
}
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 2 ) {
configPage = 6 ;
2022-10-08 22:18:30 -04:00
if ( preAlarm ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + ( firstStageTime / 60000 ) + " m " , true , false ) ;
2022-10-02 23:02:19 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + " off " , true , false ) ;
2022-10-02 23:02:19 -04:00
}
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 3 ) {
2022-10-08 22:18:30 -04:00
if ( audibleSilence ) {
2022-07-04 18:07:36 -04:00
audibleSilence = false ;
EEPROM . write ( 79 , 0 ) ;
} else {
audibleSilence = true ;
EEPROM . write ( 79 , 1 ) ;
}
EEPROM . commit ( ) ;
2022-10-08 22:18:30 -04:00
if ( keyRequiredVisual ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , ( String ) mainSettingsFireAlarmSettings [ 4 ] + keylessSilence , true , true ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , ( String ) mainSettingsFireAlarmSettings [ 4 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
2022-10-08 22:18:30 -04:00
} else if ( cursorPosition = = 4 and keyRequiredVisual ) {
if ( keylessSilence ) {
2022-09-30 23:02:37 -04:00
keylessSilence = false ;
EEPROM . write ( 27 , 0 ) ;
} else {
keylessSilence = true ;
EEPROM . write ( 27 , 1 ) ;
}
EEPROM . commit ( ) ;
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettings [ 4 ] + keylessSilence , ( String ) mainSettingsFireAlarmSettings [ 5 ] , true , false ) ;
2022-10-06 22:49:08 -04:00
} else if ( cursorPosition = = 5 ) {
2022-10-08 22:18:30 -04:00
configPage = 11 ;
2022-10-06 22:49:08 -04:00
if ( strobeSync = = 0 ) {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] ) ;
} else if ( strobeSync = = 1 ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] + " * " ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-08 22:18:30 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 6 ) {
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
useTwoWire = false ;
2022-10-06 22:49:08 -04:00
EEPROM . write ( 30 , 0 ) ;
} else {
2022-10-08 22:18:30 -04:00
useTwoWire = true ;
2022-10-06 22:49:08 -04:00
EEPROM . write ( 30 , 1 ) ;
}
EEPROM . commit ( ) ;
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , ( String ) mainSettingsFireAlarmSettings [ 0 ] + " off " , true , false ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , ( String ) mainSettingsFireAlarmSettings [ 0 ] , true , false ) ;
2022-10-06 22:49:08 -04:00
}
2022-07-04 18:07:36 -04:00
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM
//----------------------------------------------------------------------------- SETTINGS > PANEL
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 8 ) {
2022-10-15 14:32:14 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
if ( lcdTimeout = = 0 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + " off " ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout < = 30000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 1000 + " s " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 60000 + " m " ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 1 ) {
cursorPosition = 2 ;
if ( lcdTimeout = = 0 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainPanelSettings [ 2 ] + " off " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout < = 30000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 1000 + " s " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 60000 + " m " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 2 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , ( String ) mainPanelSettings [ 3 ] , ( String ) mainPanelSettings [ 4 ] ) ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 3 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainPanelSettings [ 4 ] , ( String ) mainPanelSettings [ 0 ] ) ;
2022-09-30 23:02:37 -04:00
} else if ( cursorPosition = = 4 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettings [ 0 ] , ( String ) mainPanelSettings [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
2022-10-15 14:32:14 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
configPage = 2 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettings [ 1 ] , ( String ) mainSettings [ 0 ] ) ;
2022-10-15 14:32:14 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
configPage = 10 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , " Enter Name: " , ( String ) panelName ) ;
2022-07-04 18:07:36 -04:00
lcd . blink_on ( ) ;
} else if ( cursorPosition = = 1 ) {
2022-09-25 13:24:30 -04:00
configPage = 9 ;
2022-09-25 23:54:40 -04:00
if ( keyRequiredVisual = = true ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettingsPanelSecurity [ 0 ] , ( String ) mainPanelSettingsPanelSecurity [ 1 ] + " * " ) ;
2022-09-25 13:24:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettingsPanelSecurity [ 0 ] + " * " , ( String ) mainPanelSettingsPanelSecurity [ 1 ] ) ;
2022-09-25 13:24:30 -04:00
}
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 2 ) {
if ( lcdTimeout = = 0 ) {
2022-09-27 22:31:38 -04:00
lcdTimeout = 15000 ;
2022-07-04 18:07:36 -04:00
EEPROM . write ( 80 , 1 ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout = = 15000 ) {
lcdTimeout = 30000 ;
2022-07-04 18:07:36 -04:00
EEPROM . write ( 80 , 2 ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout = = 30000 ) {
lcdTimeout = 60000 ;
2022-07-04 18:07:36 -04:00
EEPROM . write ( 80 , 4 ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout = = 60000 ) {
lcdTimeout = 300000 ;
2022-07-04 18:07:36 -04:00
EEPROM . write ( 80 , 20 ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout = = 300000 ) {
lcdTimeout = 600000 ;
2022-07-04 18:07:36 -04:00
EEPROM . write ( 80 , 40 ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout > = 600000 ) {
2022-07-04 18:07:36 -04:00
lcdTimeout = 0 ;
EEPROM . write ( 80 , 0 ) ;
}
EEPROM . commit ( ) ;
if ( lcdTimeout = = 0 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainPanelSettings [ 2 ] + " off " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-09-27 22:31:38 -04:00
} else if ( lcdTimeout < = 30000 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 1000 + " s " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 60000 + " m " , ( String ) mainPanelSettings [ 3 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 3 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 0 , " reset = yes " , " silence = no " ) ;
2022-09-19 21:52:52 -04:00
configPage = - 1 ;
2022-07-04 18:07:36 -04:00
} else if ( cursorPosition = = 4 ) {
2022-09-27 22:31:38 -04:00
configPage = 12 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettingsAbout [ 0 ] , ( String ) mainPanelSettingsAbout [ 1 ] + firmwareRev ) ;
2022-07-04 18:07:36 -04:00
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETTINGS > PANEL
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL NAME
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 10 ) { //panel rename routine
2022-10-15 14:32:14 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
clearTimer = 0 ;
if ( panelNameList [ cursorPosition ] = = 90 ) {
panelNameList [ cursorPosition ] = 32 ;
} else if ( panelNameList [ cursorPosition ] = = 32 ) {
panelNameList [ cursorPosition ] = 39 ;
} else if ( panelNameList [ cursorPosition ] = = 39 ) {
panelNameList [ cursorPosition ] = 45 ;
} else if ( panelNameList [ cursorPosition ] = = 57 ) {
panelNameList [ cursorPosition ] = 65 ;
} else {
panelNameList [ cursorPosition ] = panelNameList [ cursorPosition ] + 1 ;
}
2022-10-15 14:32:14 -04:00
} else if ( resetPressed and resetStillPressed ) {
2022-07-04 18:07:36 -04:00
clearTimer + + ;
2022-09-27 22:31:38 -04:00
if ( clearTimer > = 35 ) { //clear character if held down
2022-07-04 18:07:36 -04:00
panelNameList [ cursorPosition ] = 32 ;
}
2022-10-15 14:32:14 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
int x = 0 ;
for ( int i = 11 ; i < = 26 ; i + + ) { //write new panel name
EEPROM . write ( i , panelNameList [ x ] ) ;
x + + ;
}
lcd . blink_off ( ) ;
EEPROM . commit ( ) ;
configPage = 8 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettings [ 0 ] , ( String ) mainPanelSettings [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
x = 0 ;
panelName = " " ;
2022-09-19 20:46:43 -04:00
for ( int i = 11 ; i < = 26 ; i + + ) { //read panel name
2022-07-04 18:07:36 -04:00
if ( EEPROM . read ( i ) ! = 0 ) {
panelName = panelName + ( char ) EEPROM . read ( i ) ;
panelNameList [ x ] = EEPROM . read ( i ) ;
x + + ;
}
}
2022-10-15 14:32:14 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-07-04 19:28:48 -04:00
currentConfigTop = " e " ; //make sure the screen re-renders
2022-07-04 18:07:36 -04:00
if ( cursorPosition ! = 15 ) {
cursorPosition + + ;
} else {
cursorPosition = 0 ;
}
}
if ( configPage = = 10 ) { //make sure the panel doesn't re-render the text on the previous page when exiting
configBottom = " " ;
for ( int i = 0 ; i < = 15 ; i + + ) { //generate name to print on lcd
configBottom = configBottom + ( char ) panelNameList [ i ] ;
}
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL NAME
//----------------------------------------------------------------------------- SETTINGS > PANEL > FACTORY RESET
2022-09-19 21:52:52 -04:00
} else if ( configPage = = - 1 ) {
2022-10-15 13:52:08 -04:00
if ( silencePressed and not silenceStillPressed ) {
2022-09-19 20:46:43 -04:00
configPage = 8 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , ( String ) mainPanelSettings [ 3 ] , ( String ) mainPanelSettings [ 4 ] ) ;
} else if ( resetPressed and not resetStillPressed ) {
2022-09-21 21:57:02 -04:00
digitalWrite ( readyLed , LOW ) ; //ready LED
2022-09-19 20:46:43 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " RESETTING TO " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " FACTORY SETTINGS " ) ;
resetEEPROM ( ) ;
delay ( 4000 ) ;
ESP . restart ( ) ;
}
//----------------------------------------------------------------------------- SETTINGS > PANEL > FACTORY RESET
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > CODING
2022-07-04 18:07:36 -04:00
} else if ( configPage = = 5 ) {
2022-10-15 14:32:14 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-07-04 18:07:36 -04:00
if ( cursorPosition = = 0 ) {
if ( codeWheel = = 1 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] ) ;
} else if ( codeWheel = = 2 ) {
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 1 ) {
if ( codeWheel = = 2 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] ) ;
} else if ( codeWheel = = 3 ) {
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsCoding [ 2 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 2 ) {
if ( codeWheel = = 3 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] ) ;
} else if ( codeWheel = = 4 ) {
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsCoding [ 3 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 3 ) {
if ( codeWheel = = 4 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] ) ;
} else if ( codeWheel = = 5 ) {
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsCoding [ 4 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 4 ) {
if ( codeWheel = = 5 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 5 , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] ) ;
} else if ( codeWheel = = 0 ) {
configLCDUpdate ( 5 , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 5 , ( String ) mainSettingsFireAlarmSettingsCoding [ 5 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
}
} else if ( cursorPosition = = 5 ) {
if ( codeWheel = = 0 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] ) ;
} else if ( codeWheel = = 1 ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] + " * " ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] , ( String ) mainSettingsFireAlarmSettingsCoding [ 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
}
2022-10-15 14:32:14 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-07-04 18:07:36 -04:00
configPage = 3 ; //change screen to facp settings
2022-10-08 22:18:30 -04:00
if ( useTwoWire ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] + " off " , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-08 22:18:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettings [ 0 ] , ( String ) mainSettingsFireAlarmSettings [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
2022-10-15 14:32:14 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-09-25 13:24:30 -04:00
EEPROM . write ( 7 , cursorPosition ) ; //write the new codewheel settings to eeprom
2022-07-04 18:07:36 -04:00
EEPROM . commit ( ) ;
if ( cursorPosition = = 5 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsCoding [ cursorPosition ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ 0 ] ) ;
2022-07-04 18:07:36 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsCoding [ cursorPosition ] + " * " , ( String ) mainSettingsFireAlarmSettingsCoding [ cursorPosition + 1 ] ) ;
2022-07-04 18:07:36 -04:00
}
codeWheel = EEPROM . read ( 7 ) ; //codeWheel setting address
}
2022-09-19 20:46:43 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > CODING
2022-09-19 21:52:52 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION
} else if ( configPage = = 4 ) {
2022-10-15 13:52:08 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-09-19 21:52:52 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
if ( not verificationEnabled ) {
configLCDUpdate ( 1 , ( String ) mainSettingsVerificationSettings [ 1 ] + " off " , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , false , true ) ;
2022-09-30 19:07:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsVerificationSettings [ 1 ] + ( verificationTime / 1000 ) + " s " , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , false , true ) ;
2022-09-30 19:07:30 -04:00
}
2022-09-19 21:52:52 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorTimeout < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 1000 ) + " s " , true , false ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 60000 ) + " m " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
} else if ( cursorPosition = = 2 ) {
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorTimeout < 60000 ) {
configTop = ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 1000 ) + " s " ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-03 23:05:16 -04:00
configTop = ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 60000 ) + " m " ;
2022-10-02 22:28:59 -04:00
}
} else {
configTop = ( String ) mainSettingsVerificationSettings [ 3 ] + " off " ;
}
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorPostRestartVerificationTime < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 1000 ) + " s " ) ;
2022-10-03 23:05:16 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 60000 ) + " m " ) ;
2022-10-03 23:05:16 -04:00
}
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 3 , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + " off " ) ;
2022-10-03 23:05:16 -04:00
}
} else if ( cursorPosition = = 3 ) {
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorPostRestartVerificationTime < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 1000 ) + " s " , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , false , true ) ;
2022-10-03 23:05:16 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 60000 ) + " m " , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , false , true ) ;
2022-10-03 23:05:16 -04:00
}
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsVerificationSettings [ 4 ] + " off " , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , false , true ) ;
2022-10-03 23:05:16 -04:00
}
} else if ( cursorPosition = = 4 ) {
2022-10-15 13:52:08 -04:00
if ( not verificationEnabled ) {
configLCDUpdate ( 0 , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + " off " , true , false ) ;
2022-09-30 19:07:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + ( verificationTime / 1000 ) + " s " , true , false ) ;
2022-09-30 19:07:30 -04:00
}
2022-10-02 22:28:59 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-09-19 21:52:52 -04:00
configPage = 3 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettings [ 1 ] , ( String ) mainSettingsFireAlarmSettings [ 2 ] ) ;
} else if ( drillPressed and not drillStillPressed ) {
2022-09-19 21:52:52 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
if ( verificationEnabled ) {
2022-10-08 22:18:30 -04:00
verificationEnabled = false ;
2022-09-19 21:52:52 -04:00
EEPROM . write ( 9 , 0 ) ;
} else {
2022-10-08 22:18:30 -04:00
verificationEnabled = true ;
2022-09-19 21:52:52 -04:00
EEPROM . write ( 9 , 1 ) ;
}
EEPROM . commit ( ) ;
2022-10-15 13:52:08 -04:00
if ( not verificationEnabled ) {
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + " off " , true , false ) ;
2022-09-30 19:07:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , ( String ) mainSettingsVerificationSettings [ 1 ] + ( verificationTime / 1000 ) + " s " , true , false ) ;
2022-09-30 19:07:30 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( cursorPosition = = 1 and verificationEnabled ) {
2022-09-30 19:07:30 -04:00
if ( verificationTime = = 500 ) {
verificationTime = 1000 ;
EEPROM . write ( 10 , 10 ) ;
} else if ( verificationTime = = 1000 ) {
verificationTime = 1500 ;
EEPROM . write ( 10 , 15 ) ;
} else if ( verificationTime = = 1500 ) {
verificationTime = 2500 ;
EEPROM . write ( 10 , 25 ) ;
} else if ( verificationTime = = 2500 ) {
verificationTime = 4500 ;
EEPROM . write ( 10 , 45 ) ;
} else if ( verificationTime = = 4500 ) {
verificationTime = 7500 ;
EEPROM . write ( 10 , 75 ) ;
} else if ( verificationTime > = 7500 ) {
verificationTime = 500 ;
EEPROM . write ( 10 , 5 ) ;
}
EEPROM . commit ( ) ;
2022-10-15 13:52:08 -04:00
if ( not verificationEnabled ) {
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 1 ] + " off " , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , false , true ) ;
2022-09-30 19:07:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 1 ] + ( verificationTime / 1000 ) + " s " , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , false , true ) ;
2022-09-30 19:07:30 -04:00
}
2022-10-02 22:28:59 -04:00
} else if ( cursorPosition = = 2 ) {
2022-10-15 13:52:08 -04:00
if ( not smokeDetectorVerification ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 76 , 1 ) ; //enable pre-alarm
smokeDetectorVerification = true ;
} else {
EEPROM . write ( 76 , 0 ) ; //disable pre-alarm
smokeDetectorVerification = false ;
2022-10-03 23:05:16 -04:00
smokeDetectorOn ( true ) ; //re-enable smoke detectors in the case that smoke detectors are currently in timeout
2022-10-02 22:41:26 -04:00
digitalWrite ( alarmLed , LOW ) ;
smokeDetectorCurrentlyInVerification = false ;
smokeDetectorPostRestartTimer = 0 ;
smokeDetectorTimer = 0 ;
2022-10-02 22:28:59 -04:00
}
EEPROM . commit ( ) ;
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorTimeout < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 1000 ) + " s " , true , false ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 60000 ) + " m " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 2 ] + smokeDetectorVerification , ( String ) mainSettingsVerificationSettings [ 3 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( cursorPosition = = 3 and smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorTimeout = = 5000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 2 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 10000 ;
} else if ( smokeDetectorTimeout = = 10000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 3 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 15000 ;
} else if ( smokeDetectorTimeout = = 15000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 4 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 20000 ;
} else if ( smokeDetectorTimeout = = 20000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 6 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 30000 ;
} else if ( smokeDetectorTimeout = = 30000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 9 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 45000 ;
} else if ( smokeDetectorTimeout = = 45000 ) {
EEPROM . write ( 77 , 12 ) ;
smokeDetectorTimeout = 60000 ;
} else if ( smokeDetectorTimeout = = 60000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 24 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 120000 ;
} else if ( smokeDetectorTimeout = = 120000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 60 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 300000 ;
} else if ( smokeDetectorTimeout = = 300000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 120 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 600000 ;
} else if ( smokeDetectorTimeout = = 600000 ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 77 , 1 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorTimeout = 5000 ;
}
EEPROM . commit ( ) ;
if ( smokeDetectorTimeout < 60000 ) {
configTop = ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 1000 ) + " s " ;
} else {
configTop = ( String ) mainSettingsVerificationSettings [ 3 ] + ( smokeDetectorTimeout / 60000 ) + " m " ;
}
2022-10-15 13:52:08 -04:00
if ( smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorPostRestartVerificationTime < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 1000 ) + " s " ) ;
2022-10-03 23:05:16 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 60000 ) + " m " ) ;
2022-10-03 23:05:16 -04:00
}
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , configTop , ( String ) mainSettingsVerificationSettings [ 4 ] + " off " ) ;
2022-10-03 23:05:16 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( cursorPosition = = 4 and smokeDetectorVerification ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorPostRestartVerificationTime = = 60000 ) {
EEPROM . write ( 28 , 24 ) ;
smokeDetectorPostRestartVerificationTime = 120000 ;
} else if ( smokeDetectorPostRestartVerificationTime = = 120000 ) {
EEPROM . write ( 28 , 36 ) ;
smokeDetectorPostRestartVerificationTime = 180000 ;
} else if ( smokeDetectorPostRestartVerificationTime = = 180000 ) {
EEPROM . write ( 28 , 48 ) ;
smokeDetectorPostRestartVerificationTime = 240000 ;
} else if ( smokeDetectorPostRestartVerificationTime = = 240000 ) {
EEPROM . write ( 28 , 60 ) ;
smokeDetectorPostRestartVerificationTime = 300000 ;
} else if ( smokeDetectorPostRestartVerificationTime = = 300000 ) {
2022-10-15 13:52:08 -04:00
EEPROM . write ( 28 , 120 ) ;
2022-10-03 23:05:16 -04:00
smokeDetectorPostRestartVerificationTime = 600000 ;
} else if ( smokeDetectorPostRestartVerificationTime = = 600000 ) {
EEPROM . write ( 28 , 12 ) ;
smokeDetectorPostRestartVerificationTime = 60000 ;
2022-10-02 22:28:59 -04:00
}
EEPROM . commit ( ) ;
2022-10-03 23:05:16 -04:00
if ( smokeDetectorPostRestartVerificationTime < 60000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 1000 ) + " s " , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , false , true ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsVerificationSettings [ 4 ] + ( smokeDetectorPostRestartVerificationTime / 60000 ) + " m " , ( String ) mainSettingsVerificationSettings [ 0 ] + verificationEnabled , false , true ) ;
2022-10-02 22:28:59 -04:00
}
2022-09-19 21:52:52 -04:00
}
2022-10-03 23:05:16 -04:00
}
2022-09-25 13:24:30 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY
2022-09-27 22:31:38 -04:00
} else if ( configPage = = 9 ) {
2022-10-15 13:52:08 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-09-25 13:24:30 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
if ( keyRequiredVisual ) {
configLCDUpdate ( 1 , ( String ) mainPanelSettingsPanelSecurity [ 1 ] + " * " , ( String ) mainPanelSettingsPanelSecurity [ 0 ] ) ;
2022-09-25 13:24:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettingsPanelSecurity [ 1 ] , ( String ) mainPanelSettingsPanelSecurity [ 0 ] + " * " ) ;
2022-09-25 13:24:30 -04:00
}
} else if ( cursorPosition = = 1 ) {
2022-10-15 13:52:08 -04:00
if ( keyRequiredVisual ) {
configLCDUpdate ( 0 , ( String ) mainPanelSettingsPanelSecurity [ 0 ] , ( String ) mainPanelSettingsPanelSecurity [ 1 ] + " * " ) ;
2022-09-25 13:24:30 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettingsPanelSecurity [ 0 ] + " * " , ( String ) mainPanelSettingsPanelSecurity [ 1 ] ) ;
2022-09-25 13:24:30 -04:00
}
}
2022-10-15 13:52:08 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-09-25 13:24:30 -04:00
configPage = 8 ;
2022-10-02 23:02:19 -04:00
if ( lcdTimeout = = 0 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + " off " ) ;
2022-10-02 23:02:19 -04:00
} else if ( lcdTimeout < = 30000 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 1000 + " s " ) ;
2022-10-02 23:02:19 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettings [ 1 ] , ( String ) mainPanelSettings [ 2 ] + lcdTimeout / 60000 + " m " ) ;
2022-10-02 23:02:19 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( drillPressed and not drillStillPressed ) {
2022-09-25 13:24:30 -04:00
if ( cursorPosition = = 0 ) {
EEPROM . write ( 8 , 0 ) ; //write the new keyswitch settings to eeprom
EEPROM . commit ( ) ;
keyRequiredVisual = false ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainPanelSettingsPanelSecurity [ 0 ] + " * " , ( String ) mainPanelSettingsPanelSecurity [ 1 ] ) ;
2022-09-25 13:24:30 -04:00
} else if ( cursorPosition = = 1 ) {
EEPROM . write ( 8 , 1 ) ; //write the new keyswitch settings to eeprom
EEPROM . commit ( ) ;
keyRequiredVisual = true ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainPanelSettingsPanelSecurity [ 1 ] + " * " , ( String ) mainPanelSettingsPanelSecurity [ 0 ] ) ;
2022-09-25 13:24:30 -04:00
}
2022-09-27 22:31:38 -04:00
}
//----------------------------------------------------------------------------- SETTINGS > PANEL > PANEL SECURITY
2022-10-02 23:02:19 -04:00
//----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT
2022-09-27 22:31:38 -04:00
} else if ( configPage = = 12 ) {
2022-10-15 13:52:08 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-09-27 22:31:38 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainPanelSettingsAbout [ 1 ] + firmwareRev , ( String ) mainPanelSettingsAbout [ 2 ] ) ;
2022-09-27 22:31:38 -04:00
} else if ( cursorPosition = = 1 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainPanelSettingsAbout [ 2 ] , ( String ) mainPanelSettingsAbout [ 0 ] ) ;
2022-09-27 22:31:38 -04:00
} else if ( cursorPosition = = 2 ) {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainPanelSettingsAbout [ 0 ] , ( String ) mainPanelSettingsAbout [ 1 ] + firmwareRev ) ;
2022-09-27 22:31:38 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-09-27 22:31:38 -04:00
configPage = 8 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 4 , ( String ) mainPanelSettings [ 4 ] , ( String ) mainPanelSettings [ 0 ] ) ;
2022-09-27 22:31:38 -04:00
}
//----------------------------------------------------------------------------- SETTINGS > PANEL > ABOUT
2022-10-02 22:28:59 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM
} else if ( configPage = = 6 ) {
2022-10-15 13:52:08 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-10-02 22:28:59 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
if ( preAlarm ) {
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + ( firstStageTime / 60000 ) + " m " , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , false , true ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + " off " , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , false , true ) ;
2022-10-02 22:28:59 -04:00
}
} else if ( cursorPosition = = 1 ) {
2022-10-15 13:52:08 -04:00
if ( preAlarm ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + ( firstStageTime / 60000 ) + " m " , true , false ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
}
2022-10-15 13:52:08 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-10-02 22:28:59 -04:00
configPage = 3 ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettings [ 2 ] , ( String ) mainSettingsFireAlarmSettings [ 3 ] + audibleSilence , false , true ) ;
} else if ( drillPressed and not drillStillPressed ) {
2022-10-02 22:28:59 -04:00
if ( cursorPosition = = 0 ) {
2022-10-15 13:52:08 -04:00
if ( not preAlarm ) {
2022-10-02 22:28:59 -04:00
EEPROM . write ( 74 , 1 ) ; //enable pre-alarm
preAlarm = true ;
} else {
EEPROM . write ( 74 , 0 ) ; //disable pre-alarm
preAlarm = false ;
}
EEPROM . commit ( ) ;
2022-10-15 13:52:08 -04:00
if ( preAlarm ) {
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + ( firstStageTime / 60000 ) + " m " , true , false ) ;
2022-10-02 22:28:59 -04:00
} else {
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + " off " , true , false ) ;
2022-10-02 22:28:59 -04:00
}
2022-10-15 13:52:08 -04:00
} else if ( cursorPosition = = 1 and preAlarm ) {
2022-10-02 22:28:59 -04:00
if ( firstStageTime = = 60000 ) {
EEPROM . write ( 75 , 2 ) ;
firstStageTime = 120000 ;
} else if ( firstStageTime = = 120000 ) {
EEPROM . write ( 75 , 3 ) ;
firstStageTime = 180000 ;
} else if ( firstStageTime = = 180000 ) {
EEPROM . write ( 75 , 4 ) ;
firstStageTime = 240000 ;
} else if ( firstStageTime = = 240000 ) {
EEPROM . write ( 75 , 5 ) ;
firstStageTime = 300000 ;
} else if ( firstStageTime = = 300000 ) {
EEPROM . write ( 75 , 7 ) ;
firstStageTime = 420000 ;
} else if ( firstStageTime = = 420000 ) {
EEPROM . write ( 75 , 10 ) ;
firstStageTime = 600000 ;
} else if ( firstStageTime = = 600000 ) {
EEPROM . write ( 75 , 15 ) ;
firstStageTime = 900000 ;
} else if ( firstStageTime = = 900000 ) {
EEPROM . write ( 75 , 20 ) ;
firstStageTime = 1200000 ;
} else if ( firstStageTime = = 1200000 ) {
EEPROM . write ( 75 , 1 ) ;
firstStageTime = 60000 ;
}
EEPROM . commit ( ) ;
2022-10-15 13:52:08 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 1 ] + ( firstStageTime / 60000 ) + " m " , ( String ) mainSettingsFireAlarmSettingsPreAlarmSettings [ 0 ] + preAlarm , false , true ) ;
2022-10-02 22:28:59 -04:00
}
}
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > PRE-ALARM
2022-09-27 22:31:38 -04:00
2022-10-06 22:49:08 -04:00
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > STROBE SYNC
} else if ( configPage = = 11 ) {
2022-10-15 14:32:14 -04:00
if ( resetPressed and not resetStillPressed ) {
2022-10-06 22:49:08 -04:00
if ( cursorPosition = = 0 ) {
if ( strobeSync = = 1 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] ) ;
} else if ( strobeSync = = 2 ) {
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] + " * " ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 1 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 1 ) {
if ( strobeSync = = 2 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] ) ;
} else if ( strobeSync = = 3 ) {
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] + " * " ) ;
} else {
configLCDUpdate ( 2 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 2 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 2 ) {
if ( strobeSync = = 3 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] ) ;
} else if ( strobeSync = = 4 ) {
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] + " * " ) ;
} else {
configLCDUpdate ( 3 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 3 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 3 ) {
if ( strobeSync = = 4 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] ) ;
} else if ( strobeSync = = 5 ) {
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] + " * " ) ;
} else {
configLCDUpdate ( 4 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 4 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] ) ;
2022-10-06 22:49:08 -04:00
}
} else if ( cursorPosition = = 4 ) {
if ( strobeSync = = 0 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] ) ;
} else if ( strobeSync = = 1 ) {
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] + " * " ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 0 , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
}
2022-10-15 14:32:14 -04:00
} else if ( silencePressed and not silenceStillPressed ) {
2022-10-06 22:49:08 -04:00
configPage = 3 ; //change screen to facp settings
2022-10-15 14:32:14 -04:00
configLCDUpdate ( 5 , ( String ) mainSettingsFireAlarmSettings [ 5 ] , ( String ) mainSettingsFireAlarmSettings [ 6 ] + useTwoWire , false , true ) ;
} else if ( drillPressed and not drillStillPressed ) {
2022-10-06 22:49:08 -04:00
EEPROM . write ( 29 , cursorPosition ) ; //write strobe sync settings
EEPROM . commit ( ) ;
if ( cursorPosition = = 4 ) {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ cursorPosition ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ 0 ] ) ;
2022-10-06 22:49:08 -04:00
} else {
2022-10-15 14:32:14 -04:00
configLCDUpdate ( cursorPosition , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ cursorPosition ] + " * " , ( String ) mainSettingsFireAlarmSettingsStrobeSync [ cursorPosition + 1 ] ) ;
2022-10-06 22:49:08 -04:00
}
strobeSync = EEPROM . read ( 29 ) ; //store the new strobe sync settings
}
}
//----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > STROBE SYNC
2022-09-19 20:46:43 -04:00
2022-09-30 23:02:37 -04:00
// ---------------------------------------------------------------------------- CONFIG SCREEN REDRAW
if ( configTop ! = currentConfigTop or configBottom ! = currentConfigBottom ) { //figure out if the screen *really* needs to be re-drawn
2022-07-04 18:07:36 -04:00
lcd . clear ( ) ;
2022-09-30 23:02:37 -04:00
lcd . setCursor ( 0 , 0 ) ; //RENDER TOP OF CONFIG WINDOW
2022-09-25 13:24:30 -04:00
if ( configPage ! = - 1 ) {
2022-09-30 23:02:37 -04:00
if ( configTop . indexOf ( " * " ) > 0 ) { //Replace any "*" with a check mark
configTop . replace ( " * " , " " ) ;
2022-09-30 19:07:30 -04:00
lcd . print ( " ] " + configTop ) ;
lcd . write ( byte ( 1 ) ) ;
2022-09-27 22:31:38 -04:00
2022-09-30 23:02:37 -04:00
} else if ( configTop . indexOf ( " $ " ) > 0 ) { //Replace any "$" with an X icon
configTop . replace ( " $ " , " " ) ;
2022-09-27 22:31:38 -04:00
lcd . print ( " ] " + configTop ) ;
2022-09-30 19:07:30 -04:00
lcd . write ( byte ( 2 ) ) ;
} else {
lcd . print ( " ] " + configTop ) ;
}
2022-09-25 13:24:30 -04:00
} else {
lcd . print ( configTop ) ;
}
2022-09-30 23:02:37 -04:00
lcd . setCursor ( 0 , 1 ) ; //RENDER BOTTOM OF CONFIG WINDOW
if ( configBottom . indexOf ( " * " ) > 0 ) { //Replace any "*" with a check mark
2022-09-30 19:07:30 -04:00
configBottom . replace ( " * " , " " ) ;
lcd . print ( configBottom ) ;
lcd . write ( byte ( 1 ) ) ;
2022-09-30 23:02:37 -04:00
} else if ( configBottom . indexOf ( " $ " ) > 0 ) { //Replace any "$" with an X icon
2022-09-30 19:07:30 -04:00
configBottom . replace ( " $ " , " " ) ;
lcd . print ( configBottom ) ;
lcd . write ( byte ( 2 ) ) ;
} else {
lcd . print ( configBottom ) ;
}
2022-07-04 18:07:36 -04:00
currentConfigTop = configTop ;
currentConfigBottom = configBottom ;
if ( configPage = = 10 ) {
lcd . setCursor ( cursorPosition , 1 ) ;
}
}
2022-09-30 23:02:37 -04:00
// ---------------------------------------------------------------------------- CONFIG SCREEN REDRAW
2022-07-04 18:07:36 -04:00
2022-09-30 23:02:37 -04:00
// --------- UPDATE BUTTON VARIABLES
2022-10-15 14:32:14 -04:00
if ( digitalRead ( resetButtonPin ) ) { //RESET BUTTON
2022-07-04 18:07:36 -04:00
resetStillPressed = true ;
}
2022-10-15 14:32:14 -04:00
if ( digitalRead ( silenceButtonPin ) ) { //SILENCE BUTTON
2022-07-04 18:07:36 -04:00
silenceStillPressed = true ;
}
2022-10-15 14:32:14 -04:00
if ( digitalRead ( drillButtonPin ) ) { //DRILL BUTTON
2022-07-04 18:07:36 -04:00
drillStillPressed = true ;
}
2022-09-30 23:02:37 -04:00
// --------- UPDATE BUTTON VARIABLES
2022-07-04 18:07:36 -04:00
}
2022-09-25 23:54:40 -04:00
void lcdBacklight ( ) {
2022-07-04 18:07:36 -04:00
if ( lcdTimeout ! = 0 ) {
2022-10-15 14:32:14 -04:00
if ( lcdTimeout < = lcdTimeoutTimer and backlightOn ) {
2022-07-04 18:07:36 -04:00
lcd . noBacklight ( ) ;
backlightOn = false ;
2022-10-15 14:32:14 -04:00
} else if ( backlightOn ) {
2022-07-04 18:07:36 -04:00
lcdTimeoutTimer + + ;
}
2022-10-15 14:32:14 -04:00
if ( drillPressed or silencePressed or resetPressed or fullAlarm or trouble or ( panelUnlocked and keyRequired ) or smokeDetectorCurrentlyInVerification ) {
2022-07-04 18:07:36 -04:00
lcdTimeoutTimer = 0 ;
2022-10-15 14:32:14 -04:00
if ( not backlightOn ) {
2022-09-19 20:46:43 -04:00
lcd . backlight ( ) ;
}
2022-07-04 18:07:36 -04:00
backlightOn = true ;
}
}
2022-09-25 23:54:40 -04:00
}
2022-10-02 22:28:59 -04:00
void smokeDetector ( ) {
2022-10-03 23:05:16 -04:00
if ( smokeDetectorTimer > = smokeDetectorTimeout ) { //wait until the configured smoke timeout time has elapsed
smokeDetectorOn ( true ) ; //re-enable the smoke relay
if ( smokeDetectorPostRestartTimer > = smokeDetectorPostRestartVerificationTime ) { //wait for 120 seconds, during this time, smokeDetectorCurrentlyInVerification will be true, so any activating device will cause a full alarm
smokeDetectorCurrentlyInVerification = false ; //stop smoke detector verification, causing the smoke detectors to require double activation again
currentScreen = - 1 ; //update screen
digitalWrite ( alarmLed , LOW ) ; //disable LED
2022-10-02 22:28:59 -04:00
smokeDetectorTimer = 0 ;
} else {
smokeDetectorPostRestartTimer + + ;
}
} else {
smokeDetectorTimer + + ;
}
}
2022-10-03 23:05:16 -04:00
void failsafe ( ) { //--------------------------------------------- FAILSAFE MODE IN CASE PANEL CANT BOOT NORMALLY
2022-10-15 13:52:08 -04:00
if ( ( analogRead ( zone1Pin ) = = 0 or analogRead ( zone2Pin ) = = 0 ) and not fullAlarm ) {
2022-10-03 23:05:16 -04:00
fullAlarm = true ;
silenced = false ;
digitalWrite ( alarmLed , HIGH ) ;
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( hornRelay , HIGH ) ;
digitalWrite ( strobeRelay , HIGH ) ;
} else {
digitalWrite ( hornRelay , LOW ) ;
digitalWrite ( strobeRelay , LOW ) ;
}
2022-10-03 23:05:16 -04:00
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " FAILSAFE MODE " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " FIRE ALARM " ) ;
}
2022-10-15 14:32:14 -04:00
if ( digitalRead ( silenceButtonPin ) and not silenced and fullAlarm ) {
2022-10-03 23:05:16 -04:00
silenced = true ;
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( hornRelay , LOW ) ;
digitalWrite ( strobeRelay , LOW ) ;
} else {
digitalWrite ( hornRelay , HIGH ) ;
digitalWrite ( strobeRelay , HIGH ) ;
}
2022-10-03 23:05:16 -04:00
digitalWrite ( alarmLed , LOW ) ;
lcd . clear ( ) ;
lcd . setCursor ( 0 , 0 ) ;
lcd . print ( " FAILSAFE MODE " ) ;
lcd . setCursor ( 0 , 1 ) ;
lcd . print ( " SILENCED " ) ;
}
2022-10-15 14:32:14 -04:00
if ( digitalRead ( resetButtonPin ) ) {
2023-03-25 23:51:21 -04:00
if ( invertRelay ) {
digitalWrite ( smokeDetectorRelay , LOW ) ;
digitalWrite ( hornRelay , LOW ) ;
digitalWrite ( strobeRelay , LOW ) ;
} else {
digitalWrite ( smokeDetectorRelay , HIGH ) ;
digitalWrite ( hornRelay , HIGH ) ;
digitalWrite ( strobeRelay , HIGH ) ;
}
2022-10-03 23:05:16 -04:00
digitalWrite ( silenceLed , LOW ) ;
digitalWrite ( alarmLed , LOW ) ;
digitalWrite ( readyLed , LOW ) ;
ESP . restart ( ) ;
}
if ( troubleLedTimer > = 2000 ) {
2022-10-08 22:18:30 -04:00
if ( digitalRead ( readyLed ) ) {
2022-10-03 23:05:16 -04:00
digitalWrite ( readyLed , LOW ) ;
} else {
digitalWrite ( readyLed , HIGH ) ;
}
troubleLedTimer = 0 ;
} else {
troubleLedTimer + + ;
}
}
2022-09-25 23:54:40 -04:00
void loop ( ) {
2023-03-23 11:16:04 -04:00
systemClock = millis ( ) ; //-------------------------------------------------- SYSTEM CLOCK
2022-09-27 22:31:38 -04:00
if ( systemClock - lastPulse > = 1 ) {
2023-03-23 11:16:04 -04:00
if ( not failsafeMode ) { //execute the loop only if the panel is not in failsafe mode
2022-10-03 23:05:16 -04:00
lcdBacklight ( ) ; //------------------------------------------------------ CHECK LCD BACKLIGHT
2022-09-25 13:24:30 -04:00
2022-10-03 23:05:16 -04:00
checkDevices ( ) ; //------------------------------------------------------ CHECK ACTIVATING DEVICES
troubleCheck ( ) ; //------------------------------------------------------ TROUBLE CHECK
2022-09-27 22:31:38 -04:00
2022-10-03 23:05:16 -04:00
alarm ( ) ; //------------------------------------------------------------- ALARM CODEWHEEL
2022-09-27 22:31:38 -04:00
2022-10-15 13:52:08 -04:00
if ( smokeDetectorCurrentlyInVerification and not fullAlarm ) { //if a smoke detector is in verification, execute this function
2022-10-03 23:05:16 -04:00
smokeDetector ( ) ;
}
2022-10-02 22:28:59 -04:00
2022-10-03 23:05:16 -04:00
if ( keyCheckTimer > = 100 ) {
checkKey ( ) ; //---------------------------------------------------------- CHECK KEY
keyCheckTimer = 0 ;
} else {
keyCheckTimer + + ;
}
if ( buttonCheckTimer > = 20 ) {
2022-10-08 22:18:30 -04:00
if ( not inConfigMenu ) {
2022-10-15 13:52:08 -04:00
if ( ( panelUnlocked and keyRequired ) or ( not keyRequired ) ) {
2022-10-03 23:05:16 -04:00
checkButtons ( ) ; //check if certain buttons are pressed
2022-10-15 14:32:14 -04:00
} else if ( keylessSilence and fullAlarm and not silenced ) {
if ( digitalRead ( silenceButtonPin ) ) {
2022-10-03 23:05:16 -04:00
digitalWrite ( silenceLed , HIGH ) ;
digitalWrite ( alarmLed , LOW ) ;
digitalWrite ( readyLed , LOW ) ;
horn = false ;
2022-10-15 14:32:14 -04:00
if ( not audibleSilence ) {
2022-10-03 23:05:16 -04:00
strobe = false ;
}
silenced = true ;
noTone ( ) ;
2022-09-30 23:02:37 -04:00
}
}
2022-10-03 23:05:16 -04:00
lcdUpdate ( ) ; //------------------------------------------------------ UPDATE LCD DISPLAY
2022-09-30 23:02:37 -04:00
2022-10-08 22:18:30 -04:00
} else if ( inConfigMenu ) {
2022-10-15 13:52:08 -04:00
if ( ( panelUnlocked and keyRequired ) or ( not panelUnlocked and not keyRequired ) ) {
2022-10-03 23:05:16 -04:00
config ( ) ;
}
2022-09-27 22:31:38 -04:00
}
2022-10-03 23:05:16 -04:00
buttonCheckTimer = 0 ;
} else {
buttonCheckTimer + + ;
2022-09-27 22:31:38 -04:00
}
2023-03-23 11:16:04 -04:00
} else { //failsafe mode
2022-10-03 23:05:16 -04:00
failsafe ( ) ;
2022-09-27 22:31:38 -04:00
}
lastPulse = millis ( ) ; //update last pulse
2022-07-04 18:07:36 -04:00
}
2022-10-15 13:52:08 -04:00
}