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.
ADJDColourSensor.h
00001 /** 00002 * @section LICENSE 00003 *Copyright (c) 2010 ARM Ltd. 00004 * 00005 *Permission is hereby granted, free of charge, to any person obtaining a copy 00006 *of this software and associated documentation files (the "Software"), to deal 00007 *in the Software without restriction, including without limitation the rights 00008 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 *copies of the Software, and to permit persons to whom the Software is 00010 *furnished to do so, subject to the following conditions: 00011 * 00012 *The above copyright notice and this permission notice shall be included in 00013 *all copies or substantial portions of the Software. 00014 * 00015 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 *THE SOFTWARE. 00022 * 00023 * 00024 * @section DESCRIPTION 00025 * 00026 * 00027 */ 00028 00029 #ifndef ADJDCOLOURSENS_H_ 00030 #define ADJDCOLOURSENS_H_ 00031 00032 /** 00033 * 00034 * Includes 00035 * 00036 */ 00037 #include "mbed.h" 00038 /** 00039 * A class to interface with an Avago ADJD-S371-QR999. 00040 * The class allows you to read the light levels setected by the sensor for each colour and to set the gain settings. 00041 */ 00042 class ADJDColourSensor{ 00043 public: 00044 ADJDColourSensor (PinName sda, PinName scl, PinName LED); 00045 00046 /** 00047 * Read the colour sensor channels. 00048 * The red, green and blue values are 00049 * 00050 * @returns The clear result, ie the overall brightness 00051 */ 00052 float read(); 00053 00054 /** 00055 * Read the offsets from the device and into the corresponding members. 00056 * 00057 * @returns The value of the clear offset 00058 */ 00059 int readOffset(); 00060 00061 float red, green, blue; 00062 00063 signed int redOffset, greenOffset, blueOffset, clearOffset; 00064 00065 /** 00066 * Set the number of capacitors for each channel of the ADC. 00067 * 00068 * The values of the parameters must be between 0x00 and 0x0F 00069 * @param redCap The number of capacitors for the red channel 00070 */ 00071 void setCapacitors(int redCap, int greenCap, int blueCap, int clearCap); 00072 00073 /** 00074 * Set the integration time slot for each of the ADCs. 00075 * 00076 * All the values are as a 12 bit number 00077 * @param redInt The integration time slot for the red channel 00078 * @param greenInt The integration time slot for the green channel 00079 * @param blueInt The integration time slot for the blue channel 00080 * @param clearInt The integration time slot for the clear channel 00081 */ 00082 void setIntegrationTimeSlot(int redInt, int greenInt, int blueInt, int ClearInt); 00083 00084 void optimise(); 00085 void optimise(int optimum); 00086 void optimise(int redTarget, int blueTarget, int greenTarget, int clearTarget); 00087 00088 00089 private: 00090 I2C _sensor; 00091 DigitalOut _LED; 00092 int _red, _green, _blue, _clear; 00093 int _address; 00094 }; 00095 #endif
Generated on Thu Jul 14 2022 03:35:15 by
1.7.2