Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

Color Sensor V1
[HiTechnic]

Files

file  hitechnic-colour-v1.h
 

HiTechnic Color Sensor driver.


Defines

#define HTCS_I2C_ADDR   0x02
#define HTCS_CMD_REG   0x41
#define HTCS_OFFSET   0x42
#define HTCS_COLNUM_REG   0x00
#define HTCS_RED_REG   0x01
#define HTCS_GREEN_REG   0x02
#define HTCS_BLUE_REG   0x03
#define HTCS_RED_RAW_REG   0x04
#define HTCS_GREEN_RAW_REG   0x05
#define HTCS_BLUE_RAW_REG   0x06
#define HTSC_COL_INDEX_REG   0x07
#define HTSC_RED_NORM_REG   0x08
#define HTSC_GREEN_NORM_REG   0x09
#define HTSC_BLUE_NORM_REG   0x0A
#define HTCS_CAL_WHITE   0x43

Functions

int HTCSreadColor (tSensors link)
bool HTCSreadRGB (tSensors link, int &red, int &green, int &blue)
bool HTCSreadNormRGB (tSensors link, int &red, int &green, int &blue)
bool HTCSreadRawRGB (tSensors link, int &red, int &green, int &blue)
bool HTCScalWhite (tSensors link)
int HTCSreadColor (tMUXSensor muxsensor)
bool HTCSreadRGB (tMUXSensor muxsensor, int &red, int &green, int &blue)
bool HTCSreadHSV (tSensors link, float &hue, float &saturation, float &value)
bool HTCSreadHSV (tMUXSensor muxsensor, float &hue, float &saturation, float &value)
int HTCSreadColorIndex (tSensors link)

Variables

tConfigParams HTCS_config = {HTSMUX_CHAN_I2C, 4, 0x02, 0x42}
tByteArray HTCS_I2CRequest
tByteArray HTCS_I2CReply

Detailed Description

HiTechnic Color Sensor V1


Define Documentation

#define HTCS_BLUE_RAW_REG   0x06

Raw blue reading (2 bytes)

Definition at line 62 of file hitechnic-colour-v1.h.

#define HTCS_BLUE_REG   0x03

Blue reading

Definition at line 59 of file hitechnic-colour-v1.h.

#define HTCS_CAL_WHITE   0x43

Command to calibrate white

Definition at line 68 of file hitechnic-colour-v1.h.

#define HTCS_CMD_REG   0x41

Command register

Definition at line 54 of file hitechnic-colour-v1.h.

#define HTCS_COLNUM_REG   0x00

Color number

Definition at line 56 of file hitechnic-colour-v1.h.

#define HTCS_GREEN_RAW_REG   0x05

Raw green reading (2 bytes)

Definition at line 61 of file hitechnic-colour-v1.h.

#define HTCS_GREEN_REG   0x02

Green reading

Definition at line 58 of file hitechnic-colour-v1.h.

#define HTCS_I2C_ADDR   0x02

HTCS I2C device address

Definition at line 53 of file hitechnic-colour-v1.h.

#define HTCS_OFFSET   0x42

Offset for data registers

Definition at line 55 of file hitechnic-colour-v1.h.

#define HTCS_RED_RAW_REG   0x04

Raw red reading (2 bytes)

Definition at line 60 of file hitechnic-colour-v1.h.

#define HTCS_RED_REG   0x01

Red reading

Definition at line 57 of file hitechnic-colour-v1.h.

#define HTSC_BLUE_NORM_REG   0x0A

Normalised blue reading

Definition at line 66 of file hitechnic-colour-v1.h.

#define HTSC_COL_INDEX_REG   0x07

Color index number

Definition at line 63 of file hitechnic-colour-v1.h.

#define HTSC_GREEN_NORM_REG   0x09

Normalised green reading

Definition at line 65 of file hitechnic-colour-v1.h.

#define HTSC_RED_NORM_REG   0x08

Normalised red reading

Definition at line 64 of file hitechnic-colour-v1.h.


Function Documentation

bool HTCScalWhite ( tSensors  link )

Calibrate the sensor for white.

Parameters:
linkthe HTCS port number
Returns:
true if no error occured, false if it did
Examples:
hitechnic-colour-v1-test2.c.

Definition at line 298 of file hitechnic-colour-v1.h.

int HTCSreadColor ( tSensors  link )

Return the color number currently detected.

Parameters:
linkthe HTCS port number
Returns:
color index number or -1 if an error occurred.
Examples:
hitechnic-colour-v1-SMUX-test1.c, and hitechnic-colour-v1-test1.c.

Definition at line 91 of file hitechnic-colour-v1.h.

int HTCSreadColor ( tMUXSensor  muxsensor )

Return the color number currently detected.

Parameters:
muxsensorthe SMUX sensor port number
Returns:
color index number or -1 if an error occurred.

Definition at line 111 of file hitechnic-colour-v1.h.

int HTCSreadColorIndex ( tSensors  link )

Return the color index number currently detected. This is a single 6 bit number color index. Bits 5 and 4 encode the red signal level, bits 3 and 2 encode the green signal level and bits 1 and 0 encode the blue signal levels.

Parameters:
linkthe HTCS port number
Returns:
color index number or -1 if an error occurred.

Definition at line 280 of file hitechnic-colour-v1.h.

bool HTCSreadHSV ( tSensors  link,
float &  hue,
float &  saturation,
float &  value 
)

Get the detection levels for the hue, saturation, value components.

Parameters:
linkthe HTCS port number
huethe hue output value (from 0 to 365, or -1 if n/a)
saturationthe saruration output value (from 0 to 100, or -1 if n/a)
valuethe value output value (from 0 to 100)
Returns:
true if no error occured, false if it did

Definition at line 188 of file hitechnic-colour-v1.h.

bool HTCSreadHSV ( tMUXSensor  muxsensor,
float &  hue,
float &  saturation,
float &  value 
)

Get the detection levels for the hue, saturation, value components.

Parameters:
muxsensorthe SMUX sensor port number
huethe hue output value (from 0 to 365, or -1 if n/a)
saturationthe saruration output value (from 0 to 100, or -1 if n/a)
valuethe value output value (from 0 to 100)
Returns:
true if no error occured, false if it did

Definition at line 207 of file hitechnic-colour-v1.h.

bool HTCSreadNormRGB ( tSensors  link,
int &  red,
int &  green,
int &  blue 
)

Get the normalised RGB readings. The normalization sets the highest value of the three Red, Green and Blue reading to 255 and adjusts the other two proportionately.

Parameters:
linkthe HTCS port number
redthe red value
greenthe green value
bluethe blue value
Returns:
true if no error occured, false if it did

Definition at line 229 of file hitechnic-colour-v1.h.

bool HTCSreadRawRGB ( tSensors  link,
int &  red,
int &  green,
int &  blue 
)

Get the raw RGB readings, these are 10bit values.

Parameters:
linkthe HTCS port number
redthe red value
greenthe green value
bluethe blue value
Returns:
true if no error occured, false if it did

Definition at line 255 of file hitechnic-colour-v1.h.

bool HTCSreadRGB ( tMUXSensor  muxsensor,
int &  red,
int &  green,
int &  blue 
)

Get the detection levels for the three color components.

Parameters:
muxsensorthe SMUX sensor port number
redthe red value
greenthe green value
bluethe blue value
Returns:
true if no error occured, false if it did

Definition at line 161 of file hitechnic-colour-v1.h.

bool HTCSreadRGB ( tSensors  link,
int &  red,
int &  green,
int &  blue 
)

Get the detection levels for the three color components.

Parameters:
linkthe HTCS port number
redthe red value
greenthe green value
bluethe blue value
Returns:
true if no error occured, false if it did
Examples:
hitechnic-colour-v1-SMUX-test1.c, and hitechnic-colour-v1-test1.c.

Definition at line 134 of file hitechnic-colour-v1.h.


Variable Documentation

tConfigParams HTCS_config = {HTSMUX_CHAN_I2C, 4, 0x02, 0x42}

Array to hold SMUX config data for sensor

Definition at line 80 of file hitechnic-colour-v1.h.

Array to hold I2C reply data

Definition at line 84 of file hitechnic-colour-v1.h.

Array to hold I2C command data

Definition at line 83 of file hitechnic-colour-v1.h.