SPIKE-RT C API Reference [English]
An RTOS-based software platform for LEGO® Education SPIKE™.
Loading...
Searching...
No Matches
colorsensor.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2/*
3 * API for color sensors
4 *
5 * Copyright (c) 2022 Embedded and Real-Time Systems Laboratory,
6 * Graduate School of Information Science, Nagoya Univ., JAPAN
7 */
8
33#ifndef _PUP_COLOR_SENSOR_H_
34#define _PUP_COLOR_SENSOR_H_
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#include <stdint.h>
41#include <spike/pup_device.h>
42#include <pbio/color.h>
43
57pup_device_t *pup_color_sensor_get_device(pbio_port_id_t port);
58
70typedef struct {
71 uint16_t r, g, b;
73pup_color_rgb_t pup_color_sensor_rgb(pup_device_t *pdev);
74
91typedef pbio_color_hsv_t pup_color_hsv_t;
92pup_color_hsv_t pup_color_sensor_color(pup_device_t *pdev, bool surface);
93
111
124
137
151pbio_error_t pup_color_sensor_light_set(pup_device_t *pdev,
152 int32_t bv1, int32_t bv2, int32_t bv3);
153
167pbio_error_t pup_color_sensor_light_on(pup_device_t *pdev);
168
182pbio_error_t pup_color_sensor_light_off(pup_device_t *pdev);
183
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif // _PUP_COLOR_SENSOR_H_
203
int32_t pup_color_sensor_ambient(pup_device_t *pdev)
Get the ambient light intensity.
Definition colorsensor.c:244
pbio_error_t pup_color_sensor_light_on(pup_device_t *pdev)
Set the three light brightneses of the color sensor.
Definition colorsensor.c:266
pup_color_hsv_t pup_color_sensor_hsv(pup_device_t *pdev, bool surface)
Get the color of surface or an extra source by a color sensor.
Definition colorsensor.c:195
pbio_error_t pup_color_sensor_light_off(pup_device_t *pdev)
Set the three light brightneses of the color sensor.
Definition colorsensor.c:270
pbio_color_hsv_t pup_color_hsv_t
Get the color of surface or an extra source by a color sensor.
Definition colorsensor.h:91
pup_device_t * pup_color_sensor_get_device(pbio_port_id_t port)
Get the PUP device pointer of the color sensor specified with the port ID.
Definition colorsensor.c:177
pup_color_hsv_t * pup_color_sensor_detectable_colors(int32_t size, pup_color_hsv_t *colors)
Configure colors which color sensor should detect.
Definition colorsensor.c:274
pbio_error_t pup_color_sensor_light_set(pup_device_t *pdev, int32_t bv1, int32_t bv2, int32_t bv3)
Set the three light brightneses of the color sensor.
Definition colorsensor.c:258
int32_t pup_color_sensor_reflection(pup_device_t *pdev)
Get the percentage of how much a surface reflects the light emmited by the sensor.
Definition colorsensor.c:232
Definition pup_device.c:21
Returns the raw RGB values measured by the color sensor.
Definition colorsensor.h:70