AndruinoXTrail/firmware/XTrailMirrors/config.h
kykaevv f182df290f Add T31 CAN fold-on-lock Arduino firmware.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 13:26:49 +03:00

40 lines
1.5 KiB
C

#pragma once
#include "can_ids.h"
// Fold actuator:
// FOLD_VIA_RELAY — emulate the factory fold switch (T31: analog in the door)
// FOLD_VIA_CAN — replay frames captured with CanSniffer while pressing
// the door fold button. On T31 that button is not on OBD CAN.
#define FOLD_VIA_RELAY 1
#define FOLD_VIA_CAN 2
#define FOLD_ACTUATOR FOLD_VIA_RELAY
// Relay pins. Typical Arduino relay module is active LOW.
static const uint8_t PIN_RELAY_FOLD = 7;
static const uint8_t PIN_RELAY_UNFOLD = 8;
static const bool RELAY_ACTIVE_LOW = true;
// Mirror motors need ~8 s. Do not overlap fold/unfold.
static const uint16_t MIRROR_PULSE_MS = 8000;
static const uint16_t LOCK_STABLE_MS = 400;
static const uint16_t ACTION_COOLDOWN_MS = 12000;
// Fold only after ignition is off (do not fold while driving).
static const bool REQUIRE_IGN_OFF = true;
static const unsigned long SERIAL_BAUD = 115200;
// Fill these after a successful CanSniffer capture of the fold button.
// Leave FOLD_CAN_FRAME_COUNT = 0 until you have real payloads from THIS car.
static const unsigned long FOLD_CAN_ID = 0x000;
static const uint8_t FOLD_CAN_LEN = 8;
static const uint8_t FOLD_CAN_DATA[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static const unsigned long UNFOLD_CAN_ID = 0x000;
static const uint8_t UNFOLD_CAN_LEN = 8;
static const uint8_t UNFOLD_CAN_DATA[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static const uint8_t FOLD_CAN_FRAME_COUNT = 0; // set to 10+ after capture
static const uint16_t FOLD_CAN_INTERVAL_MS = 40;