JM9 XRCU Board 0.1.1
Libraries API Reference
Loading...
Searching...
No Matches
Color_sensor Class Reference

PKS Color Sensor Driver for XRCU. More...

#include <Color_sensor.h>

Inheritance diagram for Color_sensor:
Supported_sensor Supported_module

Public Member Functions

 Color_sensor (const uint32_t init_port)
 Creates a Color_sensor object.
 
bool begin (const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Activates this color sensor.
 
uint8_t get_color ()
 Gets a simple color.
 
rgb_t get_rgb ()
 Gets the measured color in RGB-888.
 
hsl_t get_hsl ()
 Gets the measured color in HSL.
 
rgbc_t get_rgbc ()
 Gets the measured color in RGBC.
 
void turn_on_light_bulb ()
 Turns on the detector light bulb.
 
void turn_off_light_bulb ()
 Turns off the detector light bulb.
 
void turn_on_indicator_led ()
 Turns on the indicator LED.
 
void turn_off_indicator_led ()
 Turns off the indicator LED.
 
bool cal ()
 calibrates the color sensor to provide accurate results (for future compatibility use)
 

Additional Inherited Members

- Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Detailed Description

PKS Color Sensor Driver for XRCU.

Warning
This module requires 5V power supply, which could not provided from XRCU.
Deprecated
New robot designs should not use this module with XRCU.
This library may be removed in future releases.
See warning.
Note
DISCLAIMER:
The hardware of this sensor is not provided by Journey Maker 9 Systems.
Performance and stability could not be guaranteed to JM9 competition standards.
Consult hardware distributor before using this sensor in critical competitions.
Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Color_sensor()

Color_sensor::Color_sensor ( const uint32_t init_port)

Creates a Color_sensor object.

Parameters
init_portthe I2C port connected to this color sensor

Member Function Documentation

◆ begin()

bool Color_sensor::begin ( const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS)

Activates this color sensor.

YOU MUST CALL ME IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY. Configures the settings of the I2C bus and the chip.

Parameters
init_i2c_addressthe 7-bit I2C address of this color sensor
Returns
true if the color sensor is successfully activated, false if activation failed (for future compatibility use)

◆ cal()

bool Color_sensor::cal ( )

calibrates the color sensor to provide accurate results (for future compatibility use)

Returns
true if calibration is successful, false if calibration failed

◆ get_color()

uint8_t Color_sensor::get_color ( )

Gets a simple color.

Note
DISCLAIMER:
This implementation is adopted from the driver implementation provided by hardware vendor.
Returns
the color detected, expressed as one of the options in enum color_t
See also
color_t

◆ get_hsl()

hsl_t Color_sensor::get_hsl ( )

Gets the measured color in HSL.

Note
DISCLAIMER:
This implementation is adopted from the driver implementation provided by hardware vendor.
Returns
the measured color in HSL in struct hsl_t
See also
hsl_t

◆ get_rgb()

rgb_t Color_sensor::get_rgb ( )

Gets the measured color in RGB-888.

Note
DISCLAIMER:
This implementation is adopted from the driver implementation provided by hardware vendor.
Returns
the measured color in RGB-888 in struct rgb_t
See also
rgb_t

◆ get_rgbc()

rgbc_t Color_sensor::get_rgbc ( )

Gets the measured color in RGBC.

Note
DISCLAIMER:
This implementation is adopted from the driver implementation provided by hardware vendor.
Returns
the measured color in RGBC in struct rgbc_t
See also
rgbc_t

◆ turn_off_indicator_led()

void Color_sensor::turn_off_indicator_led ( )

Turns off the indicator LED.

The indicator led tells what color the sensor has detected.

Note
DISCLAIMER:
This implementation is based on hardware vendor datasheet.
See also
turn_on_indicator_led()

◆ turn_off_light_bulb()

void Color_sensor::turn_off_light_bulb ( )

Turns off the detector light bulb.

The detector light bulb lights up the sample color plate.

Note
DISCLAIMER:
This implementation is based on hardware vendor datasheet.
See also
turn_on_light_bulb()

◆ turn_on_indicator_led()

void Color_sensor::turn_on_indicator_led ( )

Turns on the indicator LED.

The indicator led tells what color the sensor has detected.

Note
DISCLAIMER:
This implementation is based on hardware vendor datasheet.
See also
turn_off_indicator_led()

◆ turn_on_light_bulb()

void Color_sensor::turn_on_light_bulb ( )

Turns on the detector light bulb.

The detector light bulb lights up the sample color plate.

Note
DISCLAIMER:
This implementation is based on hardware vendor datasheet.
See also
turn_off_light_bulb()

The documentation for this class was generated from the following files: