C++ Library for the PsiSwarm Robot - Version 0.8
Dependents: PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk
Fork of PsiSwarmV7_CPP by
Diff: sound.cpp
- Revision:
- 12:878c6e9d9e60
- Parent:
- 11:312663037b8c
diff -r 312663037b8c -r 878c6e9d9e60 sound.cpp --- a/sound.cpp Sun Oct 16 21:06:15 2016 +0000 +++ b/sound.cpp Mon Oct 17 13:09:10 2016 +0000 @@ -1,11 +1,11 @@ /* University of York Robotics Laboratory PsiSwarm Library: Audio Driver using PIC coprocessor Source File - * + * * Copyright 2016 University of York * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and limitations under the License. * * File: sound.cpp [formerly pic.cpp] @@ -24,34 +24,37 @@ #include "psiswarm.h" -void Sound::play_audio_string(char * tune){ +void Sound::play_audio_string(char * tune) +{ char length = strlen(tune); - play_tune(tune,length); + play_tune(tune,length); } -void Sound::play_tune(char * tune, char length){ +void Sound::play_tune(char * tune, char length) +{ char to_send [length+3]; char start_array[2]; start_array [0] = 'S'; start_array [1] = length; strcpy(to_send,start_array); strncat(to_send,tune,length); - debug(to_send); + psi.debug(to_send); primary_i2c.write(PIC_ADDRESS,to_send,length+2,false); } -char Sound::IF_check_pic_firmware(){ +char Sound::IF_check_pic_firmware() +{ char buffer[6]; buffer[0] = 0; - primary_i2c.write(PIC_ADDRESS,"I",1,false); - wait(0.1); - primary_i2c.read(PIC_ADDRESS,buffer,6); - debug(buffer); - if(buffer[0] != 'F' || buffer[1] != 'W'){ - debug("WARNING: Cannot read information from PIC microcontroller"); + primary_i2c.write(PIC_ADDRESS,"I",1,false); + wait(0.1); + primary_i2c.read(PIC_ADDRESS,buffer,6); + psi.debug(buffer); + if(buffer[0] != 'F' || buffer[1] != 'W') { + psi.debug("WARNING: Cannot read information from PIC microcontroller"); return 1; } - debug(buffer); + psi.debug(buffer); return 0; } \ No newline at end of file