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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vabene
firmware
Commits
10a19ae3
Commit
10a19ae3
authored
5 years ago
by
vabene
Browse files
Options
Downloads
Patches
Plain Diff
advanced nickname config
parent
27753dfe
No related branches found
No related tags found
No related merge requests found
Pipeline
#2435
failed
5 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycardium/modules/py/nicknname.py
+36
-9
36 additions, 9 deletions
pycardium/modules/py/nicknname.py
with
36 additions
and
9 deletions
pycardium/modules/py/nicknname.py
+
36
−
9
View file @
10a19ae3
import
display
import
ujson
import
os
FILENAME
=
'
nickname.txt
'
FILENAME_ADV
=
'
nickname.json
'
def
write_nick
(
title
,
sub
=
''
,
fg
=
None
,
bg
=
None
):
def
write_nick
(
title
,
sub
=
''
,
fg
=
None
,
bg
=
None
,
fg_sub
=
None
,
bg_sub
=
None
):
posy
=
30
if
sub
!=
''
:
posy
=
18
with
display
.
open
()
as
disp
:
disp
.
print
(
title
,
fg
=
fg
,
bg
=
bg
,
posx
=
80
-
round
(
len
(
title
)
/
2
*
14
),
posy
=
posy
)
if
sub
!=
''
:
disp
.
print
(
sub
,
fg
=
fg
,
bg
=
bg
,
posx
=
80
-
round
(
len
(
sub
)
/
2
*
14
),
posy
=
42
)
disp
.
print
(
sub
,
fg
=
fg
_sub
,
bg
=
bg
_sub
,
posx
=
80
-
round
(
len
(
sub
)
/
2
*
14
),
posy
=
42
)
disp
.
update
()
disp
.
close
()
def
get_key
(
json
,
key
,
default
):
try
:
return
json
[
key
]
except
KeyError
:
return
default
with
display
.
open
()
as
disp
:
disp
.
clear
().
update
()
if
FILENAME_ADV
in
os
.
listdir
(
"
.
"
):
f
=
open
(
FILENAME_ADV
,
'
r
'
)
try
:
c
=
ujson
.
loads
(
f
.
read
())
f
.
close
()
nick
=
get_key
(
c
,
'
nickname
'
,
'
no nick
'
)
sub
=
get_key
(
c
,
'
subtitle
'
,
''
)
fg_color
=
get_key
(
c
,
'
fg_color
'
,
[
255
,
255
,
255
])
bg_color
=
get_key
(
c
,
'
bg_color
'
,
[
0
,
0
,
0
])
fg_sub_color
=
get_key
(
c
,
'
fg_sub_color
'
,
[
255
,
255
,
255
])
bg_sub_color
=
get_key
(
c
,
'
bg_sub_color
'
,
[
0
,
0
,
0
])
background
=
get_key
(
c
,
'
background
'
,
[
0
,
0
,
0
])
with
display
.
open
()
as
disp
:
disp
.
rect
(
0
,
0
,
160
,
80
,
filled
=
True
)
write_nick
(
nick
,
sub
,
fg
=
fg_color
,
bg
=
bg_color
,
fg_sub
=
fg_sub_color
,
bg_sub
=
bg_sub_color
)
except
ValueError
:
write_nick
(
'
invalid
'
,
sub
=
'
json
'
)
else
:
if
FILENAME
not
in
os
.
listdir
(
"
.
"
):
write_nick
(
'
file not
'
,
sub
=
'
found
'
)
else
:
f
=
open
(
FILENAME
,
'
r
'
)
nick
=
f
.
read
()
f
.
close
()
if
len
(
nick
)
>
11
:
write_nick
(
'
name too
'
,
sub
=
'
long
'
)
else
:
...
...
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