UKESF Headstart Summer School / PsiSwarm-Headstart

Dependents:   UKESF_Lab

Fork of PsiSwarmLibrary by James Hilder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pic.cpp Source File

pic.cpp

00001 /* University of York Robotics Laboratory PsiSwarm Library: PIC and Audio Driver Source File
00002  * 
00003  * File: pic.cpp
00004  *
00005  * (C) Dept. Electronics & Computer Science, University of York
00006  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
00007  *
00008  * PsiSwarm Library Version: 0.41
00009  *
00010  * March 2016
00011  *
00012  *
00013  */
00014 
00015 
00016 #include "psiswarm.h"
00017 
00018 
00019 void play_audio_string(char * tune){
00020     char length = strlen(tune);
00021     play_tune(tune,length);   
00022 }
00023 
00024 void play_tune(char * tune, char length){
00025     char to_send [length+3];
00026     char start_array[2];
00027     start_array [0] = 'S';
00028     start_array [1] = length;
00029     strcpy(to_send,start_array);
00030     strncat(to_send,tune,length);
00031     debug(to_send);
00032     primary_i2c.write(PIC_ADDRESS,to_send,length+2,false);
00033 }
00034 
00035 
00036 char IF_check_pic_firmware(){
00037     char buffer[6];
00038     buffer[0] = 0;
00039      primary_i2c.write(PIC_ADDRESS,"I",1,false);
00040      wait(0.1);
00041      primary_i2c.read(PIC_ADDRESS,buffer,6);   
00042          debug(buffer); 
00043     if(buffer[0] != 'F' || buffer[1] != 'W'){
00044         debug("WARNING:  Cannot read information from PIC microcontroller");
00045         return 1;
00046     }
00047     debug(buffer);
00048     return 0;
00049 }