All Projects → YukMingLaw → ArduinoJoystickWithFFBLibrary

YukMingLaw / ArduinoJoystickWithFFBLibrary

Licence: LGPL-3.0 license
An Arduino Joystick Library With Force Feedback Feature

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to ArduinoJoystickWithFFBLibrary

Nintendoextensionctrl
Arduino library for communicating with Nintendo extension controllers
Stars: ✭ 67 (-47.66%)
Mutual labels:  joystick, arduino-library
Segacontroller
Arduino library to read Sega Genesis (Mega Drive) and Master System (Mark III) controllers.
Stars: ✭ 55 (-57.03%)
Mutual labels:  joystick, arduino-library
ffbtools
Set of tools for FFB testing and debugging on GNU/Linux
Stars: ✭ 39 (-69.53%)
Mutual labels:  force-feedback
ublox
Arduino and CMake library for communicating with uBlox GPS receivers.
Stars: ✭ 89 (-30.47%)
Mutual labels:  arduino-library
DHT12 sensor library
DHT12 complete library (Original DHT clone library with same command and some addiction). I2c and OneWire support, connection schema of Arduino UNO, esp32 and esp8266 with examples.
Stars: ✭ 22 (-82.81%)
Mutual labels:  arduino-library
Adafruit DAP
port of free-DAP to standalone arduino
Stars: ✭ 63 (-50.78%)
Mutual labels:  arduino-library
PSPi-1000-Version-4
https://othermod.com/pspi-1000-version-4/
Stars: ✭ 39 (-69.53%)
Mutual labels:  joystick
DL1414
Arduino Library for DL1414 type 4 character miniature screen modules.
Stars: ✭ 14 (-89.06%)
Mutual labels:  arduino-library
Adafruit SSD1305
OLEDs with SSD1305
Stars: ✭ 20 (-84.37%)
Mutual labels:  arduino-library
Seeed Arduino AS5600
The library comes with AS5600. Through this library, we can realize read the angles 、get magnetic from a magnet underneath the sensor.
Stars: ✭ 59 (-53.91%)
Mutual labels:  arduino-library
bme280
Arduino and CMake library for communicating with the Bosch Sensortec BME280 environmental sensor.
Stars: ✭ 21 (-83.59%)
Mutual labels:  arduino-library
BME680
Arduino Library to access the Bosch BME680 - temperature, pressure, humidity and gas sensor
Stars: ✭ 30 (-76.56%)
Mutual labels:  arduino-library
Arduino-Log
Simple application log library. supporting multiple log levels, custom output & flash memory support.
Stars: ✭ 132 (+3.13%)
Mutual labels:  arduino-library
Seeed Arduino FreeRTOS
This library gives an example of how to get FreeRTOS running on Seeed production. The project can be used as a template to build your projects off of as well.
Stars: ✭ 27 (-78.91%)
Mutual labels:  arduino-library
FastPID
A fast, integer based PID controller suitable for Arduino.
Stars: ✭ 112 (-12.5%)
Mutual labels:  arduino-library
NvTx
Transactional non volatile storage for Arduino
Stars: ✭ 17 (-86.72%)
Mutual labels:  arduino-library
T-BOTS
Software for controlling and analysing T-Bots (Balancing robots)
Stars: ✭ 21 (-83.59%)
Mutual labels:  arduino-library
MyDemos
💾 Demo 集合 . 黑发不知勤学早,白首方悔读书迟.
Stars: ✭ 64 (-50%)
Mutual labels:  joystick
ADS1115 WE
An Arduino library for the 16-bit, 4 channel ADS1115 ADC. Convenient to use. All features of the ADS1115 are implemented, including alert functions.
Stars: ✭ 39 (-69.53%)
Mutual labels:  arduino-library
OMJoystick
This is the JoyStick UI library for SwiftUI.
Stars: ✭ 15 (-88.28%)
Mutual labels:  joystick

Arduino Joystick With Force Feedback Library

Statement

This is a joy library for Atmega32UX chip with force feedback, which can be used to make game handle with vibration, game steering wheel with force feedback, etc.Multi-axis-force-feedback feature is added.

Usage

0. example:examples/JoystickWithFFB/JoystickWithFFB.ino

1. create JoyStick object

params describe
REPORT_ID Hid report id
JOYSTICK_TYPE Type of devece:JOYSTICK,GAMEPAD,MULTI_AXIS
button count [0-32]
Hat Switch count [0,1,2]
X Axis enable True or False
Y Axis enable True or False
Z Axis enable True or False
Rx Axis enable True or False
Ry Axis enable True or False
Rz Axis enable True or False
Rudder enable True or False
Throttle enable True or False
Accelerator enable True or False
Brake enable True or False
Steering enable True or False

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,8, 0,false, true,true,false, false, false,false, false,false, false, false);

