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
External 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
fleur
firmware
Commits
8c8c7049
Commit
8c8c7049
authored
5 years ago
by
derf
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(card10_nickname): Indicate battery voltage in symbol
full == filled symbol, near empty == empty battery symbol, etc.
parent
48a578d5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
preload/apps/card10_nickname/__init__.py
+12
-7
12 additions, 7 deletions
preload/apps/card10_nickname/__init__.py
with
12 additions
and
7 deletions
preload/apps/card10_nickname/__init__.py
+
12
−
7
View file @
8c8c7049
...
...
@@ -80,17 +80,17 @@ def get_bat_color(bat):
Voltage threshold
'
s are currently estimates as voltage isn
'
t that great of an indicator for
battery charge.
:param bat: battery config tuple (boolean: indicator on/off, array: good rgb, array: ok rgb, array: bad rgb)
:return: false if old firmware, RGB color array otherwise
:return:
battery status tuple (float: battery voltage,
false if old firmware, RGB color array otherwise
)
"""
try
:
v
=
os
.
read_battery
()
if
v
>
3.8
:
return
bat
[
1
]
return
(
v
,
bat
[
1
]
)
if
v
>
3.6
:
return
bat
[
2
]
return
bat
[
3
]
return
(
v
,
bat
[
2
]
)
return
(
v
,
bat
[
3
]
)
except
AttributeError
:
return
False
return
(
0
,
False
)
def
render_battery
(
disp
,
bat
):
...
...
@@ -100,10 +100,15 @@ def render_battery(disp, bat):
:param disp: open display
:param bat: battery config tuple (boolean: indicator on/off, array: good rgb, array: ok rgb, array: bad rgb)
"""
c
=
get_bat_color
(
bat
)
v
,
c
=
get_bat_color
(
bat
)
if
not
c
:
return
disp
.
rect
(
140
,
2
,
155
,
9
,
filled
=
True
,
col
=
c
)
if
v
>
4.0
:
disp
.
rect
(
140
,
2
,
155
,
9
,
filled
=
True
,
col
=
c
)
else
:
disp
.
rect
(
140
,
2
,
154
,
8
,
filled
=
False
,
col
=
c
)
if
v
>
3.5
:
disp
.
rect
(
141
,
3
,
142
+
int
((
v
-
3.5
)
*
24
),
8
,
filled
=
True
,
col
=
c
)
disp
.
rect
(
155
,
4
,
157
,
7
,
filled
=
True
,
col
=
c
)
...
...
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