Skip to content

Commit

Permalink
Dev-build
Browse files Browse the repository at this point in the history
1. Add Led support to Gilphilbert 1.2 control board
2. Rudder overflow bug fix, change the travel back to 5%-95%.
3. UI improvement, Rudder text log animaiton improvement
4. Profile change now with effect status, please choose what effect bind in the profile tab then click bind button to bind profile
  • Loading branch information
tcfshcrw committed Oct 20, 2024
1 parent 4d05f43 commit 26b386b
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 60 deletions.
1 change: 1 addition & 0 deletions ESP32/include/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static const int16_t JOYSTICK_RANGE = JOYSTICK_MAX_VALUE - JOYSTICK_MIN_VALUE;


void SetupController();
void SetupController_USB(uint8_t pedal_ID);
bool IsControllerReady();

void SetControllerOutputValue(int32_t value);
Expand Down
42 changes: 25 additions & 17 deletions ESP32/include/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,41 +323,43 @@ static const uint32_t STEPS_PER_MOTOR_REVOLUTION = 6400;
#define ESPNow_Pairing_function
#define Pairing_GPIO 0
//#define ESPNow_debug_rudder
#define USING_LED
#define LED_GPIO 12
#endif

#if PCB_VERSION == 8
// ADC defines
#define PIN_DRDY 4//19// 19 --> DRDY
#define PIN_DRDY 15//19// 19 --> DRDY
#define PIN_RST 6 // X --> X
#define PIN_SCK 1//16 // 16 -->SCLK
#define PIN_MISO 3 // 18 --> DOUT
#define PIN_MOSI 2 // 17 --> DIN
#define PIN_CS 5//21 // 21 --> CS
#define PIN_SCK 16//16 // 16 -->SCLK
#define PIN_MISO 18 // 18 --> DOUT
#define PIN_MOSI 17 // 17 --> DIN
#define PIN_CS 7//21 // 21 --> CS

// stepper pins
#define dirPinStepper 6//22
#define stepPinStepper 7//23
#define dirPinStepper 37//22
#define stepPinStepper 38//23

//analog output pin
//#define D_O 25
//MCP4725 SDA SCL
//#define MCP_SDA 5
//#define MCP_SCL 4
#define MCP_SDA 5
#define MCP_SCL 4

// endstop pins
#define minPin 8
#define maxPin 9
#define minPin 12
#define maxPin 13
// Pedal assignment pin
#define PEDAL_ASSIGNMENT
#define CFG1 10
#define CFG2 11
#define CFG1 1
#define CFG2 2

//#define EMERGENCY_BUTTON
//#define ShutdownPin 6
#define EMERGENCY_BUTTON
#define ShutdownPin 6
// level shifter is present on this PCB design
#define SENSORLESS_HOMING true
#define ISV57_TXPIN 12//27 //17
#define ISV57_RXPIN 13//26 // 16
#define ISV57_TXPIN 10//27 //17
#define ISV57_RXPIN 9//26 // 16

//#define Using_analog_output_ESP32_S3
#define ESPNOW_Enable
Expand All @@ -366,4 +368,10 @@ static const uint32_t STEPS_PER_MOTOR_REVOLUTION = 6400;
#define USB_JOYSTICK

#define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 5
#define ESPNow_Pairing_function
#define Pairing_GPIO 0
//#define ESPNow_debug_rudder
#define CONTROLLER_SPECIFIC_VIDPID
#define USING_LED
#define LED_GPIO 12
#endif
21 changes: 13 additions & 8 deletions ESP32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,33 @@ lib_deps =
${common.lib_deps_external}
schnoog/Joystick_ESP32S2 @ ^0.9.4
adafruit/Adafruit MCP4725 @ ^2.0.2
regenbogencode/ESPNowW@^1.0.2
regenbogencode/ESPNowW@^1.0.2
adafruit/Adafruit NeoPixel@^1.12.3

