feat(gui): add live G29 / Steam Controller input & CRSF monitor in Settings

This commit is contained in:
bleack committed 2026-11-21 11:22:17 +01:00
1 parent 23e24cab5d
commit ebe0d9889f
5 files changed
+796 -30

No files matched your search

+38 -3
View File
@@ -209,6 +209,7 @@ volatile uint32_t momentDesarmement_ms = 0;
volatile uint8_t rugositeTerrainExterne = 0; // 0 à 255 (pilotable via CRSF télémétrie / FC)
volatile float dernierAccelPct = 0.0f; // 0.0 à 100.0%
volatile float dernierFreinPct = 0.0f; // 0.0 à 100.0%
volatile float dernierEmbrayagePct = 0.0f; // 0.0 à 100.0%
volatile uint32_t momentDernierChocRapport_ms = 0; // Horodatage du passage de vitesse
volatile int8_t directionDernierChocRapport = 0; // -1 gauche, +1 droite
volatile bool forceEstAuNeutre = false;
@@ -232,6 +233,8 @@ volatile bool extArme = false;
volatile int8_t extRapport = 0;
volatile uint8_t extAccelPct = 0;
volatile uint8_t extFreinPct = 0;
volatile uint8_t extEmbrayagePct = 0;
volatile int8_t extVolantPct = 0;
volatile uint32_t dernierPaquetRC_ms = 0;
static inline bool estActuellementArme() {
@@ -406,6 +409,8 @@ void traiterLigneSerie(char* commande) {
extRapport = 0;
extAccelPct = 0;
extFreinPct = 0;
extEmbrayagePct = 0;
extVolantPct = 0;
extRcActif = false;
sourceActive = SRC_G29;
majLedRequise = true;
@@ -634,8 +639,17 @@ void traiterLigneSerie(char* commande) {
uint8_t brakePct = (vBrake > CRSF_VAL_MID)
? (uint8_t)constrain(map(vBrake, CRSF_VAL_MID, CRSF_VAL_MAX, 0, 100), 0, 100)
: 0;
uint8_t clutchPct = (vClutch > CRSF_VAL_MID)
? (uint8_t)constrain(map(vClutch, CRSF_VAL_MID, CRSF_VAL_MAX, 0, 100), 0, 100)
: 0;
int8_t steerPct = (int8_t)constrain(
(int)(((float)((int)CRSF_VAL_MID - (int)vSteer) / (float)(CRSF_VAL_MID - CRSF_VAL_MIN)) * 100.0f),
-100, 100
);
extAccelPct = accelPct;
extFreinPct = brakePct;
extEmbrayagePct = clutchPct;
extVolantPct = steerPct;
assignerCanalCRSF(configSysteme.volant, vSteer);
assignerCanalCRSF(configSysteme.accel, vAccel);
@@ -1030,14 +1044,31 @@ void gererSortieCockpit() {
int brake = (sourceActive == SRC_EXT)
? (int)extFreinPct
: (int)constrain(dernierFreinPct + 0.5f, 0.0f, 100.0f);
int clutch = (sourceActive == SRC_EXT)
? (int)extEmbrayagePct
: (int)constrain(dernierEmbrayagePct + 0.5f, 0.0f, 100.0f);
int32_t dMax = (maxDeltaVolant > 0) ? maxDeltaVolant : DELTA_MAX_VOLANT_BRUT;
int steer = (sourceActive == SRC_EXT)
? (int)extVolantPct
: (int)constrain(((float)dernierVolantCentre / (float)dMax) * 100.0f, -100.0f, 100.0f);
uint16_t ch1 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.volant - 1];
uint16_t ch2 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.accel - 1];
uint16_t ch3 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.frein - 1];
uint16_t ch4 = failsafeActif ? CRSF_VAL_MID : crsf_channels[configSysteme.embrayage - 1];
const char* srcStr = (sourceActive == SRC_EXT) ? "EXT" : "G29";
char bufEtat[112];
char bufEtat[176];
snprintf(bufEtat, sizeof(bufEtat),
"$G29,ARM=%d,GEAR=%d,THROT=%d,BRAKE=%d,FFB=%d,VIB=%d,FAIL=%d,SRC=%s",
"$G29,ARM=%d,GEAR=%d,THROT=%d,BRAKE=%d,CLUTCH=%d,STEER=%d,CH1=%u,CH2=%u,CH3=%u,CH4=%u,FFB=%d,VIB=%d,FAIL=%d,SRC=%s",
armeOut ? 1 : 0,
(int)rapportOut,
throt,
brake,
clutch,
steer,
(unsigned int)ch1,
(unsigned int)ch2,
(unsigned int)ch3,
(unsigned int)ch4,
(int)configSysteme.forceRessort,
(int)configSysteme.intensiteVibration,
failsafeActif ? 1 : 0,
@@ -1061,6 +1092,8 @@ void gererTimeoutRcExterne() {
extArme = false;
extAccelPct = 0;
extFreinPct = 0;
extEmbrayagePct = 0;
extVolantPct = 0;
reinitialiserCanauxCRSF();
majLedRequise = true;
cockpitEtatModifie = true;
@@ -1550,6 +1583,7 @@ void reinitialiserEtatVolant() {
dernierVolantCentre = 0;
dernierAccelPct = 0.0f;
dernierFreinPct = 0.0f;
dernierEmbrayagePct = 0.0f;
rugositeTerrainExterne = 0;
}
@@ -1639,9 +1673,10 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
uint16_t freinRaw = 65535 - ((report[48] << 8) | report[47]);
uint16_t embrayageRaw = 65535 - ((report[50] << 8) | report[49]);
// Pourcentages des pédales pour la synthèse haptique (0.0 à 100.0%)
// Pourcentages des pédales pour la synthèse haptique et le moniteur cockpit (0.0 à 100.0%)
dernierAccelPct = (accelRaw > DEADZONE_PEDALE) ? (((float)(accelRaw - DEADZONE_PEDALE) / (float)(65535 - DEADZONE_PEDALE)) * 100.0f) : 0.0f;
dernierFreinPct = (freinRaw > DEADZONE_PEDALE) ? (((float)(freinRaw - DEADZONE_PEDALE) / (float)(65535 - DEADZONE_PEDALE)) * 100.0f) : 0.0f;
dernierEmbrayagePct = (embrayageRaw > DEADZONE_PEDALE) ? (((float)(embrayageRaw - DEADZONE_PEDALE) / (float)(65535 - DEADZONE_PEDALE)) * 100.0f) : 0.0f;
uint8_t boutonsEpaule = report[6];
bool pPlusActuel = (boutonsEpaule & PALETTE_PLUS_MASK);