Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- // Init ELM327
- const char* cmds[] = {"ATD\r", "ATZ\r", "ATE0\r", "ATL0\r", "ATS0\r", "ATH0\r", "ATSP0\r"};
- for (const char* cmd : cmds) {
- pRx->writeValue(cmd, strlen(cmd));
- delay(300);
- }
- // Lecture baro initiale
- pRx->writeValue("0133\r", 6);
- delay(500);
- }
- void loop() {
- static unsigned long lastRequest = 0;
- static unsigned long lastBaro = 0;
- unsigned long now = millis();
- // Envoi MAP (010B) toutes les 50ms - mitraillette
- if (now - lastRequest > 50) {
- pRx->writeValue("010B\r", 6);
- lastRequest = now;
- }
- // RequĂȘte BARO (0133) toutes les 60 secondes
- if (now - lastBaro > 60000) {
- pRx->writeValue("0133\r", 6);
- lastBaro = now;
- }
- if (notificationReceived) {
- notificationReceived = false;
- // Calcul boost PSI
- float boostPsi = (mapKpa - baroKpa) / 6.895f;
- for (int i = 0; i < 4; i++) psi_older[i] = psi_older[i + 1];
- psi_older[4] = boostPsi;
- float avgPsi = 0;
- for (int i = 0; i < 5; i++) avgPsi += psi_older[i];
- avgPsi /= 5;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement