ft. button press reset

Dependencies:   mbed

Fork of BeaconDemo_RobotCodeNew by James O'Keeffe

Committer:
jah128
Date:
Mon Oct 12 12:39:35 2015 +0000
Revision:
4:25039ea5eb09
Parent:
3:cd048f6e544e
Child:
6:ff3c66f7372b
Removed code to make 'blank' example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:8a5497a2e366 1 /***********************************************************************
jah128 0:8a5497a2e366 2 ** ██████╗ ███████╗██╗███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗ **
jah128 0:8a5497a2e366 3 ** ██╔══██╗██╔════╝██║██╔════╝██║ ██║██╔══██╗██╔══██╗████╗ ████║ **
jah128 0:8a5497a2e366 4 ** ██████╔╝███████╗██║███████╗██║ █╗ ██║███████║██████╔╝██╔████╔██║ **
jah128 0:8a5497a2e366 5 ** ██╔═══╝ ╚════██║██║╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║ **
jah128 0:8a5497a2e366 6 ** ██║ ███████║██║███████║╚███╔███╔╝██║ ██║██║ ██║██║ ╚═╝ ██║ **
jah128 0:8a5497a2e366 7 ** ╚═╝ ╚══════╝╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ **
jah128 0:8a5497a2e366 8 ************************************************************************
jah128 0:8a5497a2e366 9 **(C) Dr James Hilder - York Robotics Laboratory - University of York **
jah128 0:8a5497a2e366 10 ***********************************************************************/
jah128 0:8a5497a2e366 11
jah128 1:f6356cf1cefc 12 /// PsiSwarm Example Main File
jah128 0:8a5497a2e366 13
jah128 1:f6356cf1cefc 14 /// Include psiswarm.h - this includes all the other necessary core files
jah128 0:8a5497a2e366 15 #include "psiswarm.h"
jah128 0:8a5497a2e366 16
jah128 1:f6356cf1cefc 17 /// Use these variables to store the name for the program, the author and the version
jah128 1:f6356cf1cefc 18 /// NB: Keep the strings as short as possible (ie 12 chars or less) to ensure reliable comms and readability on display
jah128 4:25039ea5eb09 19 char * program_name = "Blank";
jah128 4:25039ea5eb09 20 char * author_name = "YRL";
jah128 1:f6356cf1cefc 21 char * version_name = "1.0";
jah128 0:8a5497a2e366 22
jah128 0:8a5497a2e366 23 // Place user variables here
jah128 0:8a5497a2e366 24
jah128 0:8a5497a2e366 25
jah128 1:f6356cf1cefc 26 ///Place user code here that should be run after initialisation but before the main loop
jah128 0:8a5497a2e366 27 void user_code_setup(){
jah128 0:8a5497a2e366 28
jah128 4:25039ea5eb09 29 pc.printf("User setup code block\n");
jah128 0:8a5497a2e366 30 }
jah128 0:8a5497a2e366 31
jah128 1:f6356cf1cefc 32 ///This function is the loop where user code should be placed
jah128 1:f6356cf1cefc 33 void user_code_loop(){
jah128 4:25039ea5eb09 34
jah128 1:f6356cf1cefc 35 ///Do not place code within a loop, but consider this function to be a loop that is always run
jah128 1:f6356cf1cefc 36 ///unless the user code is externally paused (such as by debug or recharging system)
jah128 4:25039ea5eb09 37
jah128 4:25039ea5eb09 38 pc.printf("User loop code block\n");
jah128 4:25039ea5eb09 39 wait(1);
jah128 0:8a5497a2e366 40 }
jah128 0:8a5497a2e366 41
jah128 0:8a5497a2e366 42
jah128 1:f6356cf1cefc 43 /// Code goes here to handle what should happen when the user switch is pressed
jah128 0:8a5497a2e366 44 void handle_switch_event(char switch_state)
jah128 0:8a5497a2e366 45 {
jah128 1:f6356cf1cefc 46 /// Switch_state = 1 if up is pressed, 2 if down is pressed, 4 if left is pressed, 8 if right is pressed and 16 if the center button is pressed
jah128 1:f6356cf1cefc 47 /// NB For maximum compatability it is recommended to minimise reliance on center button press
jah128 4:25039ea5eb09 48
jah128 4:25039ea5eb09 49 pc.printf("User switch code block: %d\n",switch_state);
jah128 0:8a5497a2e366 50 }
jah128 0:8a5497a2e366 51
jah128 1:f6356cf1cefc 52 /// The main routine: it is recommended to leave this function alone and add user code to the above functions
jah128 0:8a5497a2e366 53 int main() {
jah128 1:f6356cf1cefc 54 ///init() in psiswarm.cpp sets up the robot
jah128 0:8a5497a2e366 55 init();
jah128 0:8a5497a2e366 56 user_code_setup();
jah128 0:8a5497a2e366 57 user_code_running = 1;
jah128 0:8a5497a2e366 58 while(1) {
jah128 0:8a5497a2e366 59 if(user_code_running)user_code_loop();
jah128 0:8a5497a2e366 60 if(demo_on) demo_mode();
jah128 4:25039ea5eb09 61 //wait_us(5);
jah128 0:8a5497a2e366 62 }
jah128 0:8a5497a2e366 63 }