Skip to content
GitLab
Menu
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
Show 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.
...
@@ -103,4 +103,4 @@ For the time being, those are provided by the PI camera module.
## Todo
## 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
...
@@ -9,7 +9,11 @@ Created on Wed Apr 18 18:34:40 2018
import
logging
import
logging
import
pyautogui
# PyPi library
import
pyautogui
# PyPi library
from
threading
import
Thread
from
threading
import
Thread
import
RPi.GPIO
as
GPIO
from
main
import
OnRasp
if
OnRasp
:
import
RPi.GPIO
as
GPIO
from
player
import
Side
from
player
import
Side
...
@@ -28,6 +32,7 @@ class GPIOThread(Thread):
...
@@ -28,6 +32,7 @@ class GPIOThread(Thread):
self
.
dispatcher
=
dispatcher
self
.
dispatcher
=
dispatcher
self
.
continueRunning
=
True
self
.
continueRunning
=
True
if
OnRasp
:
GPIO
.
setwarnings
(
False
)
GPIO
.
setwarnings
(
False
)
GPIO
.
setmode
(
GPIO
.
BCM
)
GPIO
.
setmode
(
GPIO
.
BCM
)
...
@@ -37,6 +42,7 @@ class GPIOThread(Thread):
...
@@ -37,6 +42,7 @@ class GPIOThread(Thread):
GPIO
.
add_event_detect
(
pin
,
GPIO
.
RISING
,
callback
=
self
.
handleButtonPress
)
GPIO
.
add_event_detect
(
pin
,
GPIO
.
RISING
,
callback
=
self
.
handleButtonPress
)
def
run
(
self
):
def
run
(
self
):
if
OnRasp
:
try
:
try
:
while
self
.
continueRunning
:
while
self
.
continueRunning
:
pass
pass
...
@@ -56,4 +62,5 @@ class GPIOThread(Thread):
...
@@ -56,4 +62,5 @@ class GPIOThread(Thread):
@
staticmethod
@
staticmethod
def
clean
():
def
clean
():
if
OnRasp
:
GPIO
.
cleanup
()
GPIO
.
cleanup
()
main.py
View file @
62d68f63
...
@@ -6,6 +6,9 @@ Created on Wed Apr 18 18:34:40 2018
...
@@ -6,6 +6,9 @@ Created on Wed Apr 18 18:34:40 2018
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
"""
import
os
OnRasp
=
os
.
uname
()[
1
]
==
'raspberrypi'
import
sys
import
sys
import
logging
import
logging
import
threading
import
threading
...
...
replay.py
View file @
62d68f63
...
@@ -6,15 +6,12 @@ Created on Wed Apr 18 18:34:40 2018
...
@@ -6,15 +6,12 @@ Created on Wed Apr 18 18:34:40 2018
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
"""
import
os
from
threading
import
Thread
,
Event
from
threading
import
Thread
,
Event
from
main
import
MainWin
from
main
import
MainWin
,
OnRasp
from
settings
import
Settings
from
settings
import
Settings
onRasp
=
os
.
uname
()[
1
]
==
'raspberrypi'
if
OnRasp
:
if
onRasp
:
import
picamera
import
picamera
class
Replay
(
Thread
):
class
Replay
(
Thread
):
...
@@ -27,7 +24,7 @@ class Replay(Thread):
...
@@ -27,7 +24,7 @@ class Replay(Thread):
self
.
stop_flag
=
Event
()
self
.
stop_flag
=
Event
()
self
.
stopped_flag
=
Event
()
self
.
stopped_flag
=
Event
()
if
o
nRasp
:
if
O
nRasp
:
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
=
picamera
.
PiCamera
()
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
resolution
=
Settings
[
'picam.resolution'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
self
.
cam
.
framerate
=
Settings
[
'picam.fps'
]
...
@@ -36,14 +33,15 @@ class Replay(Thread):
...
@@ -36,14 +33,15 @@ class Replay(Thread):
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
self
.
stream
=
picamera
.
PiCameraCircularIO
(
self
.
cam
,
seconds
=
Settings
[
'replay.duration'
])
def
start_recording
(
self
):
def
start_recording
(
self
):
if
o
nRasp
:
if
O
nRasp
:
self
.
start_flag
.
set
()
self
.
start_flag
.
set
()
def
stop_recording
(
self
):
def
stop_recording
(
self
):
if
o
nRasp
:
if
O
nRasp
:
self
.
stop_flag
.
set
()
self
.
stop_flag
.
set
()
self
.
stopped_flag
.
wait
()
self
.
stopped_flag
.
wait
()
# Clear all control flags
self
.
stop_flag
.
clear
()
self
.
stop_flag
.
clear
()
self
.
start_flag
.
clear
()
self
.
start_flag
.
clear
()
self
.
stopped_flag
.
clear
()
self
.
stopped_flag
.
clear
()
...
@@ -69,6 +67,8 @@ class Replay(Thread):
...
@@ -69,6 +67,8 @@ class Replay(Thread):
self
.
stream
.
copy_to
(
self
.
replayPath
)
self
.
stream
.
copy_to
(
self
.
replayPath
)
self
.
stream
.
clear
()
self
.
stream
.
clear
()
# Set this flag to tell the calling thread that replay is saved
self
.
stopped_flag
.
set
()
self
.
stopped_flag
.
set
()
self
.
cam
.
close
()
self
.
cam
.
close
()
...
@@ -76,4 +76,4 @@ class Replay(Thread):
...
@@ -76,4 +76,4 @@ class Replay(Thread):
@
staticmethod
@
staticmethod
def
isCamAvailable
():
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
.
Attach a 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