Blank program for v0.9 API

Dependencies:   PsiSwarmV9 mbed

Fork of PsiSwarm_V8_Blank_CPP by Psi Swarm Robot

Committer:
jah128
Date:
Thu Jun 01 23:04:49 2017 +0000
Revision:
3:53cc107bcff1
Parent:
2:5d37e5fd7141
Child:
4:3af6e6afbfef
Initial commit for v0.9

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