Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Created August 15, 2016 18:31
Show Gist options
  • Select an option

  • Save mohemohe/ed4d3db589f8b78413d0f8e05bb452c5 to your computer and use it in GitHub Desktop.

Select an option

Save mohemohe/ed4d3db589f8b78413d0f8e05bb452c5 to your computer and use it in GitHub Desktop.
Raspberry Piでリモコン信号を記憶する補助スクリプト
#!/usr/bin/env python
# coding: utf-8
import signal
import sys
signal.signal(signal.SIGINT, signal.SIG_IGN)
buff = sys.stdin.read().splitlines()
buff.pop(0)
raw_data = []
for i, line in enumerate(buff):
elements = line.split()
raw_data.append(elements[1])
if (i+1) % 8 == 0:
raw_data.append("\n")
print(" ".join(raw_data))
#!/usr/bin/env python
# coding: utf-8
import os
import sys
args = sys.argv
args.pop(0) # "generate.py"
name = args.pop(0)
conf_name = args.pop(0)
code_files = args
start = """begin remote
"""
header = """flags RAW_CODES
eps 30
aeps 100
gap 200000
toggle_bit_mask 0x0
begin raw_codes
"""
end = """end raw_codes
end remote
"""
conf_file = open(conf_name, "w")
conf_file.write(start + "\n")
conf_file.write("name " + name + "\n")
conf_file.write(header + "\n")
for code_file in code_files:
conf_file.write("name " + os.path.basename(code_file) + "\n")
cf = open(code_file, "r")
conf_file.write(cf.read())
cf.close()
conf_file.write("\n")
conf_file.write(end)
conf_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment