vex_sdk/
optical.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! V5 Optical Sensor

use core::ffi::c_double;

#[cfg(any(target_env = "v5", target_env = "exp", doc))]
use crate::{map_jump_table, V5_DeviceT};

#[repr(C)]
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
pub struct V5_DeviceOpticalRaw {
    pub clear: u16,
    pub red: u16,
    pub green: u16,
    pub blue: u16,
}

#[repr(C)]
#[derive(Default, Debug, Copy, Clone, PartialEq)]
pub struct V5_DeviceOpticalRgb {
    pub red: c_double,
    pub green: c_double,
    pub blue: c_double,
    pub brightness: c_double,
}

#[repr(C)]
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
pub struct V5_DeviceOpticalGesture {
    pub udata: u8,
    pub ddata: u8,
    pub ldata: u8,
    pub rdata: u8,
    pub gesture_type: u8,
    pub padding: u8,
    pub count: u16,
    pub time: u32,
}

#[cfg(any(target_env = "v5", target_env = "exp", doc))]
map_jump_table! {
    0x528 => pub fn vexDeviceOpticalHueGet(device: V5_DeviceT) -> c_double,
    0x52c => pub fn vexDeviceOpticalSatGet(device: V5_DeviceT) -> c_double,
    0x530 => pub fn vexDeviceOpticalBrightnessGet(device: V5_DeviceT) -> c_double,
    0x534 => pub fn vexDeviceOpticalProximityGet(device: V5_DeviceT) -> i32,
    0x538 => pub fn vexDeviceOpticalRgbGet(device: V5_DeviceT, data: *mut V5_DeviceOpticalRgb),
    0x53c => pub fn vexDeviceOpticalLedPwmSet(device: V5_DeviceT, value: i32),
    0x540 => pub fn vexDeviceOpticalLedPwmGet(device: V5_DeviceT) -> i32,
    0x544 => pub fn vexDeviceOpticalStatusGet(device: V5_DeviceT) -> u32,
    0x548 => pub fn vexDeviceOpticalRawGet(device: V5_DeviceT, data: *mut V5_DeviceOpticalRaw),
    0x550 => pub fn vexDeviceOpticalModeSet(device: V5_DeviceT, mode: u32),
    0x554 => pub fn vexDeviceOpticalModeGet(device: V5_DeviceT) -> u32,
    0x558 => pub fn vexDeviceOpticalGestureGet(device: V5_DeviceT, pData: *mut V5_DeviceOpticalGesture) -> u32,
    0x55c => pub fn vexDeviceOpticalGestureEnable(device: V5_DeviceT),
    0x560 => pub fn vexDeviceOpticalGestureDisable(device: V5_DeviceT),
    0x564 => pub fn vexDeviceOpticalProximityThreshold(device: V5_DeviceT, value: i32),
    0xb40 => pub fn vexDeviceOpticalIntegrationTimeSet(device: V5_DeviceT, timeMs: c_double),
    0xb44 => pub fn vexDeviceOpticalIntegrationTimeGet(device: V5_DeviceT) -> c_double,
}