Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Principes de fonctionnement des ordinateurs
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Baviere Merlin
Principes de fonctionnement des ordinateurs
Commits
8085e77c
Commit
8085e77c
authored
5 months ago
by
Baviere Merlin
Browse files
Options
Downloads
Patches
Plain Diff
fin BE5
parent
58ffdf47
Branches
main
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BE4BE5.zip
+0
-0
0 additions, 0 deletions
BE4BE5.zip
BE5/BE5.py
+189
-7
189 additions, 7 deletions
BE5/BE5.py
with
189 additions
and
7 deletions
BE4BE5.zip
0 → 100644
+
0
−
0
View file @
8085e77c
File added
This diff is collapsed.
Click to expand it.
BE5/BE5.py
+
189
−
7
View file @
8085e77c
import
pyb
import
os
data
=
"
X8
"
;
# patte connectée à l'entrée série du MAX7219 (DIN)
load
=
"
X5
"
;
# patte de chargement des données (CS)
...
...
@@ -83,16 +85,196 @@ def setPixel(x,y,on,bitmap):
if
(
bitmap
[
x
]
%
(
pow
(
2
,(
8
-
y
))))
//
(
pow
(
2
,(
7
-
y
)))
==
1
:
bitmap
[
x
]
-=
pow
(
2
,(
7
-
y
))
for
i
in
range
(
8
):
bitmap
[
i
]
=
i
updateDisplay
(
bitmap
)
print
(
bitmap
)
setPixel
(
5
,
5
,
False
,
bitmap
)
print
(
bitmap
)
updateDisplay
(
bitmap
)
def
getPixel
(
x
,
y
,
bitmap
):
return
(
bitmap
[
x
]
%
(
pow
(
2
,(
8
-
y
))))
//
(
pow
(
2
,(
7
-
y
)))
==
1
def
testPixels
():
bitmap
=
bytearray
(
8
)
matrixOn
(
1
)
matrixTest
(
0
)
matrixDecode
(
0
)
matrixDigits
(
7
)
clearDisplay
(
bitmap
)
# Trace un O
setPixel
(
1
,
2
,
1
,
bitmap
);
setPixel
(
2
,
2
,
1
,
bitmap
);
setPixel
(
3
,
2
,
1
,
bitmap
)
setPixel
(
1
,
3
,
1
,
bitmap
);
setPixel
(
3
,
3
,
1
,
bitmap
)
setPixel
(
1
,
4
,
1
,
bitmap
);
setPixel
(
3
,
4
,
1
,
bitmap
)
setPixel
(
1
,
5
,
1
,
bitmap
);
setPixel
(
2
,
5
,
1
,
bitmap
);
setPixel
(
3
,
5
,
1
,
bitmap
)
# Trace un K
setPixel
(
5
,
2
,
1
,
bitmap
);
setPixel
(
7
,
2
,
1
,
bitmap
)
setPixel
(
5
,
3
,
1
,
bitmap
);
setPixel
(
6
,
3
,
1
,
bitmap
)
setPixel
(
5
,
4
,
1
,
bitmap
);
setPixel
(
6
,
4
,
1
,
bitmap
)
setPixel
(
5
,
5
,
1
,
bitmap
);
setPixel
(
7
,
5
,
1
,
bitmap
)
updateDisplay
(
bitmap
)
def
testPixels2
():
bitmap
=
bytearray
(
8
)
matrixOn
(
True
)
matrixTest
(
False
)
matrixDecode
(
False
)
matrixDigits
(
7
)
clearDisplay
(
bitmap
)
x
=
0
y
=
0
while
True
:
setPixel
(
x
,
y
,
True
,
bitmap
)
updateDisplay
(
bitmap
)
setPixel
(
x
,
y
,
False
,
bitmap
)
x
=
(
x
+
1
)
%
8
if
x
==
0
:
y
=
(
y
+
1
)
%
8
pyb
.
delay
(
100
)
smiley
=
(
"
****
"
,
"
* *
"
,
"
* * * *
"
,
"
* *
"
,
"
* * * *
"
,
"
* ** *
"
,
"
* *
"
,
"
****
"
)
frowney
=
(
"
****
"
,
"
* *
"
,
"
* * * *
"
,
"
* *
"
,
"
* ** *
"
,
"
* * * *
"
,
"
* *
"
,
"
****
"
)
def
displayPict
(
pict
):
bitmap
=
bytearray
(
8
)
clearDisplay
(
bitmap
)
i
=
0
for
line
in
pict
:
j
=
0
for
char
in
line
:
if
char
==
"
*
"
:
setPixel
(
i
,
j
,
1
,
bitmap
)
j
+=
1
i
+=
1
updateDisplay
(
bitmap
)
return
bitmap
def
randomBitmap
():
bitmap
=
bytearray
(
8
)
for
i
in
range
(
8
):
for
j
in
range
(
8
):
setPixel
(
i
,
j
,(
os
.
urandom
(
1
)[
0
]
>
127
)
,
bitmap
)
return
bitmap
def
countNeighbours
(
x
,
y
,
bitmap
):
vois
=
0
list_vois
=
[((
x
+
dx
)
%
8
,
(
y
+
dy
)
%
8
)
for
dx
in
(
-
1
,
0
,
1
)
for
dy
in
(
-
1
,
0
,
1
)
if
(
dx
,
dy
)
!=
(
0
,
0
)]
for
i
in
list_vois
:
if
getPixel
(
i
[
0
],
i
[
1
],
bitmap
):
vois
+=
1
return
vois
def
lifeStep
(
bitmap
):
res_bitmap
=
bytearray
(
8
)
for
x
in
range
(
8
):
for
y
in
range
(
8
):
if
countNeighbours
(
x
,
y
,
bitmap
)
==
3
:
setPixel
(
x
,
y
,
True
,
res_bitmap
)
elif
countNeighbours
(
x
,
y
,
bitmap
)
==
2
:
setPixel
(
x
,
y
,
getPixel
(
x
,
y
,
bitmap
),
res_bitmap
)
else
:
setPixel
(
x
,
y
,
False
,
res_bitmap
)
for
i
in
range
(
8
):
bitmap
[
i
]
=
res_bitmap
[
i
]
updateDisplay
(
bitmap
)
def
gameOfLife
():
bitmap
=
randomBitmap
()
while
True
:
pyb
.
delay
(
200
)
lifeStep
(
bitmap
)
# Figures stables
stableBlock
=
(
"
"
,
"
"
,
"
"
,
"
**
"
,
"
**
"
,
"
"
,
"
"
,
"
"
)
def
testBlock
():
bitmap
=
displayPict
(
stableBlock
)
pyb
.
delay
(
500
)
lifeStep
(
bitmap
)
stableTube
=
(
"
"
,
"
"
,
"
*
"
,
"
* *
"
,
"
*
"
,
"
"
,
"
"
,
"
"
)
def
testTube
():
bitmap
=
displayPict
(
stableTube
)
pyb
.
delay
(
500
)
lifeStep
(
bitmap
)
# Figures oscillantes
oscBlinker
=
(
"
"
,
"
"
,
"
"
,
"
***
"
,
"
"
,
"
"
,
"
"
,
"
"
)
def
testBlinker
():
bitmap
=
displayPict
(
oscBlinker
)
for
i
in
range
(
2
):
pyb
.
delay
(
500
)
lifeStep
(
bitmap
)
# Vaisseaux
shipGlider
=
(
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
***
"
,
"
*
"
,
"
*
"
)
def
testGlider
():
bitmap
=
displayPict
(
shipGlider
)
for
i
in
range
(
32
):
pyb
.
delay
(
500
)
lifeStep
(
bitmap
)
shipLWSS
=
(
"
"
,
"
"
,
"
* *
"
,
"
*
"
,
"
* *
"
,
"
****
"
,
"
"
,
"
"
)
def
testLWSS
():
bitmap
=
displayPict
(
shipLWSS
)
for
i
in
range
(
16
):
pyb
.
delay
(
500
)
lifeStep
(
bitmap
)
...
...
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