SPIKE-RT C API Reference [English]
An RTOS-based software platform for LEGO® Education SPIKE™.
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#include <stdint.h>
37#include <spike/pup_device.h>
38#include <pbio/color.h>
39
53pup_device_t *pup_color_sensor_get_device(pbio_port_id_t port);
54
66typedef struct {
67 uint16_t r, g, b;
69pup_color_rgb_t pup_color_sensor_rgb(pup_device_t *pdev);
70
87typedef pbio_color_hsv_t pup_color_hsv_t;
88pup_color_hsv_t pup_color_sensor_color(pup_device_t *pdev, bool surface);
89
107
120
133
147pbio_error_t pup_color_sensor_light_set(pup_device_t *pdev,
148 int32_t bv1, int32_t bv2, int32_t bv3);
149
163pbio_error_t pup_color_sensor_light_on(pup_device_t *pdev);
164
178pbio_error_t pup_color_sensor_light_off(pup_device_t *pdev);
179
193
194#endif // _PUP_COLOR_SENSOR_H_
195
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:87
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:66