Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
magic_mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
42loop
magic_mirror
Commits
35a7d59c
Commit
35a7d59c
authored
5 years ago
by
42loop
Browse files
Options
Downloads
Patches
Plain Diff
added sensor function, layout mods
parent
ccdb25d8
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/mirror.py
+36
-22
36 additions, 22 deletions
python/mirror.py
with
36 additions
and
22 deletions
python/mirror.py
+
36
−
22
View file @
35a7d59c
#!/usr/bin/env python3
#!/usr/bin/env python3
###################################################
###################################################
active
=
Tru
e
active
=
Fals
e
commentfontsize
=
1
8
commentfontsize
=
2
8
commentleft
=
1
4
00
commentleft
=
1
1
00
commenttop
=
1000
commenttop
=
1000
maxwidth
=
4
00
maxwidth
=
7
00
###################################################
###################################################
...
@@ -22,6 +22,8 @@ import RPi.GPIO as GPIO
...
@@ -22,6 +22,8 @@ import RPi.GPIO as GPIO
###################################################
###################################################
#internal variables:
#internal variables:
sensortimeout
=
0
evg
=
LibShapes
()
evg
=
LibShapes
()
t
=
None
t
=
None
...
@@ -69,15 +71,15 @@ def quicktimerevent():
...
@@ -69,15 +71,15 @@ def quicktimerevent():
toremove
=-
1
toremove
=-
1
for
i
in
range
(
0
,
len
(
activecommentsopa
)):
for
i
in
range
(
0
,
len
(
activecommentsopa
)):
if
activecommentsopa
[
i
]
>
0.01
:
if
activecommentsopa
[
i
]
>
0.01
:
activecommentsopa
[
i
]
-=
.
0
1
activecommentsopa
[
i
]
-=
.
0
05
if
activecommentsopa
[
i
]
<
0.0
1
:
if
activecommentsopa
[
i
]
<
0.0
05
:
activecommentsopa
[
i
]
=
0
activecommentsopa
[
i
]
=
0
toremove
=
i
toremove
=
i
if
toremove
>-
1
:
if
toremove
>-
1
:
del
activecomments
[
toremove
]
del
activecomments
[
toremove
]
del
activecommentsopa
[
toremove
]
del
activecommentsopa
[
toremove
]
print
(
activecomments
)
#
print(activecomments)
tenthcounter
+=
1
tenthcounter
+=
1
if
tenthcounter
==
10
:
if
tenthcounter
==
10
:
...
@@ -93,7 +95,13 @@ def sectimerevent():
...
@@ -93,7 +95,13 @@ def sectimerevent():
global
likecount
global
likecount
global
lastlike
global
lastlike
global
activecommentsopa
global
activecommentsopa
global
active
global
sensortimeout
sensortimeout
-=
1
if
sensortimeout
==
0
:
active
=
False
sensor_off
()
val
+=
1
val
+=
1
currenttext
=
random
.
randint
(
0
,
textcount
-
2
)
currenttext
=
random
.
randint
(
0
,
textcount
-
2
)
...
@@ -109,12 +117,12 @@ def sectimerevent():
...
@@ -109,12 +117,12 @@ def sectimerevent():
activecommentsopa
.
append
(
1
)
activecommentsopa
.
append
(
1
)
nl
=
random
.
randint
(
0
,
100
)
nl
=
random
.
randint
(
0
,
100
)
if
nl
<
1
0
:
if
nl
<
2
0
:
#print("new like")
#print("new like")
likecount
+=
1
likecount
+=
1
lastlike
=
0
#
lastlike=0
activecomments
.
clear
()
#
activecomments.clear()
activecommentsopa
.
clear
()
#
activecommentsopa.clear()
else
:
else
:
lastlike
+=
1
lastlike
+=
1
return
return
...
@@ -127,7 +135,7 @@ def readcontent():
...
@@ -127,7 +135,7 @@ def readcontent():
line
=
fp
.
readline
()
line
=
fp
.
readline
()
cnt
=
1
cnt
=
1
while
line
:
while
line
:
#
print(line)
textstore
.
append
(
breaklines
(
line
.
strip
()))
textstore
.
append
(
breaklines
(
line
.
strip
()))
line
=
fp
.
readline
()
line
=
fp
.
readline
()
cnt
+=
1
cnt
+=
1
...
@@ -167,6 +175,7 @@ def breaklines(line):
...
@@ -167,6 +175,7 @@ def breaklines(line):
res
+=
word
+
"
"
res
+=
word
+
"
"
print
(
res
)
tinfo
.
append
(
res
)
tinfo
.
append
(
res
)
tinfo
.
append
(
linecount
)
tinfo
.
append
(
linecount
)
return
tinfo
return
tinfo
...
@@ -175,7 +184,7 @@ def maketextbox(x,y,i,opa):
...
@@ -175,7 +184,7 @@ def maketextbox(x,y,i,opa):
#print("maketextbox")
#print("maketextbox")
lines
=
textstore
[
i
][
1
]
lines
=
textstore
[
i
][
1
]
evg
.
fill
(
255
,
255
,
255
,
opa
)
evg
.
fill
(
255
,
255
,
255
,
opa
)
height
=
lines
*
(
commentfontsize
+
commentfontsize
/
3
)
+
20
height
=
lines
*
(
commentfontsize
+
commentfontsize
/
2.5
)
+
20
evg
.
round_rect
(
x
,
y
-
height
,
maxwidth
+
20
,
height
,
10
,
10
)
evg
.
round_rect
(
x
,
y
-
height
,
maxwidth
+
20
,
height
,
10
,
10
)
evg
.
fill
(
0
,
0
,
0
,
opa
)
evg
.
fill
(
0
,
0
,
0
,
opa
)
evg
.
text
(
x
+
10
,
y
-
(
commentfontsize
+
commentfontsize
/
3
)
-
5
,
bytes
(
textstore
[
i
][
0
],
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
x
+
10
,
y
-
(
commentfontsize
+
commentfontsize
/
3
)
-
5
,
bytes
(
textstore
[
i
][
0
],
'
utf-8
'
),
None
,
commentfontsize
)
...
@@ -197,9 +206,11 @@ def sensor_on():
...
@@ -197,9 +206,11 @@ def sensor_on():
global
lastlike
global
lastlike
global
activecomments
global
activecomments
global
activecommentsopa
global
activecommentsopa
global
likecount
likecount
=
0
activecomments
.
clear
()
activecomments
.
clear
()
activecommentsopa
.
clear
()
activecommentsopa
.
clear
()
lastlike
=
-
1
lastlike
=
0
active
=
True
active
=
True
def
sensor_off
():
def
sensor_off
():
...
@@ -223,6 +234,8 @@ t2 = aTimer(.1,quicktimerevent)
...
@@ -223,6 +234,8 @@ t2 = aTimer(.1,quicktimerevent)
t2
.
start
()
t2
.
start
()
lastsens
=
True
lastsens
=
True
#quit()
while
1
:
while
1
:
evg
.
begin
()
evg
.
begin
()
...
@@ -230,20 +243,20 @@ while 1:
...
@@ -230,20 +243,20 @@ while 1:
evg
.
background
(
0
,
0
,
0
)
evg
.
background
(
0
,
0
,
0
)
evg
.
image
(
30
,
3
0
,
150
,
150
,
b
'
heart.jpg
'
)
evg
.
image
(
30
,
6
0
,
150
,
150
,
b
'
heart.jpg
'
)
if
active
:
if
active
:
evg
.
fill
(
255
,
255
,
255
,
1
)
evg
.
fill
(
255
,
255
,
255
,
1
)
if
(
lastlike
!=-
1
):
if
(
lastlike
!=-
1
):
evg
.
text
(
160
,
6
0
,
bytes
(
"
Gefällt
"
,
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
160
,
9
0
,
bytes
(
"
Gefällt
"
,
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
50
,
30
,
bytes
(
"
vor
"
+
str
(
lastlike
)
+
"
Sekunden
"
,
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
50
,
30
,
bytes
(
"
vor
"
+
str
(
lastlike
)
+
"
Sekunden
"
,
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
2
5
0
,
6
0
,
bytes
(
str
(
likecount
),
'
utf-8
'
),
None
,
100
)
evg
.
text
(
2
9
0
,
9
0
,
bytes
(
str
(
likecount
),
'
utf-8
'
),
None
,
100
)
lw
=
evg
.
text_width
(
bytes
(
str
(
likecount
),
'
utf-8
'
),
None
,
100
)
lw
=
evg
.
text_width
(
bytes
(
str
(
likecount
),
'
utf-8
'
),
None
,
100
)
evg
.
text
(
2
5
0
+
lw
+
10
,
6
0
,
bytes
(
"
Mal
"
,
'
utf-8
'
),
None
,
commentfontsize
)
evg
.
text
(
2
9
0
+
lw
+
10
,
9
0
,
bytes
(
"
Mal
"
,
'
utf-8
'
),
None
,
commentfontsize
)
makecomments
()
makecomments
()
...
@@ -252,10 +265,11 @@ while 1:
...
@@ -252,10 +265,11 @@ while 1:
sens
=
GPIO
.
input
(
sensor
)
sens
=
GPIO
.
input
(
sensor
)
if
sens
!=
lastsens
:
if
sens
!=
lastsens
:
lastsens
=
sens
lastsens
=
sens
if
sens
==
False
:
if
sens
==
True
:
if
sensortimeout
==
0
:
sensor_on
()
sensor_on
()
else
:
print
(
"
ON
"
)
sensor
_off
()
sensor
timeout
=
15
#input()
#input()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment