Skip to content

Commit

Permalink
treehouses led refactor (fixes #2041) (#2043)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
rjpadilla and dogi authored Feb 25, 2021
1 parent b1c05be commit 9221064
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 97 deletions.
156 changes: 60 additions & 96 deletions modules/led.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ function newyear {
sleep 1

counter=0
while [ $counter -le 2 ]
do
while [ $counter -le 2 ]; do
set_brightness 1 0 && set_brightness 0 1
sleep 0.5
set_brightness 1 1 && set_brightness 0 0
Expand All @@ -289,8 +288,7 @@ function newyear {
sleep 0.5

counter=0
while [ $counter -le 2 ]
do
while [ $counter -le 2 ]; do
set_brightness 1 1 && set_brightness 0 1
sleep 0.5
set_brightness 1 0 && set_brightness 0 0
Expand All @@ -309,20 +307,19 @@ function blackhistorymonth {
set_brightness 0 0 && set_brightness 1 0
sleep 1

for i in {1..20}
do
set_brightness 0 1 && set_brightness 1 1
sleep .1
for i in {1..20}; do
set_brightness 0 1 && set_brightness 1 1
sleep .1

set_brightness 0 0 && set_brightness 1 0
sleep .15
set_brightness 0 0 && set_brightness 1 0
sleep .15

set_brightness 0 1 && set_brightness 1 1
sleep .1
set_brightness 0 1 && set_brightness 1 1
sleep .1

set_brightness 0 0 && set_brightness 1 0
sleep .65
done
set_brightness 0 0 && set_brightness 1 0
sleep .65
done

led red "$current_red"
led green "$current_green"
Expand All @@ -332,8 +329,7 @@ function lunarnewyear {
current_green=$(led "green")
current_red=$(led "red")

for i in 1 2 3 4 5 6 7 8
do
for i in 1 2 3 4 5 6 7 8; do
set_brightness 1 0 && sleep 0.1
set_brightness 1 1 && sleep 0.1
done
Expand All @@ -353,8 +349,7 @@ function valentine {
sleep 0.25

counter=0
while [ $counter -le 4 ]
do
while [ $counter -le 4 ]; do
set_brightness 1 0 && set_brightness 0 1
sleep 0.25
set_brightness 1 1 && set_brightness 0 0
Expand All @@ -366,8 +361,7 @@ function valentine {
sleep 0.25

counter=0
while [ $counter -le 4 ]
do
while [ $counter -le 4 ]; do
set_brightness 1 1 && set_brightness 0 1
sleep 0.25
set_brightness 1 0 && set_brightness 0 0
Expand Down Expand Up @@ -414,17 +408,15 @@ function lantern {
set_brightness 1 0

x=1
while [ $x -lt 4 ]
do
while [ $x -lt 4 ]; do
set_brightness 0 1
sleep 0.25
set_brightness 0 0
sleep 0.25
x=$(( x+1 ))
done
done

while [ $x -lt 7 ]
do
while [ $x -lt 7 ]; do
set_brightness 0 1
sleep 0.125
set_brightness 0 0
Expand All @@ -443,8 +435,7 @@ function stpatricks {
set_brightness 1 0 # red off
set_brightness 0 0 # green off

for i in {0..4}
do
for i in {0..4}; do
set_brightness 0 1 && sleep 0.25
set_brightness 0 0 && sleep 0.25
set_brightness 0 1 && sleep 0.25
Expand All @@ -453,8 +444,7 @@ function stpatricks {
set_brightness 0 0 && sleep 1
done

for i in {0..19}
do
for i in {0..19}; do
set_brightness 0 1 && sleep 0.05
set_brightness 0 0 && sleep 0.05
done
Expand All @@ -474,16 +464,14 @@ function easter {
set_brightness 1 1 && sleep 0.25
set_brightness 1 0 && sleep 2.0

for i in {0..2}
do
for i in {0..2}; do
set_brightness 0 0 && sleep 1.0
set_brightness 0 1 && sleep 1.0
done

set_brightness 0 1 && sleep 3.0

for i in {0..2}
do
for i in {0..2}; do
set_brightness 0 1 && sleep 0.075
set_brightness 0 0 && sleep 0.075
set_brightness 1 1 && sleep 0.075
Expand All @@ -500,24 +488,21 @@ function eid {

set_brightness 1 0 && set_brightness 0 0 && sleep 1

for i in {0..2}
do
for i in {0..2}; do
set_brightness 1 1 && sleep 0.075
set_brightness 1 0 && sleep 0.075
done

set_brightness 1 1 && sleep 3

for i in {0..2}
do
for i in {0..2}; do
set_brightness 0 1 && sleep 0.075
set_brightness 0 0 && sleep 0.075
done

set_brightness 0 1 && sleep 2

for i in {0..4}
do
for i in {0..4}; do
set_brightness 1 1 && set_brightness 0 1 && sleep 0.075
set_brightness 1 0 && set_brightness 0 0 && sleep 0.075
done
Expand Down Expand Up @@ -546,19 +531,16 @@ function onam {

set_brightness 0 0 && set_brightness 1 0
counter=1
while [ $counter -le 2 ]
do
for i in {1..5}
do
while [ $counter -le 2 ]; do
for i in {1..5}; do
set_brightness 0 1 && set_brightness 1 0
sleep 0.5
set_brightness 0 0 && set_brightness 1 0
sleep 0.5
done
set_brightness 0 0 && set_brightness 1 0
sleep 1
for i in {1..5}
do
for i in {1..5}; do
set_brightness 0 0 && set_brightness 1 1
sleep 0.5
set_brightness 0 0 && set_brightness 1 0
Expand All @@ -575,22 +557,18 @@ function diwali {
current_green=$(led "green")
current_red=$(led "red")

for i in {0..4} # Green LED
do
for i in {0..4}; do # Green LED
set_brightness 0 1 && sleep 0.025 # green on
set_brightness 0 0 && sleep 0.025 # green OFF
done

for i in {0..4} # Red LED
do
for i in {0..4}; do # Red LED
set_brightness 1 1 && sleep 0.025 # red on
set_brightness 1 0 && sleep 0.025 # red OFF
done

for i in {0..4} # Both LEDs
do
for j in {0..9}
do
for i in {0..4}; do # Both LEDs
for j in {0..9}; do
set_brightness 1 1 && set_brightness 0 1
sleep 0.025
set_brightness 1 0 && set_brightness 0 0
Expand All @@ -608,10 +586,8 @@ function dragonboat {
current_red=$(led "red")

time=0.01
for i in {0..2}
do
for j in {1..10}
do
for i in {0..2}; do
for j in {1..10}; do
set_brightness 0 0 && set_brightness 1 0
sleep "$(echo "$j*$time" | bc)"
set_brightness 0 1 && set_brightness 1 1
Expand All @@ -630,18 +606,15 @@ function labourday {
current_red=$(led "red")

set_brightness 1 0
for i in {0..1}
do
for j in {1..5}
do
for i in {0..1}; do
for j in {1..5}; do
set_brightness 0 0
sleep 0.5
set_brightness 0 1
sleep 0.5
done
set_brightness 0 0
for j in {1..2}
do
for j in {1..2}; do
set_brightness 1 0
sleep 0.2
set_brightness 1 1
Expand All @@ -662,8 +635,7 @@ function independenceday {
current_green=$(led "green")

set_brightness 0 0 && set_brightness 1 0
for i in {0..1}
do
for i in {0..1}; do
set_brightness 0 0 && set_brightness 1 1
sleep 1.5
set_brightness 0 1 && set_brightness 1 0
Expand All @@ -673,8 +645,7 @@ function independenceday {
set_brightness 0 0 && set_brightness 1 0
sleep 1.0

for i in {0..6}
do
for i in {0..6}; do
set_brightness 0 0 && set_brightness 1 1
sleep 0.1
set_brightness 0 1 && set_brightness 1 0
Expand Down Expand Up @@ -708,8 +679,7 @@ function thanksgiving {
set_brightness 0 1 && sleep 0.25
set_brightness 1 1 && sleep 0.5

for i in {0..1}
do
for i in {0..1}; do
set_brightness 1 0
set_brightness 0 0 && sleep 0.25
set_brightness 1 1
Expand Down Expand Up @@ -770,8 +740,7 @@ function heavymetal {
set_brightness 0 0 && sleep 0.5 # green off
set_brightness 1 0 && sleep 0.5 # red off

for i in {0..19}
do
for i in {0..19}; do
set_brightness 0 1 && sleep 0.025
set_brightness 0 0 && sleep 0.025
set_brightness 1 1 && sleep 0.025
Expand All @@ -786,38 +755,33 @@ function kecak {
current_green=$(led "green")
current_red=$(led "red")

for i in {0..1}
do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
for i in {0..1}; do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
done

for i in {0..19}
do
set_brightness 0 1 && sleep 0.1
set_brightness 0 0
set_brightness 1 1 && sleep 0.1
set_brightness 1 0
for i in {0..19}; do
set_brightness 0 1 && sleep 0.1
set_brightness 0 0
set_brightness 1 1 && sleep 0.1
set_brightness 1 0
done

for i in {0..1}
do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
for i in {0..1}; do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
done

for i in {0..19}
do
set_brightness 0 1 && sleep 0.1
set_brightness 0 0
set_brightness 1 1 && sleep 0.1
set_brightness 1 0
for i in {0..19}; do
set_brightness 0 1 && sleep 0.1
set_brightness 0 0
set_brightness 1 1 && sleep 0.1
set_brightness 1 0
done

for i in {0..1}
do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
for i in {0..1}; do
set_brightness 0 1 && set_brightness 1 1 && sleep 1
set_brightness 0 0 && set_brightness 1 0 && sleep 1
done

led red "$current_red"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.25.8",
"version": "1.25.9",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit 9221064

Please sign in to comment.