Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
328b4fb8
Commit
328b4fb8
authored
5 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(pycardium): Fix code style of some py/ modules
parent
0a00d50c
No related branches found
No related tags found
1 merge request
!388
change(micropython): Create weak link from `(u)module` to `module`
Pipeline
#4593
passed
5 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pycardium/modules/py/ledfx.py
+3
-1
3 additions, 1 deletion
pycardium/modules/py/ledfx.py
pycardium/modules/py/pov.py
+22
-14
22 additions, 14 deletions
pycardium/modules/py/pov.py
with
25 additions
and
15 deletions
pycardium/modules/py/ledfx.py
+
3
−
1
View file @
328b4fb8
...
@@ -75,7 +75,9 @@ def kitt(
...
@@ -75,7 +75,9 @@ def kitt(
# set the color values to the LEDs by multiplying the given color
# set the color values to the LEDs by multiplying the given color
# value with the corresponding brightness value in the kitt table
# value with the corresponding brightness value in the kitt table
output
=
[[
int
(
x
*
y
)
for
y
in
rgb
]
for
x
in
kitt_table
[
j
:
(
j
+
used_leds
)]]
output
=
[
[
int
(
x
*
y
)
for
y
in
rgb
]
for
x
in
kitt_table
[
j
:
(
j
+
used_leds
)]
]
else
:
else
:
used_leds
=
len
(
spectrum
)
used_leds
=
len
(
spectrum
)
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/py/pov.py
+
22
−
14
View file @
328b4fb8
# this script reads a BMP file and displays it as POV. For optimal results use a BMP that is 11 pixels wide.
# this script reads a BMP file and displays it as POV. For optimal results use a BMP that is 11 pixels wide.
import
leds
import
leds
# default filename. Depending on how you want to run this, change it
# default filename. Depending on how you want to run this, change it
FILENAME
=
"
Smiley.bmp
"
FILENAME
=
"
Smiley.bmp
"
# Determines the Frame Rate, currently not used.
# Determines the Frame Rate, currently not used.
...
@@ -9,18 +10,18 @@ DELAY = 0
...
@@ -9,18 +10,18 @@ DELAY = 0
BRIGHTNESS
=
1.0
BRIGHTNESS
=
1.0
class
BMPError
(
Exception
):
class
BMPError
(
Exception
):
pass
pass
class
POV
:
class
POV
:
def
__init__
(
self
,
filename
=
FILENAME
):
def
__init__
(
self
,
filename
=
FILENAME
):
self
.
filename
=
filename
self
.
filename
=
filename
f
=
open
(
"
/
"
+
self
.
filename
,
"
rb
"
)
f
=
open
(
"
/
"
+
self
.
filename
,
"
rb
"
)
if
f
.
read
(
2
)
!=
b
'
BM
'
:
# check signature
if
f
.
read
(
2
)
!=
b
"
BM
"
:
# check signature
raise
BMPError
(
"
Not BitMap file
"
)
raise
BMPError
(
"
Not BitMap file
"
)
# turn into int.from_bytes
# turn into int.from_bytes
bmpFileSize
=
int
.
from_bytes
(
f
.
read
(
4
),
'
little
'
)
bmpFileSize
=
int
.
from_bytes
(
f
.
read
(
4
),
"
little
"
)
f
.
read
(
4
)
# Read & ignore creator bytes
f
.
read
(
4
)
# Read & ignore creator bytes
self
.
bmpImageOffset
=
self
.
read_le
(
f
.
read
(
4
))
# Start of image data
self
.
bmpImageOffset
=
self
.
read_le
(
f
.
read
(
4
))
# Start of image data
...
@@ -29,8 +30,10 @@ class POV:
...
@@ -29,8 +30,10 @@ class POV:
self
.
bmpHeight
=
self
.
read_le
(
f
.
read
(
4
))
self
.
bmpHeight
=
self
.
read_le
(
f
.
read
(
4
))
flip
=
False
flip
=
False
print
(
"
Size: %d
\n
Image offset: %d
\n
Header size: %d
"
%
print
(
(
bmpFileSize
,
self
.
bmpImageOffset
,
headerSize
))
"
Size: %d
\n
Image offset: %d
\n
Header size: %d
"
%
(
bmpFileSize
,
self
.
bmpImageOffset
,
headerSize
)
)
print
(
"
Width: %d
\n
Height: %d
"
%
(
self
.
bmpWidth
,
self
.
bmpHeight
))
print
(
"
Width: %d
\n
Height: %d
"
%
(
self
.
bmpWidth
,
self
.
bmpHeight
))
if
self
.
read_le
(
f
.
read
(
2
))
!=
1
:
if
self
.
read_le
(
f
.
read
(
2
))
!=
1
:
...
@@ -49,17 +52,21 @@ class POV:
...
@@ -49,17 +52,21 @@ class POV:
f
.
close
()
f
.
close
()
self
.
read_image
()
self
.
read_image
()
def
correct_brightness
(
self
,
color
):
def
correct_brightness
(
self
,
color
):
return
int
(
pow
((
color
*
BRIGHTNESS
)
/
255
,
2.7
)
*
255
+
0.5
)
return
int
(
pow
((
color
*
BRIGHTNESS
)
/
255
,
2.7
)
*
255
+
0.5
)
def
getWidth
(
self
):
def
getWidth
(
self
):
return
self
.
bmpWidth
return
self
.
bmpWidth
def
setFileOffset
(
self
,
fileOffset
):
def
setFileOffset
(
self
,
fileOffset
):
self
.
fileOffset
=
fileOffset
self
.
fileOffset
=
fileOffset
def
getFileOffset
(
self
):
def
getFileOffset
(
self
):
return
self
.
fileOffset
return
self
.
fileOffset
def
read_le
(
self
,
bytes
):
def
read_le
(
self
,
bytes
):
return
int
.
from_bytes
(
bytes
,
'
little
'
)
return
int
.
from_bytes
(
bytes
,
"
little
"
)
def
read_image
(
self
):
def
read_image
(
self
):
self
.
imageArray
=
[]
self
.
imageArray
=
[]
flip
=
True
flip
=
True
...
@@ -86,6 +93,7 @@ class POV:
...
@@ -86,6 +93,7 @@ class POV:
for
i
in
self
.
imageArray
:
for
i
in
self
.
imageArray
:
leds
.
set_all
(
i
)
leds
.
set_all
(
i
)
def
play
(
imagename
):
def
play
(
imagename
):
myPov
=
POV
(
imagename
)
myPov
=
POV
(
imagename
)
while
True
:
while
True
:
...
...
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