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
823c00a7
Commit
823c00a7
authored
5 years ago
by
markus
Browse files
Options
Downloads
Patches
Plain Diff
Add option to set time
parent
927d3057
Branches
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/main.py
+40
-0
40 additions, 0 deletions
preload/main.py
with
40 additions
and
0 deletions
preload/main.py
+
40
−
0
View file @
823c00a7
...
...
@@ -174,6 +174,8 @@ class Clock:
elif
button_pressed
and
v
&
buttons
.
BOTTOM_RIGHT
!=
0
:
self
.
setTheme
(
self
.
theme
+
1
)
self
.
writeConfig
()
elif
button_pressed
and
v
&
buttons
.
TOP_RIGHT
!=
0
:
self
.
setTime
(
disp
,
localtime
)
except
KeyboardInterrupt
:
for
i
in
range
(
11
):
...
...
@@ -245,6 +247,44 @@ class Clock:
disp
.
update
()
def
setTime
(
self
,
disp
,
localtime
):
accepted
=
False
blank
=
False
previously_pressed_button
=
buttons
.
TOP_RIGHT
button_repeat_counter
=
0
set_seconds
=
utime
.
mktime
(
localtime
)
while
not
accepted
:
v
=
buttons
.
read
(
buttons
.
BOTTOM_LEFT
|
buttons
.
BOTTOM_RIGHT
|
buttons
.
TOP_RIGHT
)
button_pressed
=
v
!=
0
if
button_pressed
:
if
v
&
previously_pressed_button
!=
0
:
button_repeat_counter
+=
1
else
:
if
v
&
buttons
.
BOTTOM_LEFT
!=
0
:
previously_pressed_button
=
buttons
.
BOTTOM_LEFT
elif
v
&
buttons
.
BOTTOM_RIGHT
!=
0
:
previously_pressed_button
=
buttons
.
BOTTOM_RIGHT
elif
v
&
buttons
.
TOP_RIGHT
!=
0
and
previously_pressed_button
!=
buttons
.
TOP_RIGHT
:
accepted
=
True
else
:
previously_pressed_button
=
0
else
:
previously_pressed_button
=
0
button_repeat_counter
=
0
seconds_change
=
int
(
min
(
1.1
**
button_repeat_counter
,
60
*
23
))
if
previously_pressed_button
==
buttons
.
BOTTOM_LEFT
:
set_seconds
-=
seconds_change
elif
previously_pressed_button
==
buttons
.
BOTTOM_RIGHT
:
set_seconds
+=
seconds_change
self
.
updateClock
(
disp
,
utime
.
localtime
(
set_seconds
))
utime
.
sleep_ms
(
23
)
utime
.
set_time
(
int
(
set_seconds
))
def
circlePoint
(
self
,
t
):
return
(
int
(
round
(
self
.
radius
*
math
.
cos
(
t
)))
+
self
.
center
[
0
],
...
...
This diff is collapsed.
Click to expand it.
markus
@markus
mentioned in commit
1dec8387
·
5 years ago
mentioned in commit
1dec8387
mentioned in commit 1dec83870e11657bb9000885aaff6aa3bfca1960
Toggle commit list
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