基盤下に耐震ジェルパッドを敷いてユルーク固定してるつもりだけどあまり意味なし。
USBスピーカーも繋げてバージョン1完成とする。
PIneApple(・・・PI in Apple)と命名する。
ただ肝心のソフトがまだだったので作成。
ざっくりとした仕様は以下。
- 赤外線リモコンで操作
- ボタンに応じてmplayerの起動、フロアライトのリモコン操作を行う
- 赤外線受信のハンドリングはirwコマンドで行う
でできたのが↓のRubyスクリプト(rirc.rb)。
- IO.popenでirwの標準出力を拾って解析
- ボタンとリモコン名からスクリプト名を決定し、スクリプトファイルがあれば実行
- どうもリモコンボタンを普通に押しただけで2回連続で赤外線とぶみたいなので、実行後1秒間の受信は無視
- cronで定時起動するようにしてロックファイルで重複実行しないように
- ボタン対応スクリプト内でAquesTalkで軽くしゃべらせる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "らじお、ていし" | aplay | |
killall mplayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "えぬえいちけい、いち、かいし" | aplay | |
killall mplayer | |
mplayer -playlist http://mfile.akamai.com/129931/live/reflector:46032.asx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "えぬえいちけい、に、かいし" | aplay | |
killall mplayer | |
mplayer -playlist http://mfile.akamai.com/129932/live/reflector:46056.asx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "えぬえいちけい、えふえむ、かいし" | aplay | |
killall mplayer | |
mplayer -playlist http://mfile.akamai.com/129933/live/reflector:46051.asx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "だらずえふえむ、かいし" | aplay | |
killall mplayer | |
mplayer -playlist http://www.darazfm.com/streaming.asx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "びーびーしー、いち、かいし" | aplay | |
killall mplayer | |
mplayer -playlist http://www.bbc.co.uk/radio/listen/live/r1.asx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "ろく" | aplay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
`/home/pi/aquestalkpi/AquesTalkPi -g 100 "ぼりゅーむ" | aplay` | |
vo=`amixer sget PCM | awk 'match($0,/([[:digit:]]+)%/,data){ print data[1]}'` | |
vo=`expr $vo + 5` | |
if [ $vo -gt 100 ] | |
then | |
vo=100 | |
fi | |
`/home/pi/aquestalkpi/AquesTalkPi -g 100 "$voぱあせんと" | aplay` | |
amixer sset PCM "$vo%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
`/home/pi/aquestalkpi/AquesTalkPi -g 100 "ぼりゅーむ" | aplay` | |
vo=`amixer sget PCM | awk 'match($0,/([[:digit:]]+)%/,data){ print data[1]}'` | |
vo=`expr $vo - 5` | |
if [ $vo -lt 75 ] | |
then | |
vo=75 | |
fi | |
`/home/pi/aquestalkpi/AquesTalkPi -g 100 "$voぱあせんと" | aplay` | |
amixer sset PCM "$vo%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "きゅう" | aplay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "でんとう" | aplay | |
irsend SEND_ONCE light power |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "ちょうこう" | aplay | |
irsend SEND_ONCE light choukou |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/aquestalkpi/AquesTalkPi -g 100 "じょうやとう" | aplay | |
irsend SEND_ONCE light jouyatou |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
class Locked < StandardError | |
end | |
def lock(lock_file_path='/tmp/rirc') | |
File.open(lock_file_path, 'w') do |lock_file| | |
if lock_file.flock(File::LOCK_EX|File::LOCK_NB) | |
yield | |
else | |
raise Locked | |
end | |
end | |
end | |
def exec_script(cmd) | |
dir = File.expand_path(File.dirname(__FILE__)) | |
script = File.join(dir,"#{cmd}.sh") | |
if File.exist?(script) | |
Process.spawn(script) | |
end | |
end | |
INTERVAL_SEC = 1.0 | |
begin | |
lock do | |
IO.popen("irw","r") do |io| | |
st = Time.now | |
loop do | |
# 0000555af1484a8b 00 1 rimokon | |
line = io.gets.chomp | |
int = Time.now - st | |
if int > INTERVAL_SEC | |
cmd = line.split(" ")[-2..-1].join("-") # => 1-remokon | |
exec_script(cmd) | |
st = Time.now | |
end | |
end | |
end | |
end | |
rescue Locked | |
exit 0 | |
end |
動作風景
見た目が若干アレなので配線の始末とか前面パネルとか作るかも知れない。
あとはLCDとかマトリックスLEDでなにか表示させるとかやってもよいかも。
見た目が若干アレなので配線の始末とか前面パネルとか作るかも知れない。
あとはLCDとかマトリックスLEDでなにか表示させるとかやってもよいかも。
0 件のコメント:
コメントを投稿