Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
dos
flow3r firmware
Commits
f979318a
Commit
f979318a
authored
Aug 15, 2023
by
alibi
Committed by
ar
Aug 16, 2023
Browse files
Options
Downloads
Patches
Plain Diff
py/nick: added color options for nick
parent
fee7e552
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/badge/usage.rst
+2
-0
2 additions, 0 deletions
docs/badge/usage.rst
python_payload/apps/nick/__init__.py
+18
-2
18 additions, 2 deletions
python_payload/apps/nick/__init__.py
with
20 additions
and
2 deletions
docs/badge/usage.rst
+
2
−
0
View file @
f979318a
...
...
@@ -59,6 +59,8 @@ note that ``pronouns`` is a list, and should be formatted as such. for example:
For the ``nick.json`` file to appear, you must have started the Nick app at
least once.
Use ``"color": "0xffffff",`` to color your name and pronouns.
When you're done editing, unmount/eject the badge from your computer
(``umount`` on Linux is enough) and press the left shoulder button to exit Disk
Mode. Then, go to Badge |rarr| Nick to see your changes!
...
...
This diff is collapsed.
Click to expand it.
python_payload/apps/nick/__init__.py
+
18
−
2
View file @
f979318a
from
st3m.application
import
Application
,
ApplicationContext
from
st3m.ui.colours
import
PUSH_RED
,
GO_GREEN
,
BLACK
from
st3m.goose
import
Dict
,
Any
from
st3m.goose
import
Dict
,
Any
,
Tuple
from
st3m.input
import
InputState
from
ctx
import
Context
import
leds
...
...
@@ -15,6 +15,7 @@ class Configuration:
self
.
font
:
int
=
5
self
.
pronouns
:
list
[
str
]
=
[]
self
.
pronouns_size
:
int
=
25
self
.
color
=
"
0x40ff22
"
@classmethod
def
load
(
cls
,
path
:
str
)
->
"
Configuration
"
:
...
...
@@ -46,6 +47,13 @@ class Configuration:
res
.
pronouns_size
=
int
(
data
[
"
pronouns_size
"
])
if
type
(
data
[
"
pronouns_size
"
])
==
int
:
res
.
pronouns_size
=
data
[
"
pronouns_size
"
]
if
(
"
color
"
in
data
and
type
(
data
[
"
color
"
])
==
str
and
data
[
"
color
"
][
0
:
2
]
==
"
0x
"
and
len
(
data
[
"
color
"
])
==
8
):
res
.
color
=
data
[
"
color
"
]
return
res
def
save
(
self
,
path
:
str
)
->
None
:
...
...
@@ -55,12 +63,20 @@ class Configuration:
"
font
"
:
self
.
font
,
"
pronouns
"
:
self
.
pronouns
,
"
pronouns_size
"
:
self
.
pronouns_size
,
"
color
"
:
self
.
color
,
}
jsondata
=
json
.
dumps
(
d
)
with
open
(
path
,
"
w
"
)
as
f
:
f
.
write
(
jsondata
)
f
.
close
()
def
to_normalized_tuple
(
self
)
->
Tuple
[
float
,
float
,
float
]:
return
(
int
(
self
.
color
[
2
:
4
],
16
)
/
255.0
,
int
(
self
.
color
[
4
:
6
],
16
)
/
255.0
,
int
(
self
.
color
[
6
:
8
],
16
)
/
255.0
,
)
class
NickApp
(
Application
):
def
__init__
(
self
,
app_ctx
:
ApplicationContext
)
->
None
:
...
...
@@ -80,7 +96,7 @@ class NickApp(Application):
ctx
.
font
=
ctx
.
get_font_name
(
self
.
_config
.
font
)
ctx
.
rgb
(
0
,
0
,
0
).
rectangle
(
-
120
,
-
120
,
240
,
240
).
fill
()
ctx
.
rgb
(
*
GO_GREEN
)
ctx
.
rgb
(
*
self
.
_config
.
to_normalized_tuple
()
)
ctx
.
move_to
(
0
,
0
)
ctx
.
save
()
...
...
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