From 33f5530a1c275205c100d13163009010d0735985 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 9 Dec 2016 23:21:32 +1100 Subject: [PATCH] Added new Candle effect - like those fake flickering led candles (#317) * Added new Candle effect - like those fake flickering led candles * Candle work... code cleanups parameter changes schema file english labels * renamed a title * candle effect german localisation * fix typo in police.py --- assets/webconfig/i18n/de.json | 4 ++ assets/webconfig/i18n/en.json | 4 ++ effects/candle.json | 11 +++++ effects/candle.py | 81 +++++++++++++++++++++++++++++++ effects/police.py | 2 +- effects/schema/candle.schema.json | 60 +++++++++++++++++++++++ 6 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 effects/candle.json create mode 100644 effects/candle.py create mode 100644 effects/schema/candle.schema.json diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index 97d6c895..7d6cf0f7 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -321,6 +321,7 @@ "edt_conf_effp_disable_itemtitle" : "Effekt", "edt_conf_log_heading_title" : "Protokoll", "edt_conf_log_level_title" : "Protokollstufe", + "edt_eff_candle_header_title" : "Kerze", "edt_eff_police_header_title" : "Polizei", "edt_eff_fade_header_title" : "Farbübergang", "edt_eff_rainbowmood_header_title" : "Regenbogen", @@ -347,6 +348,9 @@ "edt_eff_fadetime_title" : "Übergangszeit", "edt_eff_colorstart_title" : "Farbe Start", "edt_eff_colorend_title" : "Farbe Ende", + "edt_eff_colorshift_title" : "Farbverschiebung", + "edt_eff_whichleds_title" : "Welche LEDs", + "edt_eff_ledlist_title" : "LED Liste", "edt_eff_speed_title" : "Geschwindigkeit", "edt_eff_fadefactor_title" : "Verblass Faktor", "edt_eff_showseconds_title" : "Zeige Sekunden", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 1e390224..afe45eb7 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -321,6 +321,7 @@ "edt_conf_effp_disable_itemtitle" : "Effect", "edt_conf_log_heading_title" : "Logging", "edt_conf_log_level_title" : "Log-Level", + "edt_eff_candle_header_title" : "Candle", "edt_eff_police_header_title" : "Police", "edt_eff_fade_header_title" : "Fade", "edt_eff_rainbowmood_header_title" : "Rainbow Mood", @@ -347,6 +348,9 @@ "edt_eff_fadetime_title" : "Fade time", "edt_eff_colorstart_title" : "Color start", "edt_eff_colorend_title" : "Color end", + "edt_eff_colorshift_title" : "Color Shift", + "edt_eff_whichleds_title" : "Which Leds", + "edt_eff_ledlist_title" : "Led List", "edt_eff_speed_title" : "Speed", "edt_eff_fadefactor_title" : "Fade factor", "edt_eff_showseconds_title" : "Show seconds", diff --git a/effects/candle.json b/effects/candle.json new file mode 100644 index 00000000..dd607555 --- /dev/null +++ b/effects/candle.json @@ -0,0 +1,11 @@ +{ + "name" : "Candle", + "script" : "candle.py", + "args" : + { + "sleepTime" : 0.15, + "brightness" : 0.50, + "color" : [ 255, 138, 0 ], + "candles" : "all" + } +} diff --git a/effects/candle.py b/effects/candle.py new file mode 100644 index 00000000..1be744c3 --- /dev/null +++ b/effects/candle.py @@ -0,0 +1,81 @@ + +# Candleflicker effect by penfold42 +# Algorithm courtesy of +# https://cpldcpu.com/2013/12/08/hacking-a-candleflicker-led/ + +# candles can be : +# a single led number, a list of candle numbers +# "all" to flicker all the leds randomly +# "all-together" to flicker all the leds in unison + +import hyperion +import time +import colorsys +import random + +# Get parameters +color = hyperion.args.get('color', (255,138,0)) +colorShift = hyperion.args.get('colorShift', 0.01) +brightness = float(hyperion.args.get('brightness', 0.5)) + +sleepTime = float(hyperion.args.get('sleepTime', 0.14)) + +candles = hyperion.args.get('candles', "all") +ledlist = hyperion.args.get('ledlist', "1") + +candlelist = () +if (candles == "list") and (type(ledlist) is str): + for s in ledlist.split(','): + i = int(s) + if (i