Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of PsiSwarm-BeaconDemo_Bluetooth by
PsiSwarm/pic.cpp@22:3643fc1c82b6, 2017-03-08 (annotated)
- Committer:
- GusZ92
- Date:
- Wed Mar 08 11:49:39 2017 +0000
- Revision:
- 22:3643fc1c82b6
- Parent:
- 6:ff3c66f7372b
1. Flocking tune up threshold value; 2. Change the random walk to obs_avoid(new added)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jah128 | 4:25039ea5eb09 | 1 | /* University of York Robotics Laboratory PsiSwarm Library: PIC and Audio Driver Source File |
| jah128 | 4:25039ea5eb09 | 2 | * |
| jah128 | 4:25039ea5eb09 | 3 | * File: pic.cpp |
| jah128 | 4:25039ea5eb09 | 4 | * |
| jah128 | 6:ff3c66f7372b | 5 | * (C) Dept. Electronics & Computer Science, University of York |
| jah128 | 6:ff3c66f7372b | 6 | * James Hilder, Alan Millard, Homero Elizondo, Jon Timmis |
| jah128 | 4:25039ea5eb09 | 7 | * |
| jah128 | 6:ff3c66f7372b | 8 | * PsiSwarm Library Version: 0.3 |
| jah128 | 4:25039ea5eb09 | 9 | * |
| jah128 | 4:25039ea5eb09 | 10 | * October 2015 |
| jah128 | 4:25039ea5eb09 | 11 | * |
| jah128 | 4:25039ea5eb09 | 12 | */ |
| jah128 | 4:25039ea5eb09 | 13 | |
| jah128 | 4:25039ea5eb09 | 14 | |
| jah128 | 4:25039ea5eb09 | 15 | #include "psiswarm.h" |
| jah128 | 4:25039ea5eb09 | 16 | |
| jah128 | 4:25039ea5eb09 | 17 | |
| jah128 | 4:25039ea5eb09 | 18 | void play_audio_string(char * tune){ |
| jah128 | 4:25039ea5eb09 | 19 | char length = strlen(tune); |
| jah128 | 4:25039ea5eb09 | 20 | play_tune(tune,length); |
| jah128 | 4:25039ea5eb09 | 21 | } |
| jah128 | 4:25039ea5eb09 | 22 | |
| jah128 | 4:25039ea5eb09 | 23 | void play_tune(char * tune, char length){ |
| jah128 | 4:25039ea5eb09 | 24 | char to_send [length+3]; |
| jah128 | 4:25039ea5eb09 | 25 | char start_array[2]; |
| jah128 | 4:25039ea5eb09 | 26 | start_array [0] = 'S'; |
| jah128 | 4:25039ea5eb09 | 27 | start_array [1] = length; |
| jah128 | 4:25039ea5eb09 | 28 | strcpy(to_send,start_array); |
| jah128 | 4:25039ea5eb09 | 29 | strncat(to_send,tune,length); |
| jah128 | 4:25039ea5eb09 | 30 | debug(to_send); |
| jah128 | 4:25039ea5eb09 | 31 | primary_i2c.write(PIC_ADDRESS,to_send,length+2,false); |
| jah128 | 4:25039ea5eb09 | 32 | } |
| jah128 | 4:25039ea5eb09 | 33 | |
| jah128 | 4:25039ea5eb09 | 34 | |
| jah128 | 4:25039ea5eb09 | 35 | char IF_check_pic_firmware(){ |
| jah128 | 4:25039ea5eb09 | 36 | char buffer[6]; |
| jah128 | 4:25039ea5eb09 | 37 | buffer[0] = 0; |
| jah128 | 4:25039ea5eb09 | 38 | primary_i2c.write(PIC_ADDRESS,"I",1,false); |
| jah128 | 4:25039ea5eb09 | 39 | wait(0.1); |
| jah128 | 4:25039ea5eb09 | 40 | primary_i2c.read(PIC_ADDRESS,buffer,6); |
| jah128 | 4:25039ea5eb09 | 41 | debug(buffer); |
| jah128 | 4:25039ea5eb09 | 42 | if(buffer[0] != 'F' || buffer[1] != 'W'){ |
| jah128 | 4:25039ea5eb09 | 43 | debug("WARNING: Cannot read information from PIC microcontroller"); |
| jah128 | 4:25039ea5eb09 | 44 | return 1; |
| jah128 | 4:25039ea5eb09 | 45 | } |
| jah128 | 4:25039ea5eb09 | 46 | debug(buffer); |
| jah128 | 4:25039ea5eb09 | 47 | return 0; |
| jah128 | 4:25039ea5eb09 | 48 | } |
