PsiSwarm Library  0.8
colour.cpp
1 /* University of York Robotics Laboratory PsiSwarm Library: Colour Sensors Source File
2  *
3  * Copyright 2016 University of York
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
8  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9  * See the License for the specific language governing permissions and limitations under the License.
10  *
11  * File: colour.cpp
12  *
13  * (C) Dept. Electronics & Computer Science, University of York
14  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
15  *
16  * PsiSwarm Library Version: 0.8
17  *
18  * October 2016
19  *
20  */
21 
22 
23 // Base colour sensor is a TCS34725
24 // Top colour sensor (if fitted) is a TCS34721
25 #include "psiswarm.h"
26 
27 
29 
30 }
31 
33 
34 }
35 
37 
38 }
39 
41 
42 }
43 
44 char Colour::IF_check_base_colour_sensor(void){
45  //Reads the device ID flag of the colour sensor [0xB2]
46  //This should equal 0x44 for both TCS34721 (top) and TCS34725 (base) sensors
47  //Return a 1 if successful or a 0 otherwise
48  char return_value = 0;
49  char data[1] = {0x00};
50  char command[1] = {0xB2};
51  primary_i2c.write(BASE_COLOUR_ADDRESS, command, 1, false);
52  primary_i2c.read(BASE_COLOUR_ADDRESS, data, 1, false);
53  if(data[0] == 0x44) return_value = 1;
54  else psi.debug("Invalid response from colour sensor:%X\n",data[0]);
55  return return_value;
56 }
void read_base_colour_sensor_values(int *store_array)
Definition: colour.cpp:28
void set_base_colour_sensor_integration_time(char int_time)
Definition: colour.cpp:36
void enable_base_colour_sensor(void)
Definition: colour.cpp:40
void set_base_colour_sensor_gain(char gain)
Definition: colour.cpp:32
void debug(const char *format,...)
Definition: psiswarm.cpp:325