2. After the object is created, the x-axis and y-axis are bound as the force feedback axis by default.The gains of various forces effect are set through the struct and the interface as following:

//struct of gains
struct Gains{
    uint8_t totalGain         = FORCE_FEEDBACK_MAXGAIN;
	uint8_t constantGain      = FORCE_FEEDBACK_MAXGAIN;
	uint8_t rampGain          = FORCE_FEEDBACK_MAXGAIN;
	uint8_t squareGain        = FORCE_FEEDBACK_MAXGAIN;
	uint8_t sineGain          = FORCE_FEEDBACK_MAXGAIN;
	uint8_t triangleGain      = FORCE_FEEDBACK_MAXGAIN;
	uint8_t sawtoothdownGain  = FORCE_FEEDBACK_MAXGAIN;
	uint8_t sawtoothupGain    = FORCE_FEEDBACK_MAXGAIN;
	uint8_t springGain        = FORCE_FEEDBACK_MAXGAIN;
	uint8_t damperGain        = FORCE_FEEDBACK_MAXGAIN;
	uint8_t inertiaGain       = FORCE_FEEDBACK_MAXGAIN;
	uint8_t frictionGain      = FORCE_FEEDBACK_MAXGAIN;
	uint8_t customGain        = FORCE_FEEDBACK_MAXGAIN;
};
/* set gains interface func
 * param:a <Gains> array of length 2;
 *       _gains[0]-->X_Axis_gains;
 *       _gains[1]-->Y_Axis_gains;
 * return 0 :set gains successful
 *        -1:set gains failed
*/
int8_t setGains(Gains* _gains);

example code

#include "Joystick.h"

Joystick_ Joystick();

Gains mygains[2];

//set X Axis gains
mygains[0].totalGain = 50;
mygains[0].springGain = 80;

//set Y Axis gains
mygains[1].totalGain = 50;
mygains[1].springGain = 70;

void setup{
    //enable gains REQUIRED
    Joystick.setGains(mygains);
}

3.Set the parameters of spring effect, damper effect, inertia effect and friction effect through the struct and the interface as following:

//struct of Effect Params
struct EffectParams{
    //If you need to use the spring effect, set the following parameters.`Position` is the current position of the force feedback axis. 
    //For example, connect the encoder with the action axis,the current encoder value is `Positon` and the max encoder value is `MaxPosition`.
    int32_t springMaxPosition = 0;
    int32_t springPosition = 0;

    //If you need to use the damper effect, set the following parameters.`Velocity` is the current velocity of the force feedback axis.
    int32_t damperMaxVelocity = 0;
    int32_t damperVelocity = 0;

    //If you need to use the inertia effect, set the following parameters.`Acceleration` is the current acceleration of the force feedback axis.
    int32_t inertiaMaxAcceleration = 0;
    int32_t inertiaAcceleration = 0;
    
    //If you need to use the friction effect, set the following parameters.`PositionChange` is the position difference of the force feedback axis.
    int32_t frictionMaxPositionChange = 0;
    int32_t frictionPositionChange = 0;
};

/* set effect params interface func
 * param:a <EffectParams> array of length 2;
 *       _effect_params[0]-->X_Axis_params;
 *       _effect_params[1]-->Y_Axis_params;
 *
 * return 0 :set Effect Params successful
 *        -1:set Effect Params failed
*/
int8_t setEffectParams(EffectParams* _effect_params);

example code

#include "Joystick.h"

Joystick_ Joystick();

Gains mygains[2];
EffectParams myeffectparams[2];

//set X Axis gains
mygains[0].totalGain = 50;
mygains[0].springGain = 80;

//set Y Axis gains
mygains[1].totalGain = 50;
mygains[1].springGain = 70;

void setup(){
    //enable gains REQUIRED
    Joystick.setGains(mygains);
}

void loop(){
  //set X Axis Spring Effect Param
  myeffectparams[0].springMaxPosition = 1023;
  myeffectparams[0].springPosition = analogRead(A2);
  
  //set Y Axis Spring Effect Param
  myeffectparams[1].springMaxPosition = 1023;
  myeffectparams[1].springPosition = analogRead(A3);
  
  Joystick.setEffectParams(myeffectparams);
  Joystick.getForce(forces);
}

4.Finally,get the force value with

JoyStick.getForce(int32_t* forces)

params int32_t* forces is an int32 array of length 2

forces[0] is the X-Axis force data

forces[1] is the Y-Axis force data

return type void

range[-255,255]

Pay Attention!

Joystick.setGains(mygains) and Joystick.setEffectParams(myeffectparams) must be invoked before JoyStick.getForce(int32_t* forces)

Ref

This library is based on Heironimus and hoantv 's work,very grateful for their work.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].