From 3681909aed89c74d3a4c1cdf209f7cf9b1dc3c3b Mon Sep 17 00:00:00 2001 From: JLKwong <61807745+JLKwong@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:42:14 -0800 Subject: [PATCH] `treehouses led blackhistorymonth` (fixes #2035) (#2038) Co-authored-by: dogi --- README.md | 12 ++++---- modules/help.sh | 12 ++++---- modules/led.sh | 49 ++++++++++++++++++++++++++++++-- package.json | 2 +- tests/led/blackhistorymonth.bats | 7 +++++ 5 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 tests/led/blackhistorymonth.bats diff --git a/README.md b/README.md index 669e30f20e..4584176908 100644 --- a/README.md +++ b/README.md @@ -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 [rasclock|ds3231] sets up the rtc clock specified diff --git a/modules/help.sh b/modules/help.sh index 640c488c3b..a60d49e32b 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -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 [rasclock|ds3231] sets up the rtc clock specified diff --git a/modules/led.sh b/modules/led.sh index 3754ba0fe5..5fa151d7f3 100644 --- a/modules/led.sh +++ b/modules/led.sh @@ -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." @@ -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") @@ -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 @@ -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" diff --git a/package.json b/package.json index a2362f4803..ba55d6cb0b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/led/blackhistorymonth.bats b/tests/led/blackhistorymonth.bats new file mode 100644 index 0000000000..2d1ec7dcc2 --- /dev/null +++ b/tests/led/blackhistorymonth.bats @@ -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' +}