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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
30a885c8
Commit
30a885c8
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
chore(g-watch): remove trailing spaces
parent
05ba8877
No related branches found
No related tags found
1 merge request
!396
Add G-Watch to preload
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
preload/apps/g_watch/__init__.py
+39
-39
39 additions, 39 deletions
preload/apps/g_watch/__init__.py
with
39 additions
and
39 deletions
preload/apps/g_watch/__init__.py
+
39
−
39
View file @
30a885c8
...
...
@@ -7,7 +7,7 @@ import bhi160
import
utime
import
power
import
light_sensor
disp
=
display
.
open
()
sensor
=
0
sensors
=
[{
"
sensor
"
:
bhi160
.
BHI160Orientation
(
sample_rate
=
8
),
"
name
"
:
"
Orientation
"
}]
...
...
@@ -153,23 +153,23 @@ with display.open() as disp:
timeout
=
7000
#time in ms how long clock will be displayed
clock_off
=
clock_on
+
timeout
#time in ms when clock is turned off
fade_time
=
0
#fade out counter
leds
.
dim_top
(
2
)
leds_on
=
0
p_leds_on
=
0
while
True
:
millis
=
utime
.
monotonic_ms
()
lt
=
utime
.
localtime
()
dow
=
lt
[
6
]
#---------------------------------------- read brightness sensor
bri
=
light_sensor
.
get_reading
()
bri
=
light_sensor
.
get_reading
()
bri
=
int
(
fade_time
*
100
/
1000
*
bri
/
200
)
# calculate display brightness in percent (bri)
if
(
bri
>
100
):
if
(
bri
>
100
):
bri
=
100
if
(
bri
<
0
):
bri
=
0
...
...
@@ -180,7 +180,7 @@ with display.open() as disp:
#---------------------------------------- read buttons
pressed
=
buttons
.
read
(
buttons
.
BOTTOM_LEFT
|
buttons
.
BOTTOM_RIGHT
)
p_leds_on
=
leds_on
if
pressed
&
buttons
.
BOTTOM_LEFT
!=
0
:
leds_on
=
0
disp
.
clear
()
...
...
@@ -189,7 +189,7 @@ with display.open() as disp:
disp
.
backlight
(
brightness
=
50
)
utime
.
sleep_ms
(
500
)
disp
.
backlight
(
brightness
=
0
)
for
led
in
range
(
led_count
):
for
led
in
range
(
led_count
):
leds
.
prep_hsv
(
led
,
[
0
,
0
,
0
])
disp
.
update
()
...
...
@@ -201,10 +201,10 @@ with display.open() as disp:
disp
.
backlight
(
brightness
=
50
)
utime
.
sleep_ms
(
500
)
disp
.
backlight
(
brightness
=
0
)
#---------------------------------------- read orientation sensor
samples
=
sensors
[
sensor
][
"
sensor
"
].
read
()
if
len
(
samples
)
>
0
:
#get orientation sensor samples
...
...
@@ -215,37 +215,37 @@ with display.open() as disp:
yd
=
abs
(
yn
-
yo
)
yd
=
yd
%
180
yd
=
yd
*
22
#multiply rotation with amplifier
if
abs
(
sample
.
z
)
>
50
:
#if arm is hanging:
yd
=
0
#do not regard wrist rotation
ydl
=
ydl
*
.
9
ydl
=
ydl
*
.
9
ydl
=
(
yd
+
ydl
*
9
)
/
10
#low pass filter wrist rotation
if
ydl
>
100
:
#check rottion against threshold and limit value
if
ydl
>
100
:
#check rottion against threshold and limit value
ydl
=
100
if
clock_on
+
timeout
<
millis
:
clock_on
=
millis
clock_off
=
timeout
+
clock_on
#.................................... display rotation bargraph on leds // full bar == hitting threshold
if
(
leds_on
==
1
):
hour
=
lt
[
3
]
hue
=
360
-
(
hour
/
24
*
360
)
for
led
in
range
(
led_count
):
for
led
in
range
(
led_count
):
if
(
led
<
int
(
ydl
/
100
*
12
)
-
1
)
or
millis
<
clock_off
-
1500
-
((
10
-
led
)
*
15
)
+
300
:
leds
.
prep_hsv
(
10
-
led
,
[
hue
,
100
,
ledbri
])
#led=0
else
:
leds
.
prep_hsv
(
10
-
led
,
[
0
,
0
,
0
])
#---------------------------------------- display clock
disp
.
clear
()
if
clock_off
>=
millis
:
if
clock_off
>=
millis
:
#.................................... time
lt
=
utime
.
localtime
()
...
...
@@ -262,20 +262,20 @@ with display.open() as disp:
if
fade_time
<
0
:
fade_time
=
0
if
fade_time
>
1000
:
fade_time
=
1000
disp
.
backlight
(
brightness
=
bri
)
render7segment
()
#render time in 7-segment digiclock style
disp
.
print
(
'
{:02d}-{:02d}-{} {}
'
.
format
(
day
,
month
,
year
,
DOW
[
dow
]),
posx
=
10
,
posy
=
67
,
font
=
2
)
# display date
#.................................... power
pwr
=
math
.
sqrt
(
power
.
read_battery_voltage
())
#disp.print("%f" % power.read_battery_voltage(), posx=25, posy=58, font=2) # display battery voltage
full
=
2.0
empty
=
math
.
sqrt
(
3.4
)
...
...
@@ -286,10 +286,10 @@ with display.open() as disp:
if
pwrpercent
<
0
:
pwrpercent
=
0
if
pwrpercent
>
100
:
pwrpercent
=
100
disp
.
rect
(
8
,
60
,
153
,
63
,
col
=
[
100
,
100
,
100
])
# draw battery bar
c
=
[
255
,
0
,
0
]
#red=empty
...
...
@@ -297,18 +297,18 @@ with display.open() as disp:
c
=
[
255
,
255
,
0
]
#yellow=emptyish
if
pwrpercent
>
25
:
c
=
[
0
,
255
,
0
]
#green=ok
disp
.
rect
(
8
,
60
,
int
(
pwrpercent
*
1.43
+
8
),
63
,
col
=
c
)
# draw charge bar in battery bar
#---------------------------------------- do not display clock
leds
.
update
()
disp
.
update
()
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