#!/bin/bash

# Function to send LED commands with delay
send_led_command() {
    local cmd="$1"
    local delay="$2"
    echo "$cmd" > /sys/devices/platform/openvfd/attr/led
    sleep "$delay"
}

# LED on/off tests
send_led_command "#s0" 1.5  # All LEDs on
send_led_command "#c1" 1.5  # Clock off
send_led_command "#c0" 1.5  # All LEDs off
send_led_command "#s1" 5    # Only clock on

# Display test with letters
for i in {0..5}; do
    send_led_command "#m${i}tESt" 1
done

send_led_command "#m0----" 1
send_led_command "#m1t..." 1
send_led_command "#m2.E.." 1
send_led_command "#m3..S." 1
send_led_command "#m4...t" 1
send_led_command "#m5PLA4" 1
send_led_command "#m5UOL." 1
send_led_command "#m0.100" 5
send_led_command "#m00000" 0.5

# Display test with numbers
send_led_command "#m09999" 0.5
send_led_command "#m08888" 0.5
send_led_command "#m07777" 0.5
send_led_command "#m06666" 0.5
send_led_command "#m05555" 0.5
send_led_command "#m04444" 0.5
send_led_command "#m03333" 0.5
send_led_command "#m02222" 0.5
send_led_command "#m01111" 2
send_led_command "#m0...." 5

# Screen on test
for b in {0..6}; do
    echo 1 > /sys/devices/platform/openvfd/attr/b${b}
    sleep 1
done

# Screen off test
for b in {0..6}; do
    echo 0 > /sys/devices/platform/openvfd/attr/b${b}
    sleep 1
done

send_led_command "#s1" 0  # Finish

clear
