Skip to content

Add support for multiple (2) throttles #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ Constructor used to initialize and setup the Joystick. The following optional pa
- `JOYSTICK_TYPE_MULTI_AXIS` or `0x08` - Multi-axis Controller
- `uint8_t buttonCount` - Default: `32` - Indicates how many buttons will be available on the joystick.
- `uint8_t hatSwitchCount` - Default: `2` - Indicates how many hat switches will be available on the joystick. Range: `0` - `2`
- `uint8_t throttleCount` - Default: `1` - Indicates how many hat throttles will be available on the joystick. Range: `0` - `2`
- `bool includeXAxis` - Default: `true` - Indicates if the X Axis is available on the joystick.
- `bool includeYAxis` - Default: `true` - Indicates if the Y Axis is available on the joystick.
- `bool includeZAxis` - Default: `true` - Indicates if the Z Axis (in some situations this is the right X Axis) is available on the joystick.
- `bool includeRxAxis` - Default: `true` - Indicates if the X Axis Rotation (in some situations this is the right Y Axis) is available on the joystick.
- `bool includeRyAxis` - Default: `true` - Indicates if the Y Axis Rotation is available on the joystick.
- `bool includeRzAxis` - Default: `true` - Indicates if the Z Axis Rotation is available on the joystick.
- `bool includeRudder` - Default: `true` - Indicates if the Rudder is available on the joystick.
- `bool includeThrottle` - Default: `true` - Indicates if the Throttle is available on the joystick.
- `bool includeAccelerator` - Default: `true` - Indicates if the Accelerator is available on the joystick.
- `bool includeBrake` - Default: `true` - Indicates if the Brake is available on the joystick.
- `bool includeSteering` - Default: `true` - Indicates if the Steering is available on the joystick.
Expand All @@ -114,6 +114,7 @@ The following constants define the default values for the constructor parameters
- `JOYSTICK_DEFAULT_REPORT_ID` is set to `0x03`
- `JOYSTICK_DEFAULT_BUTTON_COUNT` is set to `32`
- `JOYSTICK_DEFAULT_HATSWITCH_COUNT` is set to `2`
- `JOYSTICK_DEFAULT_THROTTLE_COUNT` is set to `1`

### Joystick.begin(bool initAutoSendState)

Expand Down Expand Up @@ -183,9 +184,9 @@ Sets the Rudder value. See `setRudderRange` for the range.

Sets the range of values that will be used for the Throttle. Default: `0` to `1023`

### Joystick.setThrottle(int32_t value)
### Joystick.setThrottle(int8_t throttle, int32_t value)

Sets the Throttle value. See `setThrottleRange` for the range.
Sets the value of the specified throttle. See `setThrottleRange` for the range.

### Joystick.setAcceleratorRange(int32_t minimum, int32_t maximum)

Expand Down
4 changes: 2 additions & 2 deletions examples/ArcadeStickExample/ArcadeStickExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
8, 0, // Button Count, Hat Switch Count
8, 0, 0, // Button Count, Hat Switch Count, Throttle Count
true, true, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, false, // No rudder or throttle
false, // No rudder
false, false, false); // No accelerator, brake, or steering

void setup() {
Expand Down
7 changes: 7 additions & 0 deletions examples/DrivingControllerTest/DrivingControllerTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
false, false, false, false, false, false,
false, false, true, true, true);

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_MULTI_AXIS,
4, 0, 0, // Button Count, Hat Switch Count, Throttle Count
false, false, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, // No rudder
true, true, true); // No accelerator, brake, or steering

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
const bool testAutoSendMode = false;
Expand Down
12 changes: 7 additions & 5 deletions examples/FlightControllerTest/FlightControllerTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

#include "Joystick.h"

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 32, 0,
true, true, false, false, false, false,
true, true, false, false, false);
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_MULTI_AXIS,
32, 0, 1, // Button Count, Hat Switch Count, Throttle Count
true, true, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
true, // rudder
false, false, false); // No accelerator, brake, or steering

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
Expand Down Expand Up @@ -103,7 +105,7 @@ void testXYAxis(unsigned int currentStep)

void testThrottleRudder(unsigned int value)
{
Joystick.setThrottle(value);
Joystick.setThrottle(0, value);
Joystick.setRudder(255 - value);
}

Expand Down
14 changes: 9 additions & 5 deletions examples/FunduinoJoystickShield/FunduinoJoystickShield.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include <Joystick.h>

const uint8_t buttonCount = 7;
Joystick_ controller(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD, buttonCount,
0, true, true, false,
false, false, false,
false, false, false,
false, false);

Joystick_ controller(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
buttonCount, 0, 0, // Button Count, Hat Switch Count, Throttle Count
true, true, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, // rudder
false, false, false); // No accelerator, brake, or steering



int const BTN_A_PIN = 2;
int const BTN_B_PIN = 3;
Expand Down
4 changes: 2 additions & 2 deletions examples/GamepadExample/GamepadExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
1, 0, // Button Count, Hat Switch Count
1, 0, 0, // Button Count, Hat Switch Count, Throttle Count
true, true, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, false, // No rudder or throttle
false, // No rudder
false, false, false); // No accelerator, brake, or steering

void setup() {
Expand Down
7 changes: 7 additions & 0 deletions examples/HatSwitchTest/HatSwitchTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
false, false, false, false, false, false,
false, false, false, false, false);

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
0, JOYSTICK_DEFAULT_HATSWITCH_COUNT, 0, // Button Count, Hat Switch Count, Throttle Count
false, false, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, // No rudder
false, false, false); // No accelerator, brake, or steering

void setup() {

// Initialize Button Pins
Expand Down
8 changes: 4 additions & 4 deletions examples/MultipleJoystickTest/MultipleJoystickTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#define JOYSTICK_COUNT 4

Joystick_ Joystick[JOYSTICK_COUNT] = {
Joystick_(0x03, JOYSTICK_TYPE_JOYSTICK, 4, 2, true, true, false, false, false, false, false, false, false, false, false),
Joystick_(0x04, JOYSTICK_TYPE_JOYSTICK, 8, 1, true, true, true, true, false, false, false, false, false, false, false),
Joystick_(0x05, JOYSTICK_TYPE_JOYSTICK, 16, 0, false, true, false, true, false, false, true, true, false, false, false),
Joystick_(0x06, JOYSTICK_TYPE_JOYSTICK, 32, 1, true, true, false, true, true, false, false, false, false, false, false)
Joystick_(0x03, JOYSTICK_TYPE_JOYSTICK, 4, 2, 0, true, true, false, false, false, false, false, false, false, false),
Joystick_(0x04, JOYSTICK_TYPE_JOYSTICK, 8, 1, 0, true, true, true, true, false, false, false, false, false, false),
Joystick_(0x05, JOYSTICK_TYPE_JOYSTICK, 16, 0, 1, false, true, false, true, false, false, true, false, false, false),
Joystick_(0x06, JOYSTICK_TYPE_JOYSTICK, 32, 1, 0, true, true, false, true, true, false, false, false, false, false)
};

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
Expand Down
Loading