![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Mobile Security System - Revision 1.0
Dependencies: FXOS8700Q N5110 SDFileSystem SRF02 mbed
main.h
- Committer:
- el14dg
- Date:
- 2016-04-02
- Revision:
- 2:e504a3cfe113
- Parent:
- 1:3ae4192d0c25
- Child:
- 3:70a7b64fbd98
File content as of revision 2:e504a3cfe113:
/** @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" /** @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); Serial pc(USBTX,USBRX); PwmOut led_alarm(PTC10); PwmOut buzzer(PTC11); InterruptIn button_0(PTB23); InterruptIn button_1(PTA2); InterruptIn button_c(PTC2); Ticker read_distance; InterruptIn sw2(SW2); InterruptIn sw3(SW3); DigitalOut r_led(LED_RED); DigitalOut g_led(LED_GREEN); DigitalOut b_led(LED_BLUE); struct State { int nextState[3]; // array of next states which depend on which button was pressed }; typedef const struct State STyp; STyp fsm[9] = { {0,0,0}, // 0 - initialisation (title screen) {2,1,3}, // 1 - main menu (Set alarm or set new password) {2,2,4}, // 2 - set alarm {3,3,1}, // 3 - set new password {4,4,5}, // 4 - setting calibration {7,5,6}, // 5 - alarm activated {6,6,1}, // 6 - deactivate without triggering (enter password) {7,7,1}, // 7 - alarm triggered (enter password) {8,8,1} // 8 - display time when alarm was triggered }; int g_current_state; int distance[10]; /*!< Stores 10 distance readings from SRF02 */ int one_second_distance = 0; float one_second_avg_distance = 0; int read_distance_counter = 0; volatile int g_read_distance_flag; /*!< Flag in read_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 */ 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 read_distance_isr(); /*!< Interrupt that triggers when read_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 get_distance(); /*!< Gets the average distance in cm from the last 10 readings from the SRF02 */ void state_0_screen(); void state_1_screen(); void state_2_3_6_7_screen(); void state_4_screen(); void state_5_screen(); void state_8_screen(); void screen_selection(); /** */ #endif