Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Μ
µfrabuled
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
Libs
µfrabuled
Commits
e2e9608c
Commit
e2e9608c
authored
2 years ago
by
Martin Winter
Browse files
Options
Downloads
Patches
Plain Diff
specify get, set and blit function to correct the x-y-coordinates
parent
161ae796
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
myfrabuled/tm1640.py
+27
-2
27 additions, 2 deletions
myfrabuled/tm1640.py
with
27 additions
and
2 deletions
myfrabuled/tm1640.py
+
27
−
2
View file @
e2e9608c
...
@@ -49,7 +49,15 @@ class TM1640Matrix(LEDMatrix):
...
@@ -49,7 +49,15 @@ class TM1640Matrix(LEDMatrix):
self
.
intensity
=
max
(
0
,
min
(
7
,
intensity
))
self
.
intensity
=
max
(
0
,
min
(
7
,
intensity
))
self
.
active
=
active
self
.
active
=
active
self
.
_send_command
(
0x80
|
self
.
intensity
|
(
0x08
if
self
.
active
else
0
))
self
.
_send_command
(
0x80
|
self
.
intensity
|
(
0x08
if
self
.
active
else
0
))
def
get
(
self
,
i
:
int
,
j
:
int
)
->
bool
:
"""
Get state of one pixel.
"""
return
self
.
fb
[
7
-
i
][
7
-
j
]
def
set
(
self
,
i
:
int
,
j
:
int
,
state
:
bool
):
"""
Set state of one pixel.
"""
self
.
fb
[
i
][
7
-
j
]
=
state
def
update
(
self
):
def
update
(
self
):
data
=
self
.
_to_bytes
()
data
=
self
.
_to_bytes
()
...
@@ -62,7 +70,8 @@ class TM1640Matrix(LEDMatrix):
...
@@ -62,7 +70,8 @@ class TM1640Matrix(LEDMatrix):
def
_to_bytes
(
self
)
->
bytes
:
def
_to_bytes
(
self
)
->
bytes
:
data
=
b
""
data
=
b
""
for
row
in
range
(
self
.
rows
-
1
,
-
1
,
-
1
):
#for row in range(self.rows - 1, -1, -1):
for
row
in
range
(
self
.
rows
):
byte
=
0
byte
=
0
for
col
in
range
(
0
,
self
.
cols
):
for
col
in
range
(
0
,
self
.
cols
):
byte
|=
int
(
self
.
fb
[
row
][
col
])
<<
(
self
.
cols
-
col
-
1
)
byte
|=
int
(
self
.
fb
[
row
][
col
])
<<
(
self
.
cols
-
col
-
1
)
...
@@ -93,6 +102,22 @@ class TM1640Matrix(LEDMatrix):
...
@@ -93,6 +102,22 @@ class TM1640Matrix(LEDMatrix):
self
.
_send
(
0xCB
|
address
)
self
.
_send
(
0xCB
|
address
)
self
.
_send
(
byte
)
self
.
_send
(
byte
)
self
.
_send_end
()
self
.
_send_end
()
def
blit
(
self
,
source
:
list
[
list
[
int
|
bool
]],
source_offset
:
tuple
[
int
,
int
]
=
(
0
,
0
),
dest_offset
:
tuple
[
int
,
int
]
=
(
0
,
0
),
):
"""
Copy (part of) a source bitmap to the framebuffer.
"""
dest_width
=
self
.
cols
-
dest_offset
[
1
]
dest_height
=
self
.
rows
-
dest_offset
[
0
]
source_width
=
dest_width
-
source_offset
[
1
]
source_height
=
dest_height
-
source_offset
[
0
]
for
row
in
range
(
source_offset
[
0
],
source_height
+
source_offset
[
0
]):
for
col
in
range
(
source_offset
[
1
],
source_width
+
source_offset
[
1
]):
self
.
set
(
self
.
rows
-
(
row
+
dest_offset
[
0
])
-
1
,
col
+
dest_offset
[
1
],
bool
(
source
[
row
][
col
]))
class
WEMOSMatrixLEDShield
(
TM1640Matrix
):
class
WEMOSMatrixLEDShield
(
TM1640Matrix
):
...
...
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