Psi Swarm Robot / PsiSwarmV8_CPP

Dependents:   PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk

Fork of PsiSwarmV7_CPP by Psi Swarm Robot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers colour.cpp Source File

colour.cpp

00001 /* University of York Robotics Laboratory PsiSwarm Library: Colour Sensors 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: colour.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 // Base colour sensor is a TCS34725
00024 // Top colour sensor (if fitted) is a TCS34721
00025 #include "psiswarm.h"
00026 
00027 
00028 void Colour::read_base_colour_sensor_values(int * store_array){
00029     
00030 }
00031 
00032 void Colour::set_base_colour_sensor_gain(char gain){
00033     
00034 }
00035 
00036 void Colour::set_base_colour_sensor_integration_time(char int_time){
00037     
00038 }
00039 
00040 void Colour::enable_base_colour_sensor(void){
00041     
00042 }
00043 
00044 char Colour::IF_check_base_colour_sensor(void){
00045     //Reads the device ID flag of the colour sensor [0xB2]
00046     //This should equal 0x44 for both TCS34721 (top) and TCS34725 (base) sensors
00047     //Return a 1 if successful or a 0 otherwise
00048     char return_value = 0;
00049     char data[1] = {0x00};
00050     char command[1] = {0xB2};
00051     primary_i2c.write(BASE_COLOUR_ADDRESS, command, 1, false);
00052     primary_i2c.read(BASE_COLOUR_ADDRESS, data, 1, false);
00053     if(data[0] == 0x44) return_value = 1;
00054     else psi.debug("Invalid response from colour sensor:%X\n",data[0]);
00055     return return_value;
00056 }