diff --git a/ESP32/platformio.ini b/ESP32/platformio.ini index 1fd677bb..119df0d9 100644 --- a/ESP32/platformio.ini +++ b/ESP32/platformio.ini @@ -22,7 +22,6 @@ monitor_speed = 921600 [common] lib_deps_external = rfetick/Kalman @ ^1.1.0 - lemmingdev/ESP32-BLE-Gamepad @ ^0.5.5 #gin66/FastAccelStepper @ ^0.30.12 gin66/FastAccelStepper @ ^0.31.0 dlloydev/QuickPID @ ^3.1.9 @@ -58,6 +57,7 @@ board = esp32dev lib_deps = ${common.lib_deps_external} regenbogencode/ESPNowW@^1.0.2 + lemmingdev/ESP32-BLE-Gamepad @ ^0.5.5 build_unflags = '-D PCB_VERSION=6' build_flags = @@ -68,6 +68,7 @@ board = esp-wrover-kit lib_deps = ${common.lib_deps_external} regenbogencode/ESPNowW@^1.0.2 + lemmingdev/ESP32-BLE-Gamepad @ ^0.5.5 build_unflags = '-D PCB_VERSION=6' build_flags = @@ -97,7 +98,7 @@ lib_deps = adafruit/Adafruit MCP4725 @ ^2.0.2 regenbogencode/ESPNowW@^1.0.2 -[env:esp32s3usbotg-4R2P] +[env:esp32s3usbotg-gilphilbert_2_0] board = adafruit_feather_esp32s3 board_build.f_cpu = 240000000L build_flags = @@ -107,7 +108,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 - -DPCB_VERSION=8 + -DPCB_VERSION=7 -DUSB_VID=0xF011 -DUSB_PID=0xF011 '-DUSB_PRODUCT="DiyFfbPedal"' diff --git a/SimHubPlugin/DataPluginDemoSettings.cs b/SimHubPlugin/DataPluginDemoSettings.cs index 117d7d05..28e30eee 100644 --- a/SimHubPlugin/DataPluginDemoSettings.cs +++ b/SimHubPlugin/DataPluginDemoSettings.cs @@ -20,7 +20,7 @@ public class DataPluginDemoSettings public uint[] connect_flag = new uint[3] { 0, 0, 0 }; public uint RPM_effect_type = 0; public uint table_selected = 0; - public int[] auto_connect_flag = new int[3] { 0,0,0}; + public int[] auto_connect_flag = new int[3] { 0, 0, 0 }; public int[] selectedComPortNamesInt = new int[3] { -1, -1, -1 }; public int[] ABS_enable_flag = new int[3] { 0, 0, 0 }; public int[] RPM_enable_flag = new int[3] { 0, 0, 0 }; @@ -38,11 +38,11 @@ public class DataPluginDemoSettings public double kinematicDiagram_zeroPos_OX = 100; public double kinematicDiagram_zeroPos_OY = 20; public double kinematicDiagram_zeroPos_scale = 1.5; - public bool[] RTSDTR_False = new bool[3] { true,true,true}; + public bool[] RTSDTR_False = new bool[3] { true, true, true }; public bool[] USING_ESP32S3 = new bool[3] { true, true, true }; - public bool[] CV1_enable_flag = new bool[3] { false,false, false }; + public bool[] CV1_enable_flag = new bool[3] { false, false, false }; public int[] CV1_trigger = new int[3] { 0, 0, 0 }; - public string[] CV1_bindings = new string[3] { "","",""}; + public string[] CV1_bindings = new string[3] { "", "", "" }; public bool[] CV2_enable_flag = new bool[3] { false, false, false }; public int[] CV2_trigger = new int[3] { 0, 0, 0 }; public string[] CV2_bindings = new string[3] { "", "", "" }; @@ -54,9 +54,10 @@ public class DataPluginDemoSettings public bool Using_CDC_bridge = false; public byte[] Pedal_action_interval = new byte[3] { 50, 51, 53 }; public bool Rudder_RPM_effect_b = false; - public bool Rudder_ACC_effect_b=false; + public bool Rudder_ACC_effect_b = false; public bool Rudder_ACC_WindForce = false; public bool advanced_b = false; + public bool[,,] Effect_status_prolife = new bool[6, 3, 8] { { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } }, { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } }, { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } }, { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } }, { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } }, { { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false } } }; } diff --git a/SimHubPlugin/SettingsControlDemo.xaml b/SimHubPlugin/SettingsControlDemo.xaml index 967d1d0b..14e3c579 100644 --- a/SimHubPlugin/SettingsControlDemo.xaml +++ b/SimHubPlugin/SettingsControlDemo.xaml @@ -629,9 +629,9 @@ - + - + @@ -1581,7 +1581,7 @@ + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -2058,34 +2065,34 @@ - - + + - - + + This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. - - + + Please check github repo for detail: https://github.com/ChrGri/DIY-Sim-Racing-FFB-Pedal/ - - - - + + + + - - + + diff --git a/SimHubPlugin/SettingsControlDemo.xaml.cs b/SimHubPlugin/SettingsControlDemo.xaml.cs index 6663f873..09113894 100644 --- a/SimHubPlugin/SettingsControlDemo.xaml.cs +++ b/SimHubPlugin/SettingsControlDemo.xaml.cs @@ -600,17 +600,90 @@ public void DAP_config_set_default_rudder() //dap_config_st[pedalIdx].payloadPedalConfig_.OTA_flag = 0; dap_config_st_rudder.payloadPedalConfig_.enableReboot_u8 = 0; } - + System.Windows.Controls.CheckBox[,] Effect_status_profile=new System.Windows.Controls.CheckBox[3,8]; public SettingsControlDemo() { - + DAP_config_set_default_rudder(); for (uint pedalIdx = 0; pedalIdx < 3; pedalIdx++) { DAP_config_set_default(pedalIdx); - InitializeComponent(); + } - + InitializeComponent(); + + //initialize profile effect status + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 8; j++) + { + Effect_status_profile[i, j] = new System.Windows.Controls.CheckBox(); + Effect_status_profile[i, j].Width = 45; + Effect_status_profile[i, j].Height = 20; + Effect_status_profile[i, j].FontSize = 8; + switch (j) + { + case 0: + + Effect_status_profile[i, j].Margin = new Thickness(20, 0, 0, 0); + if (i == 0 || i == 2) + { + Effect_status_profile[i, j].Content = "TC"; + + } + else + { + Effect_status_profile[i, j].Content = "ABS"; + } + + break; + case 1: + Effect_status_profile[i, j].Content = "RPM"; + break; + case 2: + Effect_status_profile[i, j].Content = "B.P"; + Effect_status_profile[i, j].Width = 40; + break; + case 3: + Effect_status_profile[i, j].Content = "G-F"; + Effect_status_profile[i, j].Width = 40; + if (i == 0 || i == 2) + { + Effect_status_profile[i, j].IsEnabled = false; + } + break; + case 4: + Effect_status_profile[i, j].Content = "W.S"; + Effect_status_profile[i, j].Width = 40; + break; + case 5: + Effect_status_profile[i, j].Content = "IMAPCT"; + Effect_status_profile[i, j].Width = 60; + break; + case 6: + Effect_status_profile[i, j].Content = "CUS-1"; + Effect_status_profile[i, j].Width = 50; + break; + case 7: + Effect_status_profile[i, j].Content = "CUS-2"; + Effect_status_profile[i, j].Width = 50; + break; + } + switch (i) + { + case 0: + StackPanel_Effects_Status_0.Children.Add(Effect_status_profile[i, j]); + break; + case 1: + StackPanel_Effects_Status_1.Children.Add(Effect_status_profile[i, j]); + break; + case 2: + StackPanel_Effects_Status_2.Children.Add(Effect_status_profile[i, j]); + break; + } + } + } + // debug mode invisiable //text_debug_flag.Visibility = Visibility.Hidden; text_serial.Visibility = Visibility.Hidden; @@ -1812,6 +1885,21 @@ public void updateTheGuiFromConfig() { Checkbox_auto_remove_serial_line_bridge.IsChecked = false; } + //effect profile reading + for (int j = 0; j < 3; j++) + { + for (int k = 0; k < 8; k++) + { + if (Plugin.Settings.Effect_status_prolife[profile_select, j, k]) + { + Effect_status_profile[j, k].IsChecked = true; + } + else + { + Effect_status_profile[j, k].IsChecked = false; + } + } + } } } @@ -4041,15 +4129,18 @@ public void Read_for_slot(object sender, EventArgs e) string filePath = openFileDialog.FileName; - //TextBox_debugOutput.Text = Button.Name; + //TextBox_debugOutput.Text = Button.Name; + // + uint i = profile_select; + uint j = 0; if (Button.Name == "Reading_clutch") { Plugin.Settings.Pedal_file_string[profile_select,0] = filePath; Label_clutch_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 0]; Plugin.Settings.file_enable_check[profile_select, 0] = 1; - Clutch_file_check.IsChecked = true; - + Clutch_file_check.IsChecked = true; + j = 0; } if (Button.Name == "Reading_brake") { @@ -4057,6 +4148,7 @@ public void Read_for_slot(object sender, EventArgs e) Label_brake_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 1]; Plugin.Settings.file_enable_check[profile_select, 1] = 1; Brake_file_check.IsChecked = true; + j = 1; } if (Button.Name == "Reading_gas") { @@ -4064,6 +4156,21 @@ public void Read_for_slot(object sender, EventArgs e) Label_gas_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 2]; Plugin.Settings.file_enable_check[profile_select, 2] = 1; Gas_file_check.IsChecked = true; + j = 2; + } + + //write to setting + for (int k = 0; k < 8; k++) + { + if (Effect_status_profile[j, k].IsChecked == true) + { + Plugin.Settings.Effect_status_prolife[i, j, k] = true; + } + else + { + Plugin.Settings.Effect_status_prolife[i, j, k] = false; + } + } @@ -4074,6 +4181,8 @@ public void Read_for_slot(object sender, EventArgs e) public void Clear_slot(object sender, EventArgs e) { var Button = sender as SHButtonPrimary; + uint i = profile_select; + uint j = 0; if (Button.Name == "Clear_clutch") { @@ -4081,6 +4190,7 @@ public void Clear_slot(object sender, EventArgs e) Label_clutch_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 0]; Plugin.Settings.file_enable_check[profile_select, 0] = 0; Clutch_file_check.IsChecked = false; + j = 0; } if (Button.Name == "Clear_brake") @@ -4090,6 +4200,7 @@ public void Clear_slot(object sender, EventArgs e) Label_brake_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 1]; Plugin.Settings.file_enable_check[profile_select, 1] = 0; Brake_file_check.IsChecked = false; + j = 1; } if (Button.Name == "Clear_gas") @@ -4099,8 +4210,15 @@ public void Clear_slot(object sender, EventArgs e) Label_gas_file.Content = Plugin.Settings.Pedal_file_string[profile_select, 2]; Plugin.Settings.file_enable_check[profile_select, 2] = 0; Gas_file_check.IsChecked = false; + j = 2; } + //write to setting + for (int k = 0; k < 8; k++) + { + Plugin.Settings.Effect_status_prolife[i, j, k] = false; + Effect_status_profile[j, k].IsChecked = false; + } //updateTheGuiFromConfig(); } void Parsefile(uint profile_index) @@ -5143,6 +5261,75 @@ public void Profile_change(uint profile_index) break; } Plugin.current_profile = tmp; + for (int j = 0; j < 3; j++) + { + for (int k = 0; k < 8; k++) + { + if (Plugin.Settings.Effect_status_prolife[profile_select, j, k]) + { + switch (k) + { + case 0: + Plugin.Settings.ABS_enable_flag[j] = 1; + break; + case 1: + Plugin.Settings.RPM_enable_flag[j] = 1; + break; + case 2: + //Plugin.Settings. = 1; + break; + case 3: + Plugin.Settings.G_force_enable_flag[j] = 1; + break; + case 4: + Plugin.Settings.WS_enable_flag[j] = 1; + break; + case 5: + Plugin.Settings.Road_impact_enable_flag[j] = 1; + break; + case 6: + Plugin.Settings.CV1_enable_flag[j] = true; + break; + case 7: + Plugin.Settings.CV2_enable_flag[j] = true; + break; + } + } + else + { + switch (k) + { + case 0: + Plugin.Settings.ABS_enable_flag[j] = 0; + break; + case 1: + Plugin.Settings.RPM_enable_flag[j] = 0; + break; + case 2: + //Plugin.Settings. = 1; + break; + case 3: + Plugin.Settings.G_force_enable_flag[j] = 0; + break; + case 4: + Plugin.Settings.WS_enable_flag[j] = 0; + break; + case 5: + Plugin.Settings.Road_impact_enable_flag[j] = 0; + break; + case 6: + Plugin.Settings.CV1_enable_flag[j] = false; + break; + case 7: + Plugin.Settings.CV2_enable_flag[j] = false; + break; + } + } + + } + } + //effect profile change + } private void effect_bind_click(object sender, RoutedEventArgs e)