Skip to content

Commit 3681909

Browse files
JLKwongdogi
andauthored
treehouses led blackhistorymonth (fixes #2035) (#2038)
Co-authored-by: dogi <dogi@users.noreply.github.com>
1 parent a67e4de commit 3681909

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ upgrade [tag|check|bluetooth|force|cli] upgrades treehouses package using npm
7171
sshtunnel [add|remove|list|active|check] helps adding sshtunnels
7272
[key|refresh|notice|ports]
7373
led [green|red] [mode] sets the led mode
74-
[newyear|lunarnewyear|valentine]
75-
[carnival|lantern|stpatricks|easter]
76-
[labourday|eid|dragonboat]
77-
[independenceday|onam|diwali]
78-
[thanksgiving|christmas|heavymetal]
79-
[dance|kecak|random]
74+
[newyear|blackhistorymonth]
75+
[lunarnewyear|valentine|carnival]
76+
[lantern|stpatricks|easter|labourday]
77+
[eid|dragonboat|independenceday|onam]
78+
[diwali|thanksgiving|christmas]
79+
[heavymetal|dance|kecak|random]
8080
power [mode|current|freq|status] sets the power mode or check power mode/CPU frequency
8181
uptime [boot|start|stop|log] displays uptime and boot time of the Raspberry Pi
8282
rtc <on|off> [rasclock|ds3231] sets up the rtc clock specified

modules/help.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ upgrade [tag|check|bluetooth|force|cli] upgrades treehouses package using npm
4747
sshtunnel [add|remove|list|active|check] helps adding sshtunnels
4848
[key|refresh|notice|ports]
4949
led [green|red] [mode] sets the led mode
50-
[newyear|lunarnewyear|valentine]
51-
[carnival|lantern|stpatricks|easter]
52-
[labourday|eid|dragonboat]
53-
[independenceday|onam|diwali]
54-
[thanksgiving|christmas|heavymetal]
55-
[dance|kecak|random]
50+
[newyear|blackhistorymonth]
51+
[lunarnewyear|valentine|carnival]
52+
[lantern|stpatricks|easter|labourday]
53+
[eid|dragonboat|independenceday|onam]
54+
[diwali|thanksgiving|christmas]
55+
[heavymetal|dance|kecak|random]
5656
power [mode|current|freq|status] sets the power mode or check power mode/CPU frequency
5757
uptime [boot|start|stop|log] displays uptime and boot time of the Raspberry Pi
5858
rtc <on|off> [rasclock|ds3231] sets up the rtc clock specified

modules/led.sh

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ function led {
3030
echo "Both LED: flash 2 times"
3131
newyear > "$LOGFILE"
3232
;;
33+
blackhistorymonth)
34+
checkroot
35+
echo "leds are set to blackhistorymonth mode."
36+
echo "Look at your RPi leds, both leds will be in this pattern..."
37+
echo "Both LED's will flash in unison like a heartbeat"
38+
echo "Both LED: off 1 second"
39+
echo "Both LED: on .1 seconds"
40+
echo "Both LED: off .15 seconds"
41+
echo "Both LED: on .1 seconds"
42+
echo "Both LED: off .65 seconds"
43+
echo "this will happen 20 times"
44+
blackhistorymonth > "$LOGFILE"
45+
;;
3346
lunarnewyear)
3447
checkroot
3548
echo "leds are set to lunarnewyear mode."
@@ -280,6 +293,32 @@ function newyear {
280293
led red "$current_red"
281294
}
282295

296+
function blackhistorymonth {
297+
current_red=$(led "red")
298+
current_green=$(led "green")
299+
300+
set_brightness 0 0 && set_brightness 1 0
301+
sleep 1
302+
303+
for i in {1..20}
304+
do
305+
set_brightness 0 1 && set_brightness 1 1
306+
sleep .1
307+
308+
set_brightness 0 0 && set_brightness 1 0
309+
sleep .15
310+
311+
set_brightness 0 1 && set_brightness 1 1
312+
sleep .1
313+
314+
set_brightness 0 0 && set_brightness 1 0
315+
sleep .65
316+
done
317+
318+
led red "$current_red"
319+
led green "$current_green"
320+
}
321+
283322
function lunarnewyear {
284323
current_green=$(led "green")
285324
current_red=$(led "red")
@@ -793,8 +832,9 @@ function random {
793832
function led_help {
794833
echo
795834
echo "Usage: $BASENAME led [green|red] [mode]"
796-
echo " $BASENAME led [newyear|lunarnewyear|valentine|carnival|lantern|stpatricks|easter|labourday|eid]"
797-
echo " [dragonboat|independenceday|onam|diwali|thanksgiving|christmas|dance|heavymetal|random]"
835+
echo " $BASENAME led [newyear|blackhistorymonth|lunarnewyear|valentine|carnival|lantern|stpatricks]"
836+
echo " [easter|labourday|eid|dragonboat|independenceday|onam|diwali|thanksgiving]"
837+
echo " [christmas|dance|heavymetal|random]"
798838
echo
799839
echo "Sets or returns the led mode"
800840
echo
@@ -843,8 +883,11 @@ function led_help {
843883
echo " $BASENAME led newyear"
844884
echo " This will set the mode of the led to newyear"
845885
echo
886+
echo " $BASENAME led blackhistorymonth"
887+
echo " This will set the mode of the led to blackhistorymonth"
888+
echo
846889
echo " $BASENAME led lunarnewyear"
847-
echo " This wil set the mode of the led to lunarnewyear"
890+
echo " This will set the mode of the led to lunarnewyear"
848891
echo
849892
echo " $BASENAME led valentine"
850893
echo " This will set the mode of the led to valentine"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@treehouses/cli",
3-
"version": "1.25.4",
3+
"version": "1.25.5",
44
"remote": "4000",
55
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
66
"main": "cli.sh",

tests/led/blackhistorymonth.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!usr/bin/env bats
2+
load ../test-helper
3+
4+
@test "$clinom led blackhistorymonth" {
5+
run "${clicmd}" led blackhistorymonth
6+
assert_success && assert_output -p 'heartbeat'
7+
}

0 commit comments

Comments
 (0)