mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat(hub): centralize head-tracking (CH6-CH8), cockpit OSD & CRSF telemetry relay over 460800 baud wired link
This commit is contained in:
1 parent
338235f13e
commit
14f9218a44
2 files changed
+289
-14
No files matched your search
@@ -0,0 +1,66 @@
|
||||
# G29-CRSF Hub (`g29_crsf` — Waveshare RP2350-USB-A)
|
||||
|
||||
Firmware dual-core pour **Waveshare RP2350-USB-A** transformant un volant **Logitech G29** (en mode PS4) en **émetteur CRSF 16 canaux @ 166,7 Hz** vers un module **RadioMaster Nomad (ExpressLRS)** et servant de **hub central unifié (100 % filaire, zéro Wi-Fi)** pour le casque **Steam Frame (`steamframe-fpv`)**.
|
||||
|
||||
---
|
||||
|
||||
## Architecture Unifiée (100 % Filaire)
|
||||
|
||||
```text
|
||||
[Volant + Pédales G29]
|
||||
│ (USB-A Host PIO-USB GP12/13)
|
||||
▼
|
||||
[Waveshare RP2350-USB-A]
|
||||
├── GP0 (TX) / GP1 (RX) @ 420 000 bauds ◄═══► [RadioMaster Nomad (ELRS)]
|
||||
│ • Aller : CRSF 16ch @ 166.7 Hz (CH1-5 = G29, CH6-8 = Head-Tracking)
|
||||
│ • Retour : Télémétrie CRSF véhicule (Attitude, Batt, GPS, LQ/RSSI)
|
||||
│
|
||||
└── UART GP4/GP5 @ 460 800 bauds (ou USB-C /dev/ttyACM0)
|
||||
▼
|
||||
[Radxa Zero 3W (VRX)] ◄══► [Splitter USB-C PD] ◄══► [Casque Steam Frame]
|
||||
```
|
||||
|
||||
### Ce qui est centralisé sur la RP2350 :
|
||||
1. **Pilotage G29 (`CH1..CH5`)** : Volant (`CH1`), Accélérateur avec boîte séquentielle R/N/1/2/3 (`CH2`), Frein (`CH3`), Embrayage (`CH4`), Armement R2 (`CH5`).
|
||||
2. **Mixage Head-Tracking (`CH6..CH8`)** : Réception des trames `$HT,<pan>,<tilt>,<roll>` (valeurs CRSF `172..1811`, neutre `992`) depuis le casque via la Radxa Zero 3W (`Serial2` à `460 800 bauds` ou `Serial` USB-C), avec **watchdog de recentrage automatique à `500 ms`**.
|
||||
3. **Relais Télémétrie & État Cockpit** :
|
||||
- État G29 à 20 Hz (`$G29,ARM=...,GEAR=...,THROT=...,BRAKE=...,FFB=...,VIB=...,FAIL=...`).
|
||||
- Événements boutons immédiats (`$G29_EVT,BTN=...`) pour piloter l'OSD, le DVR, le mode de projection VR et la Tare Head-Tracking depuis le volant.
|
||||
- Relais complet des trames CRSF valides reçues sur `GP1` (`$CRSF,<HEX>`) vers l'OSD de `steamframe-fpv`, tout en conservant le calcul local de rugosité (`0x1E`) pour le retour de force haptique du volant.
|
||||
|
||||
---
|
||||
|
||||
## Brochage Waveshare RP2350-USB-A
|
||||
|
||||
| Broche | Fonction | Cible |
|
||||
| :--- | :--- | :--- |
|
||||
| **USB-A (GP12/GP13)** | USB Host PIO-USB | Volant Logitech G29 (mode PS4) |
|
||||
| **GP0 (Serial1 TX)** | CRSF TX `420 000 bauds` | RadioMaster Nomad (Baie JR / RX) |
|
||||
| **GP1 (Serial1 RX)** | CRSF RX `420 000 bauds` | RadioMaster Nomad (Télémétrie) |
|
||||
| **GP4 (Serial2 TX)** | Pont Cockpit TX `460 800 bauds` | Radxa Zero 3W RX (`radxa_g29_relay.py`) |
|
||||
| **GP5 (Serial2 RX)** | Pont Cockpit RX `460 800 bauds` | Radxa Zero 3W TX (`radxa_g29_relay.py`) |
|
||||
| **USB-C natif** | Série CDC + Flash | Liaison directe alternative ou debug |
|
||||
| **GP16** | LED RGB WS2812 | État armement / rapport engagé / failsafe |
|
||||
|
||||
---
|
||||
|
||||
## Commandes Série (`Serial` & `Serial2`)
|
||||
|
||||
| Commande | Description |
|
||||
| :--- | :--- |
|
||||
| `$HT,<pan>,<tilt>,<roll>` | Injecte le Head-Tracking sur `CH6, CH7, CH8` (`172..1811`) |
|
||||
| `D=<0..255>` | Règle la dureté du ressort FFB (sauvegarde différée si armé) |
|
||||
| `T=<0..100>` | Règle l'intensité des vibrations haptiques (`0` = désactivé) |
|
||||
| `P=<40..900>` | Plage de rotation du volant en degrés (désarmé uniquement) |
|
||||
| `X=<0.0..0.8>` | Expo volant (désarmé uniquement) |
|
||||
| `V/A/F/E=<ch>` | Remappage des canaux Volant / Accel / Frein / Embrayage |
|
||||
| `W=<0\|1>` | Active/désactive l'écho des trames `$G29`/`$CRSF` sur USB-C (`1` par défaut) |
|
||||
| `?` / `S` / `R` / `B` | Afficher config / Sauvegarder EEPROM / Reset usine / BOOTSEL |
|
||||
|
||||
---
|
||||
|
||||
## Compilation (`arduino-cli`)
|
||||
|
||||
```bash
|
||||
arduino-cli compile --fqbn rp2040:rp2040:waveshare_rp2350_plus:usbstack=tinyusb --build-path ./build .
|
||||
```
|
||||
+223
-14
@@ -18,10 +18,22 @@
|
||||
#define G29_PID_PS4 0xC260 // G29 en mode PS4 (le mode PS3 = 0xC24F a un autre format de rapport)
|
||||
#define G29_REPORT_ID 0x01
|
||||
|
||||
// Masques additionnels dans report[5] (D-Pad et boutons façade en mode PS4)
|
||||
#define DPAD_MASK_B5 0x0F // Quartet bas : 0=Haut, 2=Droite, 4=Bas, 6=Gauche, 8=Neutre
|
||||
#define BOUTON_CARRE_MASK 0x10 // Carré [□]
|
||||
#define BOUTON_CROIX_MASK 0x20 // Croix [✕]
|
||||
#define BOUTON_ROND_MASK 0x40 // Rond [○]
|
||||
#define BOUTON_TRIANGLE_MASK 0x80 // Triangle [△]
|
||||
|
||||
// Masques des palettes et boutons dans report[6]
|
||||
#define PALETTE_MOINS_MASK 0x01 // L1 (Palette gauche : Rétrograder)
|
||||
#define PALETTE_PLUS_MASK 0x02 // R1 (Palette droite : Monter un rapport)
|
||||
#define BOUTON_L2_MASK 0x04 // L2
|
||||
#define BOUTON_ARM_MASK 0x08 // R2 (Bascule Armé / Désarmé)
|
||||
#define BOUTON_SHARE_MASK 0x10 // Share
|
||||
#define BOUTON_OPTIONS_MASK 0x20 // Options
|
||||
#define BOUTON_L3_MASK 0x40 // L3
|
||||
#define BOUTON_R3_MASK 0x80 // R3
|
||||
|
||||
// Masques additionnels dans report[54] (Molette et boutons + / - / Enter en mode PS4 PID 0xC260)
|
||||
#define DIAL_ENTER_MASK_B54 0x01 // Bouton central de la molette
|
||||
@@ -30,16 +42,46 @@
|
||||
#define BOUTON_MOINS_MASK_B54 0x08 // Bouton [-] (Dureté -)
|
||||
#define BOUTON_PLUS_MASK_B54 0x10 // Bouton [+] (Dureté +)
|
||||
|
||||
// Masques de secours dans report[7] (Mode PC / rapport court)
|
||||
// Masques de secours dans report[7] (Mode PC / rapport court + bouton PS)
|
||||
#define BOUTON_PS_MASK_B7 0x01 // Bouton PS
|
||||
#define BOUTON_PLUS_MASK_B7 0x04 // Bouton [+]
|
||||
#define BOUTON_MOINS_MASK_B7 0x08 // Bouton [-]
|
||||
#define DIAL_CW_MASK_B7 0x10 // Molette sens horaire
|
||||
#define DIAL_CCW_MASK_B7 0x20 // Molette sens anti-horaire
|
||||
#define DIAL_ENTER_MASK_B7 0x40 // Bouton central de la molette
|
||||
|
||||
// Liaison série bidirectionnelle vers le pont Radxa Zero 3W / SteamFrame FPV Cockpit
|
||||
#define PIN_UART_BRIDGE_TX 4
|
||||
#define PIN_UART_BRIDGE_RX 5
|
||||
#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
|
||||
|
||||
// Bits d'événements boutons (Cœur 1 -> Cœur 0)
|
||||
enum CockpitBoutonBit : uint16_t {
|
||||
EVT_BTN_CROSS = (1 << 0),
|
||||
EVT_BTN_CIRCLE = (1 << 1),
|
||||
EVT_BTN_SQUARE = (1 << 2),
|
||||
EVT_BTN_TRIANGLE = (1 << 3),
|
||||
EVT_BTN_SHARE = (1 << 4),
|
||||
EVT_BTN_OPTIONS = (1 << 5),
|
||||
EVT_BTN_PS = (1 << 6),
|
||||
EVT_BTN_L3 = (1 << 7),
|
||||
EVT_BTN_R3 = (1 << 8),
|
||||
EVT_BTN_DPAD_UP = (1 << 9),
|
||||
EVT_BTN_DPAD_DOWN = (1 << 10),
|
||||
EVT_BTN_DPAD_LEFT = (1 << 11),
|
||||
EVT_BTN_DPAD_RIGHT = (1 << 12),
|
||||
};
|
||||
|
||||
// Armement ELRS : AUX1 = canal 5 (réservé, ne peut pas être mappé ailleurs)
|
||||
#define CANAL_ARM 5
|
||||
|
||||
// Head-Tracking Steam Frame : AUX2..AUX4 = canaux 6, 7, 8 (Pan, Tilt, Roll)
|
||||
#define CANAL_HT_PAN 6
|
||||
#define CANAL_HT_TILT 7
|
||||
#define CANAL_HT_ROLL 8
|
||||
|
||||
// Bornes officielles CRSF
|
||||
#define CRSF_VAL_MIN 172 // ~988 us
|
||||
#define CRSF_VAL_MID 992 // 1500 us (Neutre)
|
||||
@@ -167,11 +209,25 @@ volatile int32_t dernierVolantCentre = 0; // Position mesurée du volant par ra
|
||||
volatile bool murActifDroite = false;
|
||||
volatile bool murActifGauche = false;
|
||||
|
||||
char serialBuffer[32];
|
||||
// Variables de télémétrie, Head-Tracking & événements boutons vers SteamFrame FPV (Radxa / USB)
|
||||
volatile uint16_t evtBoutonsMasque = 0;
|
||||
volatile bool cockpitEtatModifie = true;
|
||||
volatile uint16_t etatBoutonsCockpitPrec = 0xFFFF; // Ignore tout bouton maintenu au branchement
|
||||
volatile uint8_t etatDpadPrec = 0xFF;
|
||||
bool cockpitEchoUSB = true; // Actif par défaut pour liaison directe USB-C (/dev/ttyACM0)
|
||||
uint32_t dernierPaquetHT_ms = 0;
|
||||
bool htActif = false;
|
||||
|
||||
char serialBuffer[64];
|
||||
uint8_t serialBufferIdx = 0;
|
||||
char serial2Buffer[64];
|
||||
uint8_t serial2BufferIdx = 0;
|
||||
|
||||
void reinitialiserCanauxCRSF() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (htActif && (i == (CANAL_HT_PAN - 1) || i == (CANAL_HT_TILT - 1) || i == (CANAL_HT_ROLL - 1))) {
|
||||
continue;
|
||||
}
|
||||
crsf_channels[i] = CRSF_VAL_MID;
|
||||
}
|
||||
crsf_channels[CANAL_ARM - 1] = CRSF_VAL_MIN; // Toujours désarmé par défaut
|
||||
@@ -415,28 +471,52 @@ void traiterLigneSerie(char* commande) {
|
||||
int val = atoi(&commande[2]);
|
||||
if (val >= 0 && val <= 100) {
|
||||
configSysteme.intensiteVibration = (uint8_t)val; // Atomique sur ARM Cortex-M33
|
||||
cockpitEtatModifie = true;
|
||||
demanderOuExecuterSauvegarde();
|
||||
afficherConfiguration();
|
||||
} else {
|
||||
Serial.println("!! Vibrations (T) doit etre entre 0 et 100% !!");
|
||||
}
|
||||
} else if (periph == 'W' || periph == 'w') {
|
||||
cockpitEchoUSB = (atoi(&commande[2]) != 0);
|
||||
Serial.printf(">> [COCKPIT] Echo trames $G29 sur USB : %s\n", cockpitEchoUSB ? "ON" : "OFF");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Injection Head-Tracking depuis SteamFrame FPV : $HT,<pan>,<tilt>,<roll> (172..1811)
|
||||
if (strncmp(commande, "$HT,", 4) == 0) {
|
||||
int pan = CRSF_VAL_MID, tilt = CRSF_VAL_MID, roll = CRSF_VAL_MID;
|
||||
if (sscanf(commande + 4, "%d,%d,%d", &pan, &tilt, &roll) == 3) {
|
||||
crsf_channels[CANAL_HT_PAN - 1] = (uint16_t)constrain(pan, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
crsf_channels[CANAL_HT_TILT - 1] = (uint16_t)constrain(tilt, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
crsf_channels[CANAL_HT_ROLL - 1] = (uint16_t)constrain(roll, CRSF_VAL_MIN, CRSF_VAL_MAX);
|
||||
dernierPaquetHT_ms = millis();
|
||||
htActif = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lireFluxSerie(Stream& port, char* buf, uint8_t& idx, size_t maxLen) {
|
||||
while (port.available() > 0) {
|
||||
char c = (char)port.read();
|
||||
if (c == '\n' || c == '\r') {
|
||||
if (idx > 0) {
|
||||
buf[idx] = '\0';
|
||||
traiterLigneSerie(buf);
|
||||
idx = 0;
|
||||
}
|
||||
} else if (idx < maxLen - 1) {
|
||||
buf[idx++] = c;
|
||||
} else {
|
||||
idx = 0; // Ligne trop longue, reset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void verifierCommandesSerie() {
|
||||
while (Serial.available() > 0) {
|
||||
char c = (char)Serial.read();
|
||||
if (c == '\n' || c == '\r') {
|
||||
if (serialBufferIdx > 0) {
|
||||
serialBuffer[serialBufferIdx] = '\0';
|
||||
traiterLigneSerie(serialBuffer);
|
||||
serialBufferIdx = 0;
|
||||
}
|
||||
} else if (serialBufferIdx < sizeof(serialBuffer) - 1) {
|
||||
serialBuffer[serialBufferIdx++] = c;
|
||||
}
|
||||
}
|
||||
lireFluxSerie(Serial, serialBuffer, serialBufferIdx, sizeof(serialBuffer));
|
||||
lireFluxSerie(Serial2, serial2Buffer, serial2BufferIdx, sizeof(serial2Buffer));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -551,6 +631,10 @@ void setup() {
|
||||
Serial1.setRX(1);
|
||||
Serial1.begin(420000);
|
||||
|
||||
Serial2.setTX(PIN_UART_BRIDGE_TX);
|
||||
Serial2.setRX(PIN_UART_BRIDGE_RX);
|
||||
Serial2.begin(UART_BRIDGE_BAUD);
|
||||
|
||||
Serial.println("\n--- WAVESHARE RP2350-USB-A PRETE ---");
|
||||
afficherConfiguration();
|
||||
|
||||
@@ -677,6 +761,21 @@ void traiterTelemetrieCRSF() {
|
||||
else if ((frameType == 0x7F || frameType == 0x2A) && paquetLongueurAttendue >= 3) {
|
||||
rugositeTerrainExterne = crsfRxBuffer[3];
|
||||
}
|
||||
|
||||
// Relais de la télémétrie CRSF valide vers SteamFrame FPV (OSD via Radxa/USB)
|
||||
size_t totalLen = (size_t)paquetLongueurAttendue + 2;
|
||||
if (totalLen <= 64) {
|
||||
char bufCrsf[140];
|
||||
memcpy(bufCrsf, "$CRSF,", 6);
|
||||
static const char HEX_DIGITS[] = "0123456789ABCDEF";
|
||||
for (size_t i = 0; i < totalLen; i++) {
|
||||
uint8_t byteVal = crsfRxBuffer[i];
|
||||
bufCrsf[6 + i * 2] = HEX_DIGITS[(byteVal >> 4) & 0x0F];
|
||||
bufCrsf[6 + i * 2 + 1] = HEX_DIGITS[byteVal & 0x0F];
|
||||
}
|
||||
bufCrsf[6 + totalLen * 2] = '\0';
|
||||
emettreLigneCockpit(bufCrsf);
|
||||
}
|
||||
}
|
||||
|
||||
crsfRxIdx = 0;
|
||||
@@ -707,13 +806,83 @@ void traiterTelemetrieCRSF() {
|
||||
}
|
||||
}
|
||||
|
||||
void emettreLigneCockpit(const char* ligne) {
|
||||
Serial2.println(ligne);
|
||||
if (cockpitEchoUSB) {
|
||||
Serial.println(ligne);
|
||||
}
|
||||
}
|
||||
|
||||
void gererSortieCockpit() {
|
||||
static uint32_t dernierEnvoiCockpit_ms = 0;
|
||||
|
||||
// 1. Émission immédiate des événements boutons (consommation atomique inter-cœurs)
|
||||
uint16_t evts = __atomic_exchange_n(&evtBoutonsMasque, 0, __ATOMIC_ACQ_REL);
|
||||
if (evts != 0) {
|
||||
struct BoutonNom { uint16_t bit; const char* nom; };
|
||||
static const BoutonNom TABLE_BOUTONS[] = {
|
||||
{ EVT_BTN_CROSS, "CROSS" },
|
||||
{ EVT_BTN_CIRCLE, "CIRCLE" },
|
||||
{ EVT_BTN_SQUARE, "SQUARE" },
|
||||
{ EVT_BTN_TRIANGLE, "TRIANGLE" },
|
||||
{ EVT_BTN_SHARE, "SHARE" },
|
||||
{ EVT_BTN_OPTIONS, "OPTIONS" },
|
||||
{ EVT_BTN_PS, "PS" },
|
||||
{ EVT_BTN_L3, "L3" },
|
||||
{ EVT_BTN_R3, "R3" },
|
||||
{ EVT_BTN_DPAD_UP, "DPAD_UP" },
|
||||
{ EVT_BTN_DPAD_DOWN, "DPAD_DOWN" },
|
||||
{ EVT_BTN_DPAD_LEFT, "DPAD_LEFT" },
|
||||
{ EVT_BTN_DPAD_RIGHT, "DPAD_RIGHT" },
|
||||
};
|
||||
char bufEvt[32];
|
||||
for (size_t i = 0; i < sizeof(TABLE_BOUTONS) / sizeof(TABLE_BOUTONS[0]); i++) {
|
||||
if (evts & TABLE_BOUTONS[i].bit) {
|
||||
snprintf(bufEvt, sizeof(bufEvt), "$G29_EVT,BTN=%s", TABLE_BOUTONS[i].nom);
|
||||
emettreLigneCockpit(bufEvt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Trame d'état cockpit à 20 Hz ou immédiatement sur changement critique
|
||||
uint32_t now = millis();
|
||||
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];
|
||||
snprintf(bufEtat, sizeof(bufEtat),
|
||||
"$G29,ARM=%d,GEAR=%d,THROT=%d,BRAKE=%d,FFB=%d,VIB=%d,FAIL=%d",
|
||||
estArme ? 1 : 0,
|
||||
(int)rapportEngage,
|
||||
throt,
|
||||
brake,
|
||||
(int)configSysteme.forceRessort,
|
||||
(int)configSysteme.intensiteVibration,
|
||||
failsafeActif ? 1 : 0);
|
||||
emettreLigneCockpit(bufEtat);
|
||||
}
|
||||
}
|
||||
|
||||
void gererTimeoutHeadTracking() {
|
||||
if (htActif && (millis() - dernierPaquetHT_ms > TIMEOUT_HT_MS)) {
|
||||
htActif = false;
|
||||
crsf_channels[CANAL_HT_PAN - 1] = CRSF_VAL_MID;
|
||||
crsf_channels[CANAL_HT_TILT - 1] = CRSF_VAL_MID;
|
||||
crsf_channels[CANAL_HT_ROLL - 1] = CRSF_VAL_MID;
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
rp2040.wdt_reset();
|
||||
}
|
||||
verifierCommandesSerie();
|
||||
gererTimeoutHeadTracking();
|
||||
traiterTelemetrieCRSF();
|
||||
gererSortieCockpit();
|
||||
|
||||
static int8_t dernierRapportLog = 0xFF;
|
||||
static uint32_t dernierTickAnimNeo_ms = 0;
|
||||
@@ -1223,6 +1392,10 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
|
||||
dialPlusDejaEnfonce = true;
|
||||
dialMoinsDejaEnfonce = true;
|
||||
dialEnterDejaEnfonce = true;
|
||||
etatBoutonsCockpitPrec = 0xFFFF;
|
||||
etatDpadPrec = 0xFF;
|
||||
evtBoutonsMasque = 0;
|
||||
cockpitEtatModifie = true;
|
||||
momentConnexionUSB_ms = millis();
|
||||
dernierRapportUSB_ms = millis();
|
||||
volant_est_pret = true;
|
||||
@@ -1284,6 +1457,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
rugositeTerrainExterne = 0;
|
||||
momentDesarmement_ms = millis();
|
||||
momentArmement_ms = 0;
|
||||
cockpitEtatModifie = true;
|
||||
} else if (etapeInitMoteur < ETAPES_INIT_FFB_TOTAL) {
|
||||
logArmRequis = 3;
|
||||
} else if (rapportEngage == 0 && accelRaw <= DEADZONE_PEDALE) {
|
||||
@@ -1291,6 +1465,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
logArmRequis = 1;
|
||||
momentArmement_ms = millis();
|
||||
momentDesarmement_ms = 0;
|
||||
cockpitEtatModifie = true;
|
||||
} else {
|
||||
logArmRequis = 2;
|
||||
}
|
||||
@@ -1305,6 +1480,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
int8_t ancienRapport = rapportEngage;
|
||||
rapportEngage++;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
if (estArme && ancienRapport >= 0) {
|
||||
momentDernierChocRapport_ms = millis();
|
||||
directionDernierChocRapport = 1; // À-coup sec vers la droite
|
||||
@@ -1319,6 +1495,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
if (rapportEngage > -1 && !(rapportEngage <= 0 && accelRaw > DEADZONE_PEDALE)) {
|
||||
rapportEngage--;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
if (estArme && rapportEngage >= 0) {
|
||||
momentDernierChocRapport_ms = millis();
|
||||
directionDernierChocRapport = -1; // À-coup sec vers la gauche
|
||||
@@ -1351,6 +1528,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
majRessortRequise = true;
|
||||
logDureteRequis = true;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
momentDernierChangementDurete_ms = millis();
|
||||
dialPlusDejaEnfonce = true;
|
||||
} else if (!dialPlusActuel && dialPlusDejaEnfonce) {
|
||||
@@ -1363,6 +1541,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
majRessortRequise = true;
|
||||
logDureteRequis = true;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
momentDernierChangementDurete_ms = millis();
|
||||
dialMoinsDejaEnfonce = true;
|
||||
} else if (!dialMoinsActuel && dialMoinsDejaEnfonce) {
|
||||
@@ -1375,6 +1554,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
else configSysteme.intensiteVibration = 100;
|
||||
logVibrationRequis = true;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
momentDernierChangementVib_ms = millis();
|
||||
btnPlusDejaEnfonce = true;
|
||||
} else if (!btnPlusActuel && btnPlusDejaEnfonce) {
|
||||
@@ -1387,12 +1567,41 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
||||
else configSysteme.intensiteVibration = 0;
|
||||
logVibrationRequis = true;
|
||||
majLedRequise = true;
|
||||
cockpitEtatModifie = true;
|
||||
momentDernierChangementVib_ms = millis();
|
||||
btnMoinsDejaEnfonce = true;
|
||||
} else if (!btnMoinsActuel && btnMoinsDejaEnfonce) {
|
||||
btnMoinsDejaEnfonce = false;
|
||||
}
|
||||
|
||||
// Détection des boutons libres du G29 pour piloter le casque SteamFrame FPV
|
||||
uint8_t b5 = report[5];
|
||||
uint16_t btnsActuels = 0;
|
||||
if (b5 & BOUTON_CROIX_MASK) btnsActuels |= EVT_BTN_CROSS;
|
||||
if (b5 & BOUTON_ROND_MASK) btnsActuels |= EVT_BTN_CIRCLE;
|
||||
if (b5 & BOUTON_CARRE_MASK) btnsActuels |= EVT_BTN_SQUARE;
|
||||
if (b5 & BOUTON_TRIANGLE_MASK) btnsActuels |= EVT_BTN_TRIANGLE;
|
||||
if (boutonsEpaule & BOUTON_SHARE_MASK) btnsActuels |= EVT_BTN_SHARE;
|
||||
if (boutonsEpaule & BOUTON_OPTIONS_MASK) btnsActuels |= EVT_BTN_OPTIONS;
|
||||
if (b7 & BOUTON_PS_MASK_B7) btnsActuels |= EVT_BTN_PS;
|
||||
if (boutonsEpaule & BOUTON_L3_MASK) btnsActuels |= EVT_BTN_L3;
|
||||
if (boutonsEpaule & BOUTON_R3_MASK) btnsActuels |= EVT_BTN_R3;
|
||||
|
||||
uint8_t dpadActuel = (b5 & DPAD_MASK_B5);
|
||||
if (etatDpadPrec != 0xFF && dpadActuel != etatDpadPrec) {
|
||||
if (dpadActuel == 0) btnsActuels |= EVT_BTN_DPAD_UP;
|
||||
else if (dpadActuel == 4) btnsActuels |= EVT_BTN_DPAD_DOWN;
|
||||
else if (dpadActuel == 6) btnsActuels |= EVT_BTN_DPAD_LEFT;
|
||||
else if (dpadActuel == 2) btnsActuels |= EVT_BTN_DPAD_RIGHT;
|
||||
}
|
||||
etatDpadPrec = dpadActuel;
|
||||
|
||||
uint16_t frontsMontants = btnsActuels & ~etatBoutonsCockpitPrec;
|
||||
if (frontsMontants != 0) {
|
||||
__atomic_fetch_or(&evtBoutonsMasque, frontsMontants, __ATOMIC_ACQ_REL);
|
||||
}
|
||||
etatBoutonsCockpitPrec = btnsActuels & 0x01FF; // Mémorise uniquement les boutons (pas le D-Pad)
|
||||
|
||||
// Sauvegarde en Flash protégée : nécessite un appui continu de 2 secondes sur Enter
|
||||
// véhicule à l'arrêt et désarmé, pour interdire tout gel Flash intempestif en manipulant la molette.
|
||||
static uint32_t debutAppuiEnter_ms = 0;
|
||||
|
||||
Reference in new issue
Block a user