forked from arhcf/pswai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote.py
More file actions
executable file
·84 lines (67 loc) · 1.81 KB
/
remote.py
File metadata and controls
executable file
·84 lines (67 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
#
# PSWAI: A Plate Solved Where Am I application.
# Copyright (C) 2018 arhcf (user arhcf at github 2018)
# This file is part of the pswai project.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# This is just a client for the wiimote which is used
# as a controller for the pswai
#
import os, re, sys, time, socket
import cwiid
import subprocess
import signal
import time
def rumble(n):
for i in range(n):
wii.rumble = True
time.sleep(0.3)
wii.rumble = False
time.sleep(0.2)
# pair with wimote
c=0
wii = None
print "Pairing with wiimote"
while not wii:
try:
wii=cwiid.Wiimote()
except RuntimeError:
if (c>60):
print "Failed"
quit()
print "failed " + str(c) + "...trying again"
c = c+1
time.sleep(2)
print "Paired"
rumble(1)
wii.led = 1
pid=0
dn = os.path.dirname(os.path.abspath(__file__))
solvecmd = os.path.join(dn, 'take_pic_solve')
# not needed
#os.environ["XYIIP"]="192.168.42.1"
# Check for Button A press
wii.rpt_mode = cwiid.RPT_BTN
while 1:
if (wii.state['buttons'] & cwiid.BTN_A):
print "Call take_pic_solve"
ret = subprocess.call([solvecmd])
if (ret == 0 ):
rumble(1)
else:
rumble(2)
time.sleep(0.2)