mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(dial): retablir la molette et boutons +/- sur report[54] et securiser la sauvegarde
This commit is contained in:
1 parent
1431b2e5ee
commit
2938286897
1 file changed
+33
-12
+33
-12
@@ -23,12 +23,19 @@
|
|||||||
#define PALETTE_PLUS_MASK 0x02 // R1 (Palette droite : Monter un rapport)
|
#define PALETTE_PLUS_MASK 0x02 // R1 (Palette droite : Monter un rapport)
|
||||||
#define BOUTON_ARM_MASK 0x08 // R2 (Bascule Armé / Désarmé)
|
#define BOUTON_ARM_MASK 0x08 // R2 (Bascule Armé / Désarmé)
|
||||||
|
|
||||||
// Masques additionnels dans report[7] (Molette et boutons + / - / Enter en mode PS4)
|
// Masques additionnels dans report[54] (Molette et boutons + / - / Enter en mode PS4 PID 0xC260)
|
||||||
#define BOUTON_PLUS_MASK 0x04 // Bouton [+] (Dureté +)
|
#define DIAL_ENTER_MASK_B54 0x01 // Bouton central de la molette
|
||||||
#define BOUTON_MOINS_MASK 0x08 // Bouton [-] (Dureté -)
|
#define DIAL_CCW_MASK_B54 0x02 // Molette sens anti-horaire (Dureté -)
|
||||||
#define DIAL_CW_MASK 0x10 // Molette sens horaire (Dureté +)
|
#define DIAL_CW_MASK_B54 0x04 // Molette sens horaire (Dureté +)
|
||||||
#define DIAL_CCW_MASK 0x20 // Molette sens anti-horaire (Dureté -)
|
#define BOUTON_MOINS_MASK_B54 0x08 // Bouton [-] (Dureté -)
|
||||||
#define DIAL_ENTER_MASK 0x40 // Bouton central de la molette (Sauvegarde Flash)
|
#define BOUTON_PLUS_MASK_B54 0x10 // Bouton [+] (Dureté +)
|
||||||
|
|
||||||
|
// Masques de secours dans report[7] (Mode PC / rapport court)
|
||||||
|
#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
|
||||||
|
|
||||||
// Armement ELRS : AUX1 = canal 5 (réservé, ne peut pas être mappé ailleurs)
|
// Armement ELRS : AUX1 = canal 5 (réservé, ne peut pas être mappé ailleurs)
|
||||||
#define CANAL_ARM 5
|
#define CANAL_ARM 5
|
||||||
@@ -1201,11 +1208,17 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
|||||||
paletteMoinsDejaEnfoncee = false;
|
paletteMoinsDejaEnfoncee = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Réglage de la dureté du volant à la volée via la molette ou boutons [+] / [-] (report[7])
|
// Réglage de la dureté du volant à la volée via la molette ou boutons [+] / [-]
|
||||||
|
// Sur G29 en mode PS4 (PID 0xC260), la molette et les boutons +/- sont situés dans report[54].
|
||||||
|
// On conserve également report[7] comme solution de secours universelle.
|
||||||
|
uint8_t b54 = (len > 54) ? report[54] : 0;
|
||||||
uint8_t b7 = (len > 7) ? report[7] : 0;
|
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 dialPlusActuel = (b54 & DIAL_CW_MASK_B54) || (b54 & BOUTON_PLUS_MASK_B54) ||
|
||||||
bool dialEnterActuel = (b7 & DIAL_ENTER_MASK);
|
(b7 & DIAL_CW_MASK_B7) || (b7 & BOUTON_PLUS_MASK_B7);
|
||||||
|
bool dialMoinsActuel = (b54 & DIAL_CCW_MASK_B54) || (b54 & BOUTON_MOINS_MASK_B54) ||
|
||||||
|
(b7 & DIAL_CCW_MASK_B7) || (b7 & BOUTON_MOINS_MASK_B7);
|
||||||
|
bool dialEnterActuel = (b54 & DIAL_ENTER_MASK_B54) || (b7 & DIAL_ENTER_MASK_B7);
|
||||||
|
|
||||||
if (dialPlusActuel && !dialPlusDejaEnfonce) {
|
if (dialPlusActuel && !dialPlusDejaEnfonce) {
|
||||||
if (configSysteme.forceRessort <= 245) configSysteme.forceRessort += 10;
|
if (configSysteme.forceRessort <= 245) configSysteme.forceRessort += 10;
|
||||||
@@ -1229,10 +1242,18 @@ void __not_in_flash_func(tuh_hid_report_received_cb)(uint8_t dev_addr, uint8_t i
|
|||||||
dialMoinsDejaEnfonce = false;
|
dialMoinsDejaEnfonce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialEnterActuel && !dialEnterDejaEnfonce) {
|
// 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;
|
||||||
|
if (dialEnterActuel) {
|
||||||
|
if (debutAppuiEnter_ms == 0) {
|
||||||
|
debutAppuiEnter_ms = millis();
|
||||||
|
} else if (!estArme && accelRaw <= DEADZONE_PEDALE && (millis() - debutAppuiEnter_ms >= 2000) && !dialEnterDejaEnfonce) {
|
||||||
demandeSauvegardeEEPROM = true;
|
demandeSauvegardeEEPROM = true;
|
||||||
dialEnterDejaEnfonce = true;
|
dialEnterDejaEnfonce = true;
|
||||||
} else if (!dialEnterActuel && dialEnterDejaEnfonce) {
|
}
|
||||||
|
} else {
|
||||||
|
debutAppuiEnter_ms = 0;
|
||||||
dialEnterDejaEnfonce = false;
|
dialEnterDejaEnfonce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user