void setup() {
feelix.init();
}
void loop() {
/* these functions need to update at a high frequency */
/* read angle, velocity, direction and time */
feelix.run();
/* get the values based on current angle */
/* void playHapticEffectAtAngle(FeelixEffect, float angle (in degrees))
feelix.playHapticEffectAtAngle(bump, 180);
/* write value to motors */
feelix.move_feelix();
}
Play an exported velocity effect
void setup() {
feelix.init();
delay(1000);
velocity_effect.start(); // start the effect
}
void loop() {
/* these functions need to update at a high frequency */
/* read angle, velocity, direction and time */
feelix.run();
/* get the values based on current time*/
feelix.playVelocityEffect(velocity_effect);
/* write value to motors */
feelix.move_feelix();
}
Access variables motor
The feelix.run() updates the following variables that can be accessed in the code:
The current angle of the motor in radians (float)
feelix.angle
The velocity of the motor in rad/s (float)
feelix.velocity
The time since the program started is saved in (long) current_time, the time can be reset when the (long) start_time variable is set to millis()
feelix.current_time
feelix.start_time = millis();
Get the direction in which the motor is rotating, clockwise (1) and counterclockwise (-1).
feelix.rotation_dir
Change sensor direction opposed to motor direction
/* variable will be true when enabled, false when disabled */
effect.enabled
Start velocity effect
effect.start();
Stop velocity effect
effect.stop();
Change scale
scale.x changes the angle (position/torque effects) or the duration (velocity), and scale.y changes the intensity (voltage %), velocity (velocity %), or degrees. Depending on the type of effect (torque, position, velocity over time, or angle over time)
effect.scale.x = 1.5; /* default is 1.0 */
effect.scale.y = 0.5; /* default is 1.0 */
Loop velocity effect
effect.infinite = true; /* default is false */
Repeat a haptic effect every rotation
feelix.range = 360 /* repeat effect every 360 degrees (default) */
effect.infinite = true; /* default is false */
Disable effect in clockwise direction or counterclockwise direction (haptic only)
effect.direction.cw = false; /* default is true */
effect.direction.ccw = false; /* default is true */