Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //************************************************************************************
- //**
- //** File name: G:\My Stuff\Electronic Ideas\4 Zone Alarm.c
- //** Generated by: Flowcode v4.2.3.58
- //** Date: Monday, June 27, 2011 11:14:22
- //** Licence: Professional
- //** Registered to: 20ACM8
- //**
- //**
- //** http://www.matrixmultimedia.com
- //************************************************************************************
- #define MX_PIC
- //Defines for microcontroller
- #define P16F877
- #define MX_EE
- #define MX_EE_SIZE 256
- #define MX_SPI
- #define MX_SPI_C
- #define MX_SPI_SDI 4
- #define MX_SPI_SDO 5
- #define MX_SPI_SCK 3
- #define MX_UART
- #define MX_UART_C
- #define MX_UART_TX 6
- #define MX_UART_RX 7
- #define MX_I2C
- #define MX_MI2C
- #define MX_I2C_C
- #define MX_I2C_SDA 4
- #define MX_I2C_SCL 3
- #define MX_PWM
- #define MX_PWM_CNT 2
- #define MX_PWM_TRIS1 trisc
- #define MX_PWM_1 2
- #define MX_PWM_TRIS2 trisc
- #define MX_PWM_2 1
- //Functions
- #define MX_CLK_SPEED 10000000
- #ifdef _BOOSTC
- #include <system.h>
- #endif
- #ifdef HI_TECH_C
- #include <pic.h>
- #endif
- //Configuration data
- #ifdef _BOOSTC
- #pragma DATA 0x2007, 0x3eba
- #endif
- #ifdef HI_TECH_C
- __CONFIG(0x3eba);
- #endif
- //Internal functions
- #include "C:\Flowcode V4\FCD\internals.h"
- //Macro function declarations
- void FCM_ZoneCheck();
- void FCM_Alarm(char FCL_ALARMZONE);
- void FCM_EnterCode();
- void FCM_CompareCode();
- void FCM_WrongCode();
- void FCM_Rightcode();
- void FCM_PreAlarm();
- void FCM_FirstStartup();
- //Variable declarations
- short FCV_COMPARECODE;
- char FCV_CANCELSWITCH;
- char FCV_ZONE1;
- char FCV_SYSTEMARMED;
- short FCV_SETCODE;
- char FCV_INVALIDCOUNT;
- char FCV_ZONE2;
- char FCV_ALARMZONE;
- char FCV_DIGITCOUNT;
- char FCV_KEYPADNUMBER;
- char FCV_ZONE3;
- char FCV_DIGITSET;
- char FCV_ZONE4;
- char FCV_DIGIT1;
- char FCV_DIGIT2;
- char FCV_ARMSWITCH;
- char FCV_DIGIT3;
- char FCV_FIRSTRUN;
- char FCV_INVALIDCODE;
- char FCV_DIGIT4;
- char FCV_DISPLAY;
- short FCV_COUNT;
- short FCV_CODE;
- char FCV_ALARMACTIVE;
- //Defines:
- /**** Macro Substitutions ****
- portb = D1 Port
- trisb = D1 Data Direction
- portb = D2 Port
- trisb = D2 Data Direction
- portb = D3 Port
- trisb = D3 Data Direction
- portb = D4 Port
- trisb = D4 Data Direction
- portb = RS Port
- trisb = RS Data Direction
- portb = E Port
- trisb = E Data Direction
- 2 = Data 1_Pin
- 3 = Data 2 Pin
- 4 = Data 3 Pin
- 5 = Data 4 Pin
- 0 = RS Pin
- 1 = Enable Pin
- LCD_590668 = Unique Component Reference Number
- 2 = Row Count
- 16 = Column Count
- ******************************/
- //component connections
- #define LCD_590668_PORT0 portb
- #define LCD_590668_TRIS0 trisb
- #define LCD_590668_PORT1 portb
- #define LCD_590668_TRIS1 trisb
- #define LCD_590668_PORT2 portb
- #define LCD_590668_TRIS2 trisb
- #define LCD_590668_PORT3 portb
- #define LCD_590668_TRIS3 trisb
- #define LCD_590668_PORT4 portb
- #define LCD_590668_TRIS4 trisb
- #define LCD_590668_PORT5 portb
- #define LCD_590668_TRIS5 trisb
- #define LCD_590668_BIT0 2
- #define LCD_590668_BIT1 3
- #define LCD_590668_BIT2 4
- #define LCD_590668_BIT3 5
- #define LCD_590668_RS 0
- #define LCD_590668_E 1
- #define LCD_590668_ROWCNT 2
- #define LCD_590668_COLCNT 16
- #ifdef _BOOSTC
- #define LCD_590668_DELAY delay_10us(10)
- #endif
- #ifdef _C2C_
- #define LCD_590668_DELAY delay_us(100)
- #endif
- #ifdef HI_TECH_C
- #define LCD_590668_DELAY __delay_us(120)
- #endif
- #ifndef LCD_590668_DELAY
- #define LCD_590668_DELAY delay_us(100)
- #endif
- //LCDDisplay0: //Macro function declarations
- void FCD_LCDDisplay0_RawSend(char in, char mask);
- void FCD_LCDDisplay0_Start();
- void FCD_LCDDisplay0_Clear();
- void FCD_LCDDisplay0_PrintASCII(char Character);
- void FCD_LCDDisplay0_Command(char in);
- void FCD_LCDDisplay0_Cursor(char x, char y);
- void FCD_LCDDisplay0_PrintNumber(short Number);
- void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String);
- void FCD_LCDDisplay0_ScrollDisplay(char Direction, char Num_Positions);
- void FCD_LCDDisplay0_ClearLine(char Line);
- void FCD_LCDDisplay0_RAM_Write(char nIdx, char d0, char d1, char d2, char d3, char d4, char d5, char d6, char d7);
- //Defines:
- /**** Macro Substitutions ****
- {'1','4','7','*','2','5','8','0','3','6','9','#'} = Key List (Numbers)
- {1,4,7,10,2,5,8,0,3,6,9,11} = Key List (Characters)
- trisd = Row Data Direction Register
- portd = Row Port Register
- 3 = Number Of Columns
- 4 = Number Of Rows
- trisd = Column Data Direction Register
- portd = Column Port Register
- 1 = Column 1 mask
- 2 = Column 2 mask
- 4 = Column 3 mask
- 8 = Column 4 mask
- 8 = Row 1 mask
- 16 = Row 2 mask
- 32 = Row 3 mask
- 64 = Row 4 mask
- ******************************/
- //KeyPad0: //Macro function declarations
- char FCD_KeyPad0_GetKeypadNumber();
- char FCD_KeyPad0_GetKeypadAscii();
- //Defines:
- /**** Macro Substitutions ****
- ******************************/
- //EEPROM0: //Macro function declarations
- char FCD_EEPROM0_EEPROMRead(short addr);
- void FCD_EEPROM0_WriteEEPROM(short addr, char data);
- //LCDDisplay0: //Macro implementations
- void FCD_LCDDisplay0_RawSend(char in, char mask)
- {
- unsigned char pt;
- clear_bit(LCD_590668_PORT0, LCD_590668_BIT0);
- clear_bit(LCD_590668_PORT1, LCD_590668_BIT1);
- clear_bit(LCD_590668_PORT2, LCD_590668_BIT2);
- clear_bit(LCD_590668_PORT3, LCD_590668_BIT3);
- clear_bit(LCD_590668_PORT4, LCD_590668_RS);
- clear_bit(LCD_590668_PORT5, LCD_590668_E);
- pt = ((in >> 4) & 0x0f);
- if (pt & 0x01)
- set_bit(LCD_590668_PORT0, LCD_590668_BIT0);
- if (pt & 0x02)
- set_bit(LCD_590668_PORT1, LCD_590668_BIT1);
- if (pt & 0x04)
- set_bit(LCD_590668_PORT2, LCD_590668_BIT2);
- if (pt & 0x08)
- set_bit(LCD_590668_PORT3, LCD_590668_BIT3);
- if (mask)
- set_bit(LCD_590668_PORT4, LCD_590668_RS);
- LCD_590668_DELAY;
- set_bit (LCD_590668_PORT5, LCD_590668_E);
- LCD_590668_DELAY;
- clear_bit (LCD_590668_PORT5, LCD_590668_E);
- pt = (in & 0x0f);
- LCD_590668_DELAY;
- clear_bit(LCD_590668_PORT0, LCD_590668_BIT0);
- clear_bit(LCD_590668_PORT1, LCD_590668_BIT1);
- clear_bit(LCD_590668_PORT2, LCD_590668_BIT2);
- clear_bit(LCD_590668_PORT3, LCD_590668_BIT3);
- clear_bit(LCD_590668_PORT4, LCD_590668_RS);
- clear_bit(LCD_590668_PORT5, LCD_590668_E);
- if (pt & 0x01)
- set_bit(LCD_590668_PORT0, LCD_590668_BIT0);
- if (pt & 0x02)
- set_bit(LCD_590668_PORT1, LCD_590668_BIT1);
- if (pt & 0x04)
- set_bit(LCD_590668_PORT2, LCD_590668_BIT2);
- if (pt & 0x08)
- set_bit(LCD_590668_PORT3, LCD_590668_BIT3);
- if (mask)
- set_bit(LCD_590668_PORT4, LCD_590668_RS);
- LCD_590668_DELAY;
- set_bit (LCD_590668_PORT5, LCD_590668_E);
- LCD_590668_DELAY;
- clear_bit (LCD_590668_PORT5, LCD_590668_E);
- LCD_590668_DELAY;
- }
- void FCD_LCDDisplay0_Start()
- {
- clear_bit(LCD_590668_TRIS0, LCD_590668_BIT0);
- clear_bit(LCD_590668_TRIS1, LCD_590668_BIT1);
- clear_bit(LCD_590668_TRIS2, LCD_590668_BIT2);
- clear_bit(LCD_590668_TRIS3, LCD_590668_BIT3);
- clear_bit(LCD_590668_TRIS4, LCD_590668_RS);
- clear_bit(LCD_590668_TRIS5, LCD_590668_E);
- Wdt_Delay_Ms(12);
- FCD_LCDDisplay0_RawSend(0x33, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x33, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x32, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x2c, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x06, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x0c, 0);
- Wdt_Delay_Ms(2);
- //clear the display
- FCD_LCDDisplay0_RawSend(0x01, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x02, 0);
- Wdt_Delay_Ms(2);
- }
- void FCD_LCDDisplay0_Clear()
- {
- FCD_LCDDisplay0_RawSend(0x01, 0);
- Wdt_Delay_Ms(2);
- FCD_LCDDisplay0_RawSend(0x02, 0);
- Wdt_Delay_Ms(2);
- }
- void FCD_LCDDisplay0_PrintASCII(char Character)
- {
- FCD_LCDDisplay0_RawSend(Character, 0x10);
- }
- void FCD_LCDDisplay0_Command(char in)
- {
- FCD_LCDDisplay0_RawSend(in, 0);
- Wdt_Delay_Ms(2);
- }
- void FCD_LCDDisplay0_Cursor(char x, char y)
- {
- #if (LCD_590668_ROWCNT == 1)
- y=0x80;
- #endif
- #if (LCD_590668_ROWCNT == 2)
- if (y==0)
- y=0x80;
- else
- y=0xc0;
- #endif
- #if (LCD_590668_ROWCNT == 4)
- if (y==0)
- y=0x80;
- else if (y==1)
- y=0xc0;
- #if (LCD_590668_COLCNT == 16)
- else if (y==2)
- y=0x90;
- else
- y=0xd0;
- #endif
- #if (LCD_590668_COLCNT == 20)
- else if (y==2)
- y=0x94;
- else
- y=0xd4;
- #endif
- #endif
- FCD_LCDDisplay0_RawSend(y+x, 0);
- Wdt_Delay_Ms(2);
- }
- void FCD_LCDDisplay0_PrintNumber(short Number)
- {
- short tmp_int;
- char tmp_byte;
- if (Number < 0)
- {
- FCD_LCDDisplay0_RawSend('-', 0x10);
- Number = 0 - Number;
- }
- tmp_int = Number;
- if (Number >= 10000)
- {
- tmp_byte = tmp_int / 10000;
- FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
- while (tmp_byte > 0)
- {
- tmp_int = tmp_int - 10000;
- tmp_byte--;
- }
- }
- if (Number >= 1000)
- {
- tmp_byte = tmp_int / 1000;
- FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
- while (tmp_byte > 0)
- {
- tmp_int = tmp_int - 1000;
- tmp_byte--;
- }
- }
- if (Number >= 100)
- {
- tmp_byte = tmp_int / 100;
- FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
- while (tmp_byte > 0)
- {
- tmp_int = tmp_int - 100;
- tmp_byte--;
- }
- }
- if (Number >= 10)
- {
- tmp_byte = tmp_int / 10;
- FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
- while (tmp_byte > 0)
- {
- tmp_int = tmp_int - 10;
- tmp_byte--;
- }
- }
- FCD_LCDDisplay0_RawSend('0' + tmp_int, 0x10);
- }
- void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String)
- {
- char idx = 0;
- for (idx=0; idx<MSZ_String; idx++)
- {
- #ifdef _BOOSTC
- if (String[idx] == 0)
- {
- break;
- }
- FCD_LCDDisplay0_RawSend(String[idx], 0x10);
- #endif
- #ifdef HI_TECH_C
- if (*String == 0)
- {
- break;
- }
- FCD_LCDDisplay0_RawSend(*String, 0x10);
- String++;
- #endif
- }
- }
- void FCD_LCDDisplay0_ScrollDisplay(char Direction, char Num_Positions)
- {
- char cmd = 0;
- char count;
- //Choose the direction
- switch (Direction)
- {
- case 0:
- case 'l':
- case 'L':
- cmd = 0x18;
- break;
- case 1:
- case 'r':
- case 'R':
- cmd = 0x1C;
- break;
- default:
- break;
- }
- //If direction accepted then scroll the specified amount
- if (cmd)
- {
- for (count = 0; count < Num_Positions; count++)
- FCD_LCDDisplay0_Command(cmd);
- }
- }
- void FCD_LCDDisplay0_ClearLine(char Line)
- {
- char count;
- char rowcount;
- //Define number of columns per line
- #if (LCD_590668_ROWCNT == 1)
- rowcount=80;
- #endif
- #if (LCD_590668_ROWCNT == 2)
- rowcount=40;
- #endif
- #if (LCD_590668_ROWCNT == 4)
- #if (LCD_590668_COLCNT == 16)
- rowcount=16;
- #endif
- #if (LCD_590668_COLCNT == 20)
- rowcount=20;
- #endif
- #endif
- //Start at beginning of the line
- FCD_LCDDisplay0_Cursor (0, Line);
- //Send out spaces to clear line
- for (count = 0; count < rowcount; count++)
- FCD_LCDDisplay0_RawSend(' ', 0x10);
- //Move back to the beginning of the line.
- FCD_LCDDisplay0_Cursor (0, Line);
- }
- void FCD_LCDDisplay0_RAM_Write(char nIdx, char d0, char d1, char d2, char d3, char d4, char d5, char d6, char d7)
- {
- //set CGRAM address
- FCD_LCDDisplay0_RawSend(64 + (nIdx << 3), 0);
- delay_ms(2);
- //write CGRAM data
- FCD_LCDDisplay0_RawSend(d0, 0x10);
- FCD_LCDDisplay0_RawSend(d1, 0x10);
- FCD_LCDDisplay0_RawSend(d2, 0x10);
- FCD_LCDDisplay0_RawSend(d3, 0x10);
- FCD_LCDDisplay0_RawSend(d4, 0x10);
- FCD_LCDDisplay0_RawSend(d5, 0x10);
- FCD_LCDDisplay0_RawSend(d6, 0x10);
- FCD_LCDDisplay0_RawSend(d7, 0x10);
- //Clear the display
- FCD_LCDDisplay0_RawSend(0x01, 0);
- delay_ms(2);
- FCD_LCDDisplay0_RawSend(0x02, 0);
- delay_ms(2);
- }
- //KeyPad0: //Macro implementations
- char FCD_KeyPad0_GetKeypadNumber()
- {
- //get matrices for rows and columns
- #if (3 == 1)
- #define KPAD_COL_MTX {1}
- #define KPAD_COL_MASK (1)
- #endif
- #if (3 == 2)
- #define KPAD_COL_MTX {1,2}
- #define KPAD_COL_MASK (1|2)
- #endif
- #if (3 == 3)
- #define KPAD_COL_MTX {1,2,4}
- #define KPAD_COL_MASK (1|2|4)
- #endif
- #if (3 == 4)
- #define KPAD_COL_MTX {1,2,4,8}
- #define KPAD_COL_MASK (1|2|4|8)
- #endif
- #if (4 == 1)
- #define KPAD_ROW_MTX {8}
- #define KPAD_ROW_MASK (8)
- #endif
- #if (4 == 2)
- #define KPAD_ROW_MTX {8,16}
- #define KPAD_ROW_MASK (8|16)
- #endif
- #if (4 == 3)
- #define KPAD_ROW_MTX {8,16,32}
- #define KPAD_ROW_MASK (8|16|32)
- #endif
- #if (4 == 4)
- #define KPAD_ROW_MTX {8,16,32,64}
- #define KPAD_ROW_MASK (8|16|32|64)
- #endif
- #ifndef KPAD_COL_MTX
- #pragma error Keypad error: column count is not 1-4
- #endif
- #ifndef KPAD_ROW_MTX
- #pragma error Keypad error: row count is not 1-4
- #endif
- //store keys and pin connections into a constant array
- #ifdef _BOOSTC
- rom char* mtxKeysAsNumbers = {1,4,7,10,2,5,8,0,3,6,9,11};
- rom char* mtxCols = KPAD_COL_MTX;
- rom char* mtxRows = KPAD_ROW_MTX;
- #endif
- #ifdef HI_TECH_C
- const char mtxKeysAsNumbers[] = {1,4,7,10,2,5,8,0,3,6,9,11};
- const char mtxCols[] = KPAD_COL_MTX;
- const char mtxRows[] = KPAD_ROW_MTX;
- #endif
- //set up i/o of port (rows = inputs, columns = outputs)
- trisd = (trisd | KPAD_ROW_MASK);
- trisd = (trisd & ~KPAD_COL_MASK); //BR
- char iCol;
- char iRow;
- char c_ip;
- for (iCol=0; iCol<3; iCol++)
- {
- //output the appropriate column high
- portd = mtxCols[iCol];
- //delay
- delay_us(10);
- //read the port
- c_ip = portd;
- //check for a hit
- for (iRow=0; iRow<4; iRow++)
- {
- if ((c_ip & mtxRows[iRow]) != 0)
- {
- //found it!
- goto found_key;
- }
- }
- }
- //if it gets here, it has not been found...
- return (255);
- found_key:
- return (mtxKeysAsNumbers[(iCol*4) + iRow]);
- #undef KPAD_COL_MTX
- #undef KPAD_ROW_MTX
- #undef KPAD_COL_MASK
- #undef KPAD_ROW_MASK
- }
- char FCD_KeyPad0_GetKeypadAscii()
- {
- //get matrices for rows and columns
- #if (3 == 1)
- #define KPAD_COL_MTX {1}
- #define KPAD_COL_MASK (1)
- #endif
- #if (3 == 2)
- #define KPAD_COL_MTX {1,2}
- #define KPAD_COL_MASK (1|2)
- #endif
- #if (3 == 3)
- #define KPAD_COL_MTX {1,2,4}
- #define KPAD_COL_MASK (1|2|4)
- #endif
- #if (3 == 4)
- #define KPAD_COL_MTX {1,2,4,8}
- #define KPAD_COL_MASK (1|2|4|8)
- #endif
- #if (4 == 1)
- #define KPAD_ROW_MTX {8}
- #define KPAD_ROW_MASK (8)
- #endif
- #if (4 == 2)
- #define KPAD_ROW_MTX {8,16}
- #define KPAD_ROW_MASK (8|16)
- #endif
- #if (4 == 3)
- #define KPAD_ROW_MTX {8,16,32}
- #define KPAD_ROW_MASK (8|16|32)
- #endif
- #if (4 == 4)
- #define KPAD_ROW_MTX {8,16,32,64}
- #define KPAD_ROW_MASK (8|16|32|64)
- #endif
- #ifndef KPAD_COL_MTX
- #pragma error Keypad error: column count is not 1-4
- #endif
- #ifndef KPAD_ROW_MTX
- #pragma error Keypad error: row count is not 1-4
- #endif
- //store keys and pin connections into a constant array
- #ifdef _BOOSTC
- rom char* mtxKeysAsChars = {'1','4','7','*','2','5','8','0','3','6','9','#'};
- rom char* mtxCols = KPAD_COL_MTX;
- rom char* mtxRows = KPAD_ROW_MTX;
- #endif
- #ifdef HI_TECH_C
- const char mtxKeysAsChars[] = {'1','4','7','*','2','5','8','0','3','6','9','#'};
- const char mtxCols[] = KPAD_COL_MTX;
- const char mtxRows[] = KPAD_ROW_MTX;
- #endif
- //set up i/o of port (rows = inputs, columns = outputs)
- trisd = (trisd | KPAD_ROW_MASK);
- trisd = (trisd & ~KPAD_COL_MASK);
- char iCol;
- char iRow;
- char c_ip;
- for (iCol=0; iCol<3; iCol++)
- {
- //output the appropriate column high
- portd = mtxCols[iCol];
- //delay
- delay_us(10);
- //read the port
- c_ip = portd;
- //check for a hit
- for (iRow=0; iRow<4; iRow++)
- {
- if ((c_ip & mtxRows[iRow]) != 0)
- {
- //found it!
- goto found_key;
- }
- }
- }
- //if it gets here, it has not been found...
- return (255);
- found_key:
- return (mtxKeysAsChars[(iCol*4) + iRow]);
- #undef KPAD_COL_MTX
- #undef KPAD_ROW_MTX
- #undef KPAD_COL_MASK
- #undef KPAD_ROW_MASK
- }
- //EEPROM0: //Macro implementations
- char FCD_EEPROM0_EEPROMRead(short addr)
- {
- char data = 0;
- #ifdef _BOOSTC
- #ifdef MX_EE
- #ifndef MX_EEADR
- #ifdef EEADR
- #define MX_EEADR eeadr
- #endif
- #ifdef EEADRL
- #define MX_EEADR eeadrl
- #endif
- #endif
- #ifndef MX_EEDATA
- #ifdef EEDATA
- #define MX_EEDATA eedata
- #endif
- #ifdef EEDATAL
- #define MX_EEDATA eedatal
- #endif
- #ifdef EEDATL
- #define MX_EEDATA eedatl
- #endif
- #endif
- #ifndef MX_EEADR //Catch Error
- #pragma error EEPROM error - MX_EEADR not set
- #endif
- #ifndef MX_EEDATA
- #pragma error EEPROM error - MX_EEDATA not set
- #endif
- MX_EEADR = addr & 0xff;
- #if (MX_EE_SIZE > 256)
- eeadrh = (addr & 0xff00) >> 8;
- #endif
- #ifdef MX_EE_TYPE2
- clear_bit(eecon1, EEPGD);
- #endif
- #ifdef MX_EE_TYPE3
- clear_bit(eecon1, EEPGD);
- clear_bit(eecon1, CFGS);
- #endif
- set_bit(eecon1, RD);
- data = MX_EEDATA;
- #else
- #ifdef MX_EE_TYPE67X
- #pragma error "FlowCode does not support EEPROM for this device"
- #else
- #ifdef MX_EE_TYPE62X
- #pragma error "FlowCode does not support EEPROM for this device"
- #else
- #pragma error "Chip does not have EEPROM memory"
- #endif
- #endif
- #endif
- #endif
- #ifdef HI_TECH_C
- data = eeprom_read(addr);
- #endif
- return (data);
- }
- void FCD_EEPROM0_WriteEEPROM(short addr, char data)
- {
- #ifdef _BOOSTC
- #ifdef MX_EE
- #ifndef MX_EEADR
- #ifdef EEADR
- #define MX_EEADR eeadr
- #endif
- #ifdef EEADRL
- #define MX_EEADR eeadrl
- #endif
- #endif
- #ifndef MX_EEDATA
- #ifdef EEDATA
- #define MX_EEDATA eedata
- #endif
- #ifdef EEDATAL
- #define MX_EEDATA eedatal
- #endif
- #endif
- #ifndef MX_EEADR //Catch Error
- #pragma error EEPROM error - MX_EEADR not set
- #endif
- #ifndef MX_EEDATA
- #pragma error EEPROM error - MX_EEDATA not set
- #endif
- char bInterruptsEnabled;
- //wait for previous EE writes to complete...
- while (test_bit(eecon1, WR));
- MX_EEADR = addr & 0xff;
- #if (MX_EE_SIZE > 256)
- eeadrh = (addr & 0xff00) >> 8;
- #endif
- MX_EEDATA = data;
- #ifdef MX_EE_TYPE2
- clear_bit(eecon1, EEPGD);
- #endif
- #ifdef MX_EE_TYPE3
- clear_bit(eecon1, EEPGD);
- clear_bit(eecon1, CFGS);
- #endif
- set_bit(eecon1, WREN);
- bInterruptsEnabled = test_bit(intcon, GIE);
- clear_bit(intcon, GIE); //Disable Interrupts
- eecon2 = 0x55;
- eecon2 = 0xAA;
- set_bit(eecon1, WR);
- while (test_bit(eecon1, WR)); //wait for EE write to complete...
- if (bInterruptsEnabled)
- set_bit(intcon, GIE); //Re-enable Interrupts
- clear_bit(eecon1, WREN);
- #else
- #ifdef MX_EE_TYPE67X
- #pragma error FlowCode does not support EEPROM for this device
- #else
- #ifdef MX_EE_TYPE62X
- #pragma error FlowCode does not support EEPROM for this device
- #else
- #pragma error Chip does not have EEPROM memory
- #endif
- #endif
- #endif
- #endif
- #ifdef HI_TECH_C
- eeprom_write(addr, data);
- #endif
- }
- //Macro implementations
- void FCM_ZoneCheck()
- {
- //Checks the status of the 4 zones.
- //Connection Point
- //Connection Point: [B]: B
- FCC_ZoneCheck_B:
- ;
- //Loop
- //Loop: While 1
- while (1)
- {
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- FCV_INVALIDCODE = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_ZoneCheck_B;
- }
- //Calculation
- //Calculation:
- // SystemArmed = 0
- FCV_SYSTEMARMED = 0;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- } else {
- //Input
- //Input: A5 -> Zone1
- trisa = trisa | 0x20;
- FCV_ZONE1 = ((porta & 0x20) == 0x20);
- //Decision
- //Decision: Zone1 < 1?
- if (FCV_ZONE1 < 1)
- {
- //Calculation
- //Calculation:
- // AlarmZone = 1
- FCV_ALARMZONE = 1;
- //Call Macro
- //Call Macro: Alarm(AlarmZone)
- FCM_Alarm(FCV_ALARMZONE);
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- }
- }
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- FCV_INVALIDCODE = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_ZoneCheck_B;
- }
- //Calculation
- //Calculation:
- // SystemArmed = 0
- FCV_SYSTEMARMED = 0;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- } else {
- //Input
- //Input: A4 -> Zone2
- trisa = trisa | 0x10;
- FCV_ZONE2 = ((porta & 0x10) == 0x10);
- //Decision
- //Decision: Zone2 < 1?
- if (FCV_ZONE2 < 1)
- {
- //Calculation
- //Calculation:
- // AlarmZone = 2
- FCV_ALARMZONE = 2;
- //Call Macro
- //Call Macro: Alarm(AlarmZone)
- FCM_Alarm(FCV_ALARMZONE);
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- }
- }
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- FCV_INVALIDCODE = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_ZoneCheck_B;
- }
- //Calculation
- //Calculation:
- // SystemArmed = 0
- FCV_SYSTEMARMED = 0;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- } else {
- //Input
- //Input: A3 -> Zone3
- trisa = trisa | 0x08;
- FCV_ZONE3 = ((porta & 0x08) == 0x08);
- //Decision
- //Decision: Zone3 < 1?
- if (FCV_ZONE3 < 1)
- {
- //Calculation
- //Calculation:
- // AlarmZone = 3
- FCV_ALARMZONE = 3;
- //Call Macro
- //Call Macro: Alarm(AlarmZone)
- FCM_Alarm(FCV_ALARMZONE);
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_ZoneCheck_B;
- }
- }
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- FCV_INVALIDCODE = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_ZoneCheck_B;
- }
- //Calculation
- //Calculation:
- // SystemArmed = 0
- FCV_SYSTEMARMED = 0;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- } else {
- //Input
- //Input: A2 -> Zone4
- trisa = trisa | 0x04;
- FCV_ZONE4 = ((porta & 0x04) == 0x04);
- //Decision
- //Decision: Zone4 < 1?
- if (FCV_ZONE4 < 1)
- {
- //Calculation
- //Calculation:
- // AlarmZone = 4
- FCV_ALARMZONE = 4;
- //Call Macro
- //Call Macro: Alarm(AlarmZone)
- FCM_Alarm(FCV_ALARMZONE);
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_ZoneCheck_A;
- }
- }
- }
- }
- //Connection Point
- //Connection Point: [A]: A
- FCC_ZoneCheck_A:
- ;
- }
- void FCM_Alarm(char FCL_ALARMZONE)
- {
- //Activate Alarm alerts
- //Loop
- //Loop: While 1
- while (1)
- {
- //Connection Point
- //Connection Point: [A]: A
- FCC_Alarm_A:
- ;
- //Switch
- //Switch: AlarmZone?
- switch (FCV_ALARMZONE)
- {
- case 1:
- {
- //Output
- //Output: 1 -> C3
- trisc = trisc & 0xf7;
- if (1)
- portc = (portc & 0xf7) | 0x08;
- else
- portc = portc & 0xf7;
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Call Macro
- //Call Macro: PreAlarm
- FCM_PreAlarm();
- //Decision
- //Decision: AlarmZone = 0?
- if (FCV_ALARMZONE == 0)
- {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- }
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 1")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(':');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('Z');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('1');
- //Output
- //Output: 1 -> C4
- trisc = trisc & 0xef;
- if (1)
- portc = (portc & 0xef) | 0x10;
- else
- portc = portc & 0xef;
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- break;
- }
- case 2:
- {
- //Output
- //Output: 1 -> C2
- trisc = trisc & 0xfb;
- if (1)
- portc = (portc & 0xfb) | 0x04;
- else
- portc = portc & 0xfb;
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Call Macro
- //Call Macro: PreAlarm
- FCM_PreAlarm();
- //Decision
- //Decision: AlarmZone = 0?
- if (FCV_ALARMZONE == 0)
- {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- }
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 2")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(':');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('Z');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('2');
- //Output
- //Output: 1 -> C4
- trisc = trisc & 0xef;
- if (1)
- portc = (portc & 0xef) | 0x10;
- else
- portc = portc & 0xef;
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- break;
- }
- case 3:
- {
- //Output
- //Output: 1 -> C1
- trisc = trisc & 0xfd;
- if (1)
- portc = (portc & 0xfd) | 0x02;
- else
- portc = portc & 0xfd;
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Call Macro
- //Call Macro: PreAlarm
- FCM_PreAlarm();
- //Decision
- //Decision: AlarmZone = 0?
- if (FCV_ALARMZONE == 0)
- {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- }
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 3")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(':');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('Z');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('3');
- //Output
- //Output: 1 -> C4
- trisc = trisc & 0xef;
- if (1)
- portc = (portc & 0xef) | 0x10;
- else
- portc = portc & 0xef;
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- break;
- }
- case 4:
- {
- //Output
- //Output: 1 -> C0
- trisc = trisc & 0xfe;
- if (1)
- portc = (portc & 0xfe) | 0x01;
- else
- portc = portc & 0xfe;
- //Decision
- //Decision: AlarmActive > 0?
- if (FCV_ALARMACTIVE > 0)
- {
- } else {
- //Call Macro
- //Call Macro: PreAlarm
- FCM_PreAlarm();
- //Decision
- //Decision: AlarmZone = 0?
- if (FCV_ALARMZONE == 0)
- {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- }
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm: Zone 4")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(':');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('Z');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('4');
- //Output
- //Output: 1 -> C4
- trisc = trisc & 0xef;
- if (1)
- portc = (portc & 0xef) | 0x10;
- else
- portc = portc & 0xef;
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- break;
- }
- default:
- {
- //Connection Point
- //Connection Point: [C]: C
- FCC_Alarm_C:
- ;
- //Decision
- //Decision: InvalidCount = 3?
- if (FCV_INVALIDCOUNT == 3)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Invalid Code Error")
- FCD_LCDDisplay0_PrintASCII('I');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('v');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('E');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('r');
- //Output
- //Output: 1 -> C4
- trisc = trisc & 0xef;
- if (1)
- portc = (portc & 0xef) | 0x10;
- else
- portc = portc & 0xef;
- }
- }
- }
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- // InvalidCount = InvalidCount + 1
- FCV_INVALIDCODE = 0;
- FCV_INVALIDCOUNT = FCV_INVALIDCOUNT + 1;
- //Decision
- //Decision: InvalidCount = 3?
- if (FCV_INVALIDCOUNT == 3)
- {
- //Goto Connection Point
- //Goto Connection Point: [C]: C
- goto FCC_Alarm_C;
- }
- }
- //Input
- //Input: A1 -> CancelSwitch
- trisa = trisa | 0x02;
- FCV_CANCELSWITCH = ((porta & 0x02) == 0x02);
- //Decision
- //Decision: CancelSwitch > 0?
- if (FCV_CANCELSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode > 0?
- if (FCV_INVALIDCODE > 0)
- {
- //Delay
- //Delay: 5 s
- delay_s(5);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_Alarm_A;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Output
- //Output: 0 -> PORT C
- trisc = 0x00;
- portc = 0;
- //Calculation
- //Calculation:
- // CancelSwitch = 0
- // AlarmZone = 0
- // AlarmActive = 0
- FCV_CANCELSWITCH = 0;
- FCV_ALARMZONE = 0;
- FCV_ALARMACTIVE = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode > 0?
- if (FCV_INVALIDCODE > 0)
- {
- //Delay
- //Delay: 5 s
- delay_s(5);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_Alarm_A;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Output
- //Output: 0 -> PORT C
- trisc = 0x00;
- portc = 0;
- //Calculation
- //Calculation:
- // ArmSwitch = 0
- // AlarmActive = 0
- // AlarmZone = 0
- // SystemArmed = 0
- FCV_ARMSWITCH = 0;
- FCV_ALARMACTIVE = 0;
- FCV_ALARMZONE = 0;
- FCV_SYSTEMARMED = 0;
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_Alarm_B;
- }
- }
- }
- //Connection Point
- //Connection Point: [B]: B
- FCC_Alarm_B:
- ;
- }
- void FCM_EnterCode()
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Enter Code:")
- FCD_LCDDisplay0_PrintASCII('E');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(':');
- //Decision
- //Decision: Digit1 > 0?
- if (FCV_DIGIT1 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [A]: A
- FCC_EnterCode_A:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_EnterCode_A;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
- FCD_LCDDisplay0_Cursor(0, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit1 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT1 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [B]: B
- FCC_EnterCode_B:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_EnterCode_B;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit2 > 0?
- if (FCV_DIGIT2 > 0)
- {
- } else {
- //Connection Point
- //Connection Point: [C]: C
- FCC_EnterCode_C:
- ;
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [C]: C
- goto FCC_EnterCode_C;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit2 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT2 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [D]: D
- FCC_EnterCode_D:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [D]: D
- goto FCC_EnterCode_D;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit3 > 0?
- if (FCV_DIGIT3 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [E]: E
- FCC_EnterCode_E:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [E]: E
- goto FCC_EnterCode_E;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit3 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT3 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [F]: F
- FCC_EnterCode_F:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [F]: F
- goto FCC_EnterCode_F;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit4 > 0?
- if (FCV_DIGIT4 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [G]: G
- FCC_EnterCode_G:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [G]: G
- goto FCC_EnterCode_G;
- } else {
- //Calculation
- //Calculation:
- // Digit4 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT4 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
- FCD_LCDDisplay0_Cursor(3, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [H]: H
- FCC_EnterCode_H:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [H]: H
- goto FCC_EnterCode_H;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- // Code = Digit1
- // Code = Code + (Digit2 * 1000)
- // Code = Code + (Digit3 * 100)
- // Code = Code + (Digit4 * 10)
- // Digit1 = 0
- // Digit2 = 0
- // Digit3 = 0
- // Digit4 = 0
- FCV_DIGITSET = 0;
- FCV_CODE = FCV_DIGIT1;
- FCV_CODE = FCV_CODE + (FCV_DIGIT2 * 1000);
- FCV_CODE = FCV_CODE + (FCV_DIGIT3 * 100);
- FCV_CODE = FCV_CODE + (FCV_DIGIT4 * 10);
- FCV_DIGIT1 = 0;
- FCV_DIGIT2 = 0;
- FCV_DIGIT3 = 0;
- FCV_DIGIT4 = 0;
- }
- }
- void FCM_CompareCode()
- {
- //Call Component Macro
- //Call Component Macro: Digit1=EEPROM(0)::Read(0)
- FCV_DIGIT1 = FCD_EEPROM0_EEPROMRead(0);
- //Call Component Macro
- //Call Component Macro: Digit2=EEPROM(0)::Read(1)
- FCV_DIGIT2 = FCD_EEPROM0_EEPROMRead(1);
- //Call Component Macro
- //Call Component Macro: Digit3=EEPROM(0)::Read(2)
- FCV_DIGIT3 = FCD_EEPROM0_EEPROMRead(2);
- //Call Component Macro
- //Call Component Macro: Digit4=EEPROM(0)::Read(3)
- FCV_DIGIT4 = FCD_EEPROM0_EEPROMRead(3);
- //Calculation
- //Calculation:
- // SetCode = Digit1
- // SetCode = SetCode + (Digit2 * 1000)
- // SetCode = SetCode + (Digit3 * 100)
- // SetCode = SetCode + (Digit4 * 10)
- FCV_SETCODE = FCV_DIGIT1;
- FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT2 * 1000);
- FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT3 * 100);
- FCV_SETCODE = FCV_SETCODE + (FCV_DIGIT4 * 10);
- //Decision
- //Decision: Code = SetCode?
- if (FCV_CODE == FCV_SETCODE)
- {
- //Call Macro
- //Call Macro: RightCode
- FCM_RightCode();
- } else {
- //Call Macro
- //Call Macro: WrongCode
- FCM_WrongCode();
- }
- //Calculation
- //Calculation:
- // Code = 0
- // SetCode = 0
- // Digit1 = 0
- // Digit2 = 0
- // Digit3 = 0
- // Digit4 = 0
- FCV_CODE = 0;
- FCV_SETCODE = 0;
- FCV_DIGIT1 = 0;
- FCV_DIGIT2 = 0;
- FCV_DIGIT3 = 0;
- FCV_DIGIT4 = 0;
- }
- void FCM_WrongCode()
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Invalid Code")
- FCD_LCDDisplay0_PrintASCII('I');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('v');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- //Calculation
- //Calculation:
- // InvalidCode = 1
- FCV_INVALIDCODE = 1;
- }
- void FCM_Rightcode()
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
- FCD_LCDDisplay0_Cursor(3, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Valid Code")
- FCD_LCDDisplay0_PrintASCII('V');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- }
- void FCM_PreAlarm()
- {
- //Waits a few seconds for the cancellation before setting off the alarm.
- //Calculation
- //Calculation:
- // Count = 10
- FCV_COUNT = 10;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Connection Point
- //Connection Point: [A]: A
- FCC_PreAlarm_A:
- ;
- //Decision
- //Decision: InvalidCode = 1?
- if (FCV_INVALIDCODE == 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // InvalidCode = 0
- FCV_INVALIDCODE = 0;
- }
- //Loop
- //Loop: While Count > 0
- while (1)
- {
- //Output
- //Output: 1 -> C5
- trisc = trisc & 0xdf;
- if (1)
- portc = (portc & 0xdf) | 0x20;
- else
- portc = portc & 0xdf;
- //Input
- //Input: A1 -> CancelSwitch
- trisa = trisa | 0x02;
- FCV_CANCELSWITCH = ((porta & 0x02) == 0x02);
- //Decision
- //Decision: CancelSwitch > 0?
- if (FCV_CANCELSWITCH > 0)
- {
- //Output
- //Output: 0 -> C5
- trisc = trisc & 0xdf;
- if (0)
- portc = (portc & 0xdf) | 0x20;
- else
- portc = portc & 0xdf;
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode > 0?
- if (FCV_INVALIDCODE > 0)
- {
- //Delay
- //Delay: 5 s
- delay_s(5);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_PreAlarm_A;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Output
- //Output: 0 -> PORT C
- trisc = 0x00;
- portc = 0;
- //Calculation
- //Calculation:
- // AlarmActive = 0
- // AlarmZone = 0
- // CancelSwitch = 0
- FCV_ALARMACTIVE = 0;
- FCV_ALARMZONE = 0;
- FCV_CANCELSWITCH = 0;
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_PreAlarm_B;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
- FCD_LCDDisplay0_Cursor(0, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm In:")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('I');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII(':');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(10, 1)
- FCD_LCDDisplay0_Cursor(10, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintNumber(Count)
- FCD_LCDDisplay0_PrintNumber(FCV_COUNT);
- //Decision
- //Decision: Count > 9?
- if (FCV_COUNT > 9)
- {
- //Output
- //Output: 1 -> C5
- trisc = trisc & 0xdf;
- if (1)
- portc = (portc & 0xdf) | 0x20;
- else
- portc = portc & 0xdf;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(13, 1)
- FCD_LCDDisplay0_Cursor(13, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Sec")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('c');
- } else {
- //Output
- //Output: 1 -> C5
- trisc = trisc & 0xdf;
- if (1)
- portc = (portc & 0xdf) | 0x20;
- else
- portc = portc & 0xdf;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(12, 1)
- FCD_LCDDisplay0_Cursor(12, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Sec")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('c');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(11, 1)
- FCD_LCDDisplay0_Cursor(11, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(15, 1)
- FCD_LCDDisplay0_Cursor(15, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- }
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Macro
- //Call Macro: EnterCode
- FCM_EnterCode();
- //Call Macro
- //Call Macro: CompareCode
- FCM_CompareCode();
- //Decision
- //Decision: InvalidCode > 0?
- if (FCV_INVALIDCODE > 0)
- {
- //Delay
- //Delay: 5 s
- delay_s(5);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_PreAlarm_A;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Output
- //Output: 0 -> PORT C
- trisc = 0x00;
- portc = 0;
- //Calculation
- //Calculation:
- // ArmSwitch = 0
- // AlarmActive = 0
- // AlarmZone = 0
- // SystemArmed = 0
- FCV_ARMSWITCH = 0;
- FCV_ALARMACTIVE = 0;
- FCV_ALARMZONE = 0;
- FCV_SYSTEMARMED = 0;
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_PreAlarm_B;
- }
- }
- //Calculation
- //Calculation:
- // Count = Count - 1
- FCV_COUNT = FCV_COUNT - 1;
- //Delay
- //Delay: 1 s
- delay_s(1);
- //Output
- //Output: 0 -> C5
- trisc = trisc & 0xdf;
- if (0)
- portc = (portc & 0xdf) | 0x20;
- else
- portc = portc & 0xdf;
- if ((FCV_COUNT > 0) == 0) break;
- }
- //Calculation
- //Calculation:
- // CancelSwitch = 0
- // AlarmActive = 1
- FCV_CANCELSWITCH = 0;
- FCV_ALARMACTIVE = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::ClearLine(1)
- FCD_LCDDisplay0_ClearLine(1);
- //Connection Point
- //Connection Point: [B]: B
- FCC_PreAlarm_B:
- ;
- }
- void FCM_FirstStartup()
- {
- //Sets Passcode when the system is run for the first time
- //Loop
- //Loop: While Count < 5
- while (1)
- {
- //Call Component Macro
- //Call Component Macro: EEPROM(0)::Write(Count, 0)
- FCD_EEPROM0_WriteEEPROM(FCV_COUNT, 0);
- //Calculation
- //Calculation:
- // Count = Count + 1
- FCV_COUNT = FCV_COUNT + 1;
- if ((FCV_COUNT < 5) == 0) break;
- }
- //Connection Point
- //Connection Point: [O]: O
- FCC_FirstStartup_O:
- ;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Enter Code:")
- FCD_LCDDisplay0_PrintASCII('E');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(':');
- //Decision
- //Decision: Digit1 > 0?
- if (FCV_DIGIT1 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [A]: A
- FCC_FirstStartup_A:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [A]: A
- goto FCC_FirstStartup_A;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
- FCD_LCDDisplay0_Cursor(0, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit1 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT1 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [B]: B
- FCC_FirstStartup_B:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [B]: B
- goto FCC_FirstStartup_B;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit2 > 0?
- if (FCV_DIGIT2 > 0)
- {
- } else {
- //Connection Point
- //Connection Point: [C]: C
- FCC_FirstStartup_C:
- ;
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [C]: C
- goto FCC_FirstStartup_C;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit2 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT2 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [D]: D
- FCC_FirstStartup_D:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [D]: D
- goto FCC_FirstStartup_D;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit3 > 0?
- if (FCV_DIGIT3 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [E]: E
- FCC_FirstStartup_E:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [E]: E
- goto FCC_FirstStartup_E;
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- //Calculation
- //Calculation:
- // Digit3 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT3 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- }
- //Connection Point
- //Connection Point: [F]: F
- FCC_FirstStartup_F:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [F]: F
- goto FCC_FirstStartup_F;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit4 > 0?
- if (FCV_DIGIT4 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Connection Point
- //Connection Point: [G]: G
- FCC_FirstStartup_G:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [G]: G
- goto FCC_FirstStartup_G;
- } else {
- //Calculation
- //Calculation:
- // Digit4 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT4 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
- FCD_LCDDisplay0_Cursor(3, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [H]: H
- FCC_FirstStartup_H:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [H]: H
- goto FCC_FirstStartup_H;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- // Code = Digit1
- // Code = Code + (Digit2 * 1000)
- // Code = Code + (Digit3 * 100)
- // Code = Code + (Digit4 * 10)
- // Digit1 = 0
- // Digit2 = 0
- // Digit3 = 0
- // Digit4 = 0
- FCV_DIGITSET = 0;
- FCV_CODE = FCV_DIGIT1;
- FCV_CODE = FCV_CODE + (FCV_DIGIT2 * 1000);
- FCV_CODE = FCV_CODE + (FCV_DIGIT3 * 100);
- FCV_CODE = FCV_CODE + (FCV_DIGIT4 * 10);
- FCV_DIGIT1 = 0;
- FCV_DIGIT2 = 0;
- FCV_DIGIT3 = 0;
- FCV_DIGIT4 = 0;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Confirm Code:")
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('f');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(':');
- //Decision
- //Decision: Digit1 > 0?
- if (FCV_DIGIT1 > 0)
- {
- } else {
- //Connection Point
- //Connection Point: [I]: I
- FCC_FirstStartup_I:
- ;
- //Loop
- //Loop: While Digitset < 1
- while (FCV_DIGITSET < 1)
- {
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [I]: I
- goto FCC_FirstStartup_I;
- } else {
- //Calculation
- //Calculation:
- // Digit1 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT1 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
- FCD_LCDDisplay0_Cursor(0, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [J]: J
- FCC_FirstStartup_J:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [J]: J
- goto FCC_FirstStartup_J;
- }
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit2 > 0?
- if (FCV_DIGIT2 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (1)
- {
- //Connection Point
- //Connection Point: [K]: K
- FCC_FirstStartup_K:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [K]: K
- goto FCC_FirstStartup_K;
- } else {
- //Calculation
- //Calculation:
- // Digit2 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT2 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [L]: L
- FCC_FirstStartup_L:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [L]: L
- goto FCC_FirstStartup_L;
- }
- if ((FCV_DIGITSET < 1) == 0) break;
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit3 > 0?
- if (FCV_DIGIT3 > 0)
- {
- } else {
- //Connection Point
- //Connection Point: [M]: M
- FCC_FirstStartup_M:
- ;
- //Loop
- //Loop: While Digitset < 1
- while (1)
- {
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [M]: M
- goto FCC_FirstStartup_M;
- } else {
- //Calculation
- //Calculation:
- // Digit3 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT3 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [N]: N
- FCC_FirstStartup_N:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [N]: N
- goto FCC_FirstStartup_N;
- }
- if ((FCV_DIGITSET < 1) == 0) break;
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- FCV_DIGITSET = 0;
- }
- //Decision
- //Decision: Digit4 > 0?
- if (FCV_DIGIT4 > 0)
- {
- } else {
- //Loop
- //Loop: While Digitset < 1
- while (1)
- {
- //Connection Point
- //Connection Point: [P]: P
- FCC_FirstStartup_P:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- //Goto Connection Point
- //Goto Connection Point: [P]: P
- goto FCC_FirstStartup_P;
- } else {
- //Calculation
- //Calculation:
- // Digit4 = Keypadnumber
- // Digitset = 1
- FCV_DIGIT4 = FCV_KEYPADNUMBER;
- FCV_DIGITSET = 1;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("*")
- FCD_LCDDisplay0_PrintASCII('*');
- }
- //Connection Point
- //Connection Point: [Q]: Q
- FCC_FirstStartup_Q:
- ;
- //Call Component Macro
- //Call Component Macro: Keypadnumber=KeyPad(0)::GetKeypadNumber
- FCV_KEYPADNUMBER = FCD_KeyPad0_GetKeypadNumber();
- //Decision
- //Decision: Keypadnumber = 255?
- if (FCV_KEYPADNUMBER == 255)
- {
- } else {
- //Goto Connection Point
- //Goto Connection Point: [Q]: Q
- goto FCC_FirstStartup_Q;
- }
- if ((FCV_DIGITSET < 1) == 0) break;
- }
- //Calculation
- //Calculation:
- // Digitset = 0
- // CompareCode = Digit1
- // CompareCode = CompareCode + (Digit2 * 1000)
- // CompareCode = CompareCode + (Digit3 * 100)
- // CompareCode = CompareCode + (Digit4 * 10)
- FCV_DIGITSET = 0;
- FCV_COMPARECODE = FCV_DIGIT1;
- FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT2 * 1000);
- FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT3 * 100);
- FCV_COMPARECODE = FCV_COMPARECODE + (FCV_DIGIT4 * 10);
- }
- //Decision
- //Decision: Code = CompareCode?
- if (FCV_CODE == FCV_COMPARECODE)
- {
- //Calculation
- //Calculation:
- // Count = 0
- // DigitCount = 1
- FCV_COUNT = 0;
- FCV_DIGITCOUNT = 1;
- //Loop
- //Loop: While Count < 4
- while (1)
- {
- //Call Component Macro
- //Call Component Macro: EEPROM(0)::Write(Count, DigitCount)
- FCD_EEPROM0_WriteEEPROM(FCV_COUNT, FCV_DIGITCOUNT);
- //Calculation
- //Calculation:
- // Count = Count + 1
- // DigitCount = DigitCount + 1
- FCV_COUNT = FCV_COUNT + 1;
- FCV_DIGITCOUNT = FCV_DIGITCOUNT + 1;
- if ((FCV_COUNT < 4) == 0) break;
- }
- //Calculation
- //Calculation:
- // FirstRun = 1
- FCV_FIRSTRUN = 1;
- //Call Component Macro
- //Call Component Macro: EEPROM(0)::Write(4, FirstRun)
- FCD_EEPROM0_WriteEEPROM(4, FCV_FIRSTRUN);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Code Set")
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('t');
- //Calculation
- //Calculation:
- // Keypadnumber = 0
- // Code = 0
- // CompareCode = 0
- // Digit1 = 0
- // Digit2 = 0
- // Digit3 = 0
- // Digit4 = 0
- // Count = 0
- // DigitCount = 0
- FCV_KEYPADNUMBER = 0;
- FCV_CODE = 0;
- FCV_COMPARECODE = 0;
- FCV_DIGIT1 = 0;
- FCV_DIGIT2 = 0;
- FCV_DIGIT3 = 0;
- FCV_DIGIT4 = 0;
- FCV_COUNT = 0;
- FCV_DIGITCOUNT = 0;
- //Delay
- //Delay: 5 s
- delay_s(5);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Codes Do Not Match")
- FCD_LCDDisplay0_PrintASCII('C');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('N');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('M');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('c');
- FCD_LCDDisplay0_PrintASCII('h');
- //Delay
- //Delay: 3 s
- delay_s(3);
- //Goto Connection Point
- //Goto Connection Point: [O]: O
- goto FCC_FirstStartup_O;
- }
- }
- void main()
- {
- //Initialisation
- adcon1 = 0x07;
- //Interrupt initialisation code
- option_reg = 0xC0;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Start
- FCD_LCDDisplay0_Start();
- //Delay
- //Delay: 250 ms
- delay_ms(250);
- //Call Component Macro
- //Call Component Macro: FirstRun=EEPROM(0)::Read(4)
- FCV_FIRSTRUN = FCD_EEPROM0_EEPROMRead(4);
- //Decision
- //Decision: FirstRun > 0?
- if (FCV_FIRSTRUN > 0)
- {
- } else {
- //Call Macro
- //Call Macro: FirstStartup
- FCM_FirstStartup();
- }
- //Calculation
- //Calculation:
- // Count = 10
- FCV_COUNT = 10;
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Disarmed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('D');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Loop
- //Loop: While 1
- while (1)
- {
- //Decision
- //Decision: Count < 10?
- if (FCV_COUNT < 10)
- {
- //Calculation
- //Calculation:
- // Count = 10
- FCV_COUNT = 10;
- }
- //Input
- //Input: A0 -> ArmSwitch
- trisa = trisa | 0x01;
- FCV_ARMSWITCH = ((porta & 0x01) == 0x01);
- //Decision
- //Decision: ArmSwitch > 0?
- if (FCV_ARMSWITCH > 0)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 0)
- FCD_LCDDisplay0_Cursor(0, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Alarm Active In")
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('l');
- FCD_LCDDisplay0_PrintASCII('a');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('c');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('i');
- FCD_LCDDisplay0_PrintASCII('v');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('I');
- FCD_LCDDisplay0_PrintASCII('n');
- //Loop
- //Loop: While Count > 0
- while (1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(0, 1)
- FCD_LCDDisplay0_Cursor(0, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintNumber(Count)
- FCD_LCDDisplay0_PrintNumber(FCV_COUNT);
- //Decision
- //Decision: Count > 9?
- if (FCV_COUNT > 9)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(3, 1)
- FCD_LCDDisplay0_Cursor(3, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('c');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('s');
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(1, 1)
- FCD_LCDDisplay0_Cursor(1, 1);
- //Decision
- //Decision: Count > 1?
- if (FCV_COUNT > 1)
- {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('c');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('s');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(9, 1)
- FCD_LCDDisplay0_Cursor(9, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- } else {
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 1)
- FCD_LCDDisplay0_Cursor(2, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("Seconds")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('c');
- FCD_LCDDisplay0_PrintASCII('o');
- FCD_LCDDisplay0_PrintASCII('n');
- FCD_LCDDisplay0_PrintASCII('d');
- FCD_LCDDisplay0_PrintASCII('s');
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(8, 1)
- FCD_LCDDisplay0_Cursor(8, 1);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII(" ")
- FCD_LCDDisplay0_PrintASCII(' ');
- }
- }
- //Delay
- //Delay: 1 s
- delay_s(1);
- //Calculation
- //Calculation:
- // Count = Count - 1
- FCV_COUNT = FCV_COUNT - 1;
- if ((FCV_COUNT > 0) == 0) break;
- }
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Clear
- FCD_LCDDisplay0_Clear();
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::Cursor(2, 0)
- FCD_LCDDisplay0_Cursor(2, 0);
- //Call Component Macro
- //Call Component Macro: LCDDisplay(0)::PrintASCII("System Armed")
- FCD_LCDDisplay0_PrintASCII('S');
- FCD_LCDDisplay0_PrintASCII('y');
- FCD_LCDDisplay0_PrintASCII('s');
- FCD_LCDDisplay0_PrintASCII('t');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII(' ');
- FCD_LCDDisplay0_PrintASCII('A');
- FCD_LCDDisplay0_PrintASCII('r');
- FCD_LCDDisplay0_PrintASCII('m');
- FCD_LCDDisplay0_PrintASCII('e');
- FCD_LCDDisplay0_PrintASCII('d');
- //Calculation
- //Calculation:
- // SystemArmed = 1
- // Count = 10
- FCV_SYSTEMARMED = 1;
- FCV_COUNT = 10;
- }
- //Decision
- //Decision: SystemArmed > 0?
- if (FCV_SYSTEMARMED > 0)
- {
- //Call Macro
- //Call Macro: ZoneCheck
- FCM_ZoneCheck();
- }
- }
- mainendloop: goto mainendloop;
- }
- void MX_INTERRUPT_MACRO(void)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement