Skip to content

Commit

Permalink
treehouses led blackhistorymonth (fixes #2035) (#2038)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
JLKwong and dogi authored Feb 20, 2021
1 parent a67e4de commit 3681909
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ upgrade [tag|check|bluetooth|force|cli] upgrades treehouses package using npm
sshtunnel [add|remove|list|active|check] helps adding sshtunnels
[key|refresh|notice|ports]
led [green|red] [mode] sets the led mode
[newyear|lunarnewyear|valentine]
[carnival|lantern|stpatricks|easter]
[labourday|eid|dragonboat]
[independenceday|onam|diwali]
[thanksgiving|christmas|heavymetal]
[dance|kecak|random]
[newyear|blackhistorymonth]
[lunarnewyear|valentine|carnival]
[lantern|stpatricks|easter|labourday]
[eid|dragonboat|independenceday|onam]
[diwali|thanksgiving|christmas]
[heavymetal|dance|kecak|random]
power [mode|current|freq|status] sets the power mode or check power mode/CPU frequency
uptime [boot|start|stop|log] displays uptime and boot time of the Raspberry Pi
rtc <on|off> [rasclock|ds3231] sets up the rtc clock specified
Expand Down
12 changes: 6 additions & 6 deletions modules/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ upgrade [tag|check|bluetooth|force|cli] upgrades treehouses package using npm
sshtunnel [add|remove|list|active|check] helps adding sshtunnels
[key|refresh|notice|ports]
led [green|red] [mode] sets the led mode
[newyear|lunarnewyear|valentine]
[carnival|lantern|stpatricks|easter]
[labourday|eid|dragonboat]
[independenceday|onam|diwali]
[thanksgiving|christmas|heavymetal]
[dance|kecak|random]
[newyear|blackhistorymonth]
[lunarnewyear|valentine|carnival]
[lantern|stpatricks|easter|labourday]
[eid|dragonboat|independenceday|onam]
[diwali|thanksgiving|christmas]
[heavymetal|dance|kecak|random]
power [mode|current|freq|status] sets the power mode or check power mode/CPU frequency
uptime [boot|start|stop|log] displays uptime and boot time of the Raspberry Pi
rtc <on|off> [rasclock|ds3231] sets up the rtc clock specified
Expand Down
49 changes: 46 additions & 3 deletions modules/led.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ function led {
echo "Both LED: flash 2 times"
newyear > "$LOGFILE"
;;
blackhistorymonth)
checkroot
echo "leds are set to blackhistorymonth mode."
echo "Look at your RPi leds, both leds will be in this pattern..."
echo "Both LED's will flash in unison like a heartbeat"
echo "Both LED: off 1 second"
echo "Both LED: on .1 seconds"
echo "Both LED: off .15 seconds"
echo "Both LED: on .1 seconds"
echo "Both LED: off .65 seconds"
echo "this will happen 20 times"
blackhistorymonth > "$LOGFILE"
;;
lunarnewyear)
checkroot
echo "leds are set to lunarnewyear mode."
Expand Down Expand Up @@ -280,6 +293,32 @@ function newyear {
led red "$current_red"
}

function blackhistorymonth {
current_red=$(led "red")
current_green=$(led "green")

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

set_brightness 0 0 && set_brightness 1 0
sleep .15

set_brightness 0 1 && set_brightness 1 1
sleep .1

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

led red "$current_red"
led green "$current_green"
}

function lunarnewyear {
current_green=$(led "green")
current_red=$(led "red")
Expand Down Expand Up @@ -793,8 +832,9 @@ function random {
function led_help {
echo
echo "Usage: $BASENAME led [green|red] [mode]"
echo " $BASENAME led [newyear|lunarnewyear|valentine|carnival|lantern|stpatricks|easter|labourday|eid]"
echo " [dragonboat|independenceday|onam|diwali|thanksgiving|christmas|dance|heavymetal|random]"
echo " $BASENAME led [newyear|blackhistorymonth|lunarnewyear|valentine|carnival|lantern|stpatricks]"
echo " [easter|labourday|eid|dragonboat|independenceday|onam|diwali|thanksgiving]"
echo " [christmas|dance|heavymetal|random]"
echo
echo "Sets or returns the led mode"
echo
Expand Down Expand Up @@ -843,8 +883,11 @@ function led_help {
echo " $BASENAME led newyear"
echo " This will set the mode of the led to newyear"
echo
echo " $BASENAME led blackhistorymonth"
echo " This will set the mode of the led to blackhistorymonth"
echo
echo " $BASENAME led lunarnewyear"
echo " This wil set the mode of the led to lunarnewyear"
echo " This will set the mode of the led to lunarnewyear"
echo
echo " $BASENAME led valentine"
echo " This will set the mode of the led to valentine"
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.4",
"version": "1.25.5",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down
7 changes: 7 additions & 0 deletions tests/led/blackhistorymonth.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!usr/bin/env bats
load ../test-helper

@test "$clinom led blackhistorymonth" {
run "${clicmd}" led blackhistorymonth
assert_success && assert_output -p 'heartbeat'
}

0 comments on commit 3681909

Please sign in to comment.