; =============================================================================
; LilyGo T-Echo Card — Meck variant configuration
;
; nRF52840 + SX1262 (HPB16B3) + SSD1315 OLED (72×40) + L76K GPS
; + MAX98357 Speaker + MP34DT05 PDM Mic + ICM20948 IMU + Solar + NFC
;
; Platform: nRF52 (Adafruit nRF52 Arduino)
; =============================================================================

; --- Base configuration for all T-Echo Card builds ---
[lilygo_techo_card]
extends = nrf52_base
platform = https://github.com/maxgerhardt/platform-nordicnrf52.git
board = lilygo_techo_card
board_check = false
extra_scripts =
  create-uf2.py
build_flags = ${nrf52_base.build_flags}
  -I variants/lilygo_techo_card
  -I src/helpers/ui
  -D LILYGO_TECHO_CARD
  -D NRF52_POWER_MANAGEMENT
  -D WIRE_INTERFACES_COUNT=1
  -D SPI_INTERFACES_COUNT=1
  -D ps_calloc=calloc
  ; I2C
  -D PIN_BOARD_SDA=36
  -D PIN_BOARD_SCL=34
  -D PIN_WIRE_SDA=36
  -D PIN_WIRE_SCL=34
  -D PIN_SPI_MISO=17
  -D PIN_SPI_SCK=13
  -D PIN_SPI_MOSI=15
  -D USE_LFXO
  -D LED_BLUE=39
  -D LED_BUILTIN=39
  -D LED_STATE_ON=1
  -D PINS_COUNT=48
  -D NUM_DIGITAL_PINS=48
  -D NUM_ANALOG_INPUTS=6
  -D PIN_SERIAL1_RX=21
  -D PIN_SERIAL1_TX=19
  ; LoRa SX1262 (HPB16B3 module)
  -D RADIO_CLASS=CustomSX1262
  -D WRAPPER_CLASS=CustomSX1262Wrapper
  -D P_LORA_NSS=11
  -D P_LORA_DIO_1=40
  -D P_LORA_RESET=7
  -D P_LORA_BUSY=14
  -D P_LORA_SCLK=13
  -D P_LORA_MISO=17
  -D P_LORA_MOSI=15
  -D LORA_TX_POWER=22
  -D SX126X_CURRENT_LIMIT=140
  -D SX126X_RX_BOOSTED_GAIN=1
  -D SX126X_DIO2_AS_RF_SWITCH=1
  ; Display — not defined in base; added per-env when needed
  ; (companion BLE skips display — phone app is the UI)
  -D PIN_OLED_RESET=-1
  ; GPS — L76K
  -D HAS_GPS=1
  -D PIN_GPS_TX=19
  -D PIN_GPS_RX=21
  -D PIN_GPS_EN=47
  -D GPS_EN_ACTIVE=HIGH
  -D GPS_BAUDRATE=9600
  -D ENV_INCLUDE_GPS=1
  ; Battery ADC
  -D PIN_VBAT_READ=2
  ; User button
  -D PIN_USER_BTN=42
  ; Board class
  -D BOARD_CLASS=TechoCardBoard
build_src_filter = ${nrf52_base.build_src_filter}
  +<../variants/lilygo_techo_card/*.cpp>
  +<helpers/sensors>
lib_deps = ${nrf52_base.lib_deps}
  olikraus/U8g2 @ ^2.35.19
  stevemarple/MicroNMEA @ ^2.0.6
  adafruit/Adafruit NeoPixel @ ^1.12.3
  end2endzone/NonBlockingRtttl @ ^1.3.0

; =============================================================================
; Build Environments
; =============================================================================

; --- BLE Companion Radio ---
; Pairs with MeshCore companion app (Android/iOS/Web) over Bluetooth.
; No DISPLAY_CLASS — phone app is the primary interface.
; OLED status screen will be added as a follow-up.
[env:meck_techo_card_companion_radio_ble]
extends = lilygo_techo_card
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags = ${lilygo_techo_card.build_flags}
  -I examples/companion_radio
  -D FIRMWARE_NAME='"Meck T-Echo Card BLE"'
  -D MAX_CONTACTS=350
  -D MAX_GROUP_CHANNELS=40
  -D BLE_PIN_CODE=123456
  -D OFFLINE_QUEUE_SIZE=256
  ; Debug (disable for release)
  ; -D MESH_DEBUG
  ; -D BLE_DEBUG_LOGGING
build_src_filter = ${lilygo_techo_card.build_src_filter}
  +<helpers/ui/buzzer.cpp>
  +<helpers/nrf52/SerialBLEInterface.cpp>
  +<../examples/companion_radio/*.cpp>
lib_deps = ${lilygo_techo_card.lib_deps}
  densaugeo/base64 @ ~1.4.0

; --- Repeater ---
; Standalone LoRa repeater node. GPS for position adverts.
; OLED shows status. Solar + 800mAh battery for outdoor deployment.
[env:meck_techo_card_repeater]
extends = lilygo_techo_card
build_flags = ${lilygo_techo_card.build_flags}
  -D FIRMWARE_NAME='"Meck T-Echo Card Repeater"'
  ; -D MESH_DEBUG
build_src_filter = ${lilygo_techo_card.build_src_filter}
  +<../examples/simple_repeater/*.cpp>

; --- Room Server ---
; BBS-style message board node.
[env:meck_techo_card_room_server]
extends = lilygo_techo_card
build_flags = ${lilygo_techo_card.build_flags}
  -D FIRMWARE_NAME='"Meck T-Echo Card Room"'
build_src_filter = ${lilygo_techo_card.build_src_filter}
  +<../examples/simple_room_server/*.cpp>

; --- Sensor Node ---
; Telemetry node with GPS position reporting.
; IMU data (ICM20948) can be added as a custom sensor source.
[env:meck_techo_card_sensor]
extends = lilygo_techo_card
build_flags = ${lilygo_techo_card.build_flags}
  -D FIRMWARE_NAME='"Meck T-Echo Card Sensor"'
build_src_filter = ${lilygo_techo_card.build_src_filter}
  +<../examples/simple_sensor/*.cpp>