Advertisement
Guest User

My Alarm Code

a guest
Jun 27th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 87.67 KB | None | 0 0
  1. //************************************************************************************
  2. //**  
  3. //**  File name:     G:\My Stuff\Electronic Ideas\4 Zone Alarm.c
  4. //**  Generated by:  Flowcode v4.2.3.58
  5. //**  Date:          Monday, June 27, 2011 11:14:22
  6. //**  Licence:       Professional
  7. //**  Registered to: 20ACM8
  8. //**  
  9. //**  
  10. //**  http://www.matrixmultimedia.com
  11. //************************************************************************************
  12.  
  13.  
  14. #define MX_PIC
  15.  
  16. //Defines for microcontroller
  17. #define P16F877
  18. #define MX_EE
  19. #define MX_EE_SIZE 256
  20. #define MX_SPI
  21. #define MX_SPI_C
  22. #define MX_SPI_SDI 4
  23. #define MX_SPI_SDO 5
  24. #define MX_SPI_SCK 3
  25. #define MX_UART
  26. #define MX_UART_C
  27. #define MX_UART_TX 6
  28. #define MX_UART_RX 7
  29. #define MX_I2C
  30. #define MX_MI2C
  31. #define MX_I2C_C
  32. #define MX_I2C_SDA 4
  33. #define MX_I2C_SCL 3
  34. #define MX_PWM
  35. #define MX_PWM_CNT 2
  36. #define MX_PWM_TRIS1 trisc
  37. #define MX_PWM_1 2
  38. #define MX_PWM_TRIS2 trisc
  39. #define MX_PWM_2 1
  40.  
  41. //Functions
  42. #define MX_CLK_SPEED 10000000
  43. #ifdef _BOOSTC
  44. #include <system.h>
  45. #endif
  46. #ifdef HI_TECH_C
  47. #include <pic.h>
  48. #endif
  49.  
  50. //Configuration data
  51. #ifdef _BOOSTC
  52. #pragma DATA 0x2007, 0x3eba
  53. #endif
  54. #ifdef HI_TECH_C
  55. __CONFIG(0x3eba);
  56. #endif
  57.  
  58. //Internal functions
  59. #include "C:\Flowcode V4\FCD\internals.h"
  60.  
  61. //Macro function declarations
  62. void FCM_ZoneCheck();
  63. void FCM_Alarm(char FCL_ALARMZONE);
  64. void FCM_EnterCode();
  65. void FCM_CompareCode();
  66. void FCM_WrongCode();
  67. void FCM_Rightcode();
  68. void FCM_PreAlarm();
  69. void FCM_FirstStartup();
  70.  
  71.  
  72. //Variable declarations
  73. short FCV_COMPARECODE;
  74. char FCV_CANCELSWITCH;
  75. char FCV_ZONE1;
  76. char FCV_SYSTEMARMED;
  77. short FCV_SETCODE;
  78. char FCV_INVALIDCOUNT;
  79. char FCV_ZONE2;
  80. char FCV_ALARMZONE;
  81. char FCV_DIGITCOUNT;
  82. char FCV_KEYPADNUMBER;
  83. char FCV_ZONE3;
  84. char FCV_DIGITSET;
  85. char FCV_ZONE4;
  86. char FCV_DIGIT1;
  87. char FCV_DIGIT2;
  88. char FCV_ARMSWITCH;
  89. char FCV_DIGIT3;
  90. char FCV_FIRSTRUN;
  91. char FCV_INVALIDCODE;
  92. char FCV_DIGIT4;
  93. char FCV_DISPLAY;
  94. short FCV_COUNT;
  95. short FCV_CODE;
  96. char FCV_ALARMACTIVE;
  97.  
  98.  
  99. //Defines:
  100.  
  101. /**** Macro Substitutions ****
  102. portb = D1 Port
  103. trisb = D1 Data Direction
  104. portb = D2 Port
  105. trisb = D2 Data Direction
  106. portb = D3 Port
  107. trisb = D3 Data Direction
  108. portb = D4 Port
  109. trisb = D4 Data Direction
  110. portb = RS Port
  111. trisb = RS Data Direction
  112. portb = E Port
  113. trisb = E Data Direction
  114. 2 = Data 1_Pin
  115. 3 = Data 2 Pin
  116. 4 = Data 3 Pin
  117. 5 = Data 4 Pin
  118. 0 = RS Pin
  119. 1 = Enable Pin
  120. LCD_590668 = Unique Component Reference Number
  121. 2 = Row Count
  122. 16 = Column Count
  123. ******************************/
  124.  
  125.     //component connections
  126.     #define LCD_590668_PORT0    portb
  127.     #define LCD_590668_TRIS0    trisb
  128.     #define LCD_590668_PORT1    portb
  129.     #define LCD_590668_TRIS1    trisb
  130.     #define LCD_590668_PORT2    portb
  131.     #define LCD_590668_TRIS2    trisb
  132.     #define LCD_590668_PORT3    portb
  133.     #define LCD_590668_TRIS3    trisb
  134.     #define LCD_590668_PORT4    portb
  135.     #define LCD_590668_TRIS4    trisb
  136.     #define LCD_590668_PORT5    portb
  137.     #define LCD_590668_TRIS5    trisb
  138.     #define LCD_590668_BIT0     2
  139.     #define LCD_590668_BIT1     3
  140.     #define LCD_590668_BIT2     4
  141.     #define LCD_590668_BIT3     5
  142.     #define LCD_590668_RS       0
  143.     #define LCD_590668_E        1
  144.     #define LCD_590668_ROWCNT   2
  145.     #define LCD_590668_COLCNT   16
  146.  
  147.     #ifdef _BOOSTC
  148.       #define LCD_590668_DELAY   delay_10us(10)
  149.     #endif
  150.     #ifdef _C2C_
  151.       #define LCD_590668_DELAY   delay_us(100)
  152.     #endif
  153.     #ifdef HI_TECH_C
  154.       #define LCD_590668_DELAY   __delay_us(120)
  155.     #endif
  156.     #ifndef LCD_590668_DELAY
  157.       #define LCD_590668_DELAY   delay_us(100)
  158.     #endif
  159.  
  160.  
  161.  
  162.  
  163. //LCDDisplay0: //Macro function declarations
  164.  
  165. void FCD_LCDDisplay0_RawSend(char in, char mask);
  166. void FCD_LCDDisplay0_Start();
  167. void FCD_LCDDisplay0_Clear();
  168. void FCD_LCDDisplay0_PrintASCII(char Character);
  169. void FCD_LCDDisplay0_Command(char in);
  170. void FCD_LCDDisplay0_Cursor(char x, char y);
  171. void FCD_LCDDisplay0_PrintNumber(short Number);
  172. void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String);
  173. void FCD_LCDDisplay0_ScrollDisplay(char Direction, char Num_Positions);
  174. void FCD_LCDDisplay0_ClearLine(char Line);
  175. void FCD_LCDDisplay0_RAM_Write(char nIdx, char d0, char d1, char d2, char d3, char d4, char d5, char d6, char d7);
  176. //Defines:
  177.  
  178. /**** Macro Substitutions ****
  179. {'1','4','7','*','2','5','8','0','3','6','9','#'} = Key List (Numbers)
  180. {1,4,7,10,2,5,8,0,3,6,9,11} = Key List (Characters)
  181. trisd = Row Data Direction Register
  182. portd = Row Port Register
  183. 3 = Number Of Columns
  184. 4 = Number Of Rows
  185. trisd = Column Data Direction Register
  186. portd = Column Port Register
  187. 1 = Column 1 mask
  188. 2 = Column 2 mask
  189. 4 = Column 3 mask
  190. 8 = Column 4 mask
  191. 8 = Row 1 mask
  192. 16 = Row 2 mask
  193. 32 = Row 3 mask
  194. 64 = Row 4 mask
  195. ******************************/
  196.  
  197.  
  198.  
  199.  
  200. //KeyPad0: //Macro function declarations
  201.  
  202. char FCD_KeyPad0_GetKeypadNumber();
  203. char FCD_KeyPad0_GetKeypadAscii();
  204. //Defines:
  205.  
  206. /**** Macro Substitutions ****
  207. ******************************/
  208.  
  209.  
  210.  
  211.  
  212. //EEPROM0: //Macro function declarations
  213.  
  214. char FCD_EEPROM0_EEPROMRead(short addr);
  215. void FCD_EEPROM0_WriteEEPROM(short addr, char data);
  216.  
  217.  
  218.  
  219. //LCDDisplay0: //Macro implementations
  220.  
  221.  
  222. void FCD_LCDDisplay0_RawSend(char in, char mask)
  223. {
  224.         unsigned char pt;
  225.  
  226.         clear_bit(LCD_590668_PORT0, LCD_590668_BIT0);
  227.         clear_bit(LCD_590668_PORT1, LCD_590668_BIT1);
  228.         clear_bit(LCD_590668_PORT2, LCD_590668_BIT2);
  229.         clear_bit(LCD_590668_PORT3, LCD_590668_BIT3);
  230.         clear_bit(LCD_590668_PORT4, LCD_590668_RS);
  231.         clear_bit(LCD_590668_PORT5, LCD_590668_E);
  232.         pt = ((in >> 4) & 0x0f);
  233.         if (pt & 0x01)
  234.             set_bit(LCD_590668_PORT0, LCD_590668_BIT0);
  235.         if (pt & 0x02)
  236.             set_bit(LCD_590668_PORT1, LCD_590668_BIT1);
  237.         if (pt & 0x04)
  238.             set_bit(LCD_590668_PORT2, LCD_590668_BIT2);
  239.         if (pt & 0x08)
  240.             set_bit(LCD_590668_PORT3, LCD_590668_BIT3);
  241.         if (mask)
  242.             set_bit(LCD_590668_PORT4, LCD_590668_RS);
  243.         LCD_590668_DELAY;
  244.         set_bit (LCD_590668_PORT5, LCD_590668_E);
  245.         LCD_590668_DELAY;
  246.         clear_bit (LCD_590668_PORT5, LCD_590668_E);
  247.         pt = (in & 0x0f);
  248.         LCD_590668_DELAY;
  249.         clear_bit(LCD_590668_PORT0, LCD_590668_BIT0);
  250.         clear_bit(LCD_590668_PORT1, LCD_590668_BIT1);
  251.         clear_bit(LCD_590668_PORT2, LCD_590668_BIT2);
  252.         clear_bit(LCD_590668_PORT3, LCD_590668_BIT3);
  253.         clear_bit(LCD_590668_PORT4, LCD_590668_RS);
  254.         clear_bit(LCD_590668_PORT5, LCD_590668_E);
  255.         if (pt & 0x01)
  256.             set_bit(LCD_590668_PORT0, LCD_590668_BIT0);
  257.         if (pt & 0x02)
  258.             set_bit(LCD_590668_PORT1, LCD_590668_BIT1);
  259.         if (pt & 0x04)
  260.             set_bit(LCD_590668_PORT2, LCD_590668_BIT2);
  261.         if (pt & 0x08)
  262.             set_bit(LCD_590668_PORT3, LCD_590668_BIT3);
  263.         if (mask)
  264.             set_bit(LCD_590668_PORT4, LCD_590668_RS);
  265.         LCD_590668_DELAY;
  266.         set_bit (LCD_590668_PORT5, LCD_590668_E);
  267.         LCD_590668_DELAY;
  268.         clear_bit (LCD_590668_PORT5, LCD_590668_E);
  269.         LCD_590668_DELAY;
  270. }
  271.  
  272. void FCD_LCDDisplay0_Start()
  273. {
  274.    
  275.         clear_bit(LCD_590668_TRIS0, LCD_590668_BIT0);
  276.         clear_bit(LCD_590668_TRIS1, LCD_590668_BIT1);
  277.         clear_bit(LCD_590668_TRIS2, LCD_590668_BIT2);
  278.         clear_bit(LCD_590668_TRIS3, LCD_590668_BIT3);
  279.         clear_bit(LCD_590668_TRIS4, LCD_590668_RS);
  280.         clear_bit(LCD_590668_TRIS5, LCD_590668_E);
  281.  
  282.         Wdt_Delay_Ms(12);
  283.  
  284.         FCD_LCDDisplay0_RawSend(0x33, 0);
  285.         Wdt_Delay_Ms(2);
  286.         FCD_LCDDisplay0_RawSend(0x33, 0);
  287.         Wdt_Delay_Ms(2);
  288.         FCD_LCDDisplay0_RawSend(0x32, 0);
  289.         Wdt_Delay_Ms(2);
  290.         FCD_LCDDisplay0_RawSend(0x2c, 0);
  291.         Wdt_Delay_Ms(2);
  292.         FCD_LCDDisplay0_RawSend(0x06, 0);
  293.         Wdt_Delay_Ms(2);
  294.         FCD_LCDDisplay0_RawSend(0x0c, 0);
  295.         Wdt_Delay_Ms(2);
  296.  
  297.         //clear the display
  298.         FCD_LCDDisplay0_RawSend(0x01, 0);
  299.         Wdt_Delay_Ms(2);
  300.         FCD_LCDDisplay0_RawSend(0x02, 0);
  301.         Wdt_Delay_Ms(2);
  302.  
  303. }
  304.  
  305. void FCD_LCDDisplay0_Clear()
  306. {
  307.    
  308.         FCD_LCDDisplay0_RawSend(0x01, 0);
  309.         Wdt_Delay_Ms(2);
  310.         FCD_LCDDisplay0_RawSend(0x02, 0);
  311.         Wdt_Delay_Ms(2);
  312.  
  313. }
  314.  
  315. void FCD_LCDDisplay0_PrintASCII(char Character)
  316. {
  317.    
  318.         FCD_LCDDisplay0_RawSend(Character, 0x10);
  319.  
  320. }
  321.  
  322. void FCD_LCDDisplay0_Command(char in)
  323. {
  324.    
  325.         FCD_LCDDisplay0_RawSend(in, 0);
  326.         Wdt_Delay_Ms(2);
  327.  
  328. }
  329.  
  330. void FCD_LCDDisplay0_Cursor(char x, char y)
  331. {
  332.    
  333.       #if (LCD_590668_ROWCNT == 1)
  334.         y=0x80;
  335.       #endif
  336.  
  337.       #if (LCD_590668_ROWCNT == 2)
  338.         if (y==0)
  339.             y=0x80;
  340.         else
  341.             y=0xc0;
  342.       #endif
  343.  
  344.       #if (LCD_590668_ROWCNT == 4)
  345.         if (y==0)
  346.             y=0x80;
  347.         else if (y==1)
  348.             y=0xc0;
  349.  
  350.         #if (LCD_590668_COLCNT == 16)
  351.             else if (y==2)
  352.                 y=0x90;
  353.             else
  354.                 y=0xd0;
  355.         #endif
  356.  
  357.         #if (LCD_590668_COLCNT == 20)
  358.             else if (y==2)
  359.                 y=0x94;
  360.             else
  361.                 y=0xd4;
  362.         #endif
  363.       #endif
  364.  
  365.         FCD_LCDDisplay0_RawSend(y+x, 0);
  366.         Wdt_Delay_Ms(2);
  367.  
  368. }
  369.  
  370. void FCD_LCDDisplay0_PrintNumber(short Number)
  371. {
  372.    
  373.         short tmp_int;
  374.         char tmp_byte;
  375.         if (Number < 0)
  376.         {
  377.             FCD_LCDDisplay0_RawSend('-', 0x10);
  378.             Number = 0 - Number;
  379.         }
  380.  
  381.         tmp_int = Number;
  382.         if (Number >= 10000)
  383.         {
  384.             tmp_byte = tmp_int / 10000;
  385.             FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
  386.  
  387.             while (tmp_byte > 0)
  388.             {
  389.                 tmp_int = tmp_int - 10000;
  390.                 tmp_byte--;
  391.             }
  392.         }
  393.         if (Number >= 1000)
  394.         {
  395.             tmp_byte = tmp_int / 1000;
  396.             FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
  397.  
  398.             while (tmp_byte > 0)
  399.             {
  400.                 tmp_int = tmp_int - 1000;
  401.                 tmp_byte--;
  402.             }
  403.         }
  404.         if (Number >= 100)
  405.         {
  406.             tmp_byte = tmp_int / 100;
  407.             FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
  408.  
  409.             while (tmp_byte > 0)
  410.             {
  411.                 tmp_int = tmp_int - 100;
  412.                 tmp_byte--;
  413.             }
  414.         }
  415.         if (Number >= 10)
  416.         {
  417.             tmp_byte = tmp_int / 10;
  418.             FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
  419.  
  420.             while (tmp_byte > 0)
  421.             {
  422.                 tmp_int = tmp_int - 10;
  423.                 tmp_byte--;
  424.             }
  425.         }
  426.         FCD_LCDDisplay0_RawSend('0' + tmp_int, 0x10);
  427.  
  428. }
  429.  
  430. void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String)
  431. {
  432.    
  433.         char idx = 0;
  434.  
  435.         for (idx=0; idx<MSZ_String; idx++)
  436.         {
  437.             #ifdef _BOOSTC
  438.                 if (String[idx] == 0)
  439.                 {
  440.                     break;
  441.                 }
  442.                 FCD_LCDDisplay0_RawSend(String[idx], 0x10);
  443.             #endif
  444.  
  445.             #ifdef HI_TECH_C
  446.                 if (*String == 0)
  447.                 {
  448.                     break;
  449.                 }
  450.                 FCD_LCDDisplay0_RawSend(*String, 0x10);
  451.                 String++;
  452.             #endif
  453.         }
  454.  
  455. }
  456.  
  457. void FCD_LCDDisplay0_ScrollDisplay(char Direction, char Num_Positions)
  458. {
  459.    
  460.         char cmd = 0;
  461.         char count;
  462.  
  463.         //Choose the direction
  464.         switch (Direction)
  465.         {
  466.             case 0:
  467.             case 'l':
  468.             case 'L':
  469.  
  470.                 cmd = 0x18;
  471.                 break;
  472.  
  473.             case 1:
  474.             case 'r':
  475.             case 'R':
  476.  
  477.                 cmd = 0x1C;
  478.                 break;
  479.  
  480.             default:
  481.                 break;
  482.         }
  483.  
  484.         //If direction accepted then scroll the specified amount
  485.         if (cmd)
  486.         {
  487.             for (count = 0; count < Num_Positions; count++)
  488.                 FCD_LCDDisplay0_Command(cmd);
  489.         }
  490.  
  491. }
  492.  
  493. void FCD_LCDDisplay0_ClearLine(char Line)
  494. {
  495.    
  496.         char count;
  497.         char rowcount;
  498.  
  499.         //Define number of columns per line
  500.         #if (LCD_590668_ROWCNT == 1)
  501.             rowcount=80;
  502.         #endif
  503.  
  504.         #if (LCD_590668_ROWCNT == 2)
  505.             rowcount=40;
  506.         #endif
  507.  
  508.         #if (LCD_590668_ROWCNT == 4)
  509.             #if (LCD_590668_COLCNT == 16)
  510.                 rowcount=16;
  511.             #endif
  512.             #if (LCD_590668_COLCNT == 20)
  513.                 rowcount=20;
  514.             #endif
  515.         #endif
  516.  
  517.         //Start at beginning of the line
  518.         FCD_LCDDisplay0_Cursor (0, Line);
  519.  
  520.         //Send out spaces to clear line
  521.         for (count = 0; count < rowcount; count++)
  522.             FCD_LCDDisplay0_RawSend(' ', 0x10);
  523.  
  524.         //Move back to the beginning of the line.
  525.         FCD_LCDDisplay0_Cursor (0, Line);
  526.  
  527. }
  528.  
  529. void FCD_LCDDisplay0_RAM_Write(char nIdx, char d0, char d1, char d2, char d3, char d4, char d5, char d6, char d7)
  530. {
  531.        //set CGRAM address
  532.        FCD_LCDDisplay0_RawSend(64 + (nIdx << 3), 0);
  533.        delay_ms(2);
  534.  
  535.        //write CGRAM data
  536.        FCD_LCDDisplay0_RawSend(d0, 0x10);
  537.        FCD_LCDDisplay0_RawSend(d1, 0x10);
  538.        FCD_LCDDisplay0_RawSend(d2, 0x10);
  539.        FCD_LCDDisplay0_RawSend(d3, 0x10);
  540.        FCD_LCDDisplay0_RawSend(d4, 0x10);
  541.        FCD_LCDDisplay0_RawSend(d5, 0x10);
  542.        FCD_LCDDisplay0_RawSend(d6, 0x10);
  543.        FCD_LCDDisplay0_RawSend(d7, 0x10);
  544.  
  545.        //Clear the display
  546.        FCD_LCDDisplay0_RawSend(0x01, 0);
  547.        delay_ms(2);
  548.        FCD_LCDDisplay0_RawSend(0x02, 0);
  549.        delay_ms(2);
  550. }
  551.  
  552.  
  553.  
  554. //KeyPad0: //Macro implementations
  555.  
  556.  
  557. char FCD_KeyPad0_GetKeypadNumber()
  558. {
  559.         //get matrices for rows and columns
  560.         #if (3 == 1)
  561.             #define KPAD_COL_MTX {1}
  562.             #define KPAD_COL_MASK (1)
  563.         #endif
  564.         #if (3 == 2)
  565.             #define KPAD_COL_MTX {1,2}
  566.             #define KPAD_COL_MASK (1|2)
  567.         #endif
  568.         #if (3 == 3)
  569.             #define KPAD_COL_MTX {1,2,4}
  570.             #define KPAD_COL_MASK (1|2|4)
  571.         #endif
  572.         #if (3 == 4)
  573.             #define KPAD_COL_MTX {1,2,4,8}
  574.             #define KPAD_COL_MASK (1|2|4|8)
  575.         #endif
  576.         #if (4 == 1)
  577.             #define KPAD_ROW_MTX {8}
  578.             #define KPAD_ROW_MASK (8)
  579.         #endif
  580.         #if (4 == 2)
  581.             #define KPAD_ROW_MTX {8,16}
  582.             #define KPAD_ROW_MASK (8|16)
  583.         #endif
  584.         #if (4 == 3)
  585.             #define KPAD_ROW_MTX {8,16,32}
  586.             #define KPAD_ROW_MASK (8|16|32)
  587.         #endif
  588.         #if (4 == 4)
  589.             #define KPAD_ROW_MTX {8,16,32,64}
  590.             #define KPAD_ROW_MASK (8|16|32|64)
  591.         #endif
  592.  
  593.         #ifndef KPAD_COL_MTX
  594.             #pragma error Keypad error: column count is not 1-4
  595.         #endif
  596.         #ifndef KPAD_ROW_MTX
  597.             #pragma error Keypad error: row count is not 1-4
  598.         #endif
  599.  
  600.         //store keys and pin connections into a constant array
  601.         #ifdef _BOOSTC
  602.             rom char* mtxKeysAsNumbers = {1,4,7,10,2,5,8,0,3,6,9,11};
  603.             rom char* mtxCols = KPAD_COL_MTX;
  604.             rom char* mtxRows = KPAD_ROW_MTX;
  605.         #endif
  606.         #ifdef HI_TECH_C
  607.             const char mtxKeysAsNumbers[] = {1,4,7,10,2,5,8,0,3,6,9,11};
  608.             const char mtxCols[] = KPAD_COL_MTX;
  609.             const char mtxRows[] = KPAD_ROW_MTX;
  610.         #endif
  611.  
  612.         //set up i/o of port (rows = inputs, columns = outputs)
  613.         trisd = (trisd | KPAD_ROW_MASK);
  614.         trisd = (trisd & ~KPAD_COL_MASK);       //BR
  615.  
  616.         char iCol;
  617.         char iRow;
  618.         char c_ip;
  619.         for (iCol=0; iCol<3; iCol++)
  620.         {
  621.             //output the appropriate column high
  622.             portd = mtxCols[iCol];
  623.  
  624.             //delay
  625.             delay_us(10);
  626.  
  627.             //read the port
  628.             c_ip = portd;
  629.  
  630.             //check for a hit
  631.             for (iRow=0; iRow<4; iRow++)
  632.             {
  633.                 if ((c_ip & mtxRows[iRow]) != 0)
  634.                 {
  635.                     //found it!
  636.                     goto found_key;
  637.                 }
  638.             }
  639.         }
  640.  
  641.         //if it gets here, it has not been found...
  642.         return (255);
  643.  
  644.       found_key:
  645.         return (mtxKeysAsNumbers[(iCol*4) + iRow]);
  646.  
  647.       #undef KPAD_COL_MTX
  648.       #undef KPAD_ROW_MTX
  649.       #undef KPAD_COL_MASK
  650.       #undef KPAD_ROW_MASK
  651.  
  652. }
  653.  
  654. char FCD_KeyPad0_GetKeypadAscii()
  655. {
  656.         //get matrices for rows and columns
  657.         #if (3 == 1)
  658.             #define KPAD_COL_MTX {1}
  659.             #define KPAD_COL_MASK (1)
  660.         #endif
  661.         #if (3 == 2)
  662.             #define KPAD_COL_MTX {1,2}
  663.             #define KPAD_COL_MASK (1|2)
  664.         #endif
  665.         #if (3 == 3)
  666.             #define KPAD_COL_MTX {1,2,4}
  667.             #define KPAD_COL_MASK (1|2|4)
  668.         #endif
  669.         #if (3 == 4)
  670.             #define KPAD_COL_MTX {1,2,4,8}
  671.             #define KPAD_COL_MASK (1|2|4|8)
  672.         #endif
  673.         #if (4 == 1)
  674.             #define KPAD_ROW_MTX {8}
  675.             #define KPAD_ROW_MASK (8)
  676.         #endif
  677.         #if (4 == 2)
  678.             #define KPAD_ROW_MTX {8,16}
  679.             #define KPAD_ROW_MASK (8|16)
  680.         #endif
  681.         #if (4 == 3)
  682.             #define KPAD_ROW_MTX {8,16,32}
  683.             #define KPAD_ROW_MASK (8|16|32)
  684.         #endif
  685.         #if (4 == 4)
  686.             #define KPAD_ROW_MTX {8,16,32,64}
  687.             #define KPAD_ROW_MASK (8|16|32|64)
  688.         #endif
  689.  
  690.         #ifndef KPAD_COL_MTX
  691.             #pragma error Keypad error: column count is not 1-4
  692.         #endif
  693.         #ifndef KPAD_ROW_MTX
  694.             #pragma error Keypad error: row count is not 1-4
  695.         #endif
  696.  
  697.         //store keys and pin connections into a constant array
  698.         #ifdef _BOOSTC
  699.             rom char* mtxKeysAsChars = {'1','4','7','*','2','5','8','0','3','6','9','#'};
  700.             rom char* mtxCols = KPAD_COL_MTX;
  701.             rom char* mtxRows = KPAD_ROW_MTX;
  702.         #endif
  703.         #ifdef HI_TECH_C
  704.             const char mtxKeysAsChars[] = {'1','4','7','*','2','5','8','0','3','6','9','#'};
  705.             const char mtxCols[] = KPAD_COL_MTX;
  706.             const char mtxRows[] = KPAD_ROW_MTX;
  707.         #endif
  708.  
  709.         //set up i/o of port (rows = inputs, columns = outputs)
  710.         trisd = (trisd | KPAD_ROW_MASK);
  711.         trisd = (trisd & ~KPAD_COL_MASK);
  712.  
  713.         char iCol;
  714.         char iRow;
  715.         char c_ip;
  716.         for (iCol=0; iCol<3; iCol++)
  717.         {
  718.             //output the appropriate column high
  719.             portd = mtxCols[iCol];
  720.  
  721.             //delay
  722.             delay_us(10);
  723.  
  724.             //read the port
  725.             c_ip = portd;
  726.  
  727.             //check for a hit
  728.             for (iRow=0; iRow<4; iRow++)
  729.             {
  730.                 if ((c_ip & mtxRows[iRow]) != 0)
  731.                 {
  732.                     //found it!
  733.                     goto found_key;
  734.                 }
  735.             }
  736.         }
  737.  
  738.         //if it gets here, it has not been found...
  739.         return (255);
  740.  
  741.       found_key:
  742.         return (mtxKeysAsChars[(iCol*4) + iRow]);
  743.  
  744.       #undef KPAD_COL_MTX
  745.       #undef KPAD_ROW_MTX
  746.       #undef KPAD_COL_MASK
  747.       #undef KPAD_ROW_MASK
  748.  
  749. }
  750.  
  751.  
  752.  
  753. //EEPROM0: //Macro implementations
  754.  
  755.  
  756. char FCD_EEPROM0_EEPROMRead(short addr)
  757. {
  758.         char data = 0;
  759.  
  760.         #ifdef _BOOSTC
  761.             #ifdef MX_EE
  762.                 #ifndef MX_EEADR
  763.                     #ifdef EEADR
  764.                         #define MX_EEADR eeadr
  765.                     #endif
  766.                     #ifdef EEADRL
  767.                         #define MX_EEADR eeadrl
  768.                     #endif
  769.                 #endif
  770.                 #ifndef MX_EEDATA
  771.                     #ifdef EEDATA
  772.                         #define MX_EEDATA eedata
  773.                     #endif
  774.                     #ifdef EEDATAL
  775.                         #define MX_EEDATA eedatal
  776.                     #endif
  777.                     #ifdef EEDATL
  778.                         #define MX_EEDATA eedatl
  779.                     #endif
  780.                 #endif
  781.  
  782.                 #ifndef MX_EEADR    //Catch Error
  783.                       #pragma error EEPROM error - MX_EEADR not set
  784.                 #endif
  785.  
  786.                 #ifndef MX_EEDATA
  787.                       #pragma error EEPROM error - MX_EEDATA not set
  788.                 #endif
  789.  
  790.                 MX_EEADR = addr & 0xff;
  791.                 #if (MX_EE_SIZE > 256)
  792.                     eeadrh = (addr & 0xff00) >> 8;
  793.                 #endif
  794.                 #ifdef MX_EE_TYPE2
  795.                     clear_bit(eecon1, EEPGD);
  796.                 #endif
  797.                 #ifdef MX_EE_TYPE3
  798.                     clear_bit(eecon1, EEPGD);
  799.                     clear_bit(eecon1, CFGS);
  800.                 #endif
  801.                 set_bit(eecon1, RD);
  802.                 data = MX_EEDATA;
  803.             #else
  804.                 #ifdef MX_EE_TYPE67X
  805.                     #pragma error "FlowCode does not support EEPROM for this device"
  806.                 #else
  807.                     #ifdef MX_EE_TYPE62X
  808.                         #pragma error "FlowCode does not support EEPROM for this device"
  809.                     #else
  810.                         #pragma error "Chip does not have EEPROM memory"
  811.                     #endif
  812.                 #endif
  813.             #endif
  814.         #endif
  815.         #ifdef HI_TECH_C
  816.             data = eeprom_read(addr);
  817.         #endif
  818.  
  819.         return (data);
  820.  
  821. }
  822.  
  823. void FCD_EEPROM0_WriteEEPROM(short addr, char data)
  824. {
  825.         #ifdef _BOOSTC
  826.             #ifdef MX_EE
  827.                 #ifndef MX_EEADR
  828.                     #ifdef EEADR
  829.                         #define MX_EEADR eeadr
  830.                     #endif
  831.                     #ifdef EEADRL
  832.                         #define MX_EEADR eeadrl
  833.                     #endif
  834.                 #endif
  835.                 #ifndef MX_EEDATA
  836.                     #ifdef EEDATA
  837.                         #define MX_EEDATA eedata
  838.                     #endif
  839.                     #ifdef EEDATAL
  840.                         #define MX_EEDATA eedatal
  841.                     #endif
  842.                 #endif
  843.  
  844.                 #ifndef MX_EEADR    //Catch Error
  845.                       #pragma error EEPROM error - MX_EEADR not set
  846.                 #endif
  847.  
  848.                 #ifndef MX_EEDATA
  849.                       #pragma error EEPROM error - MX_EEDATA not set
  850.                 #endif
  851.  
  852.                 char bInterruptsEnabled;
  853.  
  854.                 //wait for previous EE writes to complete...
  855.                 while (test_bit(eecon1, WR));
  856.  
  857.                 MX_EEADR = addr & 0xff;
  858.                 #if (MX_EE_SIZE > 256)
  859.                     eeadrh = (addr & 0xff00) >> 8;
  860.                 #endif
  861.                 MX_EEDATA = data;
  862.                 #ifdef MX_EE_TYPE2
  863.                     clear_bit(eecon1, EEPGD);
  864.                 #endif
  865.                 #ifdef MX_EE_TYPE3
  866.                     clear_bit(eecon1, EEPGD);
  867.                     clear_bit(eecon1, CFGS);
  868.                 #endif
  869.                 set_bit(eecon1, WREN);
  870.                 bInterruptsEnabled = test_bit(intcon, GIE);
  871.                 clear_bit(intcon, GIE);         //Disable Interrupts
  872.  
  873.                 eecon2 = 0x55;
  874.                 eecon2 = 0xAA;
  875.                 set_bit(eecon1, WR);
  876.                 while (test_bit(eecon1, WR));   //wait for EE write to complete...
  877.  
  878.                 if (bInterruptsEnabled)
  879.                     set_bit(intcon, GIE);       //Re-enable Interrupts
  880.                 clear_bit(eecon1, WREN);
  881.             #else
  882.                 #ifdef MX_EE_TYPE67X
  883.                     #pragma error FlowCode does not support EEPROM for this device
  884.                 #else
  885.                     #ifdef MX_EE_TYPE62X
  886.                         #pragma error FlowCode does not support EEPROM for this device
  887.                     #else
  888.                         #pragma error Chip does not have EEPROM memory
  889.                     #endif
  890.                 #endif
  891.             #endif
  892.         #endif
  893.         #ifdef HI_TECH_C
  894.             eeprom_write(addr, data);
  895.         #endif
  896.  
  897. }
  898.  
  899. //Macro implementations
  900.  
  901. void FCM_ZoneCheck()
  902. {
  903.     //Checks the status of the 4 zones.
  904.    
  905.     //Connection Point
  906.     //Connection Point: [B]: B
  907. FCC_ZoneCheck_B:
  908. ;
  909.  
  910.  
  911.     //Loop
  912.     //Loop: While 1
  913.     while (1)
  914.     {
  915.         //Input
  916.         //Input: A0 -> ArmSwitch
  917.         trisa = trisa | 0x01;
  918.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  919.  
  920.  
  921.         //Decision
  922.         //Decision: ArmSwitch > 0?
  923.         if (FCV_ARMSWITCH > 0)
  924.         {
  925.             //Call Macro
  926.             //Call Macro: EnterCode
  927.             FCM_EnterCode();
  928.  
  929.  
  930.             //Call Macro
  931.             //Call Macro: CompareCode
  932.             FCM_CompareCode();
  933.  
  934.  
  935.             //Decision
  936.             //Decision: InvalidCode = 1?
  937.             if (FCV_INVALIDCODE == 1)
  938.             {
  939.                 //Call Component Macro
  940.                 //Call Component Macro: LCDDisplay(0)::Clear
  941.                 FCD_LCDDisplay0_Clear();
  942.  
  943.  
  944.                 //Call Component Macro
  945.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  946.                 FCD_LCDDisplay0_Cursor(2, 0);
  947.  
  948.  
  949.                 //Call Component Macro
  950.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  951.                 FCD_LCDDisplay0_PrintASCII('S');
  952.                 FCD_LCDDisplay0_PrintASCII('y');
  953.                 FCD_LCDDisplay0_PrintASCII('s');
  954.                 FCD_LCDDisplay0_PrintASCII('t');
  955.                 FCD_LCDDisplay0_PrintASCII('e');
  956.                 FCD_LCDDisplay0_PrintASCII('m');
  957.                 FCD_LCDDisplay0_PrintASCII(' ');
  958.                 FCD_LCDDisplay0_PrintASCII('A');
  959.                 FCD_LCDDisplay0_PrintASCII('r');
  960.                 FCD_LCDDisplay0_PrintASCII('m');
  961.                 FCD_LCDDisplay0_PrintASCII('e');
  962.                 FCD_LCDDisplay0_PrintASCII('d');
  963.  
  964.  
  965.                 //Calculation
  966.                 //Calculation:
  967.                 //  InvalidCode = 0
  968.                 FCV_INVALIDCODE = 0;
  969.                
  970.  
  971.                 //Goto Connection Point
  972.                 //Goto Connection Point: [B]: B
  973.                 goto FCC_ZoneCheck_B;
  974.  
  975.  
  976.             }
  977.  
  978.  
  979.             //Calculation
  980.             //Calculation:
  981.             //  SystemArmed = 0
  982.             FCV_SYSTEMARMED = 0;
  983.            
  984.  
  985.             //Call Component Macro
  986.             //Call Component Macro: LCDDisplay(0)::Clear
  987.             FCD_LCDDisplay0_Clear();
  988.  
  989.  
  990.             //Call Component Macro
  991.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  992.             FCD_LCDDisplay0_PrintASCII('S');
  993.             FCD_LCDDisplay0_PrintASCII('y');
  994.             FCD_LCDDisplay0_PrintASCII('s');
  995.             FCD_LCDDisplay0_PrintASCII('t');
  996.             FCD_LCDDisplay0_PrintASCII('e');
  997.             FCD_LCDDisplay0_PrintASCII('m');
  998.             FCD_LCDDisplay0_PrintASCII(' ');
  999.             FCD_LCDDisplay0_PrintASCII('D');
  1000.             FCD_LCDDisplay0_PrintASCII('i');
  1001.             FCD_LCDDisplay0_PrintASCII('s');
  1002.             FCD_LCDDisplay0_PrintASCII('a');
  1003.             FCD_LCDDisplay0_PrintASCII('r');
  1004.             FCD_LCDDisplay0_PrintASCII('m');
  1005.             FCD_LCDDisplay0_PrintASCII('e');
  1006.             FCD_LCDDisplay0_PrintASCII('d');
  1007.  
  1008.  
  1009.             //Goto Connection Point
  1010.             //Goto Connection Point: [A]: A
  1011.             goto FCC_ZoneCheck_A;
  1012.  
  1013.  
  1014.         } else {
  1015.             //Input
  1016.             //Input: A5 -> Zone1
  1017.             trisa = trisa | 0x20;
  1018.             FCV_ZONE1 = ((porta & 0x20) == 0x20);
  1019.  
  1020.  
  1021.             //Decision
  1022.             //Decision: Zone1 < 1?
  1023.             if (FCV_ZONE1 < 1)
  1024.             {
  1025.                 //Calculation
  1026.                 //Calculation:
  1027.                 //  AlarmZone = 1
  1028.                 FCV_ALARMZONE = 1;
  1029.                
  1030.  
  1031.                 //Call Macro
  1032.                 //Call Macro: Alarm(AlarmZone)
  1033.                 FCM_Alarm(FCV_ALARMZONE);
  1034.  
  1035.  
  1036.                 //Decision
  1037.                 //Decision: AlarmActive > 0?
  1038.                 if (FCV_ALARMACTIVE > 0)
  1039.                 {
  1040.                 } else {
  1041.                     //Goto Connection Point
  1042.                     //Goto Connection Point: [A]: A
  1043.                     goto FCC_ZoneCheck_A;
  1044.  
  1045.  
  1046.                 }
  1047.  
  1048.  
  1049.             }
  1050.  
  1051.  
  1052.         }
  1053.  
  1054.  
  1055.         //Input
  1056.         //Input: A0 -> ArmSwitch
  1057.         trisa = trisa | 0x01;
  1058.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  1059.  
  1060.  
  1061.         //Decision
  1062.         //Decision: ArmSwitch > 0?
  1063.         if (FCV_ARMSWITCH > 0)
  1064.         {
  1065.             //Call Macro
  1066.             //Call Macro: EnterCode
  1067.             FCM_EnterCode();
  1068.  
  1069.  
  1070.             //Call Macro
  1071.             //Call Macro: CompareCode
  1072.             FCM_CompareCode();
  1073.  
  1074.  
  1075.             //Decision
  1076.             //Decision: InvalidCode = 1?
  1077.             if (FCV_INVALIDCODE == 1)
  1078.             {
  1079.                 //Call Component Macro
  1080.                 //Call Component Macro: LCDDisplay(0)::Clear
  1081.                 FCD_LCDDisplay0_Clear();
  1082.  
  1083.  
  1084.                 //Call Component Macro
  1085.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  1086.                 FCD_LCDDisplay0_Cursor(2, 0);
  1087.  
  1088.  
  1089.                 //Call Component Macro
  1090.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  1091.                 FCD_LCDDisplay0_PrintASCII('S');
  1092.                 FCD_LCDDisplay0_PrintASCII('y');
  1093.                 FCD_LCDDisplay0_PrintASCII('s');
  1094.                 FCD_LCDDisplay0_PrintASCII('t');
  1095.                 FCD_LCDDisplay0_PrintASCII('e');
  1096.                 FCD_LCDDisplay0_PrintASCII('m');
  1097.                 FCD_LCDDisplay0_PrintASCII(' ');
  1098.                 FCD_LCDDisplay0_PrintASCII('A');
  1099.                 FCD_LCDDisplay0_PrintASCII('r');
  1100.                 FCD_LCDDisplay0_PrintASCII('m');
  1101.                 FCD_LCDDisplay0_PrintASCII('e');
  1102.                 FCD_LCDDisplay0_PrintASCII('d');
  1103.  
  1104.  
  1105.                 //Calculation
  1106.                 //Calculation:
  1107.                 //  InvalidCode = 0
  1108.                 FCV_INVALIDCODE = 0;
  1109.                
  1110.  
  1111.                 //Goto Connection Point
  1112.                 //Goto Connection Point: [B]: B
  1113.                 goto FCC_ZoneCheck_B;
  1114.  
  1115.  
  1116.             }
  1117.  
  1118.  
  1119.             //Calculation
  1120.             //Calculation:
  1121.             //  SystemArmed = 0
  1122.             FCV_SYSTEMARMED = 0;
  1123.            
  1124.  
  1125.             //Call Component Macro
  1126.             //Call Component Macro: LCDDisplay(0)::Clear
  1127.             FCD_LCDDisplay0_Clear();
  1128.  
  1129.  
  1130.             //Call Component Macro
  1131.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  1132.             FCD_LCDDisplay0_PrintASCII('S');
  1133.             FCD_LCDDisplay0_PrintASCII('y');
  1134.             FCD_LCDDisplay0_PrintASCII('s');
  1135.             FCD_LCDDisplay0_PrintASCII('t');
  1136.             FCD_LCDDisplay0_PrintASCII('e');
  1137.             FCD_LCDDisplay0_PrintASCII('m');
  1138.             FCD_LCDDisplay0_PrintASCII(' ');
  1139.             FCD_LCDDisplay0_PrintASCII('D');
  1140.             FCD_LCDDisplay0_PrintASCII('i');
  1141.             FCD_LCDDisplay0_PrintASCII('s');
  1142.             FCD_LCDDisplay0_PrintASCII('a');
  1143.             FCD_LCDDisplay0_PrintASCII('r');
  1144.             FCD_LCDDisplay0_PrintASCII('m');
  1145.             FCD_LCDDisplay0_PrintASCII('e');
  1146.             FCD_LCDDisplay0_PrintASCII('d');
  1147.  
  1148.  
  1149.             //Goto Connection Point
  1150.             //Goto Connection Point: [A]: A
  1151.             goto FCC_ZoneCheck_A;
  1152.  
  1153.  
  1154.         } else {
  1155.             //Input
  1156.             //Input: A4 -> Zone2
  1157.             trisa = trisa | 0x10;
  1158.             FCV_ZONE2 = ((porta & 0x10) == 0x10);
  1159.  
  1160.  
  1161.             //Decision
  1162.             //Decision: Zone2 < 1?
  1163.             if (FCV_ZONE2 < 1)
  1164.             {
  1165.                 //Calculation
  1166.                 //Calculation:
  1167.                 //  AlarmZone = 2
  1168.                 FCV_ALARMZONE = 2;
  1169.                
  1170.  
  1171.                 //Call Macro
  1172.                 //Call Macro: Alarm(AlarmZone)
  1173.                 FCM_Alarm(FCV_ALARMZONE);
  1174.  
  1175.  
  1176.                 //Decision
  1177.                 //Decision: AlarmActive > 0?
  1178.                 if (FCV_ALARMACTIVE > 0)
  1179.                 {
  1180.                 } else {
  1181.                     //Goto Connection Point
  1182.                     //Goto Connection Point: [A]: A
  1183.                     goto FCC_ZoneCheck_A;
  1184.  
  1185.  
  1186.                 }
  1187.  
  1188.  
  1189.             }
  1190.  
  1191.  
  1192.         }
  1193.  
  1194.  
  1195.         //Input
  1196.         //Input: A0 -> ArmSwitch
  1197.         trisa = trisa | 0x01;
  1198.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  1199.  
  1200.  
  1201.         //Decision
  1202.         //Decision: ArmSwitch > 0?
  1203.         if (FCV_ARMSWITCH > 0)
  1204.         {
  1205.             //Call Macro
  1206.             //Call Macro: EnterCode
  1207.             FCM_EnterCode();
  1208.  
  1209.  
  1210.             //Call Macro
  1211.             //Call Macro: CompareCode
  1212.             FCM_CompareCode();
  1213.  
  1214.  
  1215.             //Decision
  1216.             //Decision: InvalidCode = 1?
  1217.             if (FCV_INVALIDCODE == 1)
  1218.             {
  1219.                 //Call Component Macro
  1220.                 //Call Component Macro: LCDDisplay(0)::Clear
  1221.                 FCD_LCDDisplay0_Clear();
  1222.  
  1223.  
  1224.                 //Call Component Macro
  1225.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  1226.                 FCD_LCDDisplay0_Cursor(2, 0);
  1227.  
  1228.  
  1229.                 //Call Component Macro
  1230.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  1231.                 FCD_LCDDisplay0_PrintASCII('S');
  1232.                 FCD_LCDDisplay0_PrintASCII('y');
  1233.                 FCD_LCDDisplay0_PrintASCII('s');
  1234.                 FCD_LCDDisplay0_PrintASCII('t');
  1235.                 FCD_LCDDisplay0_PrintASCII('e');
  1236.                 FCD_LCDDisplay0_PrintASCII('m');
  1237.                 FCD_LCDDisplay0_PrintASCII(' ');
  1238.                 FCD_LCDDisplay0_PrintASCII('A');
  1239.                 FCD_LCDDisplay0_PrintASCII('r');
  1240.                 FCD_LCDDisplay0_PrintASCII('m');
  1241.                 FCD_LCDDisplay0_PrintASCII('e');
  1242.                 FCD_LCDDisplay0_PrintASCII('d');
  1243.  
  1244.  
  1245.                 //Calculation
  1246.                 //Calculation:
  1247.                 //  InvalidCode = 0
  1248.                 FCV_INVALIDCODE = 0;
  1249.                
  1250.  
  1251.                 //Goto Connection Point
  1252.                 //Goto Connection Point: [B]: B
  1253.                 goto FCC_ZoneCheck_B;
  1254.  
  1255.  
  1256.             }
  1257.  
  1258.  
  1259.             //Calculation
  1260.             //Calculation:
  1261.             //  SystemArmed = 0
  1262.             FCV_SYSTEMARMED = 0;
  1263.            
  1264.  
  1265.             //Call Component Macro
  1266.             //Call Component Macro: LCDDisplay(0)::Clear
  1267.             FCD_LCDDisplay0_Clear();
  1268.  
  1269.  
  1270.             //Call Component Macro
  1271.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  1272.             FCD_LCDDisplay0_PrintASCII('S');
  1273.             FCD_LCDDisplay0_PrintASCII('y');
  1274.             FCD_LCDDisplay0_PrintASCII('s');
  1275.             FCD_LCDDisplay0_PrintASCII('t');
  1276.             FCD_LCDDisplay0_PrintASCII('e');
  1277.             FCD_LCDDisplay0_PrintASCII('m');
  1278.             FCD_LCDDisplay0_PrintASCII(' ');
  1279.             FCD_LCDDisplay0_PrintASCII('D');
  1280.             FCD_LCDDisplay0_PrintASCII('i');
  1281.             FCD_LCDDisplay0_PrintASCII('s');
  1282.             FCD_LCDDisplay0_PrintASCII('a');
  1283.             FCD_LCDDisplay0_PrintASCII('r');
  1284.             FCD_LCDDisplay0_PrintASCII('m');
  1285.             FCD_LCDDisplay0_PrintASCII('e');
  1286.             FCD_LCDDisplay0_PrintASCII('d');
  1287.  
  1288.  
  1289.             //Goto Connection Point
  1290.             //Goto Connection Point: [A]: A
  1291.             goto FCC_ZoneCheck_A;
  1292.  
  1293.  
  1294.         } else {
  1295.             //Input
  1296.             //Input: A3 -> Zone3
  1297.             trisa = trisa | 0x08;
  1298.             FCV_ZONE3 = ((porta & 0x08) == 0x08);
  1299.  
  1300.  
  1301.             //Decision
  1302.             //Decision: Zone3 < 1?
  1303.             if (FCV_ZONE3 < 1)
  1304.             {
  1305.                 //Calculation
  1306.                 //Calculation:
  1307.                 //  AlarmZone = 3
  1308.                 FCV_ALARMZONE = 3;
  1309.                
  1310.  
  1311.                 //Call Macro
  1312.                 //Call Macro: Alarm(AlarmZone)
  1313.                 FCM_Alarm(FCV_ALARMZONE);
  1314.  
  1315.  
  1316.                 //Decision
  1317.                 //Decision: AlarmActive > 0?
  1318.                 if (FCV_ALARMACTIVE > 0)
  1319.                 {
  1320.                 } else {
  1321.                     //Goto Connection Point
  1322.                     //Goto Connection Point: [B]: B
  1323.                     goto FCC_ZoneCheck_B;
  1324.  
  1325.  
  1326.                 }
  1327.  
  1328.  
  1329.             }
  1330.  
  1331.  
  1332.         }
  1333.  
  1334.  
  1335.         //Input
  1336.         //Input: A0 -> ArmSwitch
  1337.         trisa = trisa | 0x01;
  1338.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  1339.  
  1340.  
  1341.         //Decision
  1342.         //Decision: ArmSwitch > 0?
  1343.         if (FCV_ARMSWITCH > 0)
  1344.         {
  1345.             //Call Macro
  1346.             //Call Macro: EnterCode
  1347.             FCM_EnterCode();
  1348.  
  1349.  
  1350.             //Call Macro
  1351.             //Call Macro: CompareCode
  1352.             FCM_CompareCode();
  1353.  
  1354.  
  1355.             //Decision
  1356.             //Decision: InvalidCode = 1?
  1357.             if (FCV_INVALIDCODE == 1)
  1358.             {
  1359.                 //Call Component Macro
  1360.                 //Call Component Macro: LCDDisplay(0)::Clear
  1361.                 FCD_LCDDisplay0_Clear();
  1362.  
  1363.  
  1364.                 //Call Component Macro
  1365.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  1366.                 FCD_LCDDisplay0_Cursor(2, 0);
  1367.  
  1368.  
  1369.                 //Call Component Macro
  1370.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  1371.                 FCD_LCDDisplay0_PrintASCII('S');
  1372.                 FCD_LCDDisplay0_PrintASCII('y');
  1373.                 FCD_LCDDisplay0_PrintASCII('s');
  1374.                 FCD_LCDDisplay0_PrintASCII('t');
  1375.                 FCD_LCDDisplay0_PrintASCII('e');
  1376.                 FCD_LCDDisplay0_PrintASCII('m');
  1377.                 FCD_LCDDisplay0_PrintASCII(' ');
  1378.                 FCD_LCDDisplay0_PrintASCII('A');
  1379.                 FCD_LCDDisplay0_PrintASCII('r');
  1380.                 FCD_LCDDisplay0_PrintASCII('m');
  1381.                 FCD_LCDDisplay0_PrintASCII('e');
  1382.                 FCD_LCDDisplay0_PrintASCII('d');
  1383.  
  1384.  
  1385.                 //Calculation
  1386.                 //Calculation:
  1387.                 //  InvalidCode = 0
  1388.                 FCV_INVALIDCODE = 0;
  1389.                
  1390.  
  1391.                 //Goto Connection Point
  1392.                 //Goto Connection Point: [B]: B
  1393.                 goto FCC_ZoneCheck_B;
  1394.  
  1395.  
  1396.             }
  1397.  
  1398.  
  1399.             //Calculation
  1400.             //Calculation:
  1401.             //  SystemArmed = 0
  1402.             FCV_SYSTEMARMED = 0;
  1403.            
  1404.  
  1405.             //Call Component Macro
  1406.             //Call Component Macro: LCDDisplay(0)::Clear
  1407.             FCD_LCDDisplay0_Clear();
  1408.  
  1409.  
  1410.             //Call Component Macro
  1411.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  1412.             FCD_LCDDisplay0_PrintASCII('S');
  1413.             FCD_LCDDisplay0_PrintASCII('y');
  1414.             FCD_LCDDisplay0_PrintASCII('s');
  1415.             FCD_LCDDisplay0_PrintASCII('t');
  1416.             FCD_LCDDisplay0_PrintASCII('e');
  1417.             FCD_LCDDisplay0_PrintASCII('m');
  1418.             FCD_LCDDisplay0_PrintASCII(' ');
  1419.             FCD_LCDDisplay0_PrintASCII('D');
  1420.             FCD_LCDDisplay0_PrintASCII('i');
  1421.             FCD_LCDDisplay0_PrintASCII('s');
  1422.             FCD_LCDDisplay0_PrintASCII('a');
  1423.             FCD_LCDDisplay0_PrintASCII('r');
  1424.             FCD_LCDDisplay0_PrintASCII('m');
  1425.             FCD_LCDDisplay0_PrintASCII('e');
  1426.             FCD_LCDDisplay0_PrintASCII('d');
  1427.  
  1428.  
  1429.             //Goto Connection Point
  1430.             //Goto Connection Point: [A]: A
  1431.             goto FCC_ZoneCheck_A;
  1432.  
  1433.  
  1434.         } else {
  1435.             //Input
  1436.             //Input: A2 -> Zone4
  1437.             trisa = trisa | 0x04;
  1438.             FCV_ZONE4 = ((porta & 0x04) == 0x04);
  1439.  
  1440.  
  1441.             //Decision
  1442.             //Decision: Zone4 < 1?
  1443.             if (FCV_ZONE4 < 1)
  1444.             {
  1445.                 //Calculation
  1446.                 //Calculation:
  1447.                 //  AlarmZone = 4
  1448.                 FCV_ALARMZONE = 4;
  1449.                
  1450.  
  1451.                 //Call Macro
  1452.                 //Call Macro: Alarm(AlarmZone)
  1453.                 FCM_Alarm(FCV_ALARMZONE);
  1454.  
  1455.  
  1456.                 //Decision
  1457.                 //Decision: SystemArmed > 0?
  1458.                 if (FCV_SYSTEMARMED > 0)
  1459.                 {
  1460.                 } else {
  1461.                     //Goto Connection Point
  1462.                     //Goto Connection Point: [A]: A
  1463.                     goto FCC_ZoneCheck_A;
  1464.  
  1465.  
  1466.                 }
  1467.  
  1468.  
  1469.             }
  1470.  
  1471.  
  1472.         }
  1473.  
  1474.  
  1475.     }
  1476.  
  1477.  
  1478.     //Connection Point
  1479.     //Connection Point: [A]: A
  1480. FCC_ZoneCheck_A:
  1481. ;
  1482.  
  1483.  
  1484. }
  1485.  
  1486. void FCM_Alarm(char FCL_ALARMZONE)
  1487. {
  1488.     //Activate Alarm alerts
  1489.    
  1490.     //Loop
  1491.     //Loop: While 1
  1492.     while (1)
  1493.     {
  1494.         //Connection Point
  1495.         //Connection Point: [A]: A
  1496. FCC_Alarm_A:
  1497. ;
  1498.  
  1499.  
  1500.         //Switch
  1501.         //Switch: AlarmZone?
  1502.         switch (FCV_ALARMZONE)
  1503.         {
  1504.             case 1:
  1505.             {
  1506.                 //Output
  1507.                 //Output: 1 -> C3
  1508.                 trisc = trisc & 0xf7;
  1509.                 if (1)
  1510.                     portc = (portc & 0xf7) | 0x08;
  1511.                 else
  1512.                     portc = portc & 0xf7;
  1513.  
  1514.  
  1515.                 //Decision
  1516.                 //Decision: AlarmActive > 0?
  1517.                 if (FCV_ALARMACTIVE > 0)
  1518.                 {
  1519.                 } else {
  1520.                     //Call Macro
  1521.                     //Call Macro: PreAlarm
  1522.                     FCM_PreAlarm();
  1523.  
  1524.  
  1525.                     //Decision
  1526.                     //Decision: AlarmZone = 0?
  1527.                     if (FCV_ALARMZONE == 0)
  1528.                     {
  1529.                         //Goto Connection Point
  1530.                         //Goto Connection Point: [B]: B
  1531.                         goto FCC_Alarm_B;
  1532.  
  1533.  
  1534.                     }
  1535.  
  1536.  
  1537.                 }
  1538.  
  1539.  
  1540.                 //Decision
  1541.                 //Decision: SystemArmed > 0?
  1542.                 if (FCV_SYSTEMARMED > 0)
  1543.                 {
  1544.                     //Call Component Macro
  1545.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  1546.                     FCD_LCDDisplay0_Cursor(1, 1);
  1547.  
  1548.  
  1549.                     //Call Component Macro
  1550.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 1")
  1551.                     FCD_LCDDisplay0_PrintASCII('A');
  1552.                     FCD_LCDDisplay0_PrintASCII('l');
  1553.                     FCD_LCDDisplay0_PrintASCII('a');
  1554.                     FCD_LCDDisplay0_PrintASCII('r');
  1555.                     FCD_LCDDisplay0_PrintASCII('m');
  1556.                     FCD_LCDDisplay0_PrintASCII(':');
  1557.                     FCD_LCDDisplay0_PrintASCII(' ');
  1558.                     FCD_LCDDisplay0_PrintASCII('Z');
  1559.                     FCD_LCDDisplay0_PrintASCII('o');
  1560.                     FCD_LCDDisplay0_PrintASCII('n');
  1561.                     FCD_LCDDisplay0_PrintASCII('e');
  1562.                     FCD_LCDDisplay0_PrintASCII(' ');
  1563.                     FCD_LCDDisplay0_PrintASCII('1');
  1564.  
  1565.  
  1566.                     //Output
  1567.                     //Output: 1 -> C4
  1568.                     trisc = trisc & 0xef;
  1569.                     if (1)
  1570.                         portc = (portc & 0xef) | 0x10;
  1571.                     else
  1572.                         portc = portc & 0xef;
  1573.  
  1574.  
  1575.                 } else {
  1576.                     //Goto Connection Point
  1577.                     //Goto Connection Point: [B]: B
  1578.                     goto FCC_Alarm_B;
  1579.  
  1580.  
  1581.                 }
  1582.  
  1583.  
  1584.                 break;
  1585.             }
  1586.  
  1587.             case 2:
  1588.             {
  1589.                 //Output
  1590.                 //Output: 1 -> C2
  1591.                 trisc = trisc & 0xfb;
  1592.                 if (1)
  1593.                     portc = (portc & 0xfb) | 0x04;
  1594.                 else
  1595.                     portc = portc & 0xfb;
  1596.  
  1597.  
  1598.                 //Decision
  1599.                 //Decision: AlarmActive > 0?
  1600.                 if (FCV_ALARMACTIVE > 0)
  1601.                 {
  1602.                 } else {
  1603.                     //Call Macro
  1604.                     //Call Macro: PreAlarm
  1605.                     FCM_PreAlarm();
  1606.  
  1607.  
  1608.                     //Decision
  1609.                     //Decision: AlarmZone = 0?
  1610.                     if (FCV_ALARMZONE == 0)
  1611.                     {
  1612.                         //Goto Connection Point
  1613.                         //Goto Connection Point: [B]: B
  1614.                         goto FCC_Alarm_B;
  1615.  
  1616.  
  1617.                     }
  1618.  
  1619.  
  1620.                 }
  1621.  
  1622.  
  1623.                 //Decision
  1624.                 //Decision: SystemArmed > 0?
  1625.                 if (FCV_SYSTEMARMED > 0)
  1626.                 {
  1627.                     //Call Component Macro
  1628.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  1629.                     FCD_LCDDisplay0_Cursor(1, 1);
  1630.  
  1631.  
  1632.                     //Call Component Macro
  1633.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 2")
  1634.                     FCD_LCDDisplay0_PrintASCII('A');
  1635.                     FCD_LCDDisplay0_PrintASCII('l');
  1636.                     FCD_LCDDisplay0_PrintASCII('a');
  1637.                     FCD_LCDDisplay0_PrintASCII('r');
  1638.                     FCD_LCDDisplay0_PrintASCII('m');
  1639.                     FCD_LCDDisplay0_PrintASCII(':');
  1640.                     FCD_LCDDisplay0_PrintASCII(' ');
  1641.                     FCD_LCDDisplay0_PrintASCII('Z');
  1642.                     FCD_LCDDisplay0_PrintASCII('o');
  1643.                     FCD_LCDDisplay0_PrintASCII('n');
  1644.                     FCD_LCDDisplay0_PrintASCII('e');
  1645.                     FCD_LCDDisplay0_PrintASCII(' ');
  1646.                     FCD_LCDDisplay0_PrintASCII('2');
  1647.  
  1648.  
  1649.                     //Output
  1650.                     //Output: 1 -> C4
  1651.                     trisc = trisc & 0xef;
  1652.                     if (1)
  1653.                         portc = (portc & 0xef) | 0x10;
  1654.                     else
  1655.                         portc = portc & 0xef;
  1656.  
  1657.  
  1658.                 } else {
  1659.                     //Goto Connection Point
  1660.                     //Goto Connection Point: [B]: B
  1661.                     goto FCC_Alarm_B;
  1662.  
  1663.  
  1664.                 }
  1665.  
  1666.  
  1667.                 break;
  1668.             }
  1669.  
  1670.             case 3:
  1671.             {
  1672.                 //Output
  1673.                 //Output: 1 -> C1
  1674.                 trisc = trisc & 0xfd;
  1675.                 if (1)
  1676.                     portc = (portc & 0xfd) | 0x02;
  1677.                 else
  1678.                     portc = portc & 0xfd;
  1679.  
  1680.  
  1681.                 //Decision
  1682.                 //Decision: AlarmActive > 0?
  1683.                 if (FCV_ALARMACTIVE > 0)
  1684.                 {
  1685.                 } else {
  1686.                     //Call Macro
  1687.                     //Call Macro: PreAlarm
  1688.                     FCM_PreAlarm();
  1689.  
  1690.  
  1691.                     //Decision
  1692.                     //Decision: AlarmZone = 0?
  1693.                     if (FCV_ALARMZONE == 0)
  1694.                     {
  1695.                         //Goto Connection Point
  1696.                         //Goto Connection Point: [B]: B
  1697.                         goto FCC_Alarm_B;
  1698.  
  1699.  
  1700.                     }
  1701.  
  1702.  
  1703.                 }
  1704.  
  1705.  
  1706.                 //Decision
  1707.                 //Decision: SystemArmed > 0?
  1708.                 if (FCV_SYSTEMARMED > 0)
  1709.                 {
  1710.                     //Call Component Macro
  1711.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  1712.                     FCD_LCDDisplay0_Cursor(1, 1);
  1713.  
  1714.  
  1715.                     //Call Component Macro
  1716.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 3")
  1717.                     FCD_LCDDisplay0_PrintASCII('A');
  1718.                     FCD_LCDDisplay0_PrintASCII('l');
  1719.                     FCD_LCDDisplay0_PrintASCII('a');
  1720.                     FCD_LCDDisplay0_PrintASCII('r');
  1721.                     FCD_LCDDisplay0_PrintASCII('m');
  1722.                     FCD_LCDDisplay0_PrintASCII(':');
  1723.                     FCD_LCDDisplay0_PrintASCII(' ');
  1724.                     FCD_LCDDisplay0_PrintASCII('Z');
  1725.                     FCD_LCDDisplay0_PrintASCII('o');
  1726.                     FCD_LCDDisplay0_PrintASCII('n');
  1727.                     FCD_LCDDisplay0_PrintASCII('e');
  1728.                     FCD_LCDDisplay0_PrintASCII(' ');
  1729.                     FCD_LCDDisplay0_PrintASCII('3');
  1730.  
  1731.  
  1732.                     //Output
  1733.                     //Output: 1 -> C4
  1734.                     trisc = trisc & 0xef;
  1735.                     if (1)
  1736.                         portc = (portc & 0xef) | 0x10;
  1737.                     else
  1738.                         portc = portc & 0xef;
  1739.  
  1740.  
  1741.                 } else {
  1742.                     //Goto Connection Point
  1743.                     //Goto Connection Point: [B]: B
  1744.                     goto FCC_Alarm_B;
  1745.  
  1746.  
  1747.                 }
  1748.  
  1749.  
  1750.                 //Goto Connection Point
  1751.                 //Goto Connection Point: [B]: B
  1752.                 goto FCC_Alarm_B;
  1753.  
  1754.  
  1755.                 break;
  1756.             }
  1757.  
  1758.             case 4:
  1759.             {
  1760.                 //Output
  1761.                 //Output: 1 -> C0
  1762.                 trisc = trisc & 0xfe;
  1763.                 if (1)
  1764.                     portc = (portc & 0xfe) | 0x01;
  1765.                 else
  1766.                     portc = portc & 0xfe;
  1767.  
  1768.  
  1769.                 //Decision
  1770.                 //Decision: AlarmActive > 0?
  1771.                 if (FCV_ALARMACTIVE > 0)
  1772.                 {
  1773.                 } else {
  1774.                     //Call Macro
  1775.                     //Call Macro: PreAlarm
  1776.                     FCM_PreAlarm();
  1777.  
  1778.  
  1779.                     //Decision
  1780.                     //Decision: AlarmZone = 0?
  1781.                     if (FCV_ALARMZONE == 0)
  1782.                     {
  1783.                         //Goto Connection Point
  1784.                         //Goto Connection Point: [B]: B
  1785.                         goto FCC_Alarm_B;
  1786.  
  1787.  
  1788.                     }
  1789.  
  1790.  
  1791.                 }
  1792.  
  1793.  
  1794.                 //Decision
  1795.                 //Decision: SystemArmed > 0?
  1796.                 if (FCV_SYSTEMARMED > 0)
  1797.                 {
  1798.                     //Call Component Macro
  1799.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  1800.                     FCD_LCDDisplay0_Cursor(1, 1);
  1801.  
  1802.  
  1803.                     //Call Component Macro
  1804.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 4")
  1805.                     FCD_LCDDisplay0_PrintASCII('A');
  1806.                     FCD_LCDDisplay0_PrintASCII('l');
  1807.                     FCD_LCDDisplay0_PrintASCII('a');
  1808.                     FCD_LCDDisplay0_PrintASCII('r');
  1809.                     FCD_LCDDisplay0_PrintASCII('m');
  1810.                     FCD_LCDDisplay0_PrintASCII(':');
  1811.                     FCD_LCDDisplay0_PrintASCII(' ');
  1812.                     FCD_LCDDisplay0_PrintASCII('Z');
  1813.                     FCD_LCDDisplay0_PrintASCII('o');
  1814.                     FCD_LCDDisplay0_PrintASCII('n');
  1815.                     FCD_LCDDisplay0_PrintASCII('e');
  1816.                     FCD_LCDDisplay0_PrintASCII(' ');
  1817.                     FCD_LCDDisplay0_PrintASCII('4');
  1818.  
  1819.  
  1820.                     //Output
  1821.                     //Output: 1 -> C4
  1822.                     trisc = trisc & 0xef;
  1823.                     if (1)
  1824.                         portc = (portc & 0xef) | 0x10;
  1825.                     else
  1826.                         portc = portc & 0xef;
  1827.  
  1828.  
  1829.                 } else {
  1830.                     //Goto Connection Point
  1831.                     //Goto Connection Point: [B]: B
  1832.                     goto FCC_Alarm_B;
  1833.  
  1834.  
  1835.                 }
  1836.  
  1837.  
  1838.                 break;
  1839.             }
  1840.  
  1841.             default:
  1842.             {
  1843.                 //Connection Point
  1844.                 //Connection Point: [C]: C
  1845. FCC_Alarm_C:
  1846. ;
  1847.  
  1848.  
  1849.                 //Decision
  1850.                 //Decision: InvalidCount = 3?
  1851.                 if (FCV_INVALIDCOUNT == 3)
  1852.                 {
  1853.                     //Call Component Macro
  1854.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  1855.                     FCD_LCDDisplay0_Cursor(1, 1);
  1856.  
  1857.  
  1858.                     //Call Component Macro
  1859.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Invalid Code Error")
  1860.                     FCD_LCDDisplay0_PrintASCII('I');
  1861.                     FCD_LCDDisplay0_PrintASCII('n');
  1862.                     FCD_LCDDisplay0_PrintASCII('v');
  1863.                     FCD_LCDDisplay0_PrintASCII('a');
  1864.                     FCD_LCDDisplay0_PrintASCII('l');
  1865.                     FCD_LCDDisplay0_PrintASCII('i');
  1866.                     FCD_LCDDisplay0_PrintASCII('d');
  1867.                     FCD_LCDDisplay0_PrintASCII(' ');
  1868.                     FCD_LCDDisplay0_PrintASCII('C');
  1869.                     FCD_LCDDisplay0_PrintASCII('o');
  1870.                     FCD_LCDDisplay0_PrintASCII('d');
  1871.                     FCD_LCDDisplay0_PrintASCII('e');
  1872.                     FCD_LCDDisplay0_PrintASCII(' ');
  1873.                     FCD_LCDDisplay0_PrintASCII('E');
  1874.                     FCD_LCDDisplay0_PrintASCII('r');
  1875.                     FCD_LCDDisplay0_PrintASCII('r');
  1876.                     FCD_LCDDisplay0_PrintASCII('o');
  1877.                     FCD_LCDDisplay0_PrintASCII('r');
  1878.  
  1879.  
  1880.                     //Output
  1881.                     //Output: 1 -> C4
  1882.                     trisc = trisc & 0xef;
  1883.                     if (1)
  1884.                         portc = (portc & 0xef) | 0x10;
  1885.                     else
  1886.                         portc = portc & 0xef;
  1887.  
  1888.  
  1889.                 }
  1890.  
  1891.  
  1892.             }
  1893.         }
  1894.  
  1895.  
  1896.         //Decision
  1897.         //Decision: InvalidCode = 1?
  1898.         if (FCV_INVALIDCODE == 1)
  1899.         {
  1900.             //Call Component Macro
  1901.             //Call Component Macro: LCDDisplay(0)::Clear
  1902.             FCD_LCDDisplay0_Clear();
  1903.  
  1904.  
  1905.             //Call Component Macro
  1906.             //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  1907.             FCD_LCDDisplay0_Cursor(2, 0);
  1908.  
  1909.  
  1910.             //Call Component Macro
  1911.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  1912.             FCD_LCDDisplay0_PrintASCII('S');
  1913.             FCD_LCDDisplay0_PrintASCII('y');
  1914.             FCD_LCDDisplay0_PrintASCII('s');
  1915.             FCD_LCDDisplay0_PrintASCII('t');
  1916.             FCD_LCDDisplay0_PrintASCII('e');
  1917.             FCD_LCDDisplay0_PrintASCII('m');
  1918.             FCD_LCDDisplay0_PrintASCII(' ');
  1919.             FCD_LCDDisplay0_PrintASCII('A');
  1920.             FCD_LCDDisplay0_PrintASCII('r');
  1921.             FCD_LCDDisplay0_PrintASCII('m');
  1922.             FCD_LCDDisplay0_PrintASCII('e');
  1923.             FCD_LCDDisplay0_PrintASCII('d');
  1924.  
  1925.  
  1926.             //Calculation
  1927.             //Calculation:
  1928.             //  InvalidCode = 0
  1929.             //  InvalidCount = InvalidCount + 1
  1930.             FCV_INVALIDCODE = 0;
  1931.             FCV_INVALIDCOUNT = FCV_INVALIDCOUNT + 1;
  1932.            
  1933.  
  1934.             //Decision
  1935.             //Decision: InvalidCount = 3?
  1936.             if (FCV_INVALIDCOUNT == 3)
  1937.             {
  1938.                 //Goto Connection Point
  1939.                 //Goto Connection Point: [C]: C
  1940.                 goto FCC_Alarm_C;
  1941.  
  1942.  
  1943.             }
  1944.  
  1945.  
  1946.         }
  1947.  
  1948.  
  1949.         //Input
  1950.         //Input: A1 -> CancelSwitch
  1951.         trisa = trisa | 0x02;
  1952.         FCV_CANCELSWITCH = ((porta & 0x02) == 0x02);
  1953.  
  1954.  
  1955.         //Decision
  1956.         //Decision: CancelSwitch > 0?
  1957.         if (FCV_CANCELSWITCH > 0)
  1958.         {
  1959.             //Call Macro
  1960.             //Call Macro: EnterCode
  1961.             FCM_EnterCode();
  1962.  
  1963.  
  1964.             //Call Macro
  1965.             //Call Macro: CompareCode
  1966.             FCM_CompareCode();
  1967.  
  1968.  
  1969.             //Decision
  1970.             //Decision: InvalidCode > 0?
  1971.             if (FCV_INVALIDCODE > 0)
  1972.             {
  1973.                 //Delay
  1974.                 //Delay: 5 s
  1975.                 delay_s(5);
  1976.  
  1977.  
  1978.                 //Call Component Macro
  1979.                 //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  1980.                 FCD_LCDDisplay0_ClearLine(1);
  1981.  
  1982.  
  1983.                 //Goto Connection Point
  1984.                 //Goto Connection Point: [A]: A
  1985.                 goto FCC_Alarm_A;
  1986.  
  1987.  
  1988.             }
  1989.  
  1990.  
  1991.             //Call Component Macro
  1992.             //Call Component Macro: LCDDisplay(0)::Clear
  1993.             FCD_LCDDisplay0_Clear();
  1994.  
  1995.  
  1996.             //Call Component Macro
  1997.             //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  1998.             FCD_LCDDisplay0_Cursor(2, 0);
  1999.  
  2000.  
  2001.             //Call Component Macro
  2002.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  2003.             FCD_LCDDisplay0_PrintASCII('S');
  2004.             FCD_LCDDisplay0_PrintASCII('y');
  2005.             FCD_LCDDisplay0_PrintASCII('s');
  2006.             FCD_LCDDisplay0_PrintASCII('t');
  2007.             FCD_LCDDisplay0_PrintASCII('e');
  2008.             FCD_LCDDisplay0_PrintASCII('m');
  2009.             FCD_LCDDisplay0_PrintASCII(' ');
  2010.             FCD_LCDDisplay0_PrintASCII('A');
  2011.             FCD_LCDDisplay0_PrintASCII('r');
  2012.             FCD_LCDDisplay0_PrintASCII('m');
  2013.             FCD_LCDDisplay0_PrintASCII('e');
  2014.             FCD_LCDDisplay0_PrintASCII('d');
  2015.  
  2016.  
  2017.             //Output
  2018.             //Output: 0 -> PORT C
  2019.             trisc = 0x00;
  2020.             portc = 0;
  2021.  
  2022.  
  2023.             //Calculation
  2024.             //Calculation:
  2025.             //  CancelSwitch = 0
  2026.             //  AlarmZone = 0
  2027.             //  AlarmActive = 0
  2028.             FCV_CANCELSWITCH = 0;
  2029.             FCV_ALARMZONE = 0;
  2030.             FCV_ALARMACTIVE = 0;
  2031.            
  2032.  
  2033.             //Goto Connection Point
  2034.             //Goto Connection Point: [B]: B
  2035.             goto FCC_Alarm_B;
  2036.  
  2037.  
  2038.         }
  2039.  
  2040.  
  2041.         //Input
  2042.         //Input: A0 -> ArmSwitch
  2043.         trisa = trisa | 0x01;
  2044.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  2045.  
  2046.  
  2047.         //Decision
  2048.         //Decision: ArmSwitch > 0?
  2049.         if (FCV_ARMSWITCH > 0)
  2050.         {
  2051.             //Call Macro
  2052.             //Call Macro: EnterCode
  2053.             FCM_EnterCode();
  2054.  
  2055.  
  2056.             //Call Macro
  2057.             //Call Macro: CompareCode
  2058.             FCM_CompareCode();
  2059.  
  2060.  
  2061.             //Decision
  2062.             //Decision: InvalidCode > 0?
  2063.             if (FCV_INVALIDCODE > 0)
  2064.             {
  2065.                 //Delay
  2066.                 //Delay: 5 s
  2067.                 delay_s(5);
  2068.  
  2069.  
  2070.                 //Call Component Macro
  2071.                 //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  2072.                 FCD_LCDDisplay0_ClearLine(1);
  2073.  
  2074.  
  2075.                 //Goto Connection Point
  2076.                 //Goto Connection Point: [A]: A
  2077.                 goto FCC_Alarm_A;
  2078.  
  2079.  
  2080.             }
  2081.  
  2082.  
  2083.             //Call Component Macro
  2084.             //Call Component Macro: LCDDisplay(0)::Clear
  2085.             FCD_LCDDisplay0_Clear();
  2086.  
  2087.  
  2088.             //Call Component Macro
  2089.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  2090.             FCD_LCDDisplay0_PrintASCII('S');
  2091.             FCD_LCDDisplay0_PrintASCII('y');
  2092.             FCD_LCDDisplay0_PrintASCII('s');
  2093.             FCD_LCDDisplay0_PrintASCII('t');
  2094.             FCD_LCDDisplay0_PrintASCII('e');
  2095.             FCD_LCDDisplay0_PrintASCII('m');
  2096.             FCD_LCDDisplay0_PrintASCII(' ');
  2097.             FCD_LCDDisplay0_PrintASCII('D');
  2098.             FCD_LCDDisplay0_PrintASCII('i');
  2099.             FCD_LCDDisplay0_PrintASCII('s');
  2100.             FCD_LCDDisplay0_PrintASCII('a');
  2101.             FCD_LCDDisplay0_PrintASCII('r');
  2102.             FCD_LCDDisplay0_PrintASCII('m');
  2103.             FCD_LCDDisplay0_PrintASCII('e');
  2104.             FCD_LCDDisplay0_PrintASCII('d');
  2105.  
  2106.  
  2107.             //Output
  2108.             //Output: 0 -> PORT C
  2109.             trisc = 0x00;
  2110.             portc = 0;
  2111.  
  2112.  
  2113.             //Calculation
  2114.             //Calculation:
  2115.             //  ArmSwitch = 0
  2116.             //  AlarmActive = 0
  2117.             //  AlarmZone = 0
  2118.             //  SystemArmed = 0
  2119.             FCV_ARMSWITCH = 0;
  2120.             FCV_ALARMACTIVE = 0;
  2121.             FCV_ALARMZONE = 0;
  2122.             FCV_SYSTEMARMED = 0;
  2123.            
  2124.  
  2125.             //Decision
  2126.             //Decision: SystemArmed > 0?
  2127.             if (FCV_SYSTEMARMED > 0)
  2128.             {
  2129.             } else {
  2130.                 //Goto Connection Point
  2131.                 //Goto Connection Point: [B]: B
  2132.                 goto FCC_Alarm_B;
  2133.  
  2134.  
  2135.             }
  2136.  
  2137.  
  2138.         }
  2139.  
  2140.  
  2141.     }
  2142.  
  2143.  
  2144.     //Connection Point
  2145.     //Connection Point: [B]: B
  2146. FCC_Alarm_B:
  2147. ;
  2148.  
  2149.  
  2150. }
  2151.  
  2152. void FCM_EnterCode()
  2153. {
  2154.    
  2155.     //Call Component Macro
  2156.     //Call Component Macro: LCDDisplay(0)::Clear
  2157.     FCD_LCDDisplay0_Clear();
  2158.  
  2159.  
  2160.     //Call Component Macro
  2161.     //Call Component Macro: LCDDisplay(0)::PrintASCII("Enter Code:")
  2162.     FCD_LCDDisplay0_PrintASCII('E');
  2163.     FCD_LCDDisplay0_PrintASCII('n');
  2164.     FCD_LCDDisplay0_PrintASCII('t');
  2165.     FCD_LCDDisplay0_PrintASCII('e');
  2166.     FCD_LCDDisplay0_PrintASCII('r');
  2167.     FCD_LCDDisplay0_PrintASCII(' ');
  2168.     FCD_LCDDisplay0_PrintASCII('C');
  2169.     FCD_LCDDisplay0_PrintASCII('o');
  2170.     FCD_LCDDisplay0_PrintASCII('d');
  2171.     FCD_LCDDisplay0_PrintASCII('e');
  2172.     FCD_LCDDisplay0_PrintASCII(':');
  2173.  
  2174.  
  2175.     //Decision
  2176.     //Decision: Digit1 > 0?
  2177.     if (FCV_DIGIT1 > 0)
  2178.     {
  2179.     } else {
  2180.         //Loop
  2181.         //Loop: While Digitset < 1
  2182.         while (FCV_DIGITSET < 1)
  2183.         {
  2184.             //Connection Point
  2185.             //Connection Point: [A]: A
  2186. FCC_EnterCode_A:
  2187. ;
  2188.  
  2189.  
  2190.             //Call Component Macro
  2191.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2192.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2193.  
  2194.  
  2195.             //Decision
  2196.             //Decision: Keypadnumber = 255?
  2197.             if (FCV_KEYPADNUMBER == 255)
  2198.             {
  2199.                 //Goto Connection Point
  2200.                 //Goto Connection Point: [A]: A
  2201.                 goto FCC_EnterCode_A;
  2202.  
  2203.  
  2204.             } else {
  2205.                 //Call Component Macro
  2206.                 //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
  2207.                 FCD_LCDDisplay0_Cursor(0, 1);
  2208.  
  2209.  
  2210.                 //Call Component Macro
  2211.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  2212.                 FCD_LCDDisplay0_PrintASCII('*');
  2213.  
  2214.  
  2215.                 //Calculation
  2216.                 //Calculation:
  2217.                 //  Digit1 = Keypadnumber
  2218.                 //  Digitset = 1
  2219.                 FCV_DIGIT1 = FCV_KEYPADNUMBER;
  2220.                 FCV_DIGITSET = 1;
  2221.                
  2222.  
  2223.             }
  2224.  
  2225.  
  2226.             //Connection Point
  2227.             //Connection Point: [B]: B
  2228. FCC_EnterCode_B:
  2229. ;
  2230.  
  2231.  
  2232.             //Call Component Macro
  2233.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2234.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2235.  
  2236.  
  2237.             //Decision
  2238.             //Decision: Keypadnumber = 255?
  2239.             if (FCV_KEYPADNUMBER == 255)
  2240.             {
  2241.             } else {
  2242.                 //Goto Connection Point
  2243.                 //Goto Connection Point: [B]: B
  2244.                 goto FCC_EnterCode_B;
  2245.  
  2246.  
  2247.             }
  2248.  
  2249.  
  2250.         }
  2251.  
  2252.  
  2253.         //Calculation
  2254.         //Calculation:
  2255.         //  Digitset = 0
  2256.         FCV_DIGITSET = 0;
  2257.        
  2258.  
  2259.     }
  2260.  
  2261.  
  2262.     //Decision
  2263.     //Decision: Digit2 > 0?
  2264.     if (FCV_DIGIT2 > 0)
  2265.     {
  2266.     } else {
  2267.         //Connection Point
  2268.         //Connection Point: [C]: C
  2269. FCC_EnterCode_C:
  2270. ;
  2271.  
  2272.  
  2273.         //Loop
  2274.         //Loop: While Digitset < 1
  2275.         while (FCV_DIGITSET < 1)
  2276.         {
  2277.             //Call Component Macro
  2278.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2279.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2280.  
  2281.  
  2282.             //Decision
  2283.             //Decision: Keypadnumber =  255?
  2284.             if (FCV_KEYPADNUMBER ==  255)
  2285.             {
  2286.                 //Goto Connection Point
  2287.                 //Goto Connection Point: [C]: C
  2288.                 goto FCC_EnterCode_C;
  2289.  
  2290.  
  2291.             } else {
  2292.                 //Call Component Macro
  2293.                 //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  2294.                 FCD_LCDDisplay0_Cursor(1, 1);
  2295.  
  2296.  
  2297.                 //Call Component Macro
  2298.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  2299.                 FCD_LCDDisplay0_PrintASCII('*');
  2300.  
  2301.  
  2302.                 //Calculation
  2303.                 //Calculation:
  2304.                 //  Digit2 = Keypadnumber
  2305.                 //  Digitset = 1
  2306.                 FCV_DIGIT2 = FCV_KEYPADNUMBER;
  2307.                 FCV_DIGITSET = 1;
  2308.                
  2309.  
  2310.             }
  2311.  
  2312.  
  2313.             //Connection Point
  2314.             //Connection Point: [D]: D
  2315. FCC_EnterCode_D:
  2316. ;
  2317.  
  2318.  
  2319.             //Call Component Macro
  2320.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2321.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2322.  
  2323.  
  2324.             //Decision
  2325.             //Decision: Keypadnumber =  255?
  2326.             if (FCV_KEYPADNUMBER ==  255)
  2327.             {
  2328.             } else {
  2329.                 //Goto Connection Point
  2330.                 //Goto Connection Point: [D]: D
  2331.                 goto FCC_EnterCode_D;
  2332.  
  2333.  
  2334.             }
  2335.  
  2336.  
  2337.         }
  2338.  
  2339.  
  2340.         //Calculation
  2341.         //Calculation:
  2342.         //  Digitset = 0
  2343.         FCV_DIGITSET = 0;
  2344.        
  2345.  
  2346.     }
  2347.  
  2348.  
  2349.     //Decision
  2350.     //Decision: Digit3 > 0?
  2351.     if (FCV_DIGIT3 > 0)
  2352.     {
  2353.     } else {
  2354.         //Loop
  2355.         //Loop: While Digitset < 1
  2356.         while (FCV_DIGITSET < 1)
  2357.         {
  2358.             //Connection Point
  2359.             //Connection Point: [E]: E
  2360. FCC_EnterCode_E:
  2361. ;
  2362.  
  2363.  
  2364.             //Call Component Macro
  2365.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2366.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2367.  
  2368.  
  2369.             //Decision
  2370.             //Decision: Keypadnumber = 255?
  2371.             if (FCV_KEYPADNUMBER == 255)
  2372.             {
  2373.                 //Goto Connection Point
  2374.                 //Goto Connection Point: [E]: E
  2375.                 goto FCC_EnterCode_E;
  2376.  
  2377.  
  2378.             } else {
  2379.                 //Call Component Macro
  2380.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  2381.                 FCD_LCDDisplay0_Cursor(2, 1);
  2382.  
  2383.  
  2384.                 //Call Component Macro
  2385.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  2386.                 FCD_LCDDisplay0_PrintASCII('*');
  2387.  
  2388.  
  2389.                 //Calculation
  2390.                 //Calculation:
  2391.                 //  Digit3 = Keypadnumber
  2392.                 //  Digitset = 1
  2393.                 FCV_DIGIT3 = FCV_KEYPADNUMBER;
  2394.                 FCV_DIGITSET = 1;
  2395.                
  2396.  
  2397.             }
  2398.  
  2399.  
  2400.             //Connection Point
  2401.             //Connection Point: [F]: F
  2402. FCC_EnterCode_F:
  2403. ;
  2404.  
  2405.  
  2406.             //Call Component Macro
  2407.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2408.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2409.  
  2410.  
  2411.             //Decision
  2412.             //Decision: Keypadnumber = 255?
  2413.             if (FCV_KEYPADNUMBER == 255)
  2414.             {
  2415.             } else {
  2416.                 //Goto Connection Point
  2417.                 //Goto Connection Point: [F]: F
  2418.                 goto FCC_EnterCode_F;
  2419.  
  2420.  
  2421.             }
  2422.  
  2423.  
  2424.         }
  2425.  
  2426.  
  2427.         //Calculation
  2428.         //Calculation:
  2429.         //  Digitset = 0
  2430.         FCV_DIGITSET = 0;
  2431.        
  2432.  
  2433.     }
  2434.  
  2435.  
  2436.     //Decision
  2437.     //Decision: Digit4 > 0?
  2438.     if (FCV_DIGIT4 > 0)
  2439.     {
  2440.     } else {
  2441.         //Loop
  2442.         //Loop: While Digitset < 1
  2443.         while (FCV_DIGITSET < 1)
  2444.         {
  2445.             //Connection Point
  2446.             //Connection Point: [G]: G
  2447. FCC_EnterCode_G:
  2448. ;
  2449.  
  2450.  
  2451.             //Call Component Macro
  2452.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2453.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2454.  
  2455.  
  2456.             //Decision
  2457.             //Decision: Keypadnumber = 255?
  2458.             if (FCV_KEYPADNUMBER == 255)
  2459.             {
  2460.                 //Goto Connection Point
  2461.                 //Goto Connection Point: [G]: G
  2462.                 goto FCC_EnterCode_G;
  2463.  
  2464.  
  2465.             } else {
  2466.                 //Calculation
  2467.                 //Calculation:
  2468.                 //  Digit4 = Keypadnumber
  2469.                 //  Digitset = 1
  2470.                 FCV_DIGIT4 = FCV_KEYPADNUMBER;
  2471.                 FCV_DIGITSET = 1;
  2472.                
  2473.  
  2474.                 //Call Component Macro
  2475.                 //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
  2476.                 FCD_LCDDisplay0_Cursor(3, 1);
  2477.  
  2478.  
  2479.                 //Call Component Macro
  2480.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  2481.                 FCD_LCDDisplay0_PrintASCII('*');
  2482.  
  2483.  
  2484.             }
  2485.  
  2486.  
  2487.             //Connection Point
  2488.             //Connection Point: [H]: H
  2489. FCC_EnterCode_H:
  2490. ;
  2491.  
  2492.  
  2493.             //Call Component Macro
  2494.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  2495.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  2496.  
  2497.  
  2498.             //Decision
  2499.             //Decision: Keypadnumber = 255?
  2500.             if (FCV_KEYPADNUMBER == 255)
  2501.             {
  2502.             } else {
  2503.                 //Goto Connection Point
  2504.                 //Goto Connection Point: [H]: H
  2505.                 goto FCC_EnterCode_H;
  2506.  
  2507.  
  2508.             }
  2509.  
  2510.  
  2511.         }
  2512.  
  2513.  
  2514.         //Calculation
  2515.         //Calculation:
  2516.         //  Digitset = 0
  2517.         //  Code = Digit1
  2518.         //  Code = Code + (Digit2 * 1000)
  2519.         //  Code = Code + (Digit3 * 100)
  2520.         //  Code = Code + (Digit4 * 10)
  2521.         //  Digit1 = 0
  2522.         //  Digit2 = 0
  2523.         //  Digit3 = 0
  2524.         //  Digit4 = 0
  2525.         FCV_DIGITSET = 0;
  2526.         FCV_CODE = FCV_DIGIT1;
  2527.         FCV_CODE = FCV_CODE + (FCV_DIGIT2 * 1000);
  2528.         FCV_CODE = FCV_CODE + (FCV_DIGIT3 * 100);
  2529.         FCV_CODE = FCV_CODE + (FCV_DIGIT4 * 10);
  2530.         FCV_DIGIT1 = 0;
  2531.         FCV_DIGIT2 = 0;
  2532.         FCV_DIGIT3 = 0;
  2533.         FCV_DIGIT4 = 0;
  2534.        
  2535.  
  2536.     }
  2537.  
  2538.  
  2539. }
  2540.  
  2541. void FCM_CompareCode()
  2542. {
  2543.    
  2544.     //Call Component Macro
  2545.     //Call Component Macro: Digit1=EEPROM(0)::Read(0)
  2546.     FCV_DIGIT1 = FCD_EEPROM0_EEPROMRead(0);
  2547.  
  2548.  
  2549.     //Call Component Macro
  2550.     //Call Component Macro: Digit2=EEPROM(0)::Read(1)
  2551.     FCV_DIGIT2 = FCD_EEPROM0_EEPROMRead(1);
  2552.  
  2553.  
  2554.     //Call Component Macro
  2555.     //Call Component Macro: Digit3=EEPROM(0)::Read(2)
  2556.     FCV_DIGIT3 = FCD_EEPROM0_EEPROMRead(2);
  2557.  
  2558.  
  2559.     //Call Component Macro
  2560.     //Call Component Macro: Digit4=EEPROM(0)::Read(3)
  2561.     FCV_DIGIT4 = FCD_EEPROM0_EEPROMRead(3);
  2562.  
  2563.  
  2564.     //Calculation
  2565.     //Calculation:
  2566.     //  SetCode = Digit1
  2567.     //  SetCode = SetCode + (Digit2 * 1000)
  2568.     //  SetCode = SetCode + (Digit3 * 100)
  2569.     //  SetCode = SetCode + (Digit4 * 10)
  2570.     FCV_SETCODE = FCV_DIGIT1;
  2571.     FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT2 * 1000);
  2572.     FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT3 * 100);
  2573.     FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT4 * 10);
  2574.    
  2575.  
  2576.     //Decision
  2577.     //Decision: Code = SetCode?
  2578.     if (FCV_CODE == FCV_SETCODE)
  2579.     {
  2580.         //Call Macro
  2581.         //Call Macro: RightCode
  2582.         FCM_RightCode();
  2583.  
  2584.  
  2585.     } else {
  2586.         //Call Macro
  2587.         //Call Macro: WrongCode
  2588.         FCM_WrongCode();
  2589.  
  2590.  
  2591.     }
  2592.  
  2593.  
  2594.     //Calculation
  2595.     //Calculation:
  2596.     //  Code = 0
  2597.     //  SetCode = 0
  2598.     //  Digit1 = 0
  2599.     //  Digit2 = 0
  2600.     //  Digit3 = 0
  2601.     //  Digit4 = 0
  2602.     FCV_CODE = 0;
  2603.     FCV_SETCODE = 0;
  2604.     FCV_DIGIT1 = 0;
  2605.     FCV_DIGIT2 = 0;
  2606.     FCV_DIGIT3 = 0;
  2607.     FCV_DIGIT4 = 0;
  2608.    
  2609.  
  2610. }
  2611.  
  2612. void FCM_WrongCode()
  2613. {
  2614.    
  2615.     //Call Component Macro
  2616.     //Call Component Macro: LCDDisplay(0)::Clear
  2617.     FCD_LCDDisplay0_Clear();
  2618.  
  2619.  
  2620.     //Call Component Macro
  2621.     //Call Component Macro: LCDDisplay(0)::Clear
  2622.     FCD_LCDDisplay0_Clear();
  2623.  
  2624.  
  2625.     //Call Component Macro
  2626.     //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  2627.     FCD_LCDDisplay0_Cursor(2, 0);
  2628.  
  2629.  
  2630.     //Call Component Macro
  2631.     //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  2632.     FCD_LCDDisplay0_PrintASCII('S');
  2633.     FCD_LCDDisplay0_PrintASCII('y');
  2634.     FCD_LCDDisplay0_PrintASCII('s');
  2635.     FCD_LCDDisplay0_PrintASCII('t');
  2636.     FCD_LCDDisplay0_PrintASCII('e');
  2637.     FCD_LCDDisplay0_PrintASCII('m');
  2638.     FCD_LCDDisplay0_PrintASCII(' ');
  2639.     FCD_LCDDisplay0_PrintASCII('A');
  2640.     FCD_LCDDisplay0_PrintASCII('r');
  2641.     FCD_LCDDisplay0_PrintASCII('m');
  2642.     FCD_LCDDisplay0_PrintASCII('e');
  2643.     FCD_LCDDisplay0_PrintASCII('d');
  2644.  
  2645.  
  2646.     //Call Component Macro
  2647.     //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  2648.     FCD_LCDDisplay0_Cursor(2, 1);
  2649.  
  2650.  
  2651.     //Call Component Macro
  2652.     //Call Component Macro: LCDDisplay(0)::PrintASCII("Invalid Code")
  2653.     FCD_LCDDisplay0_PrintASCII('I');
  2654.     FCD_LCDDisplay0_PrintASCII('n');
  2655.     FCD_LCDDisplay0_PrintASCII('v');
  2656.     FCD_LCDDisplay0_PrintASCII('a');
  2657.     FCD_LCDDisplay0_PrintASCII('l');
  2658.     FCD_LCDDisplay0_PrintASCII('i');
  2659.     FCD_LCDDisplay0_PrintASCII('d');
  2660.     FCD_LCDDisplay0_PrintASCII(' ');
  2661.     FCD_LCDDisplay0_PrintASCII('C');
  2662.     FCD_LCDDisplay0_PrintASCII('o');
  2663.     FCD_LCDDisplay0_PrintASCII('d');
  2664.     FCD_LCDDisplay0_PrintASCII('e');
  2665.  
  2666.  
  2667.     //Calculation
  2668.     //Calculation:
  2669.     //  InvalidCode = 1
  2670.     FCV_INVALIDCODE = 1;
  2671.    
  2672.  
  2673. }
  2674.  
  2675. void FCM_Rightcode()
  2676. {
  2677.    
  2678.     //Call Component Macro
  2679.     //Call Component Macro: LCDDisplay(0)::Clear
  2680.     FCD_LCDDisplay0_Clear();
  2681.  
  2682.  
  2683.     //Call Component Macro
  2684.     //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
  2685.     FCD_LCDDisplay0_Cursor(3, 1);
  2686.  
  2687.  
  2688.     //Call Component Macro
  2689.     //Call Component Macro: LCDDisplay(0)::PrintASCII("Valid Code")
  2690.     FCD_LCDDisplay0_PrintASCII('V');
  2691.     FCD_LCDDisplay0_PrintASCII('a');
  2692.     FCD_LCDDisplay0_PrintASCII('l');
  2693.     FCD_LCDDisplay0_PrintASCII('i');
  2694.     FCD_LCDDisplay0_PrintASCII('d');
  2695.     FCD_LCDDisplay0_PrintASCII(' ');
  2696.     FCD_LCDDisplay0_PrintASCII('C');
  2697.     FCD_LCDDisplay0_PrintASCII('o');
  2698.     FCD_LCDDisplay0_PrintASCII('d');
  2699.     FCD_LCDDisplay0_PrintASCII('e');
  2700.  
  2701.  
  2702. }
  2703.  
  2704. void FCM_PreAlarm()
  2705. {
  2706.     //Waits a few seconds for the cancellation before setting off the alarm.
  2707.    
  2708.     //Calculation
  2709.     //Calculation:
  2710.     //  Count = 10
  2711.     FCV_COUNT = 10;
  2712.    
  2713.  
  2714.     //Call Component Macro
  2715.     //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  2716.     FCD_LCDDisplay0_ClearLine(1);
  2717.  
  2718.  
  2719.     //Connection Point
  2720.     //Connection Point: [A]: A
  2721. FCC_PreAlarm_A:
  2722. ;
  2723.  
  2724.  
  2725.     //Decision
  2726.     //Decision: InvalidCode = 1?
  2727.     if (FCV_INVALIDCODE == 1)
  2728.     {
  2729.         //Call Component Macro
  2730.         //Call Component Macro: LCDDisplay(0)::Clear
  2731.         FCD_LCDDisplay0_Clear();
  2732.  
  2733.  
  2734.         //Call Component Macro
  2735.         //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  2736.         FCD_LCDDisplay0_Cursor(2, 0);
  2737.  
  2738.  
  2739.         //Call Component Macro
  2740.         //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  2741.         FCD_LCDDisplay0_PrintASCII('S');
  2742.         FCD_LCDDisplay0_PrintASCII('y');
  2743.         FCD_LCDDisplay0_PrintASCII('s');
  2744.         FCD_LCDDisplay0_PrintASCII('t');
  2745.         FCD_LCDDisplay0_PrintASCII('e');
  2746.         FCD_LCDDisplay0_PrintASCII('m');
  2747.         FCD_LCDDisplay0_PrintASCII(' ');
  2748.         FCD_LCDDisplay0_PrintASCII('A');
  2749.         FCD_LCDDisplay0_PrintASCII('r');
  2750.         FCD_LCDDisplay0_PrintASCII('m');
  2751.         FCD_LCDDisplay0_PrintASCII('e');
  2752.         FCD_LCDDisplay0_PrintASCII('d');
  2753.  
  2754.  
  2755.         //Calculation
  2756.         //Calculation:
  2757.         //  InvalidCode = 0
  2758.         FCV_INVALIDCODE = 0;
  2759.        
  2760.  
  2761.     }
  2762.  
  2763.  
  2764.     //Loop
  2765.     //Loop: While Count > 0
  2766.     while (1)
  2767.     {
  2768.         //Output
  2769.         //Output: 1 -> C5
  2770.         trisc = trisc & 0xdf;
  2771.         if (1)
  2772.             portc = (portc & 0xdf) | 0x20;
  2773.         else
  2774.             portc = portc & 0xdf;
  2775.  
  2776.  
  2777.         //Input
  2778.         //Input: A1 -> CancelSwitch
  2779.         trisa = trisa | 0x02;
  2780.         FCV_CANCELSWITCH = ((porta & 0x02) == 0x02);
  2781.  
  2782.  
  2783.         //Decision
  2784.         //Decision: CancelSwitch > 0?
  2785.         if (FCV_CANCELSWITCH > 0)
  2786.         {
  2787.             //Output
  2788.             //Output: 0 -> C5
  2789.             trisc = trisc & 0xdf;
  2790.             if (0)
  2791.                 portc = (portc & 0xdf) | 0x20;
  2792.             else
  2793.                 portc = portc & 0xdf;
  2794.  
  2795.  
  2796.             //Call Macro
  2797.             //Call Macro: EnterCode
  2798.             FCM_EnterCode();
  2799.  
  2800.  
  2801.             //Call Macro
  2802.             //Call Macro: CompareCode
  2803.             FCM_CompareCode();
  2804.  
  2805.  
  2806.             //Decision
  2807.             //Decision: InvalidCode > 0?
  2808.             if (FCV_INVALIDCODE > 0)
  2809.             {
  2810.                 //Delay
  2811.                 //Delay: 5 s
  2812.                 delay_s(5);
  2813.  
  2814.  
  2815.                 //Call Component Macro
  2816.                 //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  2817.                 FCD_LCDDisplay0_ClearLine(1);
  2818.  
  2819.  
  2820.                 //Goto Connection Point
  2821.                 //Goto Connection Point: [A]: A
  2822.                 goto FCC_PreAlarm_A;
  2823.  
  2824.  
  2825.             }
  2826.  
  2827.  
  2828.             //Call Component Macro
  2829.             //Call Component Macro: LCDDisplay(0)::Clear
  2830.             FCD_LCDDisplay0_Clear();
  2831.  
  2832.  
  2833.             //Call Component Macro
  2834.             //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  2835.             FCD_LCDDisplay0_Cursor(2, 0);
  2836.  
  2837.  
  2838.             //Call Component Macro
  2839.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  2840.             FCD_LCDDisplay0_PrintASCII('S');
  2841.             FCD_LCDDisplay0_PrintASCII('y');
  2842.             FCD_LCDDisplay0_PrintASCII('s');
  2843.             FCD_LCDDisplay0_PrintASCII('t');
  2844.             FCD_LCDDisplay0_PrintASCII('e');
  2845.             FCD_LCDDisplay0_PrintASCII('m');
  2846.             FCD_LCDDisplay0_PrintASCII(' ');
  2847.             FCD_LCDDisplay0_PrintASCII('A');
  2848.             FCD_LCDDisplay0_PrintASCII('r');
  2849.             FCD_LCDDisplay0_PrintASCII('m');
  2850.             FCD_LCDDisplay0_PrintASCII('e');
  2851.             FCD_LCDDisplay0_PrintASCII('d');
  2852.  
  2853.  
  2854.             //Output
  2855.             //Output: 0 -> PORT C
  2856.             trisc = 0x00;
  2857.             portc = 0;
  2858.  
  2859.  
  2860.             //Calculation
  2861.             //Calculation:
  2862.             //  AlarmActive = 0
  2863.             //  AlarmZone = 0
  2864.             //  CancelSwitch = 0
  2865.             FCV_ALARMACTIVE = 0;
  2866.             FCV_ALARMZONE = 0;
  2867.             FCV_CANCELSWITCH = 0;
  2868.            
  2869.  
  2870.             //Goto Connection Point
  2871.             //Goto Connection Point: [B]: B
  2872.             goto FCC_PreAlarm_B;
  2873.  
  2874.  
  2875.         } else {
  2876.             //Call Component Macro
  2877.             //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
  2878.             FCD_LCDDisplay0_Cursor(0, 1);
  2879.  
  2880.  
  2881.             //Call Component Macro
  2882.             //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm In:")
  2883.             FCD_LCDDisplay0_PrintASCII('A');
  2884.             FCD_LCDDisplay0_PrintASCII('l');
  2885.             FCD_LCDDisplay0_PrintASCII('a');
  2886.             FCD_LCDDisplay0_PrintASCII('r');
  2887.             FCD_LCDDisplay0_PrintASCII('m');
  2888.             FCD_LCDDisplay0_PrintASCII(' ');
  2889.             FCD_LCDDisplay0_PrintASCII('I');
  2890.             FCD_LCDDisplay0_PrintASCII('n');
  2891.             FCD_LCDDisplay0_PrintASCII(':');
  2892.  
  2893.  
  2894.             //Call Component Macro
  2895.             //Call Component Macro: LCDDisplay(0)::Cursor(10, 1)
  2896.             FCD_LCDDisplay0_Cursor(10, 1);
  2897.  
  2898.  
  2899.             //Call Component Macro
  2900.             //Call Component Macro: LCDDisplay(0)::PrintNumber(Count)
  2901.             FCD_LCDDisplay0_PrintNumber(FCV_COUNT);
  2902.  
  2903.  
  2904.             //Decision
  2905.             //Decision: Count > 9?
  2906.             if (FCV_COUNT > 9)
  2907.             {
  2908.                 //Output
  2909.                 //Output: 1 -> C5
  2910.                 trisc = trisc & 0xdf;
  2911.                 if (1)
  2912.                     portc = (portc & 0xdf) | 0x20;
  2913.                 else
  2914.                     portc = portc & 0xdf;
  2915.  
  2916.  
  2917.                 //Call Component Macro
  2918.                 //Call Component Macro: LCDDisplay(0)::Cursor(13, 1)
  2919.                 FCD_LCDDisplay0_Cursor(13, 1);
  2920.  
  2921.  
  2922.                 //Call Component Macro
  2923.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("Sec")
  2924.                 FCD_LCDDisplay0_PrintASCII('S');
  2925.                 FCD_LCDDisplay0_PrintASCII('e');
  2926.                 FCD_LCDDisplay0_PrintASCII('c');
  2927.  
  2928.  
  2929.             } else {
  2930.                 //Output
  2931.                 //Output: 1 -> C5
  2932.                 trisc = trisc & 0xdf;
  2933.                 if (1)
  2934.                     portc = (portc & 0xdf) | 0x20;
  2935.                 else
  2936.                     portc = portc & 0xdf;
  2937.  
  2938.  
  2939.                 //Call Component Macro
  2940.                 //Call Component Macro: LCDDisplay(0)::Cursor(12, 1)
  2941.                 FCD_LCDDisplay0_Cursor(12, 1);
  2942.  
  2943.  
  2944.                 //Call Component Macro
  2945.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("Sec")
  2946.                 FCD_LCDDisplay0_PrintASCII('S');
  2947.                 FCD_LCDDisplay0_PrintASCII('e');
  2948.                 FCD_LCDDisplay0_PrintASCII('c');
  2949.  
  2950.  
  2951.                 //Call Component Macro
  2952.                 //Call Component Macro: LCDDisplay(0)::Cursor(11, 1)
  2953.                 FCD_LCDDisplay0_Cursor(11, 1);
  2954.  
  2955.  
  2956.                 //Call Component Macro
  2957.                 //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  2958.                 FCD_LCDDisplay0_PrintASCII(' ');
  2959.  
  2960.  
  2961.                 //Call Component Macro
  2962.                 //Call Component Macro: LCDDisplay(0)::Cursor(15, 1)
  2963.                 FCD_LCDDisplay0_Cursor(15, 1);
  2964.  
  2965.  
  2966.                 //Call Component Macro
  2967.                 //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  2968.                 FCD_LCDDisplay0_PrintASCII(' ');
  2969.  
  2970.  
  2971.             }
  2972.  
  2973.  
  2974.         }
  2975.  
  2976.  
  2977.         //Input
  2978.         //Input: A0 -> ArmSwitch
  2979.         trisa = trisa | 0x01;
  2980.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  2981.  
  2982.  
  2983.         //Decision
  2984.         //Decision: ArmSwitch > 0?
  2985.         if (FCV_ARMSWITCH > 0)
  2986.         {
  2987.             //Call Macro
  2988.             //Call Macro: EnterCode
  2989.             FCM_EnterCode();
  2990.  
  2991.  
  2992.             //Call Macro
  2993.             //Call Macro: CompareCode
  2994.             FCM_CompareCode();
  2995.  
  2996.  
  2997.             //Decision
  2998.             //Decision: InvalidCode > 0?
  2999.             if (FCV_INVALIDCODE > 0)
  3000.             {
  3001.                 //Delay
  3002.                 //Delay: 5 s
  3003.                 delay_s(5);
  3004.  
  3005.  
  3006.                 //Call Component Macro
  3007.                 //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  3008.                 FCD_LCDDisplay0_ClearLine(1);
  3009.  
  3010.  
  3011.                 //Goto Connection Point
  3012.                 //Goto Connection Point: [A]: A
  3013.                 goto FCC_PreAlarm_A;
  3014.  
  3015.  
  3016.             }
  3017.  
  3018.  
  3019.             //Call Component Macro
  3020.             //Call Component Macro: LCDDisplay(0)::Clear
  3021.             FCD_LCDDisplay0_Clear();
  3022.  
  3023.  
  3024.             //Call Component Macro
  3025.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  3026.             FCD_LCDDisplay0_PrintASCII('S');
  3027.             FCD_LCDDisplay0_PrintASCII('y');
  3028.             FCD_LCDDisplay0_PrintASCII('s');
  3029.             FCD_LCDDisplay0_PrintASCII('t');
  3030.             FCD_LCDDisplay0_PrintASCII('e');
  3031.             FCD_LCDDisplay0_PrintASCII('m');
  3032.             FCD_LCDDisplay0_PrintASCII(' ');
  3033.             FCD_LCDDisplay0_PrintASCII('D');
  3034.             FCD_LCDDisplay0_PrintASCII('i');
  3035.             FCD_LCDDisplay0_PrintASCII('s');
  3036.             FCD_LCDDisplay0_PrintASCII('a');
  3037.             FCD_LCDDisplay0_PrintASCII('r');
  3038.             FCD_LCDDisplay0_PrintASCII('m');
  3039.             FCD_LCDDisplay0_PrintASCII('e');
  3040.             FCD_LCDDisplay0_PrintASCII('d');
  3041.  
  3042.  
  3043.             //Output
  3044.             //Output: 0 -> PORT C
  3045.             trisc = 0x00;
  3046.             portc = 0;
  3047.  
  3048.  
  3049.             //Calculation
  3050.             //Calculation:
  3051.             //  ArmSwitch = 0
  3052.             //  AlarmActive = 0
  3053.             //  AlarmZone = 0
  3054.             //  SystemArmed = 0
  3055.             FCV_ARMSWITCH = 0;
  3056.             FCV_ALARMACTIVE = 0;
  3057.             FCV_ALARMZONE = 0;
  3058.             FCV_SYSTEMARMED = 0;
  3059.            
  3060.  
  3061.             //Decision
  3062.             //Decision: SystemArmed > 0?
  3063.             if (FCV_SYSTEMARMED > 0)
  3064.             {
  3065.             } else {
  3066.                 //Goto Connection Point
  3067.                 //Goto Connection Point: [B]: B
  3068.                 goto FCC_PreAlarm_B;
  3069.  
  3070.  
  3071.             }
  3072.  
  3073.  
  3074.         }
  3075.  
  3076.  
  3077.         //Calculation
  3078.         //Calculation:
  3079.         //  Count = Count - 1
  3080.         FCV_COUNT = FCV_COUNT - 1;
  3081.        
  3082.  
  3083.         //Delay
  3084.         //Delay: 1 s
  3085.         delay_s(1);
  3086.  
  3087.  
  3088.         //Output
  3089.         //Output: 0 -> C5
  3090.         trisc = trisc & 0xdf;
  3091.         if (0)
  3092.             portc = (portc & 0xdf) | 0x20;
  3093.         else
  3094.             portc = portc & 0xdf;
  3095.  
  3096.  
  3097.         if ((FCV_COUNT > 0) == 0) break;
  3098.     }
  3099.  
  3100.  
  3101.     //Calculation
  3102.     //Calculation:
  3103.     //  CancelSwitch = 0
  3104.     //  AlarmActive = 1
  3105.     FCV_CANCELSWITCH = 0;
  3106.     FCV_ALARMACTIVE = 1;
  3107.    
  3108.  
  3109.     //Call Component Macro
  3110.     //Call Component Macro: LCDDisplay(0)::ClearLine(1)
  3111.     FCD_LCDDisplay0_ClearLine(1);
  3112.  
  3113.  
  3114.     //Connection Point
  3115.     //Connection Point: [B]: B
  3116. FCC_PreAlarm_B:
  3117. ;
  3118.  
  3119.  
  3120. }
  3121.  
  3122. void FCM_FirstStartup()
  3123. {
  3124.     //Sets Passcode when the system is run for the first time
  3125.    
  3126.     //Loop
  3127.     //Loop: While Count < 5
  3128.     while (1)
  3129.     {
  3130.         //Call Component Macro
  3131.         //Call Component Macro: EEPROM(0)::Write(Count, 0)
  3132.         FCD_EEPROM0_WriteEEPROM(FCV_COUNT, 0);
  3133.  
  3134.  
  3135.         //Calculation
  3136.         //Calculation:
  3137.         //  Count = Count + 1
  3138.         FCV_COUNT = FCV_COUNT + 1;
  3139.        
  3140.  
  3141.         if ((FCV_COUNT < 5) == 0) break;
  3142.     }
  3143.  
  3144.  
  3145.     //Connection Point
  3146.     //Connection Point: [O]: O
  3147. FCC_FirstStartup_O:
  3148. ;
  3149.  
  3150.  
  3151.     //Call Component Macro
  3152.     //Call Component Macro: LCDDisplay(0)::Clear
  3153.     FCD_LCDDisplay0_Clear();
  3154.  
  3155.  
  3156.     //Call Component Macro
  3157.     //Call Component Macro: LCDDisplay(0)::PrintASCII("Enter Code:")
  3158.     FCD_LCDDisplay0_PrintASCII('E');
  3159.     FCD_LCDDisplay0_PrintASCII('n');
  3160.     FCD_LCDDisplay0_PrintASCII('t');
  3161.     FCD_LCDDisplay0_PrintASCII('e');
  3162.     FCD_LCDDisplay0_PrintASCII('r');
  3163.     FCD_LCDDisplay0_PrintASCII(' ');
  3164.     FCD_LCDDisplay0_PrintASCII('C');
  3165.     FCD_LCDDisplay0_PrintASCII('o');
  3166.     FCD_LCDDisplay0_PrintASCII('d');
  3167.     FCD_LCDDisplay0_PrintASCII('e');
  3168.     FCD_LCDDisplay0_PrintASCII(':');
  3169.  
  3170.  
  3171.     //Decision
  3172.     //Decision: Digit1 > 0?
  3173.     if (FCV_DIGIT1 > 0)
  3174.     {
  3175.     } else {
  3176.         //Loop
  3177.         //Loop: While Digitset < 1
  3178.         while (FCV_DIGITSET < 1)
  3179.         {
  3180.             //Connection Point
  3181.             //Connection Point: [A]: A
  3182. FCC_FirstStartup_A:
  3183. ;
  3184.  
  3185.  
  3186.             //Call Component Macro
  3187.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3188.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3189.  
  3190.  
  3191.             //Decision
  3192.             //Decision: Keypadnumber = 255?
  3193.             if (FCV_KEYPADNUMBER == 255)
  3194.             {
  3195.                 //Goto Connection Point
  3196.                 //Goto Connection Point: [A]: A
  3197.                 goto FCC_FirstStartup_A;
  3198.  
  3199.  
  3200.             } else {
  3201.                 //Call Component Macro
  3202.                 //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
  3203.                 FCD_LCDDisplay0_Cursor(0, 1);
  3204.  
  3205.  
  3206.                 //Call Component Macro
  3207.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3208.                 FCD_LCDDisplay0_PrintASCII('*');
  3209.  
  3210.  
  3211.                 //Calculation
  3212.                 //Calculation:
  3213.                 //  Digit1 = Keypadnumber
  3214.                 //  Digitset = 1
  3215.                 FCV_DIGIT1 = FCV_KEYPADNUMBER;
  3216.                 FCV_DIGITSET = 1;
  3217.                
  3218.  
  3219.             }
  3220.  
  3221.  
  3222.             //Connection Point
  3223.             //Connection Point: [B]: B
  3224. FCC_FirstStartup_B:
  3225. ;
  3226.  
  3227.  
  3228.             //Call Component Macro
  3229.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3230.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3231.  
  3232.  
  3233.             //Decision
  3234.             //Decision: Keypadnumber = 255?
  3235.             if (FCV_KEYPADNUMBER == 255)
  3236.             {
  3237.             } else {
  3238.                 //Goto Connection Point
  3239.                 //Goto Connection Point: [B]: B
  3240.                 goto FCC_FirstStartup_B;
  3241.  
  3242.  
  3243.             }
  3244.  
  3245.  
  3246.         }
  3247.  
  3248.  
  3249.         //Calculation
  3250.         //Calculation:
  3251.         //  Digitset = 0
  3252.         FCV_DIGITSET = 0;
  3253.        
  3254.  
  3255.     }
  3256.  
  3257.  
  3258.     //Decision
  3259.     //Decision: Digit2 > 0?
  3260.     if (FCV_DIGIT2 > 0)
  3261.     {
  3262.     } else {
  3263.         //Connection Point
  3264.         //Connection Point: [C]: C
  3265. FCC_FirstStartup_C:
  3266. ;
  3267.  
  3268.  
  3269.         //Loop
  3270.         //Loop: While Digitset < 1
  3271.         while (FCV_DIGITSET < 1)
  3272.         {
  3273.             //Call Component Macro
  3274.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3275.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3276.  
  3277.  
  3278.             //Decision
  3279.             //Decision: Keypadnumber =  255?
  3280.             if (FCV_KEYPADNUMBER ==  255)
  3281.             {
  3282.                 //Goto Connection Point
  3283.                 //Goto Connection Point: [C]: C
  3284.                 goto FCC_FirstStartup_C;
  3285.  
  3286.  
  3287.             } else {
  3288.                 //Call Component Macro
  3289.                 //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  3290.                 FCD_LCDDisplay0_Cursor(1, 1);
  3291.  
  3292.  
  3293.                 //Call Component Macro
  3294.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3295.                 FCD_LCDDisplay0_PrintASCII('*');
  3296.  
  3297.  
  3298.                 //Calculation
  3299.                 //Calculation:
  3300.                 //  Digit2 = Keypadnumber
  3301.                 //  Digitset = 1
  3302.                 FCV_DIGIT2 = FCV_KEYPADNUMBER;
  3303.                 FCV_DIGITSET = 1;
  3304.                
  3305.  
  3306.             }
  3307.  
  3308.  
  3309.             //Connection Point
  3310.             //Connection Point: [D]: D
  3311. FCC_FirstStartup_D:
  3312. ;
  3313.  
  3314.  
  3315.             //Call Component Macro
  3316.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3317.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3318.  
  3319.  
  3320.             //Decision
  3321.             //Decision: Keypadnumber =  255?
  3322.             if (FCV_KEYPADNUMBER ==  255)
  3323.             {
  3324.             } else {
  3325.                 //Goto Connection Point
  3326.                 //Goto Connection Point: [D]: D
  3327.                 goto FCC_FirstStartup_D;
  3328.  
  3329.  
  3330.             }
  3331.  
  3332.  
  3333.         }
  3334.  
  3335.  
  3336.         //Calculation
  3337.         //Calculation:
  3338.         //  Digitset = 0
  3339.         FCV_DIGITSET = 0;
  3340.        
  3341.  
  3342.     }
  3343.  
  3344.  
  3345.     //Decision
  3346.     //Decision: Digit3 > 0?
  3347.     if (FCV_DIGIT3 > 0)
  3348.     {
  3349.     } else {
  3350.         //Loop
  3351.         //Loop: While Digitset < 1
  3352.         while (FCV_DIGITSET < 1)
  3353.         {
  3354.             //Connection Point
  3355.             //Connection Point: [E]: E
  3356. FCC_FirstStartup_E:
  3357. ;
  3358.  
  3359.  
  3360.             //Call Component Macro
  3361.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3362.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3363.  
  3364.  
  3365.             //Decision
  3366.             //Decision: Keypadnumber = 255?
  3367.             if (FCV_KEYPADNUMBER == 255)
  3368.             {
  3369.                 //Goto Connection Point
  3370.                 //Goto Connection Point: [E]: E
  3371.                 goto FCC_FirstStartup_E;
  3372.  
  3373.  
  3374.             } else {
  3375.                 //Call Component Macro
  3376.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  3377.                 FCD_LCDDisplay0_Cursor(2, 1);
  3378.  
  3379.  
  3380.                 //Call Component Macro
  3381.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3382.                 FCD_LCDDisplay0_PrintASCII('*');
  3383.  
  3384.  
  3385.                 //Calculation
  3386.                 //Calculation:
  3387.                 //  Digit3 = Keypadnumber
  3388.                 //  Digitset = 1
  3389.                 FCV_DIGIT3 = FCV_KEYPADNUMBER;
  3390.                 FCV_DIGITSET = 1;
  3391.                
  3392.  
  3393.             }
  3394.  
  3395.  
  3396.             //Connection Point
  3397.             //Connection Point: [F]: F
  3398. FCC_FirstStartup_F:
  3399. ;
  3400.  
  3401.  
  3402.             //Call Component Macro
  3403.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3404.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3405.  
  3406.  
  3407.             //Decision
  3408.             //Decision: Keypadnumber = 255?
  3409.             if (FCV_KEYPADNUMBER == 255)
  3410.             {
  3411.             } else {
  3412.                 //Goto Connection Point
  3413.                 //Goto Connection Point: [F]: F
  3414.                 goto FCC_FirstStartup_F;
  3415.  
  3416.  
  3417.             }
  3418.  
  3419.  
  3420.         }
  3421.  
  3422.  
  3423.         //Calculation
  3424.         //Calculation:
  3425.         //  Digitset = 0
  3426.         FCV_DIGITSET = 0;
  3427.        
  3428.  
  3429.     }
  3430.  
  3431.  
  3432.     //Decision
  3433.     //Decision: Digit4 > 0?
  3434.     if (FCV_DIGIT4 > 0)
  3435.     {
  3436.     } else {
  3437.         //Loop
  3438.         //Loop: While Digitset < 1
  3439.         while (FCV_DIGITSET < 1)
  3440.         {
  3441.             //Connection Point
  3442.             //Connection Point: [G]: G
  3443. FCC_FirstStartup_G:
  3444. ;
  3445.  
  3446.  
  3447.             //Call Component Macro
  3448.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3449.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3450.  
  3451.  
  3452.             //Decision
  3453.             //Decision: Keypadnumber = 255?
  3454.             if (FCV_KEYPADNUMBER == 255)
  3455.             {
  3456.                 //Goto Connection Point
  3457.                 //Goto Connection Point: [G]: G
  3458.                 goto FCC_FirstStartup_G;
  3459.  
  3460.  
  3461.             } else {
  3462.                 //Calculation
  3463.                 //Calculation:
  3464.                 //  Digit4 = Keypadnumber
  3465.                 //  Digitset = 1
  3466.                 FCV_DIGIT4 = FCV_KEYPADNUMBER;
  3467.                 FCV_DIGITSET = 1;
  3468.                
  3469.  
  3470.                 //Call Component Macro
  3471.                 //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
  3472.                 FCD_LCDDisplay0_Cursor(3, 1);
  3473.  
  3474.  
  3475.                 //Call Component Macro
  3476.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3477.                 FCD_LCDDisplay0_PrintASCII('*');
  3478.  
  3479.  
  3480.             }
  3481.  
  3482.  
  3483.             //Connection Point
  3484.             //Connection Point: [H]: H
  3485. FCC_FirstStartup_H:
  3486. ;
  3487.  
  3488.  
  3489.             //Call Component Macro
  3490.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3491.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3492.  
  3493.  
  3494.             //Decision
  3495.             //Decision: Keypadnumber = 255?
  3496.             if (FCV_KEYPADNUMBER == 255)
  3497.             {
  3498.             } else {
  3499.                 //Goto Connection Point
  3500.                 //Goto Connection Point: [H]: H
  3501.                 goto FCC_FirstStartup_H;
  3502.  
  3503.  
  3504.             }
  3505.  
  3506.  
  3507.         }
  3508.  
  3509.  
  3510.         //Calculation
  3511.         //Calculation:
  3512.         //  Digitset = 0
  3513.         //  Code = Digit1
  3514.         //  Code = Code + (Digit2 * 1000)
  3515.         //  Code = Code + (Digit3 * 100)
  3516.         //  Code = Code + (Digit4 * 10)
  3517.         //  Digit1 = 0
  3518.         //  Digit2 = 0
  3519.         //  Digit3 = 0
  3520.         //  Digit4 = 0
  3521.         FCV_DIGITSET = 0;
  3522.         FCV_CODE = FCV_DIGIT1;
  3523.         FCV_CODE = FCV_CODE + (FCV_DIGIT2 * 1000);
  3524.         FCV_CODE = FCV_CODE + (FCV_DIGIT3 * 100);
  3525.         FCV_CODE = FCV_CODE + (FCV_DIGIT4 * 10);
  3526.         FCV_DIGIT1 = 0;
  3527.         FCV_DIGIT2 = 0;
  3528.         FCV_DIGIT3 = 0;
  3529.         FCV_DIGIT4 = 0;
  3530.        
  3531.  
  3532.     }
  3533.  
  3534.  
  3535.     //Call Component Macro
  3536.     //Call Component Macro: LCDDisplay(0)::Clear
  3537.     FCD_LCDDisplay0_Clear();
  3538.  
  3539.  
  3540.     //Call Component Macro
  3541.     //Call Component Macro: LCDDisplay(0)::PrintASCII("Confirm Code:")
  3542.     FCD_LCDDisplay0_PrintASCII('C');
  3543.     FCD_LCDDisplay0_PrintASCII('o');
  3544.     FCD_LCDDisplay0_PrintASCII('n');
  3545.     FCD_LCDDisplay0_PrintASCII('f');
  3546.     FCD_LCDDisplay0_PrintASCII('i');
  3547.     FCD_LCDDisplay0_PrintASCII('r');
  3548.     FCD_LCDDisplay0_PrintASCII('m');
  3549.     FCD_LCDDisplay0_PrintASCII(' ');
  3550.     FCD_LCDDisplay0_PrintASCII('C');
  3551.     FCD_LCDDisplay0_PrintASCII('o');
  3552.     FCD_LCDDisplay0_PrintASCII('d');
  3553.     FCD_LCDDisplay0_PrintASCII('e');
  3554.     FCD_LCDDisplay0_PrintASCII(':');
  3555.  
  3556.  
  3557.     //Decision
  3558.     //Decision: Digit1 > 0?
  3559.     if (FCV_DIGIT1 > 0)
  3560.     {
  3561.     } else {
  3562.         //Connection Point
  3563.         //Connection Point: [I]: I
  3564. FCC_FirstStartup_I:
  3565. ;
  3566.  
  3567.  
  3568.         //Loop
  3569.         //Loop: While Digitset < 1
  3570.         while (FCV_DIGITSET < 1)
  3571.         {
  3572.             //Call Component Macro
  3573.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3574.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3575.  
  3576.  
  3577.             //Decision
  3578.             //Decision: Keypadnumber = 255?
  3579.             if (FCV_KEYPADNUMBER == 255)
  3580.             {
  3581.                 //Goto Connection Point
  3582.                 //Goto Connection Point: [I]: I
  3583.                 goto FCC_FirstStartup_I;
  3584.  
  3585.  
  3586.             } else {
  3587.                 //Calculation
  3588.                 //Calculation:
  3589.                 //  Digit1 = Keypadnumber
  3590.                 //  Digitset = 1
  3591.                 FCV_DIGIT1 = FCV_KEYPADNUMBER;
  3592.                 FCV_DIGITSET = 1;
  3593.                
  3594.  
  3595.                 //Call Component Macro
  3596.                 //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
  3597.                 FCD_LCDDisplay0_Cursor(0, 1);
  3598.  
  3599.  
  3600.                 //Call Component Macro
  3601.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3602.                 FCD_LCDDisplay0_PrintASCII('*');
  3603.  
  3604.  
  3605.             }
  3606.  
  3607.  
  3608.             //Connection Point
  3609.             //Connection Point: [J]: J
  3610. FCC_FirstStartup_J:
  3611. ;
  3612.  
  3613.  
  3614.             //Call Component Macro
  3615.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3616.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3617.  
  3618.  
  3619.             //Decision
  3620.             //Decision: Keypadnumber = 255?
  3621.             if (FCV_KEYPADNUMBER == 255)
  3622.             {
  3623.             } else {
  3624.                 //Goto Connection Point
  3625.                 //Goto Connection Point: [J]: J
  3626.                 goto FCC_FirstStartup_J;
  3627.  
  3628.  
  3629.             }
  3630.  
  3631.  
  3632.         }
  3633.  
  3634.  
  3635.         //Calculation
  3636.         //Calculation:
  3637.         //  Digitset = 0
  3638.         FCV_DIGITSET = 0;
  3639.        
  3640.  
  3641.     }
  3642.  
  3643.  
  3644.     //Decision
  3645.     //Decision: Digit2 > 0?
  3646.     if (FCV_DIGIT2 > 0)
  3647.     {
  3648.     } else {
  3649.         //Loop
  3650.         //Loop: While Digitset < 1
  3651.         while (1)
  3652.         {
  3653.             //Connection Point
  3654.             //Connection Point: [K]: K
  3655. FCC_FirstStartup_K:
  3656. ;
  3657.  
  3658.  
  3659.             //Call Component Macro
  3660.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3661.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3662.  
  3663.  
  3664.             //Decision
  3665.             //Decision: Keypadnumber = 255?
  3666.             if (FCV_KEYPADNUMBER == 255)
  3667.             {
  3668.                 //Goto Connection Point
  3669.                 //Goto Connection Point: [K]: K
  3670.                 goto FCC_FirstStartup_K;
  3671.  
  3672.  
  3673.             } else {
  3674.                 //Calculation
  3675.                 //Calculation:
  3676.                 //  Digit2 = Keypadnumber
  3677.                 //  Digitset = 1
  3678.                 FCV_DIGIT2 = FCV_KEYPADNUMBER;
  3679.                 FCV_DIGITSET = 1;
  3680.                
  3681.  
  3682.                 //Call Component Macro
  3683.                 //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  3684.                 FCD_LCDDisplay0_Cursor(1, 1);
  3685.  
  3686.  
  3687.                 //Call Component Macro
  3688.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3689.                 FCD_LCDDisplay0_PrintASCII('*');
  3690.  
  3691.  
  3692.             }
  3693.  
  3694.  
  3695.             //Connection Point
  3696.             //Connection Point: [L]: L
  3697. FCC_FirstStartup_L:
  3698. ;
  3699.  
  3700.  
  3701.             //Call Component Macro
  3702.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3703.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3704.  
  3705.  
  3706.             //Decision
  3707.             //Decision: Keypadnumber = 255?
  3708.             if (FCV_KEYPADNUMBER == 255)
  3709.             {
  3710.             } else {
  3711.                 //Goto Connection Point
  3712.                 //Goto Connection Point: [L]: L
  3713.                 goto FCC_FirstStartup_L;
  3714.  
  3715.  
  3716.             }
  3717.  
  3718.  
  3719.             if ((FCV_DIGITSET < 1) == 0) break;
  3720.         }
  3721.  
  3722.  
  3723.         //Calculation
  3724.         //Calculation:
  3725.         //  Digitset = 0
  3726.         FCV_DIGITSET = 0;
  3727.        
  3728.  
  3729.     }
  3730.  
  3731.  
  3732.     //Decision
  3733.     //Decision: Digit3 > 0?
  3734.     if (FCV_DIGIT3 > 0)
  3735.     {
  3736.     } else {
  3737.         //Connection Point
  3738.         //Connection Point: [M]: M
  3739. FCC_FirstStartup_M:
  3740. ;
  3741.  
  3742.  
  3743.         //Loop
  3744.         //Loop: While Digitset < 1
  3745.         while (1)
  3746.         {
  3747.             //Call Component Macro
  3748.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3749.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3750.  
  3751.  
  3752.             //Decision
  3753.             //Decision: Keypadnumber = 255?
  3754.             if (FCV_KEYPADNUMBER == 255)
  3755.             {
  3756.                 //Goto Connection Point
  3757.                 //Goto Connection Point: [M]: M
  3758.                 goto FCC_FirstStartup_M;
  3759.  
  3760.  
  3761.             } else {
  3762.                 //Calculation
  3763.                 //Calculation:
  3764.                 //  Digit3 = Keypadnumber
  3765.                 //  Digitset = 1
  3766.                 FCV_DIGIT3 = FCV_KEYPADNUMBER;
  3767.                 FCV_DIGITSET = 1;
  3768.                
  3769.  
  3770.                 //Call Component Macro
  3771.                 //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  3772.                 FCD_LCDDisplay0_Cursor(2, 1);
  3773.  
  3774.  
  3775.                 //Call Component Macro
  3776.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3777.                 FCD_LCDDisplay0_PrintASCII('*');
  3778.  
  3779.  
  3780.             }
  3781.  
  3782.  
  3783.             //Connection Point
  3784.             //Connection Point: [N]: N
  3785. FCC_FirstStartup_N:
  3786. ;
  3787.  
  3788.  
  3789.             //Call Component Macro
  3790.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3791.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3792.  
  3793.  
  3794.             //Decision
  3795.             //Decision: Keypadnumber = 255?
  3796.             if (FCV_KEYPADNUMBER == 255)
  3797.             {
  3798.             } else {
  3799.                 //Goto Connection Point
  3800.                 //Goto Connection Point: [N]: N
  3801.                 goto FCC_FirstStartup_N;
  3802.  
  3803.  
  3804.             }
  3805.  
  3806.  
  3807.             if ((FCV_DIGITSET < 1) == 0) break;
  3808.         }
  3809.  
  3810.  
  3811.         //Calculation
  3812.         //Calculation:
  3813.         //  Digitset = 0
  3814.         FCV_DIGITSET = 0;
  3815.        
  3816.  
  3817.     }
  3818.  
  3819.  
  3820.     //Decision
  3821.     //Decision: Digit4 > 0?
  3822.     if (FCV_DIGIT4 > 0)
  3823.     {
  3824.     } else {
  3825.         //Loop
  3826.         //Loop: While Digitset < 1
  3827.         while (1)
  3828.         {
  3829.             //Connection Point
  3830.             //Connection Point: [P]: P
  3831. FCC_FirstStartup_P:
  3832. ;
  3833.  
  3834.  
  3835.             //Call Component Macro
  3836.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3837.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3838.  
  3839.  
  3840.             //Decision
  3841.             //Decision: Keypadnumber = 255?
  3842.             if (FCV_KEYPADNUMBER == 255)
  3843.             {
  3844.                 //Goto Connection Point
  3845.                 //Goto Connection Point: [P]: P
  3846.                 goto FCC_FirstStartup_P;
  3847.  
  3848.  
  3849.             } else {
  3850.                 //Calculation
  3851.                 //Calculation:
  3852.                 //  Digit4 = Keypadnumber
  3853.                 //  Digitset = 1
  3854.                 FCV_DIGIT4 = FCV_KEYPADNUMBER;
  3855.                 FCV_DIGITSET = 1;
  3856.                
  3857.  
  3858.                 //Call Component Macro
  3859.                 //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  3860.                 FCD_LCDDisplay0_Cursor(1, 1);
  3861.  
  3862.  
  3863.                 //Call Component Macro
  3864.                 //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
  3865.                 FCD_LCDDisplay0_PrintASCII('*');
  3866.  
  3867.  
  3868.             }
  3869.  
  3870.  
  3871.             //Connection Point
  3872.             //Connection Point: [Q]: Q
  3873. FCC_FirstStartup_Q:
  3874. ;
  3875.  
  3876.  
  3877.             //Call Component Macro
  3878.             //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
  3879.             FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
  3880.  
  3881.  
  3882.             //Decision
  3883.             //Decision: Keypadnumber = 255?
  3884.             if (FCV_KEYPADNUMBER == 255)
  3885.             {
  3886.             } else {
  3887.                 //Goto Connection Point
  3888.                 //Goto Connection Point: [Q]: Q
  3889.                 goto FCC_FirstStartup_Q;
  3890.  
  3891.  
  3892.             }
  3893.  
  3894.  
  3895.             if ((FCV_DIGITSET < 1) == 0) break;
  3896.         }
  3897.  
  3898.  
  3899.         //Calculation
  3900.         //Calculation:
  3901.         //  Digitset = 0
  3902.         //  CompareCode = Digit1
  3903.         //  CompareCode = CompareCode + (Digit2 * 1000)
  3904.         //  CompareCode = CompareCode + (Digit3 * 100)
  3905.         //  CompareCode = CompareCode + (Digit4 * 10)
  3906.         FCV_DIGITSET = 0;
  3907.         FCV_COMPARECODE = FCV_DIGIT1;
  3908.         FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT2 * 1000);
  3909.         FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT3 * 100);
  3910.         FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT4 * 10);
  3911.        
  3912.  
  3913.     }
  3914.  
  3915.  
  3916.     //Decision
  3917.     //Decision: Code = CompareCode?
  3918.     if (FCV_CODE == FCV_COMPARECODE)
  3919.     {
  3920.         //Calculation
  3921.         //Calculation:
  3922.         //  Count = 0
  3923.         //  DigitCount = 1
  3924.         FCV_COUNT = 0;
  3925.         FCV_DIGITCOUNT = 1;
  3926.        
  3927.  
  3928.         //Loop
  3929.         //Loop: While Count < 4
  3930.         while (1)
  3931.         {
  3932.             //Call Component Macro
  3933.             //Call Component Macro: EEPROM(0)::Write(Count, DigitCount)
  3934.             FCD_EEPROM0_WriteEEPROM(FCV_COUNT, FCV_DIGITCOUNT);
  3935.  
  3936.  
  3937.             //Calculation
  3938.             //Calculation:
  3939.             //  Count = Count + 1
  3940.             //  DigitCount = DigitCount + 1
  3941.             FCV_COUNT = FCV_COUNT + 1;
  3942.             FCV_DIGITCOUNT = FCV_DIGITCOUNT + 1;
  3943.            
  3944.  
  3945.             if ((FCV_COUNT < 4) == 0) break;
  3946.         }
  3947.  
  3948.  
  3949.         //Calculation
  3950.         //Calculation:
  3951.         //  FirstRun = 1
  3952.         FCV_FIRSTRUN = 1;
  3953.        
  3954.  
  3955.         //Call Component Macro
  3956.         //Call Component Macro: EEPROM(0)::Write(4, FirstRun)
  3957.         FCD_EEPROM0_WriteEEPROM(4, FCV_FIRSTRUN);
  3958.  
  3959.  
  3960.         //Call Component Macro
  3961.         //Call Component Macro: LCDDisplay(0)::Clear
  3962.         FCD_LCDDisplay0_Clear();
  3963.  
  3964.  
  3965.         //Call Component Macro
  3966.         //Call Component Macro: LCDDisplay(0)::PrintASCII("Code Set")
  3967.         FCD_LCDDisplay0_PrintASCII('C');
  3968.         FCD_LCDDisplay0_PrintASCII('o');
  3969.         FCD_LCDDisplay0_PrintASCII('d');
  3970.         FCD_LCDDisplay0_PrintASCII('e');
  3971.         FCD_LCDDisplay0_PrintASCII(' ');
  3972.         FCD_LCDDisplay0_PrintASCII('S');
  3973.         FCD_LCDDisplay0_PrintASCII('e');
  3974.         FCD_LCDDisplay0_PrintASCII('t');
  3975.  
  3976.  
  3977.         //Calculation
  3978.         //Calculation:
  3979.         //  Keypadnumber = 0
  3980.         //  Code = 0
  3981.         //  CompareCode = 0
  3982.         //  Digit1 = 0
  3983.         //  Digit2 = 0
  3984.         //  Digit3 = 0
  3985.         //  Digit4 = 0
  3986.         //  Count = 0
  3987.         //  DigitCount = 0
  3988.         FCV_KEYPADNUMBER = 0;
  3989.         FCV_CODE = 0;
  3990.         FCV_COMPARECODE = 0;
  3991.         FCV_DIGIT1 = 0;
  3992.         FCV_DIGIT2 = 0;
  3993.         FCV_DIGIT3 = 0;
  3994.         FCV_DIGIT4 = 0;
  3995.         FCV_COUNT = 0;
  3996.         FCV_DIGITCOUNT = 0;
  3997.        
  3998.  
  3999.         //Delay
  4000.         //Delay: 5 s
  4001.         delay_s(5);
  4002.  
  4003.  
  4004.         //Call Component Macro
  4005.         //Call Component Macro: LCDDisplay(0)::Clear
  4006.         FCD_LCDDisplay0_Clear();
  4007.  
  4008.  
  4009.     } else {
  4010.         //Call Component Macro
  4011.         //Call Component Macro: LCDDisplay(0)::Clear
  4012.         FCD_LCDDisplay0_Clear();
  4013.  
  4014.  
  4015.         //Call Component Macro
  4016.         //Call Component Macro: LCDDisplay(0)::PrintASCII("Codes Do Not Match")
  4017.         FCD_LCDDisplay0_PrintASCII('C');
  4018.         FCD_LCDDisplay0_PrintASCII('o');
  4019.         FCD_LCDDisplay0_PrintASCII('d');
  4020.         FCD_LCDDisplay0_PrintASCII('e');
  4021.         FCD_LCDDisplay0_PrintASCII('s');
  4022.         FCD_LCDDisplay0_PrintASCII(' ');
  4023.         FCD_LCDDisplay0_PrintASCII('D');
  4024.         FCD_LCDDisplay0_PrintASCII('o');
  4025.         FCD_LCDDisplay0_PrintASCII(' ');
  4026.         FCD_LCDDisplay0_PrintASCII('N');
  4027.         FCD_LCDDisplay0_PrintASCII('o');
  4028.         FCD_LCDDisplay0_PrintASCII('t');
  4029.         FCD_LCDDisplay0_PrintASCII(' ');
  4030.         FCD_LCDDisplay0_PrintASCII('M');
  4031.         FCD_LCDDisplay0_PrintASCII('a');
  4032.         FCD_LCDDisplay0_PrintASCII('t');
  4033.         FCD_LCDDisplay0_PrintASCII('c');
  4034.         FCD_LCDDisplay0_PrintASCII('h');
  4035.  
  4036.  
  4037.         //Delay
  4038.         //Delay: 3 s
  4039.         delay_s(3);
  4040.  
  4041.  
  4042.         //Goto Connection Point
  4043.         //Goto Connection Point: [O]: O
  4044.         goto FCC_FirstStartup_O;
  4045.  
  4046.  
  4047.     }
  4048.  
  4049.  
  4050. }
  4051.  
  4052. void main()
  4053. {
  4054.    
  4055.     //Initialisation
  4056.     adcon1 = 0x07;
  4057.  
  4058.  
  4059.     //Interrupt initialisation code
  4060.     option_reg = 0xC0;
  4061.  
  4062.  
  4063.     //Call Component Macro
  4064.     //Call Component Macro: LCDDisplay(0)::Start
  4065.     FCD_LCDDisplay0_Start();
  4066.  
  4067.  
  4068.     //Delay
  4069.     //Delay: 250 ms
  4070.     delay_ms(250);
  4071.  
  4072.  
  4073.     //Call Component Macro
  4074.     //Call Component Macro: FirstRun=EEPROM(0)::Read(4)
  4075.     FCV_FIRSTRUN = FCD_EEPROM0_EEPROMRead(4);
  4076.  
  4077.  
  4078.     //Decision
  4079.     //Decision: FirstRun > 0?
  4080.     if (FCV_FIRSTRUN > 0)
  4081.     {
  4082.     } else {
  4083.         //Call Macro
  4084.         //Call Macro: FirstStartup
  4085.         FCM_FirstStartup();
  4086.  
  4087.  
  4088.     }
  4089.  
  4090.  
  4091.     //Calculation
  4092.     //Calculation:
  4093.     //  Count = 10
  4094.     FCV_COUNT = 10;
  4095.    
  4096.  
  4097.     //Call Component Macro
  4098.     //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
  4099.     FCD_LCDDisplay0_PrintASCII('S');
  4100.     FCD_LCDDisplay0_PrintASCII('y');
  4101.     FCD_LCDDisplay0_PrintASCII('s');
  4102.     FCD_LCDDisplay0_PrintASCII('t');
  4103.     FCD_LCDDisplay0_PrintASCII('e');
  4104.     FCD_LCDDisplay0_PrintASCII('m');
  4105.     FCD_LCDDisplay0_PrintASCII(' ');
  4106.     FCD_LCDDisplay0_PrintASCII('D');
  4107.     FCD_LCDDisplay0_PrintASCII('i');
  4108.     FCD_LCDDisplay0_PrintASCII('s');
  4109.     FCD_LCDDisplay0_PrintASCII('a');
  4110.     FCD_LCDDisplay0_PrintASCII('r');
  4111.     FCD_LCDDisplay0_PrintASCII('m');
  4112.     FCD_LCDDisplay0_PrintASCII('e');
  4113.     FCD_LCDDisplay0_PrintASCII('d');
  4114.  
  4115.  
  4116.     //Loop
  4117.     //Loop: While 1
  4118.     while (1)
  4119.     {
  4120.         //Decision
  4121.         //Decision: Count < 10?
  4122.         if (FCV_COUNT < 10)
  4123.         {
  4124.             //Calculation
  4125.             //Calculation:
  4126.             //  Count = 10
  4127.             FCV_COUNT = 10;
  4128.            
  4129.  
  4130.         }
  4131.  
  4132.  
  4133.         //Input
  4134.         //Input: A0 -> ArmSwitch
  4135.         trisa = trisa | 0x01;
  4136.         FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
  4137.  
  4138.  
  4139.         //Decision
  4140.         //Decision: ArmSwitch > 0?
  4141.         if (FCV_ARMSWITCH > 0)
  4142.         {
  4143.             //Call Component Macro
  4144.             //Call Component Macro: LCDDisplay(0)::Clear
  4145.             FCD_LCDDisplay0_Clear();
  4146.  
  4147.  
  4148.             //Call Component Macro
  4149.             //Call Component Macro: LCDDisplay(0)::Cursor(0, 0)
  4150.             FCD_LCDDisplay0_Cursor(0, 0);
  4151.  
  4152.  
  4153.             //Call Component Macro
  4154.             //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm Active In")
  4155.             FCD_LCDDisplay0_PrintASCII('A');
  4156.             FCD_LCDDisplay0_PrintASCII('l');
  4157.             FCD_LCDDisplay0_PrintASCII('a');
  4158.             FCD_LCDDisplay0_PrintASCII('r');
  4159.             FCD_LCDDisplay0_PrintASCII('m');
  4160.             FCD_LCDDisplay0_PrintASCII(' ');
  4161.             FCD_LCDDisplay0_PrintASCII('A');
  4162.             FCD_LCDDisplay0_PrintASCII('c');
  4163.             FCD_LCDDisplay0_PrintASCII('t');
  4164.             FCD_LCDDisplay0_PrintASCII('i');
  4165.             FCD_LCDDisplay0_PrintASCII('v');
  4166.             FCD_LCDDisplay0_PrintASCII('e');
  4167.             FCD_LCDDisplay0_PrintASCII(' ');
  4168.             FCD_LCDDisplay0_PrintASCII('I');
  4169.             FCD_LCDDisplay0_PrintASCII('n');
  4170.  
  4171.  
  4172.             //Loop
  4173.             //Loop: While Count > 0
  4174.             while (1)
  4175.             {
  4176.                 //Call Component Macro
  4177.                 //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
  4178.                 FCD_LCDDisplay0_Cursor(0, 1);
  4179.  
  4180.  
  4181.                 //Call Component Macro
  4182.                 //Call Component Macro: LCDDisplay(0)::PrintNumber(Count)
  4183.                 FCD_LCDDisplay0_PrintNumber(FCV_COUNT);
  4184.  
  4185.  
  4186.                 //Decision
  4187.                 //Decision: Count > 9?
  4188.                 if (FCV_COUNT > 9)
  4189.                 {
  4190.                     //Call Component Macro
  4191.                     //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
  4192.                     FCD_LCDDisplay0_Cursor(3, 1);
  4193.  
  4194.  
  4195.                     //Call Component Macro
  4196.                     //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
  4197.                     FCD_LCDDisplay0_PrintASCII('S');
  4198.                     FCD_LCDDisplay0_PrintASCII('e');
  4199.                     FCD_LCDDisplay0_PrintASCII('c');
  4200.                     FCD_LCDDisplay0_PrintASCII('o');
  4201.                     FCD_LCDDisplay0_PrintASCII('n');
  4202.                     FCD_LCDDisplay0_PrintASCII('d');
  4203.                     FCD_LCDDisplay0_PrintASCII('s');
  4204.  
  4205.  
  4206.                 } else {
  4207.                     //Call Component Macro
  4208.                     //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
  4209.                     FCD_LCDDisplay0_Cursor(1, 1);
  4210.  
  4211.  
  4212.                     //Decision
  4213.                     //Decision: Count > 1?
  4214.                     if (FCV_COUNT > 1)
  4215.                     {
  4216.                         //Call Component Macro
  4217.                         //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  4218.                         FCD_LCDDisplay0_PrintASCII(' ');
  4219.  
  4220.  
  4221.                         //Call Component Macro
  4222.                         //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  4223.                         FCD_LCDDisplay0_Cursor(2, 1);
  4224.  
  4225.  
  4226.                         //Call Component Macro
  4227.                         //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
  4228.                         FCD_LCDDisplay0_PrintASCII('S');
  4229.                         FCD_LCDDisplay0_PrintASCII('e');
  4230.                         FCD_LCDDisplay0_PrintASCII('c');
  4231.                         FCD_LCDDisplay0_PrintASCII('o');
  4232.                         FCD_LCDDisplay0_PrintASCII('n');
  4233.                         FCD_LCDDisplay0_PrintASCII('d');
  4234.                         FCD_LCDDisplay0_PrintASCII('s');
  4235.  
  4236.  
  4237.                         //Call Component Macro
  4238.                         //Call Component Macro: LCDDisplay(0)::Cursor(9, 1)
  4239.                         FCD_LCDDisplay0_Cursor(9, 1);
  4240.  
  4241.  
  4242.                         //Call Component Macro
  4243.                         //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  4244.                         FCD_LCDDisplay0_PrintASCII(' ');
  4245.  
  4246.  
  4247.                     } else {
  4248.                         //Call Component Macro
  4249.                         //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  4250.                         FCD_LCDDisplay0_PrintASCII(' ');
  4251.  
  4252.  
  4253.                         //Call Component Macro
  4254.                         //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
  4255.                         FCD_LCDDisplay0_Cursor(2, 1);
  4256.  
  4257.  
  4258.                         //Call Component Macro
  4259.                         //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
  4260.                         FCD_LCDDisplay0_PrintASCII('S');
  4261.                         FCD_LCDDisplay0_PrintASCII('e');
  4262.                         FCD_LCDDisplay0_PrintASCII('c');
  4263.                         FCD_LCDDisplay0_PrintASCII('o');
  4264.                         FCD_LCDDisplay0_PrintASCII('n');
  4265.                         FCD_LCDDisplay0_PrintASCII('d');
  4266.                         FCD_LCDDisplay0_PrintASCII('s');
  4267.  
  4268.  
  4269.                         //Call Component Macro
  4270.                         //Call Component Macro: LCDDisplay(0)::Cursor(8, 1)
  4271.                         FCD_LCDDisplay0_Cursor(8, 1);
  4272.  
  4273.  
  4274.                         //Call Component Macro
  4275.                         //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
  4276.                         FCD_LCDDisplay0_PrintASCII(' ');
  4277.  
  4278.  
  4279.                     }
  4280.  
  4281.  
  4282.                 }
  4283.  
  4284.  
  4285.                 //Delay
  4286.                 //Delay: 1 s
  4287.                 delay_s(1);
  4288.  
  4289.  
  4290.                 //Calculation
  4291.                 //Calculation:
  4292.                 //  Count = Count - 1
  4293.                 FCV_COUNT = FCV_COUNT - 1;
  4294.                
  4295.  
  4296.                 if ((FCV_COUNT > 0) == 0) break;
  4297.             }
  4298.  
  4299.  
  4300.             //Call Component Macro
  4301.             //Call Component Macro: LCDDisplay(0)::Clear
  4302.             FCD_LCDDisplay0_Clear();
  4303.  
  4304.  
  4305.             //Call Component Macro
  4306.             //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
  4307.             FCD_LCDDisplay0_Cursor(2, 0);
  4308.  
  4309.  
  4310.             //Call Component Macro
  4311.             //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
  4312.             FCD_LCDDisplay0_PrintASCII('S');
  4313.             FCD_LCDDisplay0_PrintASCII('y');
  4314.             FCD_LCDDisplay0_PrintASCII('s');
  4315.             FCD_LCDDisplay0_PrintASCII('t');
  4316.             FCD_LCDDisplay0_PrintASCII('e');
  4317.             FCD_LCDDisplay0_PrintASCII('m');
  4318.             FCD_LCDDisplay0_PrintASCII(' ');
  4319.             FCD_LCDDisplay0_PrintASCII('A');
  4320.             FCD_LCDDisplay0_PrintASCII('r');
  4321.             FCD_LCDDisplay0_PrintASCII('m');
  4322.             FCD_LCDDisplay0_PrintASCII('e');
  4323.             FCD_LCDDisplay0_PrintASCII('d');
  4324.  
  4325.  
  4326.             //Calculation
  4327.             //Calculation:
  4328.             //  SystemArmed = 1
  4329.             //  Count = 10
  4330.             FCV_SYSTEMARMED = 1;
  4331.             FCV_COUNT = 10;
  4332.            
  4333.  
  4334.         }
  4335.  
  4336.  
  4337.         //Decision
  4338.         //Decision: SystemArmed > 0?
  4339.         if (FCV_SYSTEMARMED > 0)
  4340.         {
  4341.             //Call Macro
  4342.             //Call Macro: ZoneCheck
  4343.             FCM_ZoneCheck();
  4344.  
  4345.  
  4346.         }
  4347.  
  4348.  
  4349.     }
  4350.  
  4351.  
  4352.     mainendloop: goto mainendloop;
  4353. }
  4354.  
  4355. void MX_INTERRUPT_MACRO(void)
  4356. {
  4357. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement