#!/bin/bash
# Copies User_Setup.h into the TFT_eSPI Arduino library folder.
# Run this once after installing the TFT_eSPI library.

set -e

SRC="$(dirname "$0")/codexbar_esp32/User_Setup.h"
ARDUINO_LIB_PATH="$HOME/Documents/Arduino/libraries/TFT_eSPI"
DEST="$ARDUINO_LIB_PATH/User_Setup.h"

if [ ! -d "$ARDUINO_LIB_PATH" ]; then
  echo "ERROR: TFT_eSPI library not found at $ARDUINO_LIB_PATH"
  echo "Install it via Arduino IDE → Tools → Manage Libraries → search 'TFT_eSPI'"
  exit 1
fi

cp "$SRC" "$DEST"
echo "✓ Copied User_Setup.h to $DEST"
echo ""
echo "Next: open codexbar_esp32/codexbar_esp32.ino in Arduino IDE"
echo "  Board: ESP32 Dev Module"
echo "  Upload Speed: 921600"
echo "  Flash Size: 16MB (128Mb)"
