Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
90f86a01
Commit
90f86a01
authored
Jan 16, 2019
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esp32/machine_pin: Add Pin.off() and Pin.on() methods.
parent
36808d4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
ports/esp32/machine_pin.c
ports/esp32/machine_pin.c
+18
-0
No files found.
ports/esp32/machine_pin.c
View file @
90f86a01
...
...
@@ -221,6 +221,22 @@ STATIC mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
machine_pin_value_obj
,
1
,
2
,
machine_pin_value
);
// pin.off()
STATIC
mp_obj_t
machine_pin_off
(
mp_obj_t
self_in
)
{
machine_pin_obj_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
gpio_set_level
(
self
->
id
,
0
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
machine_pin_off_obj
,
machine_pin_off
);
// pin.on()
STATIC
mp_obj_t
machine_pin_on
(
mp_obj_t
self_in
)
{
machine_pin_obj_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
gpio_set_level
(
self
->
id
,
1
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
machine_pin_on_obj
,
machine_pin_on
);
// pin.irq(handler=None, trigger=IRQ_FALLING|IRQ_RISING)
STATIC
mp_obj_t
machine_pin_irq
(
size_t
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw_args
)
{
enum
{
ARG_handler
,
ARG_trigger
,
ARG_wake
};
...
...
@@ -290,6 +306,8 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
// instance methods
{
MP_ROM_QSTR
(
MP_QSTR_init
),
MP_ROM_PTR
(
&
machine_pin_init_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_value
),
MP_ROM_PTR
(
&
machine_pin_value_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_off
),
MP_ROM_PTR
(
&
machine_pin_off_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_on
),
MP_ROM_PTR
(
&
machine_pin_on_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_irq
),
MP_ROM_PTR
(
&
machine_pin_irq_obj
)
},
// class constants
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment