Skip to content

Commit

Permalink
h-shifter, ffb axis, startup diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
ranenbg committed Apr 26, 2024
1 parent 409b544 commit c8100e1
Show file tree
Hide file tree
Showing 15 changed files with 543 additions and 192 deletions.
17 changes: 17 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="17" />
<application android:label=""
android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
7 changes: 4 additions & 3 deletions Button_class.pde
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ class Button {
if (showInfo) {
pushMatrix();
if (dp == 0) {
translate(x, y-1.2*sy); // put description above
translate(x, y-1.15*sy); // put description above
} else if (dp == 1) {
translate(x, y+1.2*sy); // put description bellow
translate(x, y+1.15*sy); // put description bellow
} else if (dp == 2) {
translate(x-textWidth(d)-font_size, y); // put description to the left side
} else if (dp == 3) {
translate(x+sx+10, y); // put description to the right side
translate(x+sx, y); // put description to the right side
} else {
}
noFill();
rect(0, 0, textWidth(d)+font_size, sy);
Expand Down
30 changes: 12 additions & 18 deletions FFBgraph_class.pde
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
class FFBgraph {
float x;
float y;
int gh;
float x, y;
int ps;
int[] pointY = new int [gbuffer];
float gwidthX, sclX, sclY;
float gwidthX, gh, sclX, sclY;

FFBgraph(float posx, float posy, int gheight, int pointsize) {
x = posx;
y = posy;
gh = gheight;
FFBgraph(float posx, float posy, float gheight, int pointsize) {
x = posx - 1;
y = posy - 1;
gh = gheight - 1;
ps = pointsize;
gwidthX = gbuffer/gskip;
gwidthX = gbuffer / gskip;
sclX = gwidthX / gbuffer;
sclY = float(gh) / (2*maxTorque);
sclY = gh / (2*maxTorque);
}

void update(String val1) {
Expand All @@ -38,16 +36,12 @@ class FFBgraph {
pushMatrix();
translate(-9, gh);
int l = 32;
float n = (gh+1)/l;
float n = gh/l;
float m = n/5;
for (int i = 0; i >= -l; i--) {
for (int j = 0; j > -5; j--) {
if (i > -l) {
line(0, i*n, 9, i*n); // small ticks
line(4, j*m + i*n, 9, j*m + i*n); // major ticks
} else {
line(0, (i*n)+1, 9, (i*n)+1);
}
line(0, n*i, 9, n*i); // major ticks
if (i > -l) line(4, m*j + n*i, 9, m*j + n*i); // small ticks (do not draw them after last major tick)
}
}
popMatrix();
Expand All @@ -62,7 +56,7 @@ class FFBgraph {
//stroke(32, 255, 255);
strokeWeight(ps);
stroke(map(abs(pointY[i]), 0, maxTorque, 145, 0), 255, 255);
line(1+i*sclX, gh/2-sclY*pointY[i], 1+(i+1)*sclX, gh/2-sclY*pointY[i+1]);
line(sclX*i+1, gh/2-sclY*pointY[i], sclX*(i+1)+1, gh/2-sclY*pointY[i+1]);
}
popMatrix();
}
Expand Down
47 changes: 38 additions & 9 deletions Profile_class.pde
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,49 @@ class Profile {
this.fromContents();
}
void storeToFile(String fn) {
String tempName = "";
if (name == "default") {
showMessageDialog(frame, "Can not be modifyed.\nSelect another profile.");
String tempStr = "";
int tempOpt = -1;
if (this.name.equals("default")) {
showMessageDialog(frame, "Can not be modified.\nSelect another profile.");
} else {
tempName = showInputDialog("Profile name", name);
if (tempName != null) {
name = tempName;
tempStr = showInputDialog("Save profile name as?", this.name);
if (tempStr != null) {
this.name = tempStr;
cp5.get(ScrollableList.class, "profile").setItems(ProfileNameList());
upload();
saveStrings("/data/"+fn+".txt", contents);
println(name, "saved in "+fn+".txt");
if (nameExists(name)) { // if this profile name arleady exists
showConfirmDialog(frame, "Name already exists.\nOverwrite?");
}
if (tempOpt == -1 || tempOpt == 0) {
upload();
saveStrings("/data/"+fn+".txt", contents);
println(this.name, "saved as "+fn+".txt");
}
}
}
}
String getPrfParm(int iProfile, int iParm) { // retrieve certain parameter from a given profile
String profileContents[] = new String[num_profiles];
profileContents = loadStrings("profile"+str(iProfile)+".txt");
if (profileContents == null) {
return null;
} else {
return profileContents[iParm];
}
}
boolean nameExists(String cName) { // returns true if profile with this name already exists
String pName;
boolean c = false;
for (int i=1; i<num_profiles; i++) { // look through all found profiles
File p = new File(dataPath("profile"+str(i)+".txt"));
if (p.exists()) {
pName = getPrfParm(i, 0);
if (pName.equals(cName)) {
c = true;
}
}
}
return c;
}
boolean exists(int i) {
boolean r = false;
File p = new File(dataPath("profile"+str(i)+".txt"));
Expand Down
27 changes: 24 additions & 3 deletions Slajder_class.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class Slajder {
float x, y, s, am, axisVal;
String l, la, lb;
xyCal[] yLimits = new xyCal[2];
boolean yLimitsVisible;
boolean yLimitsVisible, ffb;
float[] pCal = new float[2];
int id;

Slajder(color acolor, float posx, float posy, float size, float axisMax, String label, String labela, String labelb) {
Slajder(color acolor, float posx, float posy, float size, float axisMax, String label, String labela, String labelb, boolean ffbaxis) {
c = acolor;
x = posx;
y = posy;
Expand All @@ -16,6 +16,7 @@ class Slajder {
l = label;
la = labela;
lb = labelb;
ffb = ffbaxis;
yLimits[0] = new xyCal(x-2.8*s, y, s, s, 3, la);
yLimits[1] = new xyCal(x-2.8*s, y-2*axisScale, s, s, 3, lb);
yLimits[0].active = true;
Expand All @@ -40,6 +41,12 @@ class Slajder {
} else {
axisVal = 0.0;
}
// update axis view with FFB marking
if (FFBAxisIndex == i) {
ffb = true; // axis with FFB mark
} else {
ffb = false; // axis without FFB mark
}
setpCal();
id = i;
}
Expand Down Expand Up @@ -115,7 +122,21 @@ class Slajder {
line(0, -20*n, 10, -20*n);
fill(255);
text(round(map(axisVal, -1, 1, 0, am)), 0, -(2*n+1)*10);
text(l, 0, 20);
if (ffb) {
noFill();
//stroke(c);
rect(15, 14, 18, -10);
textSize(0.8*font_size);
//fill(c);
text("FFB", 15, 13);
}
fill(255);
textSize(font_size);
if (id < 3) {
text(l, -2, 20);
} else {
text(l, -font_size/2, 20);
}
popMatrix();
if (yLimitsVisible) {
for (int j=0; j<yLimits.length; j++) {
Expand Down
4 changes: 2 additions & 2 deletions XYshifter.pde
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ class XYshifter {
noStroke();
translate(x, y+dy);
fill(51);
rect(-0.1*dx, 0.1*dy, dx*1.2, -dy*1.2); // shifter background
rect(-0.025*dx, 0.07*dy, dx*1.15, -dy*1.18); // shifter background
stroke(255);
strokeWeight(1);
noFill();
rect(0, 0, dx, -dy); // shifter zone
fill(255);
String sName = "XY shifter";
String sName = "Analog XY H-shifter";
text(sName, dx-textWidth(sName), font_size);
noStroke();
fill(32, 255, 255);
Expand Down
2 changes: 1 addition & 1 deletion data/COM_cfg.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
COM5
COM5
Binary file modified data/Wheel_control_step0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/Wheel_control_v2_5_1.png
Binary file not shown.
Binary file added data/Wheel_control_v2_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions data/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Milos Rankovic, ranenbg@gmail.com
created 09.04.2024
last updated 17.04.2024.

GUI change log from v2.5.1 to v2.6.0

- added support for new firmware version and its options (v230, option "x")
- added dropdown list for selecting which axis is tied to the FFB axis (allows analog axis for FFB, opt "x")
- added advanced H-shifter option buttons (X,Y-axis invert, reverse gear button invert, only from v230f)
- when other than X-axis are selected for FFB, animated sprite wheel angle is updated according to selected axis
- improved handling of firmware options readout
- improved handling of FFB monitor (if left running - auto stop on next startup)
- added more startup info in the bottom of window (added complete firmware options readout)
- minor H-shifter graphical updates and fixes
- fixed a small bug where desktop user effects were not updated correctly at startup
- minor change of some button names and/or descriptions (shifter, pedal calibration, save, store)
- show arduino HEX firmware version in window info
- improved handling of how a profile is stored (overwrite check added)
- axis max value gets updated according to the firmware features (default 1023, ads1105 4095, hx711 65535)
- FFB effect sliders values now show 100% instead of 1.0%
13 changes: 8 additions & 5 deletions data/manual.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Milos Rankovic
ranenbg@gmail.com
23.12.2022.
wheel control v2.5.1 - compatible with Arduino HEX versions fw-v220 (backward compatible with v170, v180, v190, v200 and v210)
14.04.2024.
wheel control v2.6.0 - compatible with Arduino HEX versions fw-v230 (backward compatible with v170, v180, v190, v200, v210 and v220)

About:
Wheel control GUI is made in windows programming environment called Processing v3.5.4, which is based on Java. It opperartes by directly reading HID values from Arduino such as axis and buttons. It uses RS232 or virtual serial port to send many settings that you may like to adjust (check firmware_info.txt for more details). The settings can be stored in Arduino EEPROM, such that they will be saved and automatically loaded at every powerup. Arduino firmware and GUI are developed and tested in Win10.
Wheel control GUI is made in windows programming environment called Processing v3.5.4, which is based on Java. It opperartes by directly reading HID values from Arduino such as axis and buttons. It uses RS232 or virtual serial port to send many settings that you may like to adjust (check firmware_info.txt for more details). The settings can be stored in Arduino EEPROM, such that they will be saved and automatically loaded at every powerup. Arduino firmware and GUI are developed and tested in Win7/10/11.
You can use Arduino Leonardo, Arduino Micro or Arduino Pro Micro boards. They need to have a correct bootloader. You can verify by pressing restart button, if the Arduino enters bootloader mode for about 8sec it is ok, LED will slowly blink during this time. If it instantly restarts you will need to upload bootloader. Complete description of that procedure is outside of the scope of this manual (https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoISP).

How to start wheel control:
Expand All @@ -23,7 +23,7 @@ How to use wheel control:
[3] select PWM type (phase correct is recommended, but you can use fast top for twice higher frequency at the same resolution)
[4] select PWM mode (pwm+-, pwm+dir, pwm0.50.100-use or rcm)
[5] select PWM frequency (check firmware_info.txt for more details)
[6] press pwm button and close wheel control, restart or replug Arduino to apply new PWM settings, start wheel control
[6] press pwm button and close wheel control, restart or replug Arduino to apply new PWM settings, start wheel control again

The utility supports user effects or sometimes called desktop effects. These are "allways on" effects that will be added to any other FFB effects which other games or application may send. You may enable certain desktop effects like spring, damper, inertia or friction by pressing a square button next to the corresponding slider. These effects may be usefull for DD wheels, to simulate some liveliness of AC motor like moment of inertia (inertia gain), autocentering (spring gain) or friction (friction gain).
Use overall gain to set the master volume or gain for all FFB effects. You may use min PWM slider to compensate for startup current and system friction when using other motor types than AC servo motors. It is very usefull for DC brushed motors especially.
Expand All @@ -37,7 +37,7 @@ The axis colors are stored in a axisColor.txt file in a HEX format. This file wi
https://www.rapidtables.com/convert/color/rgb-to-hex.html

XY analog shifter setup:
This version of wheel control allows you to setup an analog shifter. The shifter supports 8 gears + reverse, while you can edit its calibration limits by pressing "shifter" button. There are 5 pointers (sliders) which you can move with mouse by dragging. Make sure to release mouse left button while the cursor is still inside the pointer in order for change to take place. Once happy, you can click "save" button to store shifter calibration to Arduino (save values in EEPROM). There is an additional button that allows you to configure where a reverse gear will be. If the small button is red (not activated) the shifter is configured to 6 gears + reverse, while if the button is green (activated) then the reverse is in 8th gear. To activate reverse gear you need to press button0 (by default it's at Arduino pin D4, but may be elsewhere depending on firmware version and options).
This version of wheel control allows you to setup an analog shifter. The shifter supports 8 gears + reverse, while you can edit its calibration limits by pressing "shifter" button. There are 5 pointers (sliders) which you can move with mouse by dragging. Make sure to release mouse left button while the cursor is still inside the pointer in order for change to take place. Once happy, you can click "save" button to store shifter calibration to Arduino (save values in EEPROM). There is an additional button that allows you to configure where a reverse gear will be. If the small button is red (not activated) the shifter is configured to 6 gears + reverse, while if the button is green (activated) then the reverse is in 8th gear. To activate reverse gear you need to press button0 (by default it's at Arduino pin D4, but may be elsewhere depending on firmware version and options). You can use additional shifter options (available only from fw-v230f), to invert shifter X or Y axis or invert the reverse gear button (logitech h-shifter support).

Manual pedal axis calibration
In this version you can manual set pedal axis calibration limits and save them into Arduino EEPROM. The calibration values are automatically loaded at each powerup of Arduino. Each time you start wheel control it will ask Arduino for latest calibration values and update the sliders accordingly. In order to set calibration limits first press "manual cal" button to unhide the calibration sliders. Move sliders to ther lowest (0) and maximum (4095) positions if they are not already there. Now press each pedal to its full range and set its corresponding maximum slider to a value slightly below the pedal axis value. Once done, now move back each pedal into ther lowest position and set the minimim slider to a value slightly above the pedal axis value. Pedal axis values should show a full range 0-4095 if done correctly. Once happy with your pedal travel and calibration limits you can press "save" button.
Expand All @@ -48,6 +48,9 @@ Some RC servos and other brushless motor drivers require a special pwm mode for
Using encoder Z-index
If you encoder has a 3rd channel called Z-index you can use HEX firmware with "z" option to automatically set the zero angle. This version of wheel control in combination with HEX v22Xz (X-0,1,2,3) allows you to reset the Z-index offset in the firmware and set a new one. After firmware upload and first start of wheel control you can re-align your wheel to a desired zero deg position and press center button, then press save button to remember the settings in Arduino memory. If you are not happy with the centering and wish to do it again, you have to press the z button first and repeat the above described process.

Using FFB axis selector
You can now select which axis is tied to FFB with a dropdown list selector. If you select any other axis than X (encoder axis), then you can utilize analog axis as FFB input. This means that all internal and user FFB effects will also work in addition to the FFB effects that the game is sending. In that case you have to consider the rotation angle as this will depend on the sensor you use. Potentiometers normaly have about 270-300deg range, while some can have more than 1 turn as well. If you use a hall sensor, then cosider the mechanics which determine final angular range for your axis. This is only visual, it doesn't change anything, because axis range is anyway in arbitrary units as seen by the game or windows. You can set CPR to configure how much axis range you can utilize. Normaly CPR of 1000 and 300deg rotation is fine for analog axis on a potentiometer. Bare in mind that manual or automatic calibration ranges for pedals (analog) axis will also have their effect on the final resolution of you input steering axis for FFB.

Hopefully everything else will be self explanatory, enjoy :)
rane.

Expand Down
72 changes: 36 additions & 36 deletions data/processing_3_5_4_status_log.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
=======================================================
Arduino Leonardo FFB user interface
wheel control v2.5 created by Milos Rankovic
=======================================================
GameControlPlus V1.2.2 created by
Christian Riekoff and Peter Lager
=======================================================
Instance: org.gamecontrolplus.ControlIO@6e6606a9
##########################################################################################
Game Control Plus - available devices
--------------------------------------
0 Mouse [Mouse] on [Unknown]
1 Keyboard [Keyboard] on [Unknown]
2 G203 LIGHTSYNC Gaming Mouse [Unknown] on [Unknown]
3 G203 LIGHTSYNC Gaming Mouse [Unknown] on [Unknown]
4 G203 LIGHTSYNC Gaming Mouse [Unknown] on [Unknown]
5 G203 LIGHTSYNC Gaming Mouse [Unknown] on [Unknown]
6 Lenovo USB Keyboard [Unknown] on [Unknown]
7 Lenovo USB Keyboard [Unknown] on [Unknown]
8 Arduino Leonardo [Stick] on [Unknown]
##########################################################################################
Device: Arduino Leonardo
COM: loaded from txt
axis colors: loaded from txt
=======================================================
G4P V4.3.8 created by Peter Lager
=======================================================
Wheel parameters:
1080.0 1.0 0.5 0.5 1.0 1.0 1.0 0.5 0.7 1.0 0.0 45.0 1 10000 4000 33; 2ms
WB:V, RB:fw-v222zh; 1ms
WB:V, RB:fw-v222zh; 10ms
WB:YR, RB:0 4095 0 4095 0 4095 0 4095; 21ms
WB:V, RB:fw-v222zh; 10ms
ControlP5 2.2.6 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
profile1.txt found
=======================================================
Arduino Leonardo FFB user interface
wheel control v2.6.0 created by Milos Rankovic
=======================================================
GameControlPlus V1.2.2 created by
Christian Riekoff and Peter Lager
=======================================================
Failed to initialize device ELAN Miniport PTP Driver because of: java.io.IOException: Failed to acquire device (8007001e)
Instance: org.gamecontrolplus.ControlIO@20da7359
##########################################################################################
Game Control Plus - available devices
--------------------------------------
0 Mouse [Mouse] on [Unknown]
1 Keyboard [Keyboard] on [Unknown]
2 Arduino Leonardo [Stick] on [Unknown]
##########################################################################################

Device: Arduino Leonardo
COM: loaded from txt
axis colors: loaded from txt
=======================================================
G4P V4.3.9 created by Peter Lager
=======================================================
Arduino FFB Wheel detected
1080.0 1.0 0.5 0.5 1.0 1.0 1.0 0.5 0.7 1.0 0.0 128.0 65 10000 1000 33; 12ms
Reading firmware version
WB:V, RB:fw-v230zxm; 15ms
Manual pcal detected
Encoder Z-index detected
ProMicro pinouts detected
Analog axis for FFB detected
WB:YR, RB:0 4095 0 4095 0 4095 0 4095; 16ms
WB:V, RB:fw-v230zxm; 18ms
ControlP5 2.2.6 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
profile1.txt found
profile2.txt found
Loading

0 comments on commit c8100e1

Please sign in to comment.