Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MIBAM
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefy Lanza (nextime / spora )
MIBAM
Commits
bb79c051
Commit
bb79c051
authored
May 01, 2015
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
394 additions
and
0 deletions
+394
-0
BAM.py
BAM.py
+195
-0
MIBAM.py
MIBAM.py
+196
-0
README.txt
README.txt
+3
-0
No files found.
BAM.py
0 → 100644
View file @
bb79c051
import
pygame
,
sys
import
time
pygame
.
init
()
size
=
width
,
height
=
1024
,
512
screen
=
pygame
.
display
.
set_mode
(
size
)
screen
.
fill
((
0
,
0
,
0
))
rs
=
pygame
.
Surface
((
1
,
2
))
rs
.
fill
((
255
,
0
,
0
))
r
=
[]
bs
=
pygame
.
Surface
((
1
,
2
))
bs
.
fill
((
0
,
0
,
255
))
b
=
[]
gs
=
pygame
.
Surface
((
1
,
2
))
gs
.
fill
((
0
,
255
,
0
))
g
=
[]
per
=
pygame
.
Surface
((
1
,
30
))
per
.
fill
((
255
,
255
,
255
))
pr
=
per
.
get_rect
(
center
=
(
255
,
317
))
pr2
=
per
.
get_rect
(
center
=
(
510
,
317
))
pr3
=
per
.
get_rect
(
center
=
(
765
,
317
))
rrs
=
pygame
.
Surface
((
90
,
30
))
rrs
.
fill
((
255
,
0
,
0
))
ggs
=
pygame
.
Surface
((
90
,
30
))
ggs
.
fill
((
0
,
255
,
0
))
bbs
=
pygame
.
Surface
((
90
,
30
))
bbs
.
fill
((
0
,
0
,
255
))
rr
=
rrs
.
get_rect
(
center
=
(
256
,
100
))
gg
=
ggs
.
get_rect
(
center
=
(
256
,
130
))
bb
=
bbs
.
get_rect
(
center
=
(
256
,
160
))
rgbs
=
pygame
.
Surface
((
90
,
90
))
rgbs
.
fill
((
255
,
255
,
255
))
rgb
=
rgbs
.
get_rect
(
center
=
(
768
,
130
))
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
296
))
)
font
=
pygame
.
font
.
Font
(
None
,
40
)
text
=
font
.
render
(
'RGB VALUES:
%
d,
%
d,
%
d'
%
(
255
,
255
,
255
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
# Create a rectangle
textRect
=
text
.
get_rect
(
center
=
(
512
,
400
))
vals
=
pygame
.
font
.
Font
(
None
,
40
)
valstext
=
font
.
render
(
'PERIOD TICK:
%
d'
%
0
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstextrect
=
valstext
.
get_rect
(
center
=
(
512
,
440
))
vals2
=
pygame
.
font
.
Font
(
None
,
40
)
valstext2
=
font
.
render
(
'DUTY:
%
d'
%
0x80
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstextrect2
=
valstext2
.
get_rect
(
center
=
(
512
,
480
))
Rval
=
255
Gval
=
255
Bval
=
255
Rled
=
0
Gled
=
0
Bled
=
0
#TOS=[0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80]
TOS
=
[
0x80
,
0x40
,
0x20
,
0x10
,
0x8
,
0x4
,
0x2
,
0x1
]
DUTYC
=
0
TICK
=
0
PERIOD
=
0
timer
=
0
maxtimer
=
0
# Questo rappresenta lo scalar
evb
=
'R'
while
True
:
if
timer
==
0
:
# XXX Qui e' come se avvenisse un interrupt.
valstext2
=
font
.
render
(
'DUTY:
%
s (
%
d)'
%
(
str
(
TOS
[
DUTYC
])
.
rjust
(
3
,
'0'
),
DUTYC
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
# Controlliamo se dobbiamo accendere i tre "led" o "colori"
Rled
=
Rval
&
TOS
[
DUTYC
]
Gled
=
Gval
&
TOS
[
DUTYC
]
Bled
=
Bval
&
TOS
[
DUTYC
]
# Modifico il timer scaler nel pic, qui setto semplicmente al prossimo dutyc
maxtimer
=
TOS
[
DUTYC
]
DUTYC
+=
1
# E se siamo arrivati alla fine dei DUTY, partiamo da capo.
if
(
DUTYC
>=
len
(
TOS
)):
DUTYC
=
0
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
sys
.
exit
()
elif
event
.
type
==
pygame
.
KEYDOWN
:
if
event
.
key
==
pygame
.
K_r
:
evb
=
'R'
elif
event
.
key
==
pygame
.
K_g
:
evb
=
'G'
elif
event
.
key
==
pygame
.
K_b
:
evb
=
'B'
elif
event
.
key
==
pygame
.
K_UP
:
if
evb
==
'B'
and
Bval
<
255
:
Bval
+=
1
elif
evb
==
'G'
and
Gval
<
255
:
Gval
+=
1
elif
evb
==
'R'
and
Rval
<
255
:
Rval
+=
1
elif
event
.
key
==
pygame
.
K_DOWN
:
if
evb
==
'B'
and
Bval
>
0
:
Bval
-=
1
elif
evb
==
'G'
and
Gval
>
0
:
Gval
-=
1
elif
evb
==
'R'
and
Rval
>
0
:
Rval
-=
1
elif
event
.
type
==
pygame
.
MOUSEBUTTONDOWN
:
if
event
.
button
==
5
:
if
evb
==
'B'
and
Bval
>
0
:
Bval
-=
1
elif
evb
==
'G'
and
Gval
>
0
:
Gval
-=
1
elif
evb
==
'R'
and
Rval
>
0
:
Rval
-=
1
elif
event
.
button
==
4
:
if
evb
==
'B'
and
Bval
<
255
:
Bval
+=
1
elif
evb
==
'G'
and
Gval
<
255
:
Gval
+=
1
elif
evb
==
'R'
and
Rval
<
255
:
Rval
+=
1
rrs
.
fill
((
Rval
,
0
,
0
))
bbs
.
fill
((
0
,
0
,
Bval
))
ggs
.
fill
((
0
,
Gval
,
0
))
if
Rled
:
screen
.
blit
(
rs
,
r
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
rrs
,
rr
)
if
Gled
:
screen
.
blit
(
gs
,
g
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
ggs
,
gg
)
if
Bled
:
screen
.
blit
(
bs
,
b
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
bbs
,
bb
)
rgbs
.
fill
((
Rval
,
Gval
,
Bval
))
screen
.
blit
(
rgbs
,
rgb
)
screen
.
blit
(
per
,
pr
)
screen
.
blit
(
per
,
pr2
)
screen
.
blit
(
per
,
pr3
)
text
=
font
.
render
(
'RGB VALUES:
%
d,
%
d,
%
d'
%
(
Rval
,
Gval
,
Bval
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstext
=
font
.
render
(
'PERIOD TICK:
%
d'
%
TICK
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
screen
.
blit
(
text
,
textRect
)
timer
+=
1
TICK
+=
1
if
(
maxtimer
==
timer
):
# imposto il timer a 0
timer
=
0
if
TICK
==
255
:
TICK
=
0
PERIOD
+=
1
if
PERIOD
==
4
:
PERIOD
=
0
pygame
.
display
.
flip
()
screen
.
fill
((
0
,
0
,
0
))
MIBAM.py
0 → 100644
View file @
bb79c051
import
pygame
,
sys
import
time
pygame
.
init
()
size
=
width
,
height
=
1024
,
512
screen
=
pygame
.
display
.
set_mode
(
size
)
screen
.
fill
((
0
,
0
,
0
))
rs
=
pygame
.
Surface
((
1
,
2
))
rs
.
fill
((
255
,
0
,
0
))
r
=
[]
bs
=
pygame
.
Surface
((
1
,
2
))
bs
.
fill
((
0
,
0
,
255
))
b
=
[]
gs
=
pygame
.
Surface
((
1
,
2
))
gs
.
fill
((
0
,
255
,
0
))
g
=
[]
per
=
pygame
.
Surface
((
1
,
30
))
per
.
fill
((
255
,
255
,
255
))
pr
=
per
.
get_rect
(
center
=
(
255
,
317
))
pr2
=
per
.
get_rect
(
center
=
(
510
,
317
))
pr3
=
per
.
get_rect
(
center
=
(
765
,
317
))
rrs
=
pygame
.
Surface
((
90
,
30
))
rrs
.
fill
((
255
,
0
,
0
))
ggs
=
pygame
.
Surface
((
90
,
30
))
ggs
.
fill
((
0
,
255
,
0
))
bbs
=
pygame
.
Surface
((
90
,
30
))
bbs
.
fill
((
0
,
0
,
255
))
rr
=
rrs
.
get_rect
(
center
=
(
256
,
100
))
gg
=
ggs
.
get_rect
(
center
=
(
256
,
130
))
bb
=
bbs
.
get_rect
(
center
=
(
256
,
160
))
rgbs
=
pygame
.
Surface
((
90
,
90
))
rgbs
.
fill
((
255
,
255
,
255
))
rgb
=
rgbs
.
get_rect
(
center
=
(
768
,
130
))
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
255
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
510
,
296
))
)
for
i
in
range
(
0
,
256
):
r
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
256
))
)
g
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
276
))
)
b
.
append
(
rs
.
get_rect
(
center
=
(
i
+
765
,
296
))
)
font
=
pygame
.
font
.
Font
(
None
,
40
)
text
=
font
.
render
(
'RGB VALUES:
%
d,
%
d,
%
d'
%
(
255
,
255
,
255
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
# Create a rectangle
textRect
=
text
.
get_rect
(
center
=
(
512
,
400
))
vals
=
pygame
.
font
.
Font
(
None
,
40
)
valstext
=
font
.
render
(
'PERIOD TICK:
%
d'
%
0
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstextrect
=
valstext
.
get_rect
(
center
=
(
512
,
440
))
vals2
=
pygame
.
font
.
Font
(
None
,
40
)
valstext2
=
font
.
render
(
'DUTY:
%
d'
%
0x80
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstextrect2
=
valstext2
.
get_rect
(
center
=
(
512
,
480
))
Rval
=
255
Gval
=
255
Bval
=
255
Rled
=
0
Gled
=
0
Bled
=
0
TOS
=
[
0x80
,
0x40
,
0x20
,
0x10
,
0x8
,
0x4
,
0x2
,
0x1
,
0x1
,
0x2
,
0x4
,
0x8
,
0x10
,
0x20
,
0x40
,
0x80
]
#TOS=[0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1]
DUTYC
=
0
TICK
=
0
PERIOD
=
0
timer
=
0
maxtimer
=
0
# Questo rappresenta lo scalar
evb
=
'R'
while
True
:
if
timer
==
0
:
# XXX Qui e' come se avvenisse un interrupt.
valstext2
=
font
.
render
(
'DUTY:
%
s (
%
d)'
%
(
str
(
TOS
[
DUTYC
])
.
rjust
(
3
,
'0'
),
DUTYC
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
# Controlliamo se dobbiamo accendere i tre "led" o "colori"
Rled
=
Rval
&
TOS
[
DUTYC
]
Gled
=
Gval
&
TOS
[
DUTYC
]
Bled
=
Bval
&
TOS
[
DUTYC
]
# Modifico il timer scaler nel pic, qui setto semplicmente al prossimo dutyc
maxtimer
=
TOS
[
DUTYC
]
DUTYC
+=
1
# E se siamo arrivati alla fine dei DUTY, partiamo da capo.
if
(
DUTYC
>=
len
(
TOS
)):
DUTYC
=
0
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
sys
.
exit
()
elif
event
.
type
==
pygame
.
KEYDOWN
:
if
event
.
key
==
pygame
.
K_r
:
evb
=
'R'
elif
event
.
key
==
pygame
.
K_g
:
evb
=
'G'
elif
event
.
key
==
pygame
.
K_b
:
evb
=
'B'
elif
event
.
key
==
pygame
.
K_UP
:
if
evb
==
'B'
and
Bval
<
255
:
Bval
+=
1
elif
evb
==
'G'
and
Gval
<
255
:
Gval
+=
1
elif
evb
==
'R'
and
Rval
<
255
:
Rval
+=
1
elif
event
.
key
==
pygame
.
K_DOWN
:
if
evb
==
'B'
and
Bval
>
0
:
Bval
-=
1
elif
evb
==
'G'
and
Gval
>
0
:
Gval
-=
1
elif
evb
==
'R'
and
Rval
>
0
:
Rval
-=
1
elif
event
.
type
==
pygame
.
MOUSEBUTTONDOWN
:
if
event
.
button
==
5
:
if
evb
==
'B'
and
Bval
>
0
:
Bval
-=
1
elif
evb
==
'G'
and
Gval
>
0
:
Gval
-=
1
elif
evb
==
'R'
and
Rval
>
0
:
Rval
-=
1
elif
event
.
button
==
4
:
if
evb
==
'B'
and
Bval
<
255
:
Bval
+=
1
elif
evb
==
'G'
and
Gval
<
255
:
Gval
+=
1
elif
evb
==
'R'
and
Rval
<
255
:
Rval
+=
1
rrs
.
fill
((
Rval
,
0
,
0
))
bbs
.
fill
((
0
,
0
,
Bval
))
ggs
.
fill
((
0
,
Gval
,
0
))
if
Rled
:
screen
.
blit
(
rs
,
r
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
rrs
,
rr
)
if
Gled
:
screen
.
blit
(
gs
,
g
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
ggs
,
gg
)
if
Bled
:
screen
.
blit
(
bs
,
b
[
TICK
+
(
PERIOD
*
256
)])
screen
.
blit
(
bbs
,
bb
)
rgbs
.
fill
((
Rval
,
Gval
,
Bval
))
screen
.
blit
(
rgbs
,
rgb
)
screen
.
blit
(
per
,
pr
)
screen
.
blit
(
per
,
pr2
)
screen
.
blit
(
per
,
pr3
)
text
=
font
.
render
(
'RGB VALUES:
%
d,
%
d,
%
d'
%
(
Rval
,
Gval
,
Bval
),
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
valstext
=
font
.
render
(
'PERIOD TICK:
%
d'
%
TICK
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
screen
.
blit
(
text
,
textRect
)
timer
+=
1
TICK
+=
1
if
(
maxtimer
==
timer
):
# imposto il timer a 0
timer
=
0
if
TICK
==
255
:
TICK
=
0
PERIOD
+=
1
if
PERIOD
==
4
:
PERIOD
=
0
pygame
.
display
.
flip
()
screen
.
fill
((
0
,
0
,
0
))
README.txt
0 → 100644
View file @
bb79c051
You can change the R, G, B values by selecting the channel
with r, g and b key, and then using keyboard up and down or
the mouse wheel.
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