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