-
Notifications
You must be signed in to change notification settings - Fork 1
/
blink
executable file
·47 lines (40 loc) · 1.09 KB
/
blink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
if [ $# -ge 4 ] || [[ $1 == "--help" ]] || [ $(id -u) -ne 0 ];then
/show/messagebox "$0"
/show/info "[beta] [gpio] [led] [electronics] [orangepi]"
/show/usageDescription "Blink a led"
/show/usage "$0 pin or $0 pin number_of_times or $0 pin number_of_times speed (in s)"
/show/example "$0 21 or $0 21 3 $0 21 3 0.1"
exit 1
else
hardware=$(/pi/getBoard)
if [ $# -eq 0 ];then
/show/gpio
/show/listecho "Could you tell me where the led is plugged ?" $WARN
exit 314
else
ledPin=$1
# If only pin is defined
if [ $# -eq 1 ];then
loopUntil=3
speed=0.1
fi
# If only pin and number of times the led blink is defined
if [ $# -eq 2 ];then
loopUntil=$2
speed=0.1
fi
# If pin, number of blink and speed is defined
if [ $# -eq 3 ];then
loopUntil=$2
speed=$3
fi
/show/colecho "Blink LED $ledPin" $WARN
if [[ $hardware == "orangepi" ]];then
ledPin=$(/system/h3ToBcm $ledPin)
/do/led/python/blink_orange.py $ledPin $loopUntil $speed
else
/do/led/python/blink.py $ledPin $loopUntil $speed
fi
fi
fi