YRL Maze lab made more script-y

Dependencies:   PsiSwarmLab-ScriptingBased mbed

Fork of UKESF_Lab by UKESF Headstart Summer School

main.cpp

Committer:
jah128
Date:
2015-10-05
Revision:
3:cd048f6e544e
Parent:
2:a6214fd156ff
Child:
4:25039ea5eb09

File content as of revision 3:cd048f6e544e:

/*********************************************************************** 
**  ██████╗ ███████╗██╗███████╗██╗    ██╗ █████╗ ██████╗ ███╗   ███╗  **
**  ██╔══██╗██╔════╝██║██╔════╝██║    ██║██╔══██╗██╔══██╗████╗ ████║  **
**  ██████╔╝███████╗██║███████╗██║ █╗ ██║███████║██████╔╝██╔████╔██║  **
**  ██╔═══╝ ╚════██║██║╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║  **
**  ██║     ███████║██║███████║╚███╔███╔╝██║  ██║██║  ██║██║ ╚═╝ ██║  **
**  ╚═╝     ╚══════╝╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝  **
************************************************************************
**(C) Dr James Hilder - York Robotics Laboratory - University of York **
***********************************************************************/

/// PsiSwarm Example Main File

/// Include psiswarm.h - this includes all the other necessary core files
#include "psiswarm.h"

/// Use these variables to store the name for the program, the author and the version
/// NB: Keep the strings as short as possible (ie 12 chars or less) to ensure reliable comms and readability on display
char * program_name = "Example";
char * author_name  = "JAH-YRL";
char * version_name = "1.0";

// Place user variables here

//char green = 3;

///Place user code here that should be run after initialisation but before the main loop
void user_code_setup(){

    /*
    wait(2);
    calibrate_base_ir_sensors();
    wait(2);
    */
}

///This function is the loop where user code should be placed
void user_code_loop(){   
    store_line_position();
    ///Do not place code within a loop, but consider this function to be a loop that is always run
    ///unless the user code is externally paused (such as by debug or recharging system)
    
    if(line_found == 1)pc.printf("%f\n",line_position); 
    wait(0.25);
}


/// Code goes here to handle what should happen when the user switch is pressed
void handle_switch_event(char switch_state)
{
    /// 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   
    /// NB For maximum compatability it is recommended to minimise reliance on center button press
}

/// The main routine: it is recommended to leave this function alone and add user code to the above functions
int main() {
    ///init() in psiswarm.cpp sets up the robot
    init();
    user_code_setup();
    user_code_running = 1;
    while(1) {
       if(user_code_running)user_code_loop();
       if(demo_on) demo_mode();
       wait_us(250);
    }
}