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
b4641dde
Commit
b4641dde
authored
5 years ago
by
dx
Browse files
Options
Downloads
Plain Diff
Merge 'add set_time_ms and set_unix_time_ms'
See merge request
card10/firmware!289
parents
1631a288
76a079ba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pycardium/modules/qstrdefs.h
+2
-0
2 additions, 0 deletions
pycardium/modules/qstrdefs.h
pycardium/modules/utime.c
+26
-0
26 additions, 0 deletions
pycardium/modules/utime.c
with
28 additions
and
0 deletions
pycardium/modules/qstrdefs.h
+
2
−
0
View file @
b4641dde
...
...
@@ -55,7 +55,9 @@ Q(time_ms)
Q
(
unix_time
)
Q
(
unix_time_ms
)
Q
(
set_time
)
Q
(
set_time_ms
)
Q
(
set_unix_time
)
Q
(
set_unix_time_ms
)
/* vibra */
Q
(
vibra
)
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/utime.c
+
26
−
0
View file @
b4641dde
...
...
@@ -5,6 +5,7 @@
#include
"py/mpconfig.h"
#include
"py/obj.h"
#include
"py/objint.h"
#include
"py/runtime.h"
#include
"extmod/utime_mphal.h"
...
...
@@ -26,6 +27,17 @@ static mp_obj_t time_set_time(mp_obj_t secs)
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
time_set_time_obj
,
time_set_time
);
static
mp_obj_t
time_set_time_ms
(
mp_obj_t
msecs_obj
)
{
uint64_t
msecs
=
0
;
mp_obj_int_to_bytes_impl
(
msecs_obj
,
false
,
8
,
(
byte
*
)
&
msecs
);
uint64_t
timestamp
=
msecs
+
EPOCH_OFFSET
*
1000ULL
-
TZONE_OFFSET
*
1000ULL
;
epic_rtc_set_milliseconds
(
timestamp
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
time_set_time_ms_obj
,
time_set_time_ms
);
static
mp_obj_t
time_set_unix_time
(
mp_obj_t
secs
)
{
uint64_t
timestamp
=
mp_obj_get_int
(
secs
)
*
1000ULL
;
...
...
@@ -34,6 +46,17 @@ static mp_obj_t time_set_unix_time(mp_obj_t secs)
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
time_set_unix_time_obj
,
time_set_unix_time
);
static
mp_obj_t
time_set_unix_time_ms
(
mp_obj_t
msecs_obj
)
{
uint64_t
timestamp
=
0
;
mp_obj_int_to_bytes_impl
(
msecs_obj
,
false
,
8
,
(
byte
*
)
&
timestamp
);
epic_rtc_set_milliseconds
(
timestamp
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
time_set_unix_time_ms_obj
,
time_set_unix_time_ms
);
static
mp_obj_t
time_time
(
void
)
{
mp_int_t
seconds
;
...
...
@@ -167,8 +190,11 @@ static const mp_rom_map_elem_t time_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_monotonic_ms
),
MP_ROM_PTR
(
&
time_monotonic_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_time
),
MP_ROM_PTR
(
&
time_set_time_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_time_ms
),
MP_ROM_PTR
(
&
time_set_time_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_unix_time
),
MP_ROM_PTR
(
&
time_set_unix_time_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_unix_time_ms
),
MP_ROM_PTR
(
&
time_set_unix_time_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_localtime
),
MP_ROM_PTR
(
&
time_localtime_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_mktime
),
MP_ROM_PTR
(
&
time_mktime_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep
),
MP_ROM_PTR
(
&
mp_utime_sleep_obj
)
},
...
...
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