YRL Maze lab made more script-y
Dependencies: PsiSwarmLab-ScriptingBased mbed
Fork of UKESF_Lab by
main.cpp@30:513457c1ad12, 2016-03-15 (annotated)
- Committer:
- jah128
- Date:
- Tue Mar 15 00:58:43 2016 +0000
- Revision:
- 30:513457c1ad12
- Parent:
- 28:46d650381972
- Child:
- 31:7fa2c47d73a2
Added serial handling for Psi Console
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 6:ff3c66f7372b | 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 | 30:513457c1ad12 | 12 | /// PsiSwarm Blank Example Code |
jah128 | 30:513457c1ad12 | 13 | /// Version 0.41 |
jah128 | 30:513457c1ad12 | 14 | /// James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis |
jah128 | 6:ff3c66f7372b | 15 | /// University of York |
jah128 | 0:8a5497a2e366 | 16 | |
jah128 | 10:1b09d4bb847b | 17 | /// Include main.h - this includes psiswarm.h all the other necessary core files |
jah128 | 10:1b09d4bb847b | 18 | #include "main.h" |
jah128 | 9:085e090e1ec1 | 19 | |
jah128 | 30:513457c1ad12 | 20 | char * program_name = "Blank"; |
jah128 | 10:1b09d4bb847b | 21 | char * author_name = "YRL"; |
jah128 | 30:513457c1ad12 | 22 | char * version_name = "0.41"; |
jah128 | 6:ff3c66f7372b | 23 | |
jah128 | 30:513457c1ad12 | 24 | void user_code_loop() |
jah128 | 9:085e090e1ec1 | 25 | { |
jah128 | 30:513457c1ad12 | 26 | wait(1); |
jah128 | 9:085e090e1ec1 | 27 | } |
jah128 | 9:085e090e1ec1 | 28 | |
jah128 | 1:f6356cf1cefc | 29 | ///Place user code here that should be run after initialisation but before the main loop |
jah128 | 6:ff3c66f7372b | 30 | void user_code_setup() |
jah128 | 13:f5994956b1ba | 31 | { |
jah128 | 30:513457c1ad12 | 32 | wait(1); |
jah128 | 9:085e090e1ec1 | 33 | display.clear_display(); |
jah128 | 9:085e090e1ec1 | 34 | display.set_position(0,0); |
jah128 | 30:513457c1ad12 | 35 | display.write_string("No Code"); |
jah128 | 30:513457c1ad12 | 36 | |
jah128 | 30:513457c1ad12 | 37 | //bmeme_user_code_setup(); |
jah128 | 0:8a5497a2e366 | 38 | } |
jah128 | 0:8a5497a2e366 | 39 | |
jah128 | 1:f6356cf1cefc | 40 | /// Code goes here to handle what should happen when the user switch is pressed |
jah128 | 0:8a5497a2e366 | 41 | void handle_switch_event(char switch_state) |
jah128 | 0:8a5497a2e366 | 42 | { |
jah128 | 6:ff3c66f7372b | 43 | /// 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 | 44 | /// NB For maximum compatability it is recommended to minimise reliance on center button press |
jah128 | 30:513457c1ad12 | 45 | |
jah128 | 30:513457c1ad12 | 46 | //bmeme_handle_switch_event(switch_state); |
jah128 | 30:513457c1ad12 | 47 | } |
jah128 | 30:513457c1ad12 | 48 | |
jah128 | 30:513457c1ad12 | 49 | void handle_user_serial_message(char * message, char length, char interface) |
jah128 | 30:513457c1ad12 | 50 | { |
jah128 | 30:513457c1ad12 | 51 | // This is where user code for handling a (non-system) serial message should go |
jah128 | 30:513457c1ad12 | 52 | // |
jah128 | 30:513457c1ad12 | 53 | // message = pointer to message char array |
jah128 | 30:513457c1ad12 | 54 | // length = length of message |
jah128 | 30:513457c1ad12 | 55 | // interface = 0 for PC serial connection, 1 for Bluetooth |
jah128 | 30:513457c1ad12 | 56 | |
jah128 | 30:513457c1ad12 | 57 | //bmeme_handle_user_serial_message(message, length, interface); |
jah128 | 0:8a5497a2e366 | 58 | } |
jah128 | 0:8a5497a2e366 | 59 | |
jah128 | 1:f6356cf1cefc | 60 | /// The main routine: it is recommended to leave this function alone and add user code to the above functions |
jah128 | 6:ff3c66f7372b | 61 | int main() |
jah128 | 6:ff3c66f7372b | 62 | { |
jah128 | 1:f6356cf1cefc | 63 | ///init() in psiswarm.cpp sets up the robot |
jah128 | 0:8a5497a2e366 | 64 | init(); |
jah128 | 0:8a5497a2e366 | 65 | user_code_setup(); |
jah128 | 0:8a5497a2e366 | 66 | user_code_running = 1; |
jah128 | 0:8a5497a2e366 | 67 | while(1) { |
jah128 | 30:513457c1ad12 | 68 | user_code_loop(); |
jah128 | 0:8a5497a2e366 | 69 | } |
jah128 | 0:8a5497a2e366 | 70 | } |