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.
Dependents: ColorDetector ColorDetectorV2 offline_sync_k64f
Fork of GroveColourSensor by
GroveColourSensor.h
- Committer:
- bridadan
- Date:
- 2015-04-15
- Revision:
- 2:50cb56828ab9
- Child:
- 3:a401a082d57e
File content as of revision 2:50cb56828ab9:
/* * Copyright (c) 2006-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __GROVE_COLOUR_SENSOR_H__ #define __GROVE_COLOUR_SENSOR_H__ #include "mbed.h" struct RGBC_Sample { uint16_t red, green, blue, clear; }; union RGBC { RGBC_Sample ch; uint16_t data[4]; }; class GroveColourSensor { public: enum Colour_t { GREEN = 0, RED, BLUE, CLEAR, NUM_COLORS }; GroveColourSensor(I2C *i2c); bool powerUp(void); void powerDown(void); void setGain(uint8_t gain); uint16_t readColour(Colour_t colour); void setBlockRead(); void readBlock(RGBC *sample); uint16_t readColour(unsigned colour); private: static const uint8_t SEVEN_BIT_ADDRESS = 0x39; I2C *i2c; uint16_t bytesTo16bit(char lowByte, char highByte); }; #endif /* #ifndef __GROVE_COLOUR_SENSOR_H__ */