-
-
Save electricbaka/5e3dea3f7554628824d2aa8c7bcf3252 to your computer and use it in GitHub Desktop.
ダイソー「クローゼットライト」改造のソースコード
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
#Escキー2回押しで着実に終了 | |
import RPi.GPIO as GPIO | |
import subprocess | |
import time | |
#Viewerフルスクリーン起動 | |
p = subprocess.Popen(['gpicview', '01.png']) | |
time.sleep(1) | |
subprocess.Popen(['xte', 'key F11']) | |
#GPIO18pin:入力モード, pull-up設定 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
#メインループ | |
sw_status = 0 | |
sw_status_old = 0 | |
while True: | |
try: | |
#Viewerが終了したらbreak | |
if p.poll() == 0: | |
break | |
#入力に変化があったら画像変更 | |
sw_status = GPIO.input(18) | |
if sw_status != sw_status_old: | |
if sw_status == 0: | |
print('Changed 1 to 0') | |
subprocess.Popen(['xte', 'key Left']) | |
else: | |
print('Changed 0 to 1') | |
subprocess.Popen(['xte', 'key Right']) | |
#過去の入力値の更新 | |
sw_status_old = sw_status | |
time.sleep(0.1) | |
except: | |
break | |
#お掃除 | |
GPIO.cleanup() | |
print("end") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment