From d2f896842e59f2e8bdce44926b1bf49672c9c91f Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 11 May 2017 16:06:41 +0200 Subject: [PATCH] m 2 led-fader: rm ad-hoc script --- makefu/1systems/wbob.nix | 3 + .../{led-fader/default.nix => led-fader.nix} | 0 makefu/2configs/deployment/led-fader/fade.py | 78 ------------------- 3 files changed, 3 insertions(+), 78 deletions(-) rename makefu/2configs/deployment/{led-fader/default.nix => led-fader.nix} (100%) delete mode 100755 makefu/2configs/deployment/led-fader/fade.py diff --git a/makefu/1systems/wbob.nix b/makefu/1systems/wbob.nix index 43fbd6d2b..f2c42692c 100644 --- a/makefu/1systems/wbob.nix +++ b/makefu/1systems/wbob.nix @@ -15,6 +15,8 @@ in { ../2configs/tools/media.nix ../2configs/virtualization.nix ../2configs/tinc/retiolum.nix + ../2configs/mqtt.nix + ../2configs/deployment/led-fader.nix ]; krebs = { @@ -43,6 +45,7 @@ in { networking.firewall.allowedUDPPorts = [ 655 ]; networking.firewall.allowedTCPPorts = [ 655 49152 ]; + networking.firewall.trustedInterfaces = [ "enp0s25" ]; #services.tinc.networks.siem = { # name = "display"; # extraConfig = '' diff --git a/makefu/2configs/deployment/led-fader/default.nix b/makefu/2configs/deployment/led-fader.nix similarity index 100% rename from makefu/2configs/deployment/led-fader/default.nix rename to makefu/2configs/deployment/led-fader.nix diff --git a/makefu/2configs/deployment/led-fader/fade.py b/makefu/2configs/deployment/led-fader/fade.py deleted file mode 100755 index 8178ad6e8..000000000 --- a/makefu/2configs/deployment/led-fader/fade.py +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i python3 -p python3 python35Packages.docopt -""" usage: run [options] NUMLEDS (loop [--skip-unchanged] [STEP] [DELAY]|single STARTVAL) - - --add-empty essentially add a single empty led in front, does not count into NUMLEDS - - --mode=TYPE mode of fading (Default: chain) - --output=TYPE output type, either json or raw (Default: json) - --skip-unchanged if the value in the loop is unchanged, skip the output - -running with loop this script essentially becomes a generator which outputs the -next value each "DELAY" -single returns a single output with STARTVAL as starting point for the first led - -NUMLEDS is the number of leds to output data for (--add-empty does not count in here) -STEP defaults to 0.01 -DELAY defaults to 1 second - -""" -from docopt import docopt -import time -from colorsys import hsv_to_rgb -import json -import sys - -def calc_chain(numleds,val): - divisor = 1.0 / numleds - ret = [] - for i in range(numleds): - v = float(divisor * i + val) % 1 - r,g,b = hsv_to_rgb(v,0.9,1) - ret.append([int(r*255), - int(g*255), - int(b*255)]) - return ret - -def calc_single(numleds,val): - ret = [] - for i in range(numleds): - r,g,b = hsv_to_rgb(val,1,1) - ret.append([int(r*255), - int(g*255), - int(b*255)]) - return ret - -def main(): - args = docopt(__doc__) - numleds = int(args['NUMLEDS']) - mode = args['--mode'] - step = float(args['STEP'] or 0.01) - delay = float(args['DELAY'] or 1) - val = float(args['STARTVAL'] or 0) - last = [] - while True: - if mode == "chain": - ret = calc_chain(numleds,val) - elif mode == "single": - ret = calc_single(numleds,val) - - if args['--add-empty']: - ret.insert(0,[0,0,0]) - - # early serialization makes comparsion easy - ret = json.dumps(ret) - if not (args['--skip-unchanged'] and last == ret): - last = ret - print(ret) - sys.stdout.flush() - if args['single']: - break - else: - val += step % 1 - time.sleep(delay) - - - -if __name__ == "__main__": - main()