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.
Dependents: PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk
Fork of PsiSwarmV7_CPP by
sound.cpp
00001 /* University of York Robotics Laboratory PsiSwarm Library: Audio Driver using PIC coprocessor Source File 00002 * 00003 * Copyright 2016 University of York 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 00007 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS 00008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00009 * See the License for the specific language governing permissions and limitations under the License. 00010 * 00011 * File: sound.cpp [formerly pic.cpp] 00012 * 00013 * (C) Dept. Electronics & Computer Science, University of York 00014 * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis 00015 * 00016 * PsiSwarm Library Version: 0.8 00017 * 00018 * October 2016 00019 * 00020 * 00021 */ 00022 00023 00024 #include "psiswarm.h" 00025 00026 00027 void Sound::play_audio_string(char * tune) 00028 { 00029 char length = strlen(tune); 00030 play_tune(tune,length); 00031 } 00032 00033 void Sound::play_tune(char * tune, char length) 00034 { 00035 char to_send [length+3]; 00036 char start_array[2]; 00037 start_array [0] = 'S'; 00038 start_array [1] = length; 00039 strcpy(to_send,start_array); 00040 strncat(to_send,tune,length); 00041 psi.debug(to_send); 00042 primary_i2c.write(PIC_ADDRESS,to_send,length+2,false); 00043 } 00044 00045 00046 char Sound::IF_check_pic_firmware() 00047 { 00048 char buffer[6]; 00049 buffer[0] = 0; 00050 primary_i2c.write(PIC_ADDRESS,"I",1,false); 00051 wait(0.1); 00052 primary_i2c.read(PIC_ADDRESS,buffer,6); 00053 psi.debug(buffer); 00054 if(buffer[0] != 'F' || buffer[1] != 'W') { 00055 psi.debug("WARNING: Cannot read information from PIC microcontroller"); 00056 return 1; 00057 } 00058 psi.debug(buffer); 00059 return 0; 00060 }
Generated on Tue Jul 12 2022 21:11:24 by
1.7.2