[env:esp32s3usbotg-gilphilbert_2_0]
board = adafruit_feather_esp32s3
board_build.f_cpu = 240000000L
build_unflags =
-DARDUINO_USB_CDC_ON_BOOT=1
build_flags =
-DARDUINO_RUNNING_CORE=1
-DCORE_DEBUG_LEVEL=1
-DCORE_DEBUG_LEVEL=0
-DARDUINO_USB_MODE=0
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_CDC_ON_BOOT=0
-DARDUINO_USB_MSC_ON_BOOT=0
-DARDUINO_USB_DFU_ON_BOOT=0
-DPCB_VERSION=7
-DUSB_VID=0xF011
-DUSB_PID=0xF011
-DPCB_VERSION=8
'-DUSB_VID=0xF011'
'-DUSB_PID=0xF011'
'-DUSB_PRODUCT="DiyFfbPedal"'
'-DUSB_MANUFACTURER="OpenSource"'
board_upload.use_1200bps_touch = yes
board_upload.wait_for_upload_port = yes
board_upload.require_upload_port = yes
lib_deps =
${common.lib_deps_external}
schnoog/Joystick_ESP32S2 @ ^0.9.4
Joystick_ESP32S2=https://github.com/schnoog/Joystick_ESP32S2/archive/refs/heads/dev.zip
adafruit/Adafruit MCP4725 @ ^2.0.2
regenbogencode/ESPNowW@^1.0.2
regenbogencode/ESPNowW@^1.0.2
adafruit/Adafruit BusIO@^1.16.1
adafruit/Adafruit NeoPixel@^1.12.3
33 changes: 33 additions & 0 deletions ESP32/src/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,39 @@
//USB.begin();

}
void SetupController_USB(uint8_t pedal_ID)
{
int PID;
char *APname;
switch(pedal_ID)
{
case 0:
PID=0x8214;
APname="FFB_Pedal_Clutch";
break;
case 1:
PID=0x8215;
APname="FFB_Pedal_Brake";
break;
case 2:
PID=0x8216;
APname="FFB_Pedal_Throttle";
break;
default:
PID=0x8217;
APname="FFB_Pedal_NOASSIGNMENT";
break;

}
USB.PID(PID);
USB.VID(0x3035);
USB.productName(APname);
USB.manufacturerName("OpenSource");
USB.begin();
Joystick.setBrakeRange(JOYSTICK_MIN_VALUE, JOYSTICK_MAX_VALUE);
delay(100);
Joystick.begin();
}
bool IsControllerReady() { return true; }
void SetControllerOutputValue(int32_t value) {
Joystick.setBrake(value);
Expand Down
124 changes: 90 additions & 34 deletions ESP32/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ char* APhost;
TaskHandle_t Task6;
#endif

#ifdef USING_LED
#include "soc/soc_caps.h"
#include <Adafruit_NeoPixel.h>
#define LEDS_COUNT 1
Adafruit_NeoPixel pixels(LEDS_COUNT, LED_GPIO, NEO_GRB + NEO_KHZ800);
#define CHANNEL 0
#define LED_BRIGHT 30
/*
static const crgb_t L_RED = 0xff0000;
static const crgb_t L_GREEN = 0x00ff00;
static const crgb_t L_BLUE = 0x0000ff;
static const crgb_t L_WHITE = 0xe0e0e0;
static const crgb_t L_YELLOW = 0xffde21;
static const crgb_t L_ORANGE = 0xffa500;
static const crgb_t L_CYAN = 0x00ffff;
static const crgb_t L_PURPLE = 0x800080;
*/
#endif


/**********************************************************************************************/
Expand All @@ -267,20 +285,29 @@ void setup()
//Serial.begin(921600);
//Serial.begin(512000);
//
#ifdef USING_LED
pixels.begin();
pixels.setBrightness(20);
pixels.setPixelColor(0,0xff,0xff,0xff);
pixels.show();
#endif


#if PCB_VERSION == 6
#if PCB_VERSION == 6 || PCB_VERSION == 7
Serial.setTxTimeoutMs(0);
Serial.begin(921600);
#else
Serial.begin(921600);
Serial.setTimeout(5);
#endif
Serial.println(" ");
Serial.println(" ");
Serial.println(" ");

// init controller
SetupController();
#ifndef CONTROLLER_SPECIFIC_VIDPID
// init controller
SetupController();
delay(3000);
#endif
delay(3000);
Serial.println("This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.");
Serial.println("Please check github repo for more detail: https://github.com/ChrGri/DIY-Sim-Racing-FFB-Pedal");
Expand All @@ -299,6 +326,13 @@ void setup()
if (!isv57slaveIdFound_b)
{
Serial.println( "Restarting ESP" );
#ifdef USING_LED
pixels.setBrightness(20);
pixels.setPixelColor(0,0xff,0x00,0x00);
pixels.show();
delay(3000);
#endif

ESP.restart();
}

Expand All @@ -308,6 +342,12 @@ void setup()
if (!isv57LifeSignal_b)
{
Serial.println( "Restarting ESP" );
#ifdef USING_LED
pixels.setBrightness(20);
pixels.setPixelColor(0,0xff,0x00,0x00);
pixels.show();
delay(3000);
#endif
ESP.restart();
}

Expand Down Expand Up @@ -402,7 +442,12 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);

