Skip to main content

Crate gtec

Crate gtec 

Source
Expand description

§gtec

Rust library and terminal UI for the g.tec Unicorn Hybrid Black 8-channel EEG headset via the Unicorn C API, loaded at runtime.

§Cross-platform

Works on Windows and Linux (x86_64). The Unicorn.dll / libunicorn.so shared library is loaded at runtime via libloading — no build-time C dependencies.

§Quick start

use gtec::prelude::*;

let serials = UnicornDevice::scan(true)?;
let mut device = UnicornDevice::open(&serials[0])?;

println!("Info: {:?}", device.device_info()?);

let scans = device.capture(UNICORN_SAMPLING_RATE * 4)?;
for s in &scans[..5] {
    println!("EEG: {:?}", s.eeg());
}

§Using as a library

[dependencies]
gtec = "0.0.1"
gtec = { version = "0.0.1", default-features = false }

§Module overview

ModulePurpose
ffiRuntime-loaded Unicorn C API for Hybrid Black (16/16 functions)
ffi_bleRuntime-loaded libgtecble BLE API for BCI Core-8 (9/9 functions)
[ble]Pure-Rust BLE backend for BCI Core-8 via btleplug (all OS, no native lib)
types#[repr(C)] types matching unicorn.h
protocolPure-Rust BT protocol (Hybrid Black, no native lib needed)
deviceHigh-level device API
verifySHA-256 integrity verification
sandboxOS-level network sandboxing
errorError types
preludeConvenience re-exports

Modules§

device
High-level device abstraction for the Unicorn Hybrid Black.
error
Error types for the g.tec Unicorn API wrapper.
ffi
Runtime-loaded FFI bindings to the Unicorn C API.
ffi_ble
Runtime-loaded FFI bindings to the libgtecble BLE library.
prelude
Convenience re-exports.
protocol
Unicorn Hybrid Black Bluetooth protocol implementation.
sandbox
Process-level network sandboxing (same as brainbit-rs).
types
FFI types matching unicorn.h from the Unicorn C API.
verify
SHA-256 integrity verification for the Unicorn native library.