Blank program code for the Psi Swarm robot (PCB 1.5) using API version 0.7

Dependencies:   PsiSwarmV7 mbed

Committer:
jah128
Date:
Sat Oct 15 13:52:26 2016 +0000
Revision:
0:9c0ccd879613
Initial commit of blank program code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:9c0ccd879613 1 /***********************************************************************
jah128 0:9c0ccd879613 2 ** ██████╗ ███████╗██╗███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗ **
jah128 0:9c0ccd879613 3 ** ██╔══██╗██╔════╝██║██╔════╝██║ ██║██╔══██╗██╔══██╗████╗ ████║ **
jah128 0:9c0ccd879613 4 ** ██████╔╝███████╗██║███████╗██║ █╗ ██║███████║██████╔╝██╔████╔██║ **
jah128 0:9c0ccd879613 5 ** ██╔═══╝ ╚════██║██║╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║ **
jah128 0:9c0ccd879613 6 ** ██║ ███████║██║███████║╚███╔███╔╝██║ ██║██║ ██║██║ ╚═╝ ██║ **
jah128 0:9c0ccd879613 7 ** ╚═╝ ╚══════╝╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ **
jah128 0:9c0ccd879613 8 ************************************************************************
jah128 0:9c0ccd879613 9 ** Copyright 2016 University of York **
jah128 0:9c0ccd879613 10 ** **
jah128 0:9c0ccd879613 11 ** Licensed under the Apache License, Version 2.0 (the "License") **
jah128 0:9c0ccd879613 12 ** You may not use this file except in compliance with the License. **
jah128 0:9c0ccd879613 13 ** You may obtain a copy of the License at **
jah128 0:9c0ccd879613 14 ** http://www.apache.org/licenses/LICENSE-2.0 Unless required by **
jah128 0:9c0ccd879613 15 ** applicable law or agreed to in writing, software distributed under **
jah128 0:9c0ccd879613 16 ** under the License is distributed on an "AS IS" BASIS WITHOUT **
jah128 0:9c0ccd879613 17 ** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. **
jah128 0:9c0ccd879613 18 ** See the License for the specific language governing permissions **
jah128 0:9c0ccd879613 19 ** and limitations under the License. **
jah128 0:9c0ccd879613 20 ***********************************************************************/
jah128 0:9c0ccd879613 21
jah128 0:9c0ccd879613 22 /// PsiSwarm Blank Example Code
jah128 0:9c0ccd879613 23 /// Version 0.7
jah128 0:9c0ccd879613 24 /// James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
jah128 0:9c0ccd879613 25 /// University of York
jah128 0:9c0ccd879613 26
jah128 0:9c0ccd879613 27 /// Include main.h - this includes psiswarm.h all the other necessary core files
jah128 0:9c0ccd879613 28 #include "main.h"
jah128 0:9c0ccd879613 29
jah128 0:9c0ccd879613 30 char * program_name = "Blank";
jah128 0:9c0ccd879613 31 char * author_name = "YRL";
jah128 0:9c0ccd879613 32 char * version_name = "0.41";
jah128 0:9c0ccd879613 33
jah128 0:9c0ccd879613 34 void user_code_loop()
jah128 0:9c0ccd879613 35 {
jah128 0:9c0ccd879613 36 wait(1);
jah128 0:9c0ccd879613 37 }
jah128 0:9c0ccd879613 38
jah128 0:9c0ccd879613 39 ///Place user code here that should be run after initialisation but before the main loop
jah128 0:9c0ccd879613 40 void user_code_setup()
jah128 0:9c0ccd879613 41 {
jah128 0:9c0ccd879613 42 wait(1);
jah128 0:9c0ccd879613 43 display.clear_display();
jah128 0:9c0ccd879613 44 display.set_position(0,0);
jah128 0:9c0ccd879613 45 display.write_string("No Code");
jah128 0:9c0ccd879613 46 }
jah128 0:9c0ccd879613 47
jah128 0:9c0ccd879613 48 /// Code goes here to handle what should happen when the user switch is pressed
jah128 0:9c0ccd879613 49 void handle_switch_event(char switch_state)
jah128 0:9c0ccd879613 50 {
jah128 0:9c0ccd879613 51 /// 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 0:9c0ccd879613 52 /// NB For maximum compatability it is recommended to minimise reliance on center button press
jah128 0:9c0ccd879613 53
jah128 0:9c0ccd879613 54 }
jah128 0:9c0ccd879613 55
jah128 0:9c0ccd879613 56 void handle_user_serial_message(char * message, char length, char interface)
jah128 0:9c0ccd879613 57 {
jah128 0:9c0ccd879613 58 // This is where user code for handling a (non-system) serial message should go
jah128 0:9c0ccd879613 59 //
jah128 0:9c0ccd879613 60 // message = pointer to message char array
jah128 0:9c0ccd879613 61 // length = length of message
jah128 0:9c0ccd879613 62 // interface = 0 for PC serial connection, 1 for Bluetooth
jah128 0:9c0ccd879613 63
jah128 0:9c0ccd879613 64 }
jah128 0:9c0ccd879613 65
jah128 0:9c0ccd879613 66 /// The main routine: it is recommended to leave this function alone and add user code to the above functions
jah128 0:9c0ccd879613 67 int main()
jah128 0:9c0ccd879613 68 {
jah128 0:9c0ccd879613 69 ///init() in psiswarm.cpp sets up the robot
jah128 0:9c0ccd879613 70 init();
jah128 0:9c0ccd879613 71 user_code_setup();
jah128 0:9c0ccd879613 72 user_code_running = 1;
jah128 0:9c0ccd879613 73 while(1) {
jah128 0:9c0ccd879613 74 user_code_loop();
jah128 0:9c0ccd879613 75 }
jah128 0:9c0ccd879613 76 }