Mobile Security System - Revision 1.0
Dependencies: FXOS8700Q N5110 SDFileSystem SRF02 mbed
main.h
- Committer:
- el14dg
- Date:
- 2016-04-15
- Revision:
- 3:70a7b64fbd98
- Parent:
- 2:e504a3cfe113
- Child:
- 4:9cac024c057c
File content as of revision 3:70a7b64fbd98:
/** @file main.h @brief Header file containing functions prototypes, defines and global variables. @brief Revision 1.0. @author Daniel Gibbons @date March 2016 */ #ifndef MAIN_H #define MAIN_H #define PI 3.14159265359 #include "mbed.h" #include "N5110.h" #include "SRF02.h" #include "SDFileSystem.h" /** @namespace lcd @brief N5110 LCD connections @namespace srf02 @brief SRF02 sensor connections @namespace pc @brief UART connection to PC for debugging @namespace led_alarm @brief LED to indicate status of the alarm: flashing -> setting or triggered ; constant -> set @namespace buzzer @brief indicates status of the alarm: buzzes when alarm is setting and when triggered @namespace zero @brief first button input @namespace one @brief second button input @namespace confirm @brief third button input @namespace read_distance @brief K64F fires to read distance @namespace sw2 @brief K64F on-board switch @namespace sw3 @brief K64F on-board switch @namespace r_led @brief K64F on-board red LED @namespace g_led @brief K64F on-board green LED @namespace b_led @brief K64F on-board blue LED */ // VCC, SCE, RST, D/C, MOSI, SCLK, LED N5110 lcd(PTE26,PTA0,PTC4,PTD0,PTD2,PTD1,PTC3); SRF02 srf02(I2C_SDA,I2C_SCL); // MOSI, MISO, SCK, CS SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); Serial pc(USBTX,USBRX); PwmOut led_alarm(PTC10); PwmOut buzzer(PTC11); InterruptIn button_0(PTB23); InterruptIn button_1(PTA2); InterruptIn button_c(PTC2); InterruptIn sw2(SW2); InterruptIn sw3(SW3); Ticker setting_distance; Ticker intruder_distance; Timeout transition; DigitalOut r_led(LED_RED); DigitalOut g_led(LED_GREEN); DigitalOut b_led(LED_BLUE); struct State { int nextState[4]; // array of next states which depend on which button was pressed }; typedef const struct State STyp; STyp fsm[9] = { {0,0,0,0}, // 0 - initialisation (title screen) {2,1,3,3}, // 1 - main menu (Set alarm or set new password) {2,2,4,1}, // 2 - set alarm {3,3,1,1}, // 3 - set new password {4,4,4,4}, // 4 - setting calibration {7,5,6,6}, // 5 - alarm activated {6,6,1,5}, // 6 - deactivate without triggering (enter password) {7,7,1,8}, // 7 - alarm triggered (enter password) {8,8,1,1} // 8 - display time when alarm was triggered }; FILE *pin; // this is our file pointer int entered_pin[4]; int set_pin[4]; int index_array[4]; int pin_counter; int g_current_state; int g_next_state; float distance[10]; /*!< Stores 10 distance readings from SRF02 */ float one_second_distance; double one_second_avg_distance; double initial_setting_distance; int setting_distance_counter; int intruder_distance_counter; volatile int g_setting_distance_flag; /*!< Flag in setting_distance_isr */ volatile int g_intruder_distance_flag; /*!< Flag in intruder_distance_isr */ volatile int g_button_0_flag; /*!< Flag in button_0_isr */ volatile int g_button_1_flag; /*!< Flag in button_1_isr */ volatile int g_button_c_flag; /*!< Flag in button_c_isr */ int setting_distance_ticker_status; int intruder_distance_ticker_status; char buffer[14]; /*!< Stores any string that is going to be displayed on the LCD */ int length; /*!< Stores the length of any string that is going to be displayed on the LCD */ void error(); /*!< Hangs flashing on_board LED */ void init_serial(); /*!< Set-up the serial port */ void init_K64F(); /*!< Set-up the on-board LEDs and switches */ void init_buttons(); /*!< Set-up the three external buttons */ void setting_distance_isr(); /*!< Interrupt that triggers when setting_distance ticker fires */ void intruder_distance_isr(); /*!< Interrupt that triggers when intruder_distance ticker fires */ void button_0_isr(); /*!< Interrupt that triggers when button_0 is pressed by the user */ void button_1_isr(); /*!< Interrupt that triggers when button_1 is pressed by the user */ void button_c_isr(); /*!< Interrupt that triggers when button_c is pressed by the user */ void button_0_protocol(); void button_1_protocol(); void button_c_protocol(); void state_0_screen(); void state_1_screen(); void state_2_6_7_screen(); void state_3_screen(); void state_4_screen(); void state_5_screen(); void state_8_screen(); void screen_selection(); void get_setting_distance(); void get_intruder_distance(); void calculate_setting_distance(); void calculate_intruder_distance(); void screen_5_transition(); void change_pin(); void read_pin(); void delete_file(char filename[]); /** */ #endif