Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gopro
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tony Mai
gopro
Commits
afa27fda
Commit
afa27fda
authored
Aug 03, 2019
by
Tony Mai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f199c2ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
57 deletions
+89
-57
gui.py
python/gui.py
+46
-27
wireless_copy_files_to_nfs.py
python/wireless_copy_files_to_nfs.py
+43
-30
No files found.
python/gui.py
View file @
afa27fda
...
@@ -13,6 +13,13 @@ import subprocess
...
@@ -13,6 +13,13 @@ import subprocess
import
os
import
os
import
netifaces
import
netifaces
#Colours
WHITE
=
(
255
,
255
,
255
)
BLACK
=
(
0
,
0
,
0
)
RED
=
(
255
,
0
,
0
)
GREEN
=
(
0
,
255
,
0
)
BLUE
=
(
0
,
0
,
255
)
def
write_log
(
str
):
def
write_log
(
str
):
global
log
global
log
...
@@ -26,6 +33,7 @@ def write_log(str):
...
@@ -26,6 +33,7 @@ def write_log(str):
refresh
()
refresh
()
time
.
sleep
(
0.1
)
...
@@ -49,8 +57,8 @@ def printEvent(event):
...
@@ -49,8 +57,8 @@ def printEvent(event):
print
(
"Type: {0}"
.
format
(
event
.
type
))
print
(
"Type: {0}"
.
format
(
event
.
type
))
print
(
"Code: {0}"
.
format
(
event
.
code
))
print
(
"Code: {0}"
.
format
(
event
.
code
))
def
text_objects
(
text
,
font
):
def
text_objects
(
text
,
font
,
color
=
WHITE
):
textSurface
=
font
.
render
(
text
,
True
,
WHITE
)
textSurface
=
font
.
render
(
text
,
True
,
color
)
return
textSurface
,
textSurface
.
get_rect
()
return
textSurface
,
textSurface
.
get_rect
()
# This is the important bit
# This is the important bit
...
@@ -63,17 +71,23 @@ def refresh():
...
@@ -63,17 +71,23 @@ def refresh():
f
.
write
(
lcd
.
convert
(
16
,
0
)
.
get_buffer
())
f
.
write
(
lcd
.
convert
(
16
,
0
)
.
get_buffer
())
# We can then close our access to the framebuffer
# We can then close our access to the framebuffer
f
.
close
()
f
.
close
()
time
.
sleep
(
0.1
)
#
time.sleep(0.1)
def
button
(
lcd
,
msg
,
x
,
y
,
w
,
h
,
ic
,
ac
,
mouse
,
action
=
None
,
next_layout
=
None
):
def
button
(
lcd
,
msg
,
x
,
y
,
w
,
h
,
ic
,
ac
,
mouse
,
action
=
None
,
next_layout
=
None
):
if
x
+
w
>
mouse
[
0
]
>
x
and
y
+
h
>
mouse
[
1
]
>
y
:
if
x
+
w
>
mouse
[
0
]
>
x
and
y
+
h
>
mouse
[
1
]
>
y
:
pygame
.
draw
.
rect
(
lcd
,
ac
,(
x
,
y
,
w
,
h
))
pygame
.
draw
.
rect
(
lcd
,
ic
,(
x
,
y
,
w
,
h
))
text
=
pygame
.
font
.
SysFont
(
"comicsansms"
,
25
)
textSurf
,
textRect
=
text_objects
(
msg
,
text
,
ac
)
textRect
.
center
=
(
(
x
+
(
w
/
2
)),
(
y
+
(
h
/
2
))
)
lcd
.
blit
(
textSurf
,
textRect
)
refresh
()
time
.
sleep
(
0.1
)
#scroll_up()
lcd
.
fill
(
BLACK
)
lcd
.
fill
(
BLACK
)
refresh
()
refresh
()
if
action
!=
None
:
if
action
!=
None
:
print
(
"clicked "
+
msg
)
action
()
action
()
global
layout
global
layout
layout
=
next_layout
layout
=
next_layout
...
@@ -82,30 +96,38 @@ def button(lcd,msg,x,y,w,h,ic,ac,mouse,action=None,next_layout=None):
...
@@ -82,30 +96,38 @@ def button(lcd,msg,x,y,w,h,ic,ac,mouse,action=None,next_layout=None):
return
0
return
0
else
:
else
:
pygame
.
draw
.
rect
(
lcd
,
ic
,(
x
,
y
,
w
,
h
),
1
)
pygame
.
draw
.
rect
(
lcd
,
ic
,(
x
,
y
,
w
,
h
),
1
)
text
=
pygame
.
font
.
SysFont
(
"comicsansms"
,
25
)
text
=
pygame
.
font
.
SysFont
(
"comicsansms"
,
25
)
textSurf
,
textRect
=
text_objects
(
msg
,
text
)
textSurf
,
textRect
=
text_objects
(
msg
,
text
,
ic
)
textRect
.
center
=
(
(
x
+
(
w
/
2
)),
(
y
+
(
h
/
2
))
)
textRect
.
center
=
(
(
x
+
(
w
/
2
)),
(
y
+
(
h
/
2
))
)
lcd
.
blit
(
textSurf
,
textRect
)
lcd
.
blit
(
textSurf
,
textRect
)
return
1
return
1
def
main_layout
(
lcd
,
mouse
):
def
main_layout
(
lcd
,
mouse
):
button
(
lcd
,
"Copy Fusion to BACKUP"
,
5
,
45
,
230
,
50
,
WHITE
,
WHITE
,
mouse
,
wireless_copy_files_to_backup
.
run
,
log_layout
)
and
\
button
(
lcd
,
"Copy Fusion to BACKUP"
,
5
,
45
,
230
,
50
,
WHITE
,
BLACK
,
mouse
,
wireless_copy_files_to_backup
.
run
,
log_layout
)
and
\
button
(
lcd
,
"Copy Fusion to NFS"
,
5
,
100
,
230
,
50
,
WHITE
,
WHITE
,
mouse
,
wireless_copy_files_to_nfs
.
run
,
log_layout
)
and
\
button
(
lcd
,
"Copy Fusion to NFS"
,
5
,
100
,
230
,
50
,
WHITE
,
BLACK
,
mouse
,
wireless_copy_files_to_nfs
.
run
,
log_layout
)
and
\
button
(
lcd
,
"Network Info."
,
5
,
155
,
230
,
50
,
WHITE
,
WHITE
,
mouse
,
show_network_info
,
log_layout
)
and
\
button
(
lcd
,
"Network Info."
,
5
,
155
,
230
,
50
,
WHITE
,
BLACK
,
mouse
,
show_network_info
,
log_layout
)
and
\
button
(
lcd
,
"Shutdown..."
,
5
,
210
,
230
,
50
,
WHITE
,
WHITE
,
mouse
,
None
,
dialog_shutdown_layout
)
and
\
button
(
lcd
,
"Shutdown..."
,
5
,
210
,
230
,
50
,
WHITE
,
BLACK
,
mouse
,
None
,
dialog_shutdown_layout
)
and
\
button
(
lcd
,
"Reboot..."
,
240
,
210
,
230
,
50
,
WHITE
,
WHITE
,
mouse
,
None
,
dialog_reboot_layout
)
button
(
lcd
,
"Reboot..."
,
240
,
210
,
230
,
50
,
WHITE
,
BLACK
,
mouse
,
None
,
dialog_reboot_layout
)
def
dialog_shutdown_layout
(
lcd
,
mouse
):
def
dialog_shutdown_layout
(
lcd
,
mouse
):
lcd
.
blit
(
defaultFont
.
render
(
"Shutdown?"
,
False
,
WHITE
),(
190
,
70
))
lcd
.
blit
(
defaultFont
.
render
(
"Shutdown?"
,
False
,
WHITE
),(
190
,
70
))
button
(
lcd
,
"Yes"
,
65
,
145
,
140
,
50
,
WHITE
,
WHITE
,
mouse
,
shutdown
,
main_layout
)
and
\
button
(
lcd
,
"Yes"
,
65
,
145
,
140
,
50
,
WHITE
,
BLACK
,
mouse
,
shutdown
,
main_layout
)
and
\
button
(
lcd
,
"No"
,
265
,
145
,
140
,
50
,
WHITE
,
WHITE
,
mouse
,
None
,
main_layout
)
button
(
lcd
,
"No"
,
265
,
145
,
140
,
50
,
WHITE
,
BLACK
,
mouse
,
None
,
main_layout
)
def
dialog_reboot_layout
(
lcd
,
mouse
):
def
dialog_reboot_layout
(
lcd
,
mouse
):
lcd
.
blit
(
defaultFont
.
render
(
"Reboot?"
,
False
,
WHITE
),(
190
,
70
))
lcd
.
blit
(
defaultFont
.
render
(
"Reboot?"
,
False
,
WHITE
),(
190
,
70
))
button
(
lcd
,
"Yes"
,
65
,
145
,
140
,
50
,
WHITE
,
WHITE
,
mouse
,
reboot
,
main_layout
)
and
\
button
(
lcd
,
"Yes"
,
65
,
145
,
140
,
50
,
WHITE
,
BLACK
,
mouse
,
reboot
,
main_layout
)
and
\
button
(
lcd
,
"No"
,
265
,
145
,
140
,
50
,
WHITE
,
WHITE
,
mouse
,
None
,
main_layout
)
button
(
lcd
,
"No"
,
265
,
145
,
140
,
50
,
WHITE
,
BLACK
,
mouse
,
None
,
main_layout
)
def
scroll_up
():
for
i
in
range
(
0
,
surfaceSize
[
1
],
1
):
pygame
.
draw
.
rect
(
lcd
,
BLACK
,(
0
,
surfaceSize
[
1
]
-
i
,
surfaceSize
[
0
],
i
))
refresh
()
lcd
.
fill
(
BLACK
)
refresh
()
def
reboot
():
def
reboot
():
os
.
system
(
'shutdown -r'
)
os
.
system
(
'shutdown -r'
)
exit
()
exit
()
...
@@ -115,12 +137,13 @@ def shutdown():
...
@@ -115,12 +137,13 @@ def shutdown():
exit
()
exit
()
def
show_network_info
():
def
show_network_info
():
reset_log_buffer
()
write_log
(
"SSID: WAPPI"
)
write_log
(
"SSID: WAPPI"
)
write_log
(
netifaces
.
ifaddresses
(
'wlan0'
)[
netifaces
.
AF_INET
][
0
][
'addr'
])
write_log
(
netifaces
.
ifaddresses
(
'wlan0'
)[
netifaces
.
AF_INET
][
0
][
'addr'
])
def
log_layout
(
lcd
,
mouse
):
def
log_layout
(
lcd
,
mouse
):
lcd
.
blit
(
defaultFont
.
render
(
"Log:"
,
False
,
WHITE
),(
0
,
0
))
lcd
.
blit
(
defaultFont
.
render
(
"Log:"
,
False
,
WHITE
),(
0
,
0
))
button
(
lcd
,
"Done"
,
340
,
0
,
100
,
50
,
WHITE
,
WHITE
,
mouse
,
None
,
main_layout
)
button
(
lcd
,
"Done"
,
340
,
0
,
100
,
50
,
WHITE
,
BLACK
,
mouse
,
None
,
main_layout
)
...
@@ -141,6 +164,10 @@ def read_log(file_ptr):
...
@@ -141,6 +164,10 @@ def read_log(file_ptr):
return
file_ptr
.
readline
()
return
file_ptr
.
readline
()
def
reset_log_buffer
():
global
log
log
=
[
""
]
*
LOGSIZE
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
...
@@ -160,13 +187,12 @@ LOGSIZE=25
...
@@ -160,13 +187,12 @@ LOGSIZE=25
log
=
[
""
]
*
LOGSIZE
log
=
[
""
]
*
LOGSIZE
import
wireless_copy_files_to_backup
import
wireless_copy_files_to_backup
import
wireless_copy_files_to_nfs
import
wireless_copy_files_to_nfs
# Very important: the exact pixel size of the TFT screen must be known so we can build graphics at this exact format
# Very important: the exact pixel size of the TFT screen must be known so we can build graphics at this exact format
surfaceSize
=
(
480
,
320
)
surfaceSize
=
(
480
,
320
)
...
@@ -193,13 +219,6 @@ tftAbsDelta = (abs(tftEnd [0] - tftOrig [0]), abs(tftEnd [1] - tftOrig [1]))
...
@@ -193,13 +219,6 @@ tftAbsDelta = (abs(tftEnd [0] - tftOrig [0]), abs(tftEnd [1] - tftOrig [1]))
#Colours
WHITE
=
(
255
,
255
,
255
)
BLACK
=
(
0
,
0
,
0
)
RED
=
(
255
,
0
,
0
)
GREEN
=
(
0
,
255
,
0
)
BLUE
=
(
0
,
0
,
255
)
lcd
.
fill
(
BLACK
)
lcd
.
fill
(
BLACK
)
...
...
python/wireless_copy_files_to_nfs.py
View file @
afa27fda
...
@@ -8,9 +8,10 @@ import os
...
@@ -8,9 +8,10 @@ import os
import
sys
import
sys
import
re
import
re
import
time
import
time
import
netifaces
NFSPATH
=
"/nfs/ANGELICA/
videos/
"
NFSPATH
=
"/nfs/ANGELICA/
camera
"
method_ptr
=
None
method_ptr
=
None
...
@@ -46,6 +47,11 @@ def camera_info(cam_ptr):
...
@@ -46,6 +47,11 @@ def camera_info(cam_ptr):
msg
(
"firmware version: "
+
""
+
cam_ptr
.
infoCamera
(
constants
.
Camera
.
Firmware
))
msg
(
"firmware version: "
+
""
+
cam_ptr
.
infoCamera
(
constants
.
Camera
.
Firmware
))
msg
(
"serial number: "
+
""
+
cam_ptr
.
infoCamera
(
constants
.
Camera
.
SerialNumber
))
msg
(
"serial number: "
+
""
+
cam_ptr
.
infoCamera
(
constants
.
Camera
.
SerialNumber
))
def
ping
(
hostname
):
#returns 0 if hostame is up
return
os
.
system
(
"ping -c 1 "
+
hostname
)
def
run
(
folder_dst
=
None
,
ptr
=
None
):
def
run
(
folder_dst
=
None
,
ptr
=
None
):
...
@@ -53,18 +59,17 @@ def run(folder_dst=None,ptr=None):
...
@@ -53,18 +59,17 @@ def run(folder_dst=None,ptr=None):
if
(
ptr
):
if
(
ptr
):
log_ptr
=
ptr
log_ptr
=
ptr
os
.
system
(
"umount
/nfs/ANGELICA/videos"
)
os
.
system
(
"umount
"
+
NFSPATH
)
if
os
.
system
(
"mount 192.168.0.2:/mnt/user/
videos /nfs/ANGELICA/videos"
)
!=
0
:
if
os
.
system
(
"mount 192.168.0.2:/mnt/user/
camera "
+
NFSPATH
)
!=
0
:
msg
(
"fail to mount 192.168.0.2:/mnt/user/
videos
... exiting.."
)
msg
(
"fail to mount 192.168.0.2:/mnt/user/
camera
... exiting.."
)
return
return
msg
(
"192.168.0.2:/mnt/user/
videos
mounted..."
)
msg
(
"192.168.0.2:/mnt/user/
camera
mounted..."
)
if
folder_dst
==
None
:
if
folder_dst
==
None
:
msg
(
"Generating generic folder..."
)
msg
(
"Generating generic folder..."
)
for
i
in
range
(
0
,
1000
):
for
i
in
range
(
0
,
1000
):
folder_dst
=
NFSPATH
+
"/CP_"
+
str
(
i
)
folder_dst
=
NFSPATH
+
"/fusion/CP_"
+
str
(
i
)
#if not(os.path.isdir(BACKUPPATH+"/CP_"+str(i))) or not(os.path.exists(BACKUPPATH+"/CP_"+str(i))):
if
not
(
os
.
path
.
isdir
(
folder_dst
))
or
not
(
os
.
path
.
exists
(
folder_dst
)):
if
not
(
os
.
path
.
isdir
(
folder_dst
))
or
not
(
os
.
path
.
exists
(
folder_dst
)):
break
break
if
i
==
1000
:
if
i
==
1000
:
...
@@ -82,11 +87,6 @@ def run(folder_dst=None,ptr=None):
...
@@ -82,11 +87,6 @@ def run(folder_dst=None,ptr=None):
os
.
system
(
"mkdir "
+
folder_dst
)
msg
(
"mkdir "
+
folder_dst
)
msg
(
"Checking wlan1..."
)
msg
(
"Checking wlan1..."
)
try
:
try
:
...
@@ -94,19 +94,32 @@ def run(folder_dst=None,ptr=None):
...
@@ -94,19 +94,32 @@ def run(folder_dst=None,ptr=None):
except
:
except
:
msg
(
"wlan1 not connected to Gopro SSID. exiting..."
)
msg
(
"wlan1 not connected to Gopro SSID. exiting..."
)
return
return
gpCam
=
GoProCamera
.
GoPro
()
gpCam
=
GoProCamera
.
GoPro
()
#if ping(gpCam.ip_addr):
# msg ("Ping gopro ("+gpCam.ip_addr+") failed. Exit...")
# return
#else:
# msg ("Ping gopro ok.")
gpCam
.
pair
(
usepin
=
False
)
gpCam
.
pair
(
usepin
=
False
)
#gpCam.pair(usepin=True)
#gpCam.pair(usepin=True)
os
.
system
(
"mkdir "
+
folder_dst
)
msg
(
"mkdir "
+
folder_dst
)
print
(
"Start..."
)
msg
(
"Start..."
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
start_time
=
time
.
time
()
start_time
=
time
.
time
()
print
(
"Start time :"
,
localtime
)
msg
(
"Start time :"
+
str
(
localtime
)
)
camera_info
(
gpCam
)
camera_info
(
gpCam
)
data
=
gpCam
.
listMedia
(
True
,
True
)
data
=
gpCam
.
listMedia
(
True
,
True
)
for
i
in
range
(
len
(
data
)):
for
i
in
range
(
len
(
data
)):
...
@@ -116,27 +129,27 @@ def run(folder_dst=None,ptr=None):
...
@@ -116,27 +129,27 @@ def run(folder_dst=None,ptr=None):
for
i
in
data
:
for
i
in
data
:
folder
=
i
[
0
]
folder
=
i
[
0
]
if
not
os
.
path
.
exists
(
f
ile_path
+
"/"
+
folder
):
if
not
os
.
path
.
exists
(
f
older_dst
+
"/"
+
folder
):
os
.
makedirs
(
f
ile_path
+
"/"
+
folder
);
os
.
makedirs
(
f
older_dst
+
"/"
+
folder
);
mp4_file
=
i
[
1
]
mp4_file
=
i
[
1
]
lrv_file
=
re
.
sub
(
".MP4"
,
".LRV"
,
mp4_file
)
lrv_file
=
re
.
sub
(
".MP4"
,
".LRV"
,
mp4_file
)
msg
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
f
ile_path
);
msg
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
f
older_dst
);
gpCam
.
downloadMedia
(
folder
,
mp4_file
,
f
ile_path
+
"/"
+
folder
+
"/"
+
mp4_file
)
gpCam
.
downloadMedia
(
folder
,
mp4_file
,
f
older_dst
+
"/"
+
folder
+
"/"
+
mp4_file
)
msg
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
f
ile_path
);
msg
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
f
older_dst
);
gpCam
.
downloadMedia
(
folder
,
lrv_file
,
f
ile_path
+
"/"
+
folder
+
"/"
+
lrv_file
)
gpCam
.
downloadMedia
(
folder
,
lrv_file
,
f
older_dst
+
"/"
+
folder
+
"/"
+
lrv_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
)
or
re
.
search
(
"GB"
,
mp4_file
):
if
re
.
search
(
"GPBK"
,
mp4_file
)
or
re
.
search
(
"GB"
,
mp4_file
):
wav_file
=
re
.
sub
(
".MP4"
,
".WAV"
,
mp4_file
)
wav_file
=
re
.
sub
(
".MP4"
,
".WAV"
,
mp4_file
)
#msg("copy "+folder+"/"+wav_file+" to "+f
ile_path
);
#msg("copy "+folder+"/"+wav_file+" to "+f
older_dst
);
gpCam
.
downloadMedia
(
folder
,
wav_file
,
f
ile_path
+
"/"
+
folder
+
"/"
+
wav_file
)
gpCam
.
downloadMedia
(
folder
,
wav_file
,
f
older_dst
+
"/"
+
folder
+
"/"
+
wav_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
):
if
re
.
search
(
"GPBK"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#msg("copy "+folder+"/"+thm_file+" to "+f
ile_path
);
#msg("copy "+folder+"/"+thm_file+" to "+f
older_dst
);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
f
ile_path
+
"/"
+
folder
+
"/"
+
thm_file
)
gpCam
.
downloadMedia
(
folder
,
thm_file
,
f
older_dst
+
"/"
+
folder
+
"/"
+
thm_file
)
if
re
.
search
(
"GPFR"
,
mp4_file
):
if
re
.
search
(
"GPFR"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#msg("copy "+folder+"/"+thm_file+" to "+f
ile_path
);
#msg("copy "+folder+"/"+thm_file+" to "+f
older_dst
);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
f
ile_path
+
"/"
+
folder
+
"/"
+
thm_file
)
gpCam
.
downloadMedia
(
folder
,
thm_file
,
f
older_dst
+
"/"
+
folder
+
"/"
+
thm_file
)
...
@@ -145,7 +158,7 @@ def run(folder_dst=None,ptr=None):
...
@@ -145,7 +158,7 @@ def run(folder_dst=None,ptr=None):
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
elapsed_time
=
time
.
time
()
-
start_time
elapsed_time
=
time
.
time
()
-
start_time
msg
(
"End time :"
,
localtime
)
msg
(
"End time :"
+
str
(
localtime
)
)
hours
,
rem
=
divmod
(
elapsed_time
,
3600
)
hours
,
rem
=
divmod
(
elapsed_time
,
3600
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
...
...
Write
Preview
Markdown
is supported
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