Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PR-Baby-A18
Babyfut
Commits
62d68f63
Commit
62d68f63
authored
Nov 02, 2018
by
Antoine Lima
Browse files
Fixed crashing bug when not on rasp
parent
b731184c
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
62d68f63
...
...
@@ -103,4 +103,4 @@ For the time being, those are provided by the PI camera module.
## Todo
*
[ ]
Filter serial ports to get arduinos or specific serial id
*
[ ]
Add the possibility to stop the replay mid-video by pushing any button
input.py
View file @
62d68f63
...
...
@@ -9,7 +9,11 @@ Created on Wed Apr 18 18:34:40 2018
import
logging
import
pyautogui
# PyPi library
from
threading
import
Thread
import
RPi.GPIO
as
GPIO
from
main
import
OnRasp
if
OnRasp
:
import
RPi.GPIO
as
GPIO
from
player
import
Side
...
...
@@ -27,21 +31,23 @@ class GPIOThread(Thread):
Thread
.
__init__
(
self
)
self
.
dispatcher
=
dispatcher
self
.
continueRunning
=
True
if
OnRasp
:
GPIO
.
setwarnings
(
False
)
GPIO
.
setmode
(
GPIO
.
BCM
)
GPIO
.
setwarnings
(
False
)
GPIO
.
setmode
(
GPIO
.
BCM
)
for
pin
in
GPIOThread
.
_keyButtonBindings
.
keys
():
print
(
pin
)
GPIO
.
setup
(
pin
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_UP
)
GPIO
.
add_event_detect
(
pin
,
GPIO
.
RISING
,
callback
=
self
.
handleButtonPress
)
for
pin
in
GPIOThread
.
_keyButtonBindings
.
keys
():
print
(
pin
)
GPIO
.
setup
(
pin
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_UP
)
GPIO
.
add_event_detect
(
pin
,
GPIO
.
RISING
,
callback
=
self
.
handleButtonPress
)
def
run
(
self
):
try
:
while
self
.
continueRunning
:
pass
finally
:
GPIOThread
.
clean
()
if
OnRasp
:
try
:
while
self
.
continueRunning
:
pass
finally
:
GPIOThread
.
clean
()
def
handleButtonPress
(
self
,
button_pin
):
if
button_pin
not
in
GPIOThread
.
_keyButtonBindings
.
keys
():
...
...
@@ -56,4 +62,5 @@ class GPIOThread(Thread):
@
staticmethod
def
clean
():
GPIO
.
cleanup
()
if
OnRasp
:
GPIO
.
cleanup
()
main.py
View file @
62d68f63
...
...
@@ -6,6 +6,9 @@ Created on Wed Apr 18 18:34:40 2018
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import
os
OnRasp
=
os
.
uname
()[
1
]
==
'raspberrypi'
import
sys
import
logging
import
threading
...
...
replay.py
View file @
62d68f63
...
...
@@ -6,15 +6,12 @@ Created on Wed Apr 18 18:34:40 2018
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import
os
from
threading
import
Thread
,
Event
from
main
import
MainWin
from
main
import
MainWin
,
OnRasp
from
settings
import
Settings
onRasp
=
os
.
uname
()[
1
]
==
'raspberrypi'
if
onRasp
:
if
OnRasp
:
import
picamera
class
Replay
(
Thread
):
...
...
@@ -27,7 +24,7 @@ class Replay(Thread):
self
.
stop_flag
=
Event
()
self
.
stopped_flag
=
Event
()
if
o
nRasp
:
if
O
nRasp
:
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
...
...
@@ -36,14 +33,15 @@ class Replay(Thread):
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
def
start_recording
(
self
):
if
o
nRasp
:
if
O
nRasp
:
self
.
start_flag
.
set
()
def
stop_recording
(
self
):
if
o
nRasp
:
if
O
nRasp
:
self
.
stop_flag
.
set
()
self
.
stopped_flag
.
wait
()
# Clear all control flags
self
.
stop_flag
.
clear
()
self
.
start_flag
.
clear
()
self
.
stopped_flag
.
clear
()
...
...
@@ -69,6 +67,8 @@ class Replay(Thread):
self
.
stream
.
copy_to
(
self
.
replayPath
)
self
.
stream
.
clear
()
# Set this flag to tell the calling thread that replay is saved
self
.
stopped_flag
.
set
()
self
.
cam
.
close
()
...
...
@@ -76,4 +76,4 @@ class Replay(Thread):
@
staticmethod
def
isCamAvailable
():
return
o
nRasp
# and other checks (ToDo)
return
O
nRasp
# and other checks (ToDo)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment