#!/bin/bash
# LED Test Script for reTerminal DM4

LED_PATH='/sys/class/leds/usr-led/brightness'

echo "Testing reTerminal DM4 LED"
echo "=========================="
echo ""

# Test 1: Turn ON
echo "Test 1: Turning LED ON..."
echo 1 | sudo tee $LED_PATH > /dev/null
sleep 1
echo "LED should be ON now"
echo ""

# Test 2: Turn OFF
echo "Test 2: Turning LED OFF..."
echo 0 | sudo tee $LED_PATH > /dev/null
sleep 1
echo "LED should be OFF now"
echo ""

# Test 3: Blink pattern
echo "Test 3: Blinking LED (5 times)..."
for i in {1..5}; do
    echo 1 | sudo tee $LED_PATH > /dev/null
    sleep 0.2
    echo 0 | sudo tee $LED_PATH > /dev/null
    sleep 0.2
done
echo ""

# Test 4: Fast blink
echo "Test 4: Fast blink (10 times)..."
for i in {1..10}; do
    echo 1 | sudo tee $LED_PATH > /dev/null
    sleep 0.1
    echo 0 | sudo tee $LED_PATH > /dev/null
    sleep 0.1
done
echo ""

# Test 5: Slow blink
echo "Test 5: Slow blink (3 times)..."
for i in {1..3}; do
    echo 1 | sudo tee $LED_PATH > /dev/null
    sleep 0.5
    echo 0 | sudo tee $LED_PATH > /dev/null
    sleep 0.5
done
echo ""

# Ensure LED is off
echo 0 | sudo tee $LED_PATH > /dev/null

echo "LED test complete!"
echo ""
echo "Current LED status:"
cat $LED_PATH && echo " (0 = OFF, 1 = ON)"
