Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Haun
firmware
Commits
e7144129
Verified
Commit
e7144129
authored
Aug 31, 2019
by
Rahix
Browse files
refactor(bme680): Create a Python wrapper module
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
34341e8d
Changes
4
Hide whitespace changes
Inline
Side-by-side
pycardium/modules/py/bme680.py
0 → 100644
View file @
e7144129
import
sys_bme680
import
ucollections
# Import old module for compatibility
from
sys_bme680
import
*
# noqa
Bme680Data
=
ucollections
.
namedtuple
(
"Bme680Data"
,
[
"temperature"
,
"humidity"
,
"pressure"
,
"gas_resistance"
]
)
class
Bme680
:
def
__init__
(
self
):
sys_bme680
.
init
()
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
*
args
):
self
.
close
()
def
get_data
(
self
):
return
Bme680Data
(
*
sys_bme680
.
get_data
())
def
close
(
self
):
sys_bme680
.
deinit
()
def
temperature
(
self
):
return
self
.
get_data
().
temperature
def
humidity
(
self
):
return
self
.
get_data
().
humidity
def
pressure
(
self
):
return
self
.
get_data
().
pressure
def
gas_resistance
(
self
):
return
self
.
get_data
().
gas_resistance
pycardium/modules/py/meson.build
View file @
e7144129
python_modules
=
files
(
python_modules
=
files
(
'bhi160.py'
,
'bhi160.py'
,
'bme680.py'
,
'color.py'
,
'color.py'
,
'htmlcolor.py'
,
'htmlcolor.py'
,
'display.py'
,
'display.py'
,
...
...
pycardium/modules/qstrdefs.h
View file @
e7144129
...
@@ -104,7 +104,7 @@ Q(stop)
...
@@ -104,7 +104,7 @@ Q(stop)
Q
(
read
)
Q
(
read
)
/* bme680 */
/* bme680 */
Q
(
bme680
)
Q
(
sys_
bme680
)
Q
(
init
)
Q
(
init
)
Q
(
deinit
)
Q
(
deinit
)
Q
(
get_data
)
Q
(
get_data
)
...
...
pycardium/modules/sys_bme680.c
View file @
e7144129
...
@@ -46,7 +46,7 @@ static mp_obj_t mp_bme680_get_data()
...
@@ -46,7 +46,7 @@ static mp_obj_t mp_bme680_get_data()
static
MP_DEFINE_CONST_FUN_OBJ_0
(
bme680_get_data_obj
,
mp_bme680_get_data
);
static
MP_DEFINE_CONST_FUN_OBJ_0
(
bme680_get_data_obj
,
mp_bme680_get_data
);
static
const
mp_rom_map_elem_t
bme680_module_globals_table
[]
=
{
static
const
mp_rom_map_elem_t
bme680_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_bme680
)
},
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_
sys_
bme680
)
},
{
MP_ROM_QSTR
(
MP_QSTR_init
),
MP_ROM_PTR
(
&
bme680_init_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_init
),
MP_ROM_PTR
(
&
bme680_init_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_deinit
),
MP_ROM_PTR
(
&
bme680_deinit_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_deinit
),
MP_ROM_PTR
(
&
bme680_deinit_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_data
),
MP_ROM_PTR
(
&
bme680_get_data_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_data
),
MP_ROM_PTR
(
&
bme680_get_data_obj
)
},
...
@@ -59,4 +59,4 @@ const mp_obj_module_t bme680_module = {
...
@@ -59,4 +59,4 @@ const mp_obj_module_t bme680_module = {
};
};
/* Register the module to make it available in Python */
/* Register the module to make it available in Python */
MP_REGISTER_MODULE
(
MP_QSTR_bme680
,
bme680_module
,
MODULE_BME680_ENABLED
);
MP_REGISTER_MODULE
(
MP_QSTR_
sys_
bme680
,
bme680_module
,
MODULE_BME680_ENABLED
);
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment