From 929b958d627cf28a61a09b79e0298a341b16504b Mon Sep 17 00:00:00 2001 From: Lexzach <53662039+Lexzach@users.noreply.github.com> Date: Fri, 30 Sep 2022 19:07:30 -0400 Subject: [PATCH] fixed bugs --- .directory | 8 ++ facp/.gitignore => .gitignore | 0 facp/.directory | 8 ++ facp/include/README | 39 ------- facp/lib/README | 46 --------- facp/src/main.cpp | 188 +++++++++++++++++++++++++++------- 6 files changed, 167 insertions(+), 122 deletions(-) create mode 100644 .directory rename facp/.gitignore => .gitignore (100%) create mode 100644 facp/.directory delete mode 100644 facp/include/README delete mode 100644 facp/lib/README diff --git a/.directory b/.directory new file mode 100644 index 0000000..b58f602 --- /dev/null +++ b/.directory @@ -0,0 +1,8 @@ +[Dolphin] +SortRole=type +Timestamp=2022,9,30,19,7,6.6530000000000005 +Version=4 +VisibleRoles=Icons_text,Icons_size,Icons_duration + +[Settings] +HiddenFilesShown=true diff --git a/facp/.gitignore b/.gitignore similarity index 100% rename from facp/.gitignore rename to .gitignore diff --git a/facp/.directory b/facp/.directory new file mode 100644 index 0000000..811f996 --- /dev/null +++ b/facp/.directory @@ -0,0 +1,8 @@ +[Dolphin] +SortRole=type +Timestamp=2022,9,30,19,6,56.829 +Version=4 +VisibleRoles=Icons_text,Icons_size,Icons_duration + +[Settings] +HiddenFilesShown=true diff --git a/facp/include/README b/facp/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/facp/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/facp/lib/README b/facp/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/facp/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/facp/src/main.cpp b/facp/src/main.cpp index 433c0b8..7469733 100644 --- a/facp/src/main.cpp +++ b/facp/src/main.cpp @@ -29,7 +29,6 @@ bool silenceStillPressed = false; //make sure that presses don't count more than bool drillStillPressed = false; bool updateScreen = false; //updating the screen in the config menu bool possibleAlarm = false; //panel receieved 0 from pull station ciruit and is now investigating -bool definiteAlarm = false; //panel has investigated and determined that it was not a fluke bool walkTest = false; //is the system in walk test bool silentWalkTest = false; bool backlightOn = true; @@ -59,6 +58,8 @@ String configTop; //configuration menu strings for lcd String configBottom; String currentConfigTop; //configuration menu strings for current lcd display String currentConfigBottom; + +//---------------------------------------- CUSTOM LCD CHARACTERS byte lock[] = { //lock icon B01110, B10001, @@ -81,6 +82,18 @@ byte check[] = { //check mark icon B00000 }; +byte cross[] = { //x mark + B00000, + B11011, + B01110, + B00100, + B01110, + B11011, + B00000, + B00000 +}; +//---------------------------------------- CUSTOM LCD CHARACTERS + //Default EEPROM values in the case that the EEPROM fails to load bool keyRequired = false; //determine if key switch is required to operate buttons bool isVerification = true; //is verification turned on @@ -91,7 +104,7 @@ bool audibleSilence = true; int smokeDetectorTimeout = 5; //how long should smoke detector pre-alarm wait before cancelling the pre-alarm int firstStageTime = 1; //time in minutes that first stage should last int codeWheel = 0; //which alarm pattern to use, code-3 default -int verificationTime = 2500; +float verificationTime = 2500; //int resistorLenience = 0; DEPRECATED int panelHomescreen = 0; int lcdTimeout = 0; @@ -227,7 +240,9 @@ void setup() { lcd.init(); //initialize LCD lcd.createChar(0, lock); //create the lock character lcd.createChar(1, check); //create the lock character + lcd.createChar(2, cross); //create the lock character + lcd.backlight(); //----------------------------------------------------------------------------- EEPROM RESET BUTTONS @@ -451,7 +466,7 @@ void checkKey(){ } } -//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES +//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!] void checkDevices(){ if (debug == true){ Serial.println(analogRead(zone1Pin)); @@ -461,8 +476,8 @@ void checkDevices(){ possibleAlarm = true; } - if (possibleAlarm == true and horn != true and strobe != true and silenced==false and isVerification == true){ //verification code - if (verification >= verificationTime){ + if (possibleAlarm == true and horn != true and strobe != true and silenced==false){ + if (verification >= verificationTime or isVerification == false){ if (analogRead(zone1Pin) == 0 or analogRead(zone2Pin) == 0){ if (analogRead(zone1Pin) == 0 and analogRead(zone2Pin) == 0){ zoneAlarm = 3; //both @@ -471,7 +486,7 @@ void checkDevices(){ } else { zoneAlarm = 1; //z1 } - definiteAlarm = true; + activateNAC(); possibleAlarm = false; verification = 0; } else { @@ -489,10 +504,16 @@ void checkDevices(){ smokeDetectorOn(false); strobeOn(true); delay(500); - hornOn(true); + digitalWrite(alarmLed, HIGH); + if (silentWalkTest == false){ + hornOn(true); + } delay(500); - hornOn(false); + if (silentWalkTest == false){ + hornOn(false); + } delay(3000); + digitalWrite(alarmLed, LOW); strobeOn(false); smokeDetectorOn(true); } else if (analogRead(zone2Pin) == 0){ @@ -500,13 +521,23 @@ void checkDevices(){ smokeDetectorOn(false); strobeOn(true); delay(500); - hornOn(true); + digitalWrite(alarmLed, HIGH); + if (silentWalkTest == false){ + hornOn(true); + } delay(500); - hornOn(false); + if (silentWalkTest == false){ + hornOn(false); + } delay(500); - hornOn(true); + if (silentWalkTest == false){ + hornOn(true); + } delay(500); - hornOn(false); + if (silentWalkTest == false){ + hornOn(false); + } + digitalWrite(alarmLed, LOW); delay(3000); strobeOn(false); smokeDetectorOn(true); @@ -515,19 +546,18 @@ void checkDevices(){ } } - if (definiteAlarm == true or (isVerification == false and analogRead(zone1Pin) == 0 and horn != true and silenced==false)){ //activate the horns and strobes after verification - activateNAC(); - definiteAlarm = false; - } else if ((analogRead(zone1Pin) == 4095 or analogRead(zone2Pin) == 4095) and eolResistor == true and troubleTimer >= 200) { - trouble = true; - troubleType=1; - } else if ((analogRead(zone1Pin) == 4095 or analogRead(zone2Pin) == 4095) and eolResistor == true and troubleTimer <= 200){ - troubleTimer++; + if ((analogRead(zone1Pin) == 4095 or analogRead(zone2Pin) == 4095) and eolResistor == true) { + if (troubleTimer >= 10){ + trouble = true; + troubleType=1; + } else { + troubleTimer++; + } } else { troubleTimer = 0; } } -//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES +//----------------------------------------------------------------------------- CHECK ACTIVATION DEVICES [!THIS CODE MUST WORK!] //----------------------------------------------------------------------------- TROUBLE RESPONSE @@ -862,8 +892,8 @@ 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 - char *mainSettingsFireAlarmSettings[] = {"Coding","Verification","Pre-Alarm","Audible Sil.: ","Keyless Sil."}; //menu 3 - char *mainSettingsVerificationSettings[] = {"Verification: ","Verif. Time"}; //menu 4 + char *mainSettingsFireAlarmSettings[] = {"Coding","Verification","Pre-Alarm","Audible Sil.:","Keyless Sil."}; //menu 3 + char *mainSettingsVerificationSettings[] = {"Verification:","V.Time:"}; //menu 4 char *mainSettingsFireAlarmSettingsCoding[] = {"Temporal Three","Marchtime","4-4","Continuous","California","Slow Marchtime"}; //menu 5 char *mainSettingsFireAlarmSettingsPreAlarmSettings[] = {"Pre-Alarm: ","stage 1: ","Detector PreAlrm"}; //menu 6 char *mainSettingsFireAlarmSettingsPreAlarmSettingsSmokeDetectorPreAlarmSettings[] = {"Det. PreAlrm: ","Det. 1st stge: ","Det. Tmeout: "}; //menu 7 @@ -947,6 +977,9 @@ void config(){ configTop = (String)main[0]; configBottom = (String)main[1]; strobe = false; + smokeDetectorOn(true); + digitalWrite(readyLed,HIGH); + readyLedStatus = true; } else if (drillPressed == true and drillStillPressed == false){ if (cursorPosition == 0){ walkTest = true; @@ -967,9 +1000,15 @@ void config(){ } else if (cursorPosition == 2) { if (strobe == false){ strobe = true; + smokeDetectorOn(false); //prevent (specifically cheap IR) smoke detectors from tripping from the strobe + digitalWrite(readyLed,LOW); + readyLedStatus = false; configTop = (String)mainTesting[2]+" *"; } else { strobe = false; + smokeDetectorOn(true); + digitalWrite(readyLed,HIGH); + readyLedStatus = true; configTop = (String)mainTesting[2]; } } @@ -1019,10 +1058,14 @@ void config(){ cursorPosition = 2; configTop = (String)mainSettingsFireAlarmSettings[2]; configBottom = (String)mainSettingsFireAlarmSettings[3]+audibleSilence; + configBottom.replace("1","*"); + configBottom.replace("0","$"); } else if (cursorPosition == 2) { cursorPosition = 3; configTop = (String)mainSettingsFireAlarmSettings[3]+audibleSilence; configBottom = (String)mainSettingsFireAlarmSettings[0]; + configTop.replace("1","*"); + configTop.replace("0","$"); } else if (cursorPosition == 3) { cursorPosition = 0; configTop = (String)mainSettingsFireAlarmSettings[0]; @@ -1051,8 +1094,14 @@ void config(){ } else if (cursorPosition == 1) { configPage = 4; cursorPosition = 0; - configTop = (String)mainSettingsVerificationSettings[0]+isVerification; - configBottom = (String)mainSettingsVerificationSettings[1]; + configTop = (String)mainSettingsVerificationSettings[0] + isVerification; + if (isVerification == false){ + configBottom = (String)mainSettingsVerificationSettings[1] + "off"; + } else { + configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; + } + configTop.replace("1","*"); + configTop.replace("0","$"); } else if (cursorPosition == 2) { configPage = 6; cursorPosition = 0; @@ -1069,6 +1118,8 @@ void config(){ EEPROM.commit(); configTop = (String)mainSettingsFireAlarmSettings[3]+audibleSilence; configBottom = (String)mainSettingsFireAlarmSettings[0]; + configTop.replace("1","*"); + configTop.replace("0","$"); } } //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM @@ -1173,7 +1224,7 @@ void config(){ configPage = 12; cursorPosition = 0; configTop = (String)mainPanelSettingsAbout[0]; - configBottom = (String)mainPanelSettingsAbout[1]+firmwareRev; + configBottom = (String)mainPanelSettingsAbout[1] + firmwareRev; } } //----------------------------------------------------------------------------- SETTINGS > PANEL @@ -1357,12 +1408,24 @@ void config(){ if (resetPressed == true and resetStillPressed == false){ if (cursorPosition == 0){ cursorPosition = 1; - configTop = (String)mainSettingsVerificationSettings[1]; + if (isVerification == false){ + configTop = (String)mainSettingsVerificationSettings[1] + "off"; + } else { + configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; + } configBottom = (String)mainSettingsVerificationSettings[0]+isVerification; + configBottom.replace("1","*"); + configBottom.replace("0","$"); } else if (cursorPosition == 1) { cursorPosition = 0; configTop = (String)mainSettingsVerificationSettings[0]+isVerification; - configBottom = (String)mainSettingsVerificationSettings[1]; + if (isVerification == false){ + configBottom = (String)mainSettingsVerificationSettings[1] + "off"; + } else { + configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; + } + configTop.replace("1","*"); + configTop.replace("0","$"); } } else if (silencePressed == true and silenceStillPressed == false){ configPage = 3; @@ -1380,9 +1443,42 @@ void config(){ } EEPROM.commit(); configTop = (String)mainSettingsVerificationSettings[0]+isVerification; - configBottom = (String)mainSettingsVerificationSettings[1]; - } else if (cursorPosition == 1) { - //computer do shit + if (isVerification == false){ + configBottom = (String)mainSettingsVerificationSettings[1] + "off"; + } else { + configBottom = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; + } + configTop.replace("1","*"); + configTop.replace("0","$"); + } else if (cursorPosition == 1 and isVerification == true) { + 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(); + if (isVerification == false){ + configTop = (String)mainSettingsVerificationSettings[1] + "off"; + } else { + configTop = (String)mainSettingsVerificationSettings[1] + (verificationTime/1000)+"s"; + } + configBottom = (String)mainSettingsVerificationSettings[0]+isVerification; + configBottom.replace("1","*"); + configBottom.replace("0","$"); } } //----------------------------------------------------------------------------- SETTINGS > FIRE ALARM > VERIFICATION @@ -1468,17 +1564,35 @@ void config(){ lcd.clear(); lcd.setCursor(0,0); if (configPage != -1){ - // if (configTop.indexOf("*")>0){ //replace any "*" with nothing, then add a check mark to the end - // lcd.print("]" + configTop.replace("*","")); - - // } else { //---------------------------------------------------------------------------------------- experimental code for check mark + if (configTop.indexOf("*")>0){ //RENDER TOP OF CONFIG WINDOW + configTop.replace("*",""); lcd.print("]" + configTop); - //} + lcd.write(byte(1)); + + } else if (configTop.indexOf("$")>0) { + configTop.replace("$",""); + lcd.print("]" + configTop); + lcd.write(byte(2)); + } else { + lcd.print("]" + configTop); + } } else { lcd.print(configTop); } lcd.setCursor(0,1); - lcd.print(configBottom); + if (configBottom.indexOf("*")>0){ //RENDER BOTTOM OF CONFIG WINDOW + configBottom.replace("*",""); + lcd.print(configBottom); + lcd.write(byte(1)); + + } else if (configBottom.indexOf("$")>0) { + configBottom.replace("$",""); + lcd.print(configBottom); + lcd.write(byte(2)); + + } else { + lcd.print(configBottom); + } currentConfigTop = configTop; currentConfigBottom = configBottom; if (configPage == 10){