![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Psi Swarm Code V0.41 [With Beautiful Meme program]
Dependencies: PsiSwarmLibrary mbed
Fork of BeautifulMemeProjectBT by
Diff: main.cpp
- Revision:
- 0:8a5497a2e366
- Child:
- 1:f6356cf1cefc
diff -r 000000000000 -r 8a5497a2e366 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 03 22:48:50 2015 +0000 @@ -0,0 +1,105 @@ +/*********************************************************************** +** ██████╗ ███████╗██╗███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗ ** +** ██╔══██╗██╔════╝██║██╔════╝██║ ██║██╔══██╗██╔══██╗████╗ ████║ ** +** ██████╔╝███████╗██║███████╗██║ █╗ ██║███████║██████╔╝██╔████╔██║ ** +** ██╔═══╝ ╚════██║██║╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║ ** +** ██║ ███████║██║███████║╚███╔███╔╝██║ ██║██║ ██║██║ ╚═╝ ██║ ** +** ╚═╝ ╚══════╝╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ** +************************************************************************ +**(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 and the author +// NB: Keep the strings as short as possible (ie 12 chars or less) to ensure reliable comms +char * program_name = "Example"; +char * author_name = "JAH-YRL"; + +// Place user variables here + +char green = 3; +char red = 48; +int re =0 ; +int le =0; + +//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(){ + + + //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) + + + + + /* + store_base_ir_values(); + bt.printf("OFF: %d %d %d %d %d\n ON: %d %d %d %d %d\n\n", + get_background_base_ir_value(0), + get_background_base_ir_value(1), + get_background_base_ir_value(2), + get_background_base_ir_value(3), + get_background_base_ir_value(4), + get_illuminated_base_ir_value(0), + get_illuminated_base_ir_value(1), + get_illuminated_base_ir_value(2), + get_illuminated_base_ir_value(3), + get_illuminated_base_ir_value(4)); + set_leds(green,red); + switch(green){ + case 192: green = 129; break; + case 129: green = 3; break; + default: green = green << 1; break; + } + switch(red){ + case 192: red = 129; break; + case 129: red = 3; break; + default: red = red << 1; break; + } + + + if(re != right_encoder){ + re = right_encoder; + pc.printf("Right:%d\n",re); + } + if(le != left_encoder){ + le = left_encoder; + pc.printf("Left:%d\n",le); + } + wait(0.3); + */ +} + + +// 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 +} + +// 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); + } +} \ No newline at end of file