diff --git a/.gitignore b/.gitignore index 7a60b85..8cbfc39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ *.pyc +build/ diff --git a/g29_crsf.ino b/g29_crsf.ino index 17470a3..fa0b568 100644 --- a/g29_crsf.ino +++ b/g29_crsf.ino @@ -23,12 +23,12 @@ #define PALETTE_PLUS_MASK 0x02 // R1 (Palette droite : Monter un rapport) #define BOUTON_ARM_MASK 0x08 // R2 (Bascule Armé / Désarmé) -// Masques additionnels dans report[7] (Molette et boutons + / - / Enter) -#define BOUTON_PLUS_MASK 0x04 // Bouton [+] (Dureté +) +// Masques additionnels dans report[54] (Molette et boutons + / - / Enter en mode PS4) +#define DIAL_ENTER_MASK 0x01 // Bouton central de la molette (Sauvegarde Flash) +#define DIAL_CCW_MASK 0x02 // Molette sens anti-horaire (Dureté -) +#define DIAL_CW_MASK 0x04 // Molette sens horaire (Dureté +) #define BOUTON_MOINS_MASK 0x08 // Bouton [-] (Dureté -) -#define DIAL_CW_MASK 0x10 // Molette sens horaire (Dureté +) -#define DIAL_CCW_MASK 0x20 // Molette sens anti-horaire (Dureté -) -#define DIAL_ENTER_MASK 0x40 // Bouton central de la molette (Sauvegarde Flash) +#define BOUTON_PLUS_MASK 0x10 // Bouton [+] (Dureté +) // Armement ELRS : AUX1 = canal 5 (réservé, ne peut pas être mappé ailleurs) #define CANAL_ARM 5 @@ -200,7 +200,7 @@ void afficherConfiguration() { 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("Vibrations (T) : %d%% [T=0..100] (Mix 12Hz/60Hz + Telemetrie)\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), ?"); + 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), ?"); } void chargerConfiguration() { @@ -252,6 +252,12 @@ void traiterLigneSerie(char* commande) { afficherConfiguration(); return; } + if (commande[0] == 'B' || commande[0] == 'b') { + Serial.println(">> Redemarrage en mode BOOTSEL..."); + Serial.flush(); + rp2040.rebootToBootloader(); + return; + } if (commande[0] == 'S' || commande[0] == 's') { sauvegarderConfiguration(); return; @@ -909,7 +915,7 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i if (dev_addr != g29_dev_addr || instance != g29_instance) { return; // Ne pas réarmer la réception d'un périphérique étranger } - if (len < 51 || report[0] != G29_REPORT_ID) { + if (len < 55 || report[0] != G29_REPORT_ID) { compteurRapportsRejetes++; tuh_hid_receive_report(dev_addr, instance); return; @@ -990,10 +996,10 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i } // Réglage de la dureté du volant à la volée via la molette ou boutons [+] / [-] - uint8_t b7 = (len > 7) ? report[7] : 0; - bool dialPlusActuel = (b7 & DIAL_CW_MASK) || (b7 & BOUTON_PLUS_MASK); - bool dialMoinsActuel = (b7 & DIAL_CCW_MASK) || (b7 & BOUTON_MOINS_MASK); - bool dialEnterActuel = (b7 & DIAL_ENTER_MASK); + uint8_t b54 = (len > 54) ? report[54] : 0; + bool dialPlusActuel = (b54 & DIAL_CW_MASK) || (b54 & BOUTON_PLUS_MASK); + bool dialMoinsActuel = (b54 & DIAL_CCW_MASK) || (b54 & BOUTON_MOINS_MASK); + bool dialEnterActuel = (b54 & DIAL_ENTER_MASK); if (dialPlusActuel && !dialPlusDejaEnfonce) { if (configSysteme.forceRessort <= 245) configSysteme.forceRessort += 10;