mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat: add Steam Controller support with hot-switchable G29/Steam selector
This commit is contained in:
1 parent
d5dc1de504
commit
95ad271232
11 files changed
+1979
-81
No files matched your search
+244
-47
@@ -56,6 +56,13 @@
|
||||
#define UART_BRIDGE_BAUD 460800
|
||||
#define INTERVALLE_COCKPIT_MS 50 // 20 Hz
|
||||
#define TIMEOUT_HT_MS 500 // Retour au centre si le casque ne répond plus
|
||||
#define TIMEOUT_RC_EXT_MS 400 // Watchdog failsafe si la manette externe (Steam Controller) ne répond plus
|
||||
|
||||
// Source active de pilotage (bascule via $SRC,G29 ou $SRC,EXT)
|
||||
enum SourceControle : uint8_t {
|
||||
SRC_G29 = 0,
|
||||
SRC_EXT = 1,
|
||||
};
|
||||
|
||||
// Bits d'événements boutons (Cœur 1 -> Cœur 0)
|
||||
enum CockpitBoutonBit : uint16_t {
|
||||
@@ -218,6 +225,29 @@ bool cockpitEchoUSB = true; // Actif par défaut pour lia
|
||||
uint32_t dernierPaquetHT_ms = 0;
|
||||
bool htActif = false;
|
||||
|
||||
// Pilotage externe (Steam Controller via SteamFrame FPV -> Radxa -> RP2350)
|
||||
volatile uint8_t sourceActive = SRC_G29;
|
||||
volatile bool extRcActif = false;
|
||||
volatile bool extArme = false;
|
||||
volatile int8_t extRapport = 0;
|
||||
volatile uint8_t extAccelPct = 0;
|
||||
volatile uint8_t extFreinPct = 0;
|
||||
volatile uint32_t dernierPaquetRC_ms = 0;
|
||||
|
||||
static inline bool estActuellementArme() {
|
||||
return (sourceActive == SRC_EXT) ? extArme : estArme;
|
||||
}
|
||||
|
||||
static inline int8_t rapportActuel() {
|
||||
return (sourceActive == SRC_EXT) ? extRapport : rapportEngage;
|
||||
}
|
||||
|
||||
static inline void assignerCanalCRSF(uint8_t numeroCh, uint16_t valeur11bits) {
|
||||
if (numeroCh >= 1 && numeroCh <= 16 && numeroCh != CANAL_ARM) {
|
||||
crsf_channels[numeroCh - 1] = valeur11bits;
|
||||
}
|
||||
}
|
||||
|
||||
char serialBuffer[64];
|
||||
uint8_t serialBufferIdx = 0;
|
||||
char serial2Buffer[64];
|
||||
@@ -276,8 +306,10 @@ void afficherConfiguration() {
|
||||
configSysteme.forceRessort, (configSysteme.forceRessort * 100) / 255);
|
||||
Serial.printf("Plage Volant(P): %d degres [P=40..900]\n", configSysteme.angleSouhaiteTotal);
|
||||
Serial.printf("Expo Volant(X) : %.2f [X=0.00..0.80]\n", configSysteme.expoVolant);
|
||||
Serial.printf("Source active : %s [$SRC,G29 | $SRC,EXT]\n",
|
||||
(sourceActive == SRC_EXT) ? "EXT (Steam Controller)" : "G29 (Volant)");
|
||||
Serial.printf("Vibrations (T) : %d%% [Boutons +/- ou T=0..100] (0 = desactive)\n", configSysteme.intensiteVibration);
|
||||
Serial.println("Commandes : V=ch, A=ch, F=ch, E=ch, D=val, P=val, X=val, T=val, S(save), R(reset), B(bootsel), ?");
|
||||
Serial.println("Commandes : V=ch, A=ch, F=ch, E=ch, D=val, P=val, X=val, T=val, $SRC,G29|EXT, $RC,..., $HT,..., S(save), R(reset), B(bootsel), ?");
|
||||
}
|
||||
|
||||
void chargerConfiguration() {
|
||||
@@ -325,7 +357,7 @@ void chargerConfiguration() {
|
||||
// GESTION SÉRIE NON BLOQUANTE
|
||||
// -------------------------------------------------------------------------
|
||||
void demanderOuExecuterSauvegarde() {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
sauvegardeDifferee = true;
|
||||
Serial.println(">> Modification appliquee (sauvegarde Flash differee au desarmement).");
|
||||
} else {
|
||||
@@ -341,7 +373,7 @@ void traiterLigneSerie(char* commande) {
|
||||
return;
|
||||
}
|
||||
if (commande[0] == 'B' || commande[0] == 'b') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Redemarrage BOOTSEL refuse pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -351,7 +383,7 @@ void traiterLigneSerie(char* commande) {
|
||||
return;
|
||||
}
|
||||
if (commande[0] == 'S' || commande[0] == 's') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Sauvegarde Flash refusee pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -361,7 +393,7 @@ void traiterLigneSerie(char* commande) {
|
||||
return;
|
||||
}
|
||||
if (commande[0] == 'R' || commande[0] == 'r') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Reinitialisation refusee pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -370,7 +402,14 @@ void traiterLigneSerie(char* commande) {
|
||||
reinitialiserCanauxCRSF();
|
||||
rapportEngage = 0;
|
||||
estArme = false;
|
||||
extArme = false;
|
||||
extRapport = 0;
|
||||
extAccelPct = 0;
|
||||
extFreinPct = 0;
|
||||
extRcActif = false;
|
||||
sourceActive = SRC_G29;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
momentDernierChangementDurete_ms = 0;
|
||||
sauvegardeDifferee = false;
|
||||
rp2040.resumeOtherCore();
|
||||
@@ -384,7 +423,7 @@ void traiterLigneSerie(char* commande) {
|
||||
char periph = commande[0];
|
||||
if (periph == 'V' || periph == 'v' || periph == 'A' || periph == 'a' ||
|
||||
periph == 'F' || periph == 'f' || periph == 'E' || periph == 'e') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Remappage des canaux refuse pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -436,7 +475,7 @@ void traiterLigneSerie(char* commande) {
|
||||
Serial.println("!! Durete (D) doit etre entre 0 et 255 !!");
|
||||
}
|
||||
} else if (periph == 'P' || periph == 'p') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Reglage de plage (P) refuse pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -453,7 +492,7 @@ void traiterLigneSerie(char* commande) {
|
||||
Serial.println("!! Plage d'angle (P) doit etre entre 40 et 900 degres !!");
|
||||
}
|
||||
} else if (periph == 'X' || periph == 'x') {
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! Reglage d'expo (X) refuse pendant la conduite (desarmer d'abord) !!");
|
||||
return;
|
||||
}
|
||||
@@ -494,6 +533,124 @@ void traiterLigneSerie(char* commande) {
|
||||
dernierPaquetHT_ms = millis();
|
||||
htActif = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Sélection de la source de pilotage : $SRC,G29 ou $SRC,EXT (Steam Controller)
|
||||
if (strncmp(commande, "$SRC,", 5) == 0) {
|
||||
const char* mode = commande + 5;
|
||||
uint8_t cible = sourceActive;
|
||||
if (strcmp(mode, "G29") == 0 || strcmp(mode, "g29") == 0) {
|
||||
cible = SRC_G29;
|
||||
} else if (strcmp(mode, "EXT") == 0 || strcmp(mode, "ext") == 0 || strcmp(mode, "STEAM") == 0) {
|
||||
cible = SRC_EXT;
|
||||
} else {
|
||||
Serial.printf("!! [SRC] Source inconnue : %s (attendu G29 ou EXT) !!\n", mode);
|
||||
return;
|
||||
}
|
||||
if (cible == sourceActive) {
|
||||
cockpitEtatModifie = true;
|
||||
return;
|
||||
}
|
||||
if (estActuellementArme()) {
|
||||
Serial.println("!! [SRC] Changement de controleur refuse : desarmer d'abord !!");
|
||||
cockpitEtatModifie = true;
|
||||
return;
|
||||
}
|
||||
rp2040.idleOtherCore();
|
||||
sourceActive = cible;
|
||||
extRcActif = false;
|
||||
extArme = false;
|
||||
extRapport = 0;
|
||||
extAccelPct = 0;
|
||||
extFreinPct = 0;
|
||||
estArme = false;
|
||||
rapportEngage = 0;
|
||||
boutonArmDejaEnfonce = true;
|
||||
palettePlusDejaEnfoncee = true;
|
||||
paletteMoinsDejaEnfoncee = true;
|
||||
etatBoutonsCockpitPrec = 0xFFFF;
|
||||
reinitialiserCanauxCRSF();
|
||||
rp2040.resumeOtherCore();
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
Serial.printf(">> [SRC] Source active basculee sur : %s\n",
|
||||
(sourceActive == SRC_EXT) ? "EXT (Steam Controller)" : "G29 (Volant)");
|
||||
return;
|
||||
}
|
||||
|
||||
// Injection conduite externe (Steam Controller via SteamFrame FPV) :
|
||||
// $RC,<steer>,<accel>,<brake>,<clutch>,<arm>,<gear>
|
||||
if (strncmp(commande, "$RC,", 4) == 0) {
|
||||
if (sourceActive != SRC_EXT) {
|
||||
return;
|
||||
}
|
||||
int steer = CRSF_VAL_MID, accel = CRSF_VAL_MID, brake = CRSF_VAL_MID, clutch = CRSF_VAL_MID;
|
||||
int arm = 0, gear = 0;
|
||||
if (sscanf(commande + 4, "%d,%d,%d,%d,%d,%d", &steer, &accel, &brake, &clutch, &arm, &gear) == 6) {
|
||||
uint16_t vSteer = (uint16_t)constrain(steer, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
uint16_t vAccel = (uint16_t)constrain(accel, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
uint16_t vBrake = (uint16_t)constrain(brake, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
uint16_t vClutch = (uint16_t)constrain(clutch, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
int8_t vGear = (int8_t)constrain(gear, -1, 3);
|
||||
bool demandeArm = (arm != 0);
|
||||
|
||||
// Sécurité : refuser un armement (0 -> 1) si rapport != N ou gaz non neutres
|
||||
if (demandeArm && !extArme) {
|
||||
if (vGear == 0 && vAccel == CRSF_VAL_MID) {
|
||||
extArme = true;
|
||||
momentArmement_ms = millis();
|
||||
momentDesarmement_ms = 0;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
Serial.println(">> [ARM EXT] ARME (Steam Controller)");
|
||||
}
|
||||
} else if (!demandeArm && extArme) {
|
||||
extArme = false;
|
||||
momentDesarmement_ms = millis();
|
||||
momentArmement_ms = 0;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
Serial.println(">> [ARM EXT] DESARME (Steam Controller)");
|
||||
}
|
||||
|
||||
if (vGear != extRapport) {
|
||||
extRapport = vGear;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
}
|
||||
|
||||
if (!extArme || extRapport == 0) {
|
||||
vAccel = CRSF_VAL_MID;
|
||||
}
|
||||
|
||||
uint8_t accelPct = 0;
|
||||
if (extArme && extRapport >= 1 && extRapport <= 3 && vAccel >= GAZ_AVANT_MIN) {
|
||||
uint16_t maxV = GAZ_AVANT_MAX_PAR_VITESSE[extRapport - 1];
|
||||
accelPct = (uint8_t)constrain(map(vAccel, GAZ_AVANT_MIN, maxV, 0, 100), 0, 100);
|
||||
} else if (extArme && extRapport == -1 && vAccel <= GAZ_ARRIERE_MIN) {
|
||||
accelPct = (uint8_t)constrain(map(vAccel, GAZ_ARRIERE_MIN, GAZ_ARRIERE_MAX, 0, 100), 0, 100);
|
||||
}
|
||||
uint8_t brakePct = (vBrake > CRSF_VAL_MID)
|
||||
? (uint8_t)constrain(map(vBrake, CRSF_VAL_MID, CRSF_VAL_MAX, 0, 100), 0, 100)
|
||||
: 0;
|
||||
extAccelPct = accelPct;
|
||||
extFreinPct = brakePct;
|
||||
|
||||
assignerCanalCRSF(configSysteme.volant, vSteer);
|
||||
assignerCanalCRSF(configSysteme.accel, vAccel);
|
||||
assignerCanalCRSF(configSysteme.frein, vBrake);
|
||||
assignerCanalCRSF(configSysteme.embrayage, vClutch);
|
||||
crsf_channels[CANAL_ARM - 1] = extArme ? CRSF_VAL_MAX : CRSF_VAL_MIN;
|
||||
|
||||
dernierPaquetRC_ms = millis();
|
||||
if (!extRcActif) {
|
||||
extRcActif = true;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,19 +695,19 @@ void actualiserLED() {
|
||||
} else if (momentDesarmement_ms > 0 && dtDesarm < 250) {
|
||||
// Animation NeoPixel au desarmement : flash rouge d'arret
|
||||
r = 255; g = 20; b = 0;
|
||||
} else if (!volant_est_pret) {
|
||||
b = 255; // Bleu : Attente G29
|
||||
} else if ((sourceActive == SRC_G29 && !volant_est_pret) || (sourceActive == SRC_EXT && !extRcActif)) {
|
||||
b = 255; // Bleu : Attente contrôleur actif (G29 ou Steam Controller)
|
||||
} else if (failsafeActif) {
|
||||
r = 255; g = 255; b = 255; // Blanc : Failsafe (G29 muet)
|
||||
r = 255; g = 255; b = 255; // Blanc : Failsafe
|
||||
} else {
|
||||
switch (rapportEngage) {
|
||||
switch (rapportActuel()) {
|
||||
case -1: r = 255; g = 0; b = 0; break; // Rouge : R
|
||||
case 0: r = 255; g = 100; b = 0; break; // Orange : N
|
||||
case 1: r = 0; g = 255; b = 255; break; // Cyan : 1ère
|
||||
case 2: r = 0; g = 255; b = 0; break; // Vert : 2ème
|
||||
case 3: r = 180; g = 0; b = 255; break; // Violet : 3ème
|
||||
}
|
||||
if (!estArme) { // Désarmé : couleur du rapport très atténuée
|
||||
if (!estActuellementArme()) { // Désarmé : couleur du rapport très atténuée
|
||||
r /= 10; g /= 10; b /= 10;
|
||||
}
|
||||
}
|
||||
@@ -659,14 +816,26 @@ bool evaluerFailsafe() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Déconnexion matérielle du volant G29 (câble USB arraché ou hors tension)
|
||||
if (!volant_est_pret) {
|
||||
if (!failsafeActif) {
|
||||
failsafeActif = true;
|
||||
majLedRequise = true;
|
||||
Serial.println(F("!! [FAILSAFE] Volant G29 non detecte ou debranche !!"));
|
||||
// 2. Surveillance de la source active (Steam Controller externe ou Volant G29)
|
||||
if (sourceActive == SRC_EXT) {
|
||||
if (!extRcActif || (now - dernierPaquetRC_ms > TIMEOUT_RC_EXT_MS)) {
|
||||
if (!failsafeActif) {
|
||||
failsafeActif = true;
|
||||
majLedRequise = true;
|
||||
Serial.println(F("!! [FAILSAFE] Steam Controller inactif ou deconnecte !!"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Déconnexion matérielle du volant G29 (câble USB arraché ou hors tension)
|
||||
if (!volant_est_pret) {
|
||||
if (!failsafeActif) {
|
||||
failsafeActif = true;
|
||||
majLedRequise = true;
|
||||
Serial.println(F("!! [FAILSAFE] Volant G29 non detecte ou debranche !!"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Volant branché et Cœur 1 fonctionnel : liaison valide (pas de faux failsafe quand le volant est immobile)
|
||||
@@ -727,7 +896,7 @@ void traiterTelemetrieCRSF() {
|
||||
dernierPaquetTelemetrie_ms = millis();
|
||||
uint8_t frameType = crsfRxBuffer[2];
|
||||
|
||||
if (!estArme) {
|
||||
if (!estArme || sourceActive != SRC_G29) {
|
||||
rugositeTerrainExterne = 0;
|
||||
attitudeInitialisee = false;
|
||||
} else if (frameType == 0x1E && paquetLongueurAttendue >= 8) {
|
||||
@@ -789,7 +958,7 @@ void traiterTelemetrieCRSF() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!estArme) {
|
||||
if (!estArme || sourceActive != SRC_G29) {
|
||||
rugositeTerrainExterne = 0;
|
||||
attitudeInitialisee = false;
|
||||
return;
|
||||
@@ -853,18 +1022,26 @@ void gererSortieCockpit() {
|
||||
bool modif = __atomic_exchange_n(&cockpitEtatModifie, false, __ATOMIC_ACQ_REL);
|
||||
if (modif || (now - dernierEnvoiCockpit_ms >= INTERVALLE_COCKPIT_MS)) {
|
||||
dernierEnvoiCockpit_ms = now;
|
||||
int throt = (int)constrain(dernierAccelPct + 0.5f, 0.0f, 100.0f);
|
||||
int brake = (int)constrain(dernierFreinPct + 0.5f, 0.0f, 100.0f);
|
||||
char bufEtat[96];
|
||||
bool armeOut = estActuellementArme();
|
||||
int8_t rapportOut = rapportActuel();
|
||||
int throt = (sourceActive == SRC_EXT)
|
||||
? (int)extAccelPct
|
||||
: (int)constrain(dernierAccelPct + 0.5f, 0.0f, 100.0f);
|
||||
int brake = (sourceActive == SRC_EXT)
|
||||
? (int)extFreinPct
|
||||
: (int)constrain(dernierFreinPct + 0.5f, 0.0f, 100.0f);
|
||||
const char* srcStr = (sourceActive == SRC_EXT) ? "EXT" : "G29";
|
||||
char bufEtat[112];
|
||||
snprintf(bufEtat, sizeof(bufEtat),
|
||||
"$G29,ARM=%d,GEAR=%d,THROT=%d,BRAKE=%d,FFB=%d,VIB=%d,FAIL=%d",
|
||||
estArme ? 1 : 0,
|
||||
(int)rapportEngage,
|
||||
"$G29,ARM=%d,GEAR=%d,THROT=%d,BRAKE=%d,FFB=%d,VIB=%d,FAIL=%d,SRC=%s",
|
||||
armeOut ? 1 : 0,
|
||||
(int)rapportOut,
|
||||
throt,
|
||||
brake,
|
||||
(int)configSysteme.forceRessort,
|
||||
(int)configSysteme.intensiteVibration,
|
||||
failsafeActif ? 1 : 0);
|
||||
failsafeActif ? 1 : 0,
|
||||
srcStr);
|
||||
emettreLigneCockpit(bufEtat);
|
||||
}
|
||||
}
|
||||
@@ -878,6 +1055,19 @@ void gererTimeoutHeadTracking() {
|
||||
}
|
||||
}
|
||||
|
||||
void gererTimeoutRcExterne() {
|
||||
if (sourceActive == SRC_EXT && extRcActif && (millis() - dernierPaquetRC_ms > TIMEOUT_RC_EXT_MS)) {
|
||||
extRcActif = false;
|
||||
extArme = false;
|
||||
extAccelPct = 0;
|
||||
extFreinPct = 0;
|
||||
reinitialiserCanauxCRSF();
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
Serial.println(F("!! [FAILSAFE] Perte de liaison Steam Controller ($RC timeout) !!"));
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Watchdog dual-core : ne réarmer le watchdog matériel que si le Cœur 1 est également vivant
|
||||
if (heartbeatCore1_ms == 0 || (millis() - heartbeatCore1_ms <= TIMEOUT_FAILSAFE_MS)) {
|
||||
@@ -885,6 +1075,7 @@ void loop() {
|
||||
}
|
||||
verifierCommandesSerie();
|
||||
gererTimeoutHeadTracking();
|
||||
gererTimeoutRcExterne();
|
||||
traiterTelemetrieCRSF();
|
||||
gererSortieCockpit();
|
||||
|
||||
@@ -897,9 +1088,10 @@ void loop() {
|
||||
majLedRequise = false;
|
||||
dernierTickAnimNeo_ms = millis();
|
||||
actualiserLED();
|
||||
if (rapportEngage != dernierRapportLog) {
|
||||
dernierRapportLog = rapportEngage;
|
||||
Serial.printf("[BOITE] Rapport engage : %d\n", rapportEngage);
|
||||
int8_t rap = rapportActuel();
|
||||
if (rap != dernierRapportLog) {
|
||||
dernierRapportLog = rap;
|
||||
Serial.printf("[BOITE] Rapport engage : %d (%s)\n", rap, (sourceActive == SRC_EXT) ? "EXT" : "G29");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +1132,7 @@ void loop() {
|
||||
}
|
||||
|
||||
// Sauvegarde différée suite à une commande série (D= / T=) passée pendant la conduite
|
||||
if (!estArme && sauvegardeDifferee) {
|
||||
if (!estActuellementArme() && sauvegardeDifferee) {
|
||||
sauvegardeDifferee = false;
|
||||
sauvegarderConfiguration();
|
||||
}
|
||||
@@ -949,7 +1141,7 @@ void loop() {
|
||||
// (interdite en conduite armée pour éviter un gel Flash)
|
||||
if (demandeSauvegardeEEPROM) {
|
||||
demandeSauvegardeEEPROM = false;
|
||||
if (estArme) {
|
||||
if (estActuellementArme()) {
|
||||
Serial.println(F("!! Sauvegarde Flash refusee pendant la conduite (desarmer d'abord) !!"));
|
||||
} else {
|
||||
momentDernierChangementDurete_ms = 0;
|
||||
@@ -966,10 +1158,11 @@ void loop() {
|
||||
uint32_t compteOK = compteurRapportsOK;
|
||||
uint32_t rapportsParSec = ((compteOK - dernierCompteOK) * 1000UL) / (dt ? dt : 1);
|
||||
dernierCompteOK = compteOK;
|
||||
Serial.printf("[ETAT] G29_Pret=%d (PID=%04X) | InitFFB=%d/%d | Durete=%d/255 | Vib=%d%% | Rugosite=%d | Plage=%d deg | Rapport=%d | Arme=%d | Statut_LED=%d | USB=%lu rap/s | Rejetes=%lu (L=%d,ID=%02X) | Failsafe=%d\n",
|
||||
volant_est_pret, g29_pid, etapeInitMoteur, ETAPES_INIT_FFB_TOTAL, configSysteme.forceRessort,
|
||||
Serial.printf("[ETAT] SRC=%s | G29_Pret=%d (PID=%04X) | ExtRC=%d | InitFFB=%d/%d | Durete=%d/255 | Vib=%d%% | Rugosite=%d | Plage=%d deg | Rapport=%d | Arme=%d | Statut_LED=%d | USB=%lu rap/s | Rejetes=%lu (L=%d,ID=%02X) | Failsafe=%d\n",
|
||||
(sourceActive == SRC_EXT) ? "EXT" : "G29",
|
||||
volant_est_pret, g29_pid, extRcActif, etapeInitMoteur, ETAPES_INIT_FFB_TOTAL, configSysteme.forceRessort,
|
||||
configSysteme.intensiteVibration, rugositeTerrainExterne, configSysteme.angleSouhaiteTotal,
|
||||
rapportEngage, estArme, statutEnvoiLed,
|
||||
rapportActuel(), estActuellementArme(), statutEnvoiLed,
|
||||
(unsigned long)rapportsParSec, (unsigned long)compteurRapportsRejetes,
|
||||
dernierRejetLen, dernierRejetId, failsafeActif);
|
||||
}
|
||||
@@ -1187,7 +1380,7 @@ void gererVibrationHaptique() {
|
||||
|
||||
// 2. Gestion des vibrations haptiques et retours mécaniques
|
||||
uint8_t intensite = configSysteme.intensiteVibration;
|
||||
if (!estArme || intensite == 0) {
|
||||
if (sourceActive != SRC_G29 || !estArme || intensite == 0) {
|
||||
dernierCalculPhase_us = 0;
|
||||
directionDernierChocRapport = 0;
|
||||
if (!forceEstAuNeutre) {
|
||||
@@ -1321,8 +1514,8 @@ void loop1() {
|
||||
}
|
||||
}
|
||||
|
||||
// Arrêt prioritaire du moteur de vibration dès le désarmement (avant l'animation LED)
|
||||
if (!estArme && !forceEstAuNeutre) {
|
||||
// Arrêt prioritaire du moteur de vibration dès le désarmement (ou si source externe active)
|
||||
if ((sourceActive != SRC_G29 || !estArme) && !forceEstAuNeutre) {
|
||||
if (arreterForceG29()) {
|
||||
forceEstAuNeutre = true;
|
||||
return;
|
||||
@@ -1360,12 +1553,6 @@ void reinitialiserEtatVolant() {
|
||||
rugositeTerrainExterne = 0;
|
||||
}
|
||||
|
||||
static inline void assignerCanalCRSF(uint8_t numeroCh, uint16_t valeur11bits) {
|
||||
if (numeroCh >= 1 && numeroCh <= 16 && numeroCh != CANAL_ARM) {
|
||||
crsf_channels[numeroCh - 1] = valeur11bits;
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// CALLBACKS HID USB HOST (Exécutés sur Core 1)
|
||||
// =========================================================================
|
||||
@@ -1417,7 +1604,9 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) {
|
||||
g29_vid = 0;
|
||||
g29_pid = 0;
|
||||
reinitialiserEtatVolant();
|
||||
reinitialiserCanauxCRSF();
|
||||
if (sourceActive == SRC_G29) {
|
||||
reinitialiserCanauxCRSF();
|
||||
}
|
||||
majLedRequise = true;
|
||||
}
|
||||
|
||||
@@ -1437,6 +1626,14 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
{
|
||||
compteurRapportsOK++;
|
||||
|
||||
// Si la source active est la manette externe (Steam Controller), on maintient la liaison USB
|
||||
// mais on ignore les axes/boutons G29 pour éviter toute interférence.
|
||||
if (sourceActive != SRC_G29) {
|
||||
dernierRapportUSB_ms = millis();
|
||||
tuh_hid_receive_report(dev_addr, instance);
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t volantRaw = (report[44] << 8) | report[43];
|
||||
uint16_t accelRaw = 65535 - ((report[46] << 8) | report[45]);
|
||||
uint16_t freinRaw = 65535 - ((report[48] << 8) | report[47]);
|
||||
|
||||
Reference in new issue
Block a user