// interprete config values
dap_calculationVariables_st.updateFromConfig(dap_config_st);

#ifdef USING_LED
//pixels.setBrightness(20);
pixels.setPixelColor(0,0xff,0x0f,0x00);//Orange
pixels.show();
//delay(3000);
#endif


bool invMotorDir = dap_config_st.payLoadPedalConfig_.invertMotorDirection_u8 > 0;
Expand Down Expand Up @@ -439,7 +484,12 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);
kalman = new KalmanFilter(loadcell->getVarianceEstimate());

kalman_2nd_order = new KalmanFilter_2nd_order(1);

#ifdef USING_LED
//pixels.setBrightness(20);
pixels.setPixelColor(0, 0x80, 0x00, 0x80);//purple
pixels.show();
//delay(3000);
#endif



Expand Down Expand Up @@ -533,28 +583,24 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);
delay(500);
#endif



switch(dap_config_st.payLoadPedalConfig_.pedal_type)
{
case 0:
APhost="FFBPedalClutch";
break;
case 1:
APhost="FFBPedalBrake";
break;
case 2:
APhost="FFBPedalGas";
break;
default:
APhost="FFBPedal";
break;

}
//Serial.begin(115200);
#ifdef OTA_update

switch(dap_config_st.payLoadPedalConfig_.pedal_type)
{
case 0:
APhost="FFBPedalClutch";
break;
case 1:
APhost="FFBPedalBrake";
break;
case 2:
APhost="FFBPedalGas";
break;
default:
APhost="FFBPedal";
break;

}

xTaskCreatePinnedToCore(
OTATask,
"OTATask",
Expand All @@ -565,7 +611,6 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);
&Task4,
0);
delay(500);

#endif

//MCP setup
Expand Down Expand Up @@ -608,6 +653,14 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);
//MCP.begin();
}
#endif

#ifdef USING_LED
//pixels.setBrightness(20);
pixels.setPixelColor(0,0x00,0x00,0xff);//Blue
pixels.show();
//delay(3000);
#endif

#ifdef PEDAL_ASSIGNMENT
pinMode(CFG1, INPUT_PULLUP);
pinMode(CFG2, INPUT_PULLUP);
Expand Down Expand Up @@ -672,16 +725,19 @@ pinMode(Pairing_GPIO, INPUT_PULLUP);
0);
delay(500);
}






#endif
#ifdef CONTROLLER_SPECIFIC_VIDPID
SetupController_USB(dap_config_st.payLoadPedalConfig_.pedal_type);
delay(3000);
#endif

Serial.println("Setup end");

#ifdef USING_LED
//pixels.setBrightness(20);
pixels.setPixelColor(0,0x00,0xff,0x00);//Green
pixels.show();
//delay(3000);
#endif
}


Expand Down
2 changes: 1 addition & 1 deletion SimHubPlugin/SettingsControlDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
</StackPanel>
<StackPanel Height="20" Width="160" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,2,0,0">
<styles:SHToggleButton x:Name="CheckBox_Pedal_ESPNow_SyncFlag" Content="" Checked="CheckBox_Pedal_ESPNow_SyncFlag_Checked" Unchecked="CheckBox_Pedal_ESPNow_SyncFlag_Unchecked" IsChecked="False" FontSize="10" Width="35" Height="15" HorizontalAlignment="Left" FontFamily="Arial" RenderTransformOrigin="0.5,0.5" Margin="-10,0,0,0" />
<Label Content="Wireless Sync to Pedal" Height="20" Width="130" Padding="0,0,0,0" VerticalContentAlignment="Center" FontFamily="Arial" HorizontalAlignment="Left" FontSize="10" Margin="4,0,0,0"/>
<Label Content="Wireless Comunication" Height="20" Width="130" Padding="0,0,0,0" VerticalContentAlignment="Center" FontFamily="Arial" HorizontalAlignment="Left" FontSize="10" Margin="4,0,0,0"/>
</StackPanel>

<StackPanel Height="20" Width="160" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,2,0,0">
Expand Down

0 comments on commit 26b386b

Please sign in to comment.