Sha256: c8c2c9f3e80b02a5eb58cfd50ce3b68226f95c5bb147931d39a643b23994837a
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
#!/usr/bin/env ruby DEBUG = true if ARGV[0] && ARGV[0]=='-b' case ARGV[1] when 'set' require 'ws_light/benchmark/set_benchmark' when 'animation' require 'ws_light/benchmark/animation_benchmark' when 'ws2801' require 'ws_light/benchmark/ws2801_benchmark' else puts 'Available benchmarks: set, animation, ws2801' end exit end require 'pi_piper' include PiPiper require 'bundler' require 'ws_light/strip' require 'ws_light/sd_logger' logger = WSLight::SDLogger.new logger.debug = DEBUG logger.filename = 'motion.log' logger.log 'Starting up' # Trap ^C Signal.trap('INT') { logger.log 'Shutting down' logger.write_log exit } # Trap `kill ` Signal.trap('TERM') { logger.log 'Shutting down' logger.write_log exit } strip = WSLight::Strip.new strip.debug = DEBUG pin_right = PiPiper::Pin.new(:pin => 22, :direction => :in) pin_left = PiPiper::Pin.new(:pin => 23, :direction => :in) after :pin => 23, :goes => :high do logger.log('Motion detected: RIGHT') strip.on(WSLight::Strip::DIRECTION_RIGHT) while pin_right.on? strip.on(WSLight::Strip::DIRECTION_RIGHT) sleep 1 end end after :pin => 24, :goes => :high do logger.log('Motion detected: LEFT') strip.on(WSLight::Strip::DIRECTION_LEFT) while pin_left.on? strip.on(WSLight::Strip::DIRECTION_LEFT) sleep 1 end end PiPiper.wait
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ws_light-0.2.0 | bin/ws_light |