Bluetooth communication for flocking.

Dependencies:   mbed

Fork of BeautifulMemeProject by James Hilder

Committer:
jah128
Date:
Sat Oct 03 22:48:50 2015 +0000
Revision:
0:8a5497a2e366
Child:
6:ff3c66f7372b
Initial commit of PsiSwarm API and example code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:8a5497a2e366 1 /* University of York Robotics Laboratory PsiSwarm Library: Colour Sensors Source File
jah128 0:8a5497a2e366 2 *
jah128 0:8a5497a2e366 3 * File: colour.cpp
jah128 0:8a5497a2e366 4 *
jah128 0:8a5497a2e366 5 * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York
jah128 0:8a5497a2e366 6 *
jah128 0:8a5497a2e366 7 * PsiSwarm Library Version: 0.2
jah128 0:8a5497a2e366 8 *
jah128 0:8a5497a2e366 9 * October 2015
jah128 0:8a5497a2e366 10 *
jah128 0:8a5497a2e366 11 */
jah128 0:8a5497a2e366 12
jah128 0:8a5497a2e366 13
jah128 0:8a5497a2e366 14 // Base colour sensor is a TCS34725
jah128 0:8a5497a2e366 15 // Top colour sensor (if fitted) is a TCS34721
jah128 0:8a5497a2e366 16 #include "psiswarm.h"
jah128 0:8a5497a2e366 17
jah128 0:8a5497a2e366 18
jah128 0:8a5497a2e366 19 void read_base_colour_sensor_values(int * store_array){
jah128 0:8a5497a2e366 20
jah128 0:8a5497a2e366 21 }
jah128 0:8a5497a2e366 22
jah128 0:8a5497a2e366 23 void set_base_colour_sensor_gain(char gain){
jah128 0:8a5497a2e366 24
jah128 0:8a5497a2e366 25 }
jah128 0:8a5497a2e366 26
jah128 0:8a5497a2e366 27 void set_base_colour_sensor_integration_time(char int_time){
jah128 0:8a5497a2e366 28
jah128 0:8a5497a2e366 29 }
jah128 0:8a5497a2e366 30
jah128 0:8a5497a2e366 31 void enable_base_colour_sensor(void){
jah128 0:8a5497a2e366 32
jah128 0:8a5497a2e366 33 }
jah128 0:8a5497a2e366 34
jah128 0:8a5497a2e366 35 char IF_check_base_colour_sensor(void){
jah128 0:8a5497a2e366 36 //Reads the device ID flag of the colour sensor [0xB2]
jah128 0:8a5497a2e366 37 //This should equal 0x44 for both TCS34721 (top) and TCS34725 (base) sensors
jah128 0:8a5497a2e366 38 //Return a 1 if successful or a 0 otherwise
jah128 0:8a5497a2e366 39 char return_value = 0;
jah128 0:8a5497a2e366 40 char data[1] = {0x00};
jah128 0:8a5497a2e366 41 char command[1] = {0xB2};
jah128 0:8a5497a2e366 42 primary_i2c.write(BASE_COLOUR_ADDRESS, command, 1, false);
jah128 0:8a5497a2e366 43 primary_i2c.read(BASE_COLOUR_ADDRESS, data, 1, false);
jah128 0:8a5497a2e366 44 if(data[0] == 0x44) return_value = 1;
jah128 0:8a5497a2e366 45 else debug("Invalid response from colour sensor:%X\n",data[0]);
jah128 0:8a5497a2e366 46 return return_value;
jah128 0:8a5497a2e366 47 }