Hapticlabs
#Description
A toolkit that allows you to test detailed, haptic feedback.
Requires the Hapticlabs toolkit. Find out more about it here.
This component requires 2 pins.
#Links
#Functions
#Toolkit
This component works with the Hapticlabs Toolkit. Find out more about it here.
#JavaScript / Node.js
Hapticlabs dual-channel haptic feedback controller. Controls two digital output pins for haptic actuators.
#Value type
interface HapticlabsValue {
pin1: number; // 0 = inactive, 1 = active
pin2: number; // 0 = inactive, 1 = active
}#Constructor options
| Option | Type | Required | Description |
|---|---|---|---|
pin1 | number | required | — |
pin2 | number | required | — |
#Events
| Event | Parameters | Description |
|---|---|---|
change | value: HapticlabsValue | — |
#Methods
get value→ HapticlabsValue | undefinedfrom ComponentBaseGet the current value of the component.
#Example
import { Board, Hapticlabs } from "@blokdots/components";
const board = new Board("/dev/ttyACM0");
await board.open();
const hapticlabs = new Hapticlabs({ board, pin1: "D5", pin2: "D5" });#C++ (Arduino)
Dual-channel haptic feedback controller Controls two digital output pins for haptic actuators Features: - Two independent haptic tracks (Track 1 and Track 2) - Simple HIGH/LOW control for haptic actuators - Non-blocking timed triggering with automatic shutoff - Continuous triggering with duration control Usage: - playTrack1() / playTrack2() - Activate track - stopTrack1() / stopTrack2() - Deactivate track - triggerTrack1(durationMs) - Trigger for specific duration (non-blocking) - triggerTrack2(durationMs) - Trigger for specific duration (non-blocking) - isTrack1Active() / isTrack2Active() - Check state
#Setup
#include "blokdots.h"
Hapticlabs myComponent(0, 0);#Constructor
Hapticlabs(pin1, pin2)Basic constructor (no EventBus)
| Parameter | Type | Default |
|---|---|---|
pin1 | uint8_t | required |
pin2 | uint8_t | required |
Hapticlabs(bus, pin1, pin2, evtChange)Constructor with EventBus for trigger support
| Parameter | Type | Default |
|---|---|---|
bus | EventBus | required |
pin1 | uint8_t | required |
pin2 | uint8_t | required |
evtChange | uint8_t | required |
#Methods
playTrack1()stopTrack1()triggerTrack1(durationMs)Non-blocking trigger with automatic shutoff
| Parameter | Type | Default |
|---|---|---|
durationMs | uint32_t | required |
isTrack1Active()→ boolplayTrack2()stopTrack2()triggerTrack2(durationMs)Non-blocking trigger with automatic shutoff
| Parameter | Type | Default |
|---|---|---|
durationMs | uint32_t | required |
isTrack2Active()→ boolstopAll()emittedValue()→ intFor triggers: returns bitmask (bit 0 = track1, bit 1 = track2)