8000 Merge remote-tracking branch 'origin/main' into main · unixjazz/circuitpython@70a325b · GitHub
[go: up one dir, main page]

Skip to content

Commit 70a325b

Browse files
committed
Merge remote-tracking branch 'origin/main' into main
2 parents 6a502a9 + a70fc0c commit 70a325b

File tree

166 files changed

+4548
-2399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+4548
-2399
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2020 Damien P. George
3+
Copyright (c) 2013-2021 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/library/binascii.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ Functions
1414

1515
.. function:: hexlify(data, [sep])
1616

17-
Convert binary data to hexadecimal representation. Returns bytes string.
18-
19-
.. admonition:: Difference to CPython
20-
:class: attention
17+
Convert the bytes in the *data* object to a hexadecimal representation.
18+
Returns a bytes object.
2119

22-
If additional argument, *sep* is supplied, it is used as a separator
23-
between hexadecimal values.
20+
If the additional argument *sep* is supplied it is used as a separator
21+
between hexadecimal values.
2422

2523
.. function:: unhexlify(data)
2624

docs/library/btree.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Methods
120120
.. method:: btree.__getitem__(key)
121121
btree.get(key, default=None, /)
122122
btree.__setitem__(key, val)
123-
btree.__detitem__(key)
123+
btree.__delitem__(key)
124124
btree.__contains__(key)
125125

126126
Standard dictionary methods.

docs/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:mod:`sys` -- system specific functions
2-
=======================================
2+
========================================
33

44
.. include:: ../templates/unsupported_in_circuitpython.inc
55

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Include MicroPython API.
2+
#include "py/runtime.h"
3+
4+
// This is the function which will be called from Python as cexample.add_ints(a, b).
5+
STATIC mp_obj_t example_add_ints(mp_obj_t a_obj, mp_obj_t b_obj) {
6+
// Extract the ints from the micropython input objects.
7+
int a = mp_obj_get_int(a_obj);
8+
int b = mp_obj_get_int(b_obj);
9+
10+
// Calculate the addition and convert to MicroPython object.
11+
return mp_obj_new_int(a + b);
12+
}
13+
// Define a Python reference to the function above.
14+
STATIC MP_DEFINE_CONST_FUN_OBJ_2(example_add_ints_obj, example_add_ints);
15+
16+
// Define all properties of the module.
17+
// Table entries are key/value pairs of the attribute name (a string)
18+
// and the MicroPython object reference.
19+
// All identifiers and strings are written as MP_QSTR_xxx and will be
20+
// optimized to word-sized integers by the build system (interned strings).
21+
STATIC const mp_rom_map_elem_t example_module_globals_table[] = {
22+
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cexample) },
23+
{ MP_ROM_QSTR(MP_QSTR_add_ints), MP_ROM_PTR(&example_add_ints_obj) },
24+
};
25+
STATIC MP_DEFINE_CONST_DICT(example_module_globals, example_module_globals_table);
26+
27+
// Define module object.
28+
const mp_obj_module_t example_user_cmodule = {
29+
.base = { &mp_type_module },
30+
.globals = (mp_obj_dict_t *)&example_module_globals,
31+
};
32+
33+
// Register the module to make it available in Python.
34+
MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, MODULE_CEXAMPLE_ENABLED);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
EXAMPLE_MOD_DIR := $(USERMOD_DIR)
2+
3+
# Add all C files to SRC_USERMOD.
4+
SRC_USERMOD += $(EXAMPLE_MOD_DIR)/examplemodule.c
5+
6+
# We can add our module folder to include paths if needed
7+
# This is not actually needed in this example.
8+
CFLAGS_USERMOD += -I$(EXAMPLE_MOD_DIR)
9+
CEXAMPLE_MOD_DIR := $(USERMOD_DIR)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
extern "C" {
2+
#include <examplemodule.h>
3+
4+
// Here we implement the function using C++ code, but since it's
5+
// declaration has to be compatible with C everything goes in extern "C" scope.
6+
mp_obj_t cppfunc(mp_obj_t a_obj, mp_obj_t b_obj) {
7+
// Prove we have (at least) C++11 features.
8+
const auto a = mp_obj_get_int(a_obj);
9+
const auto b = mp_obj_get_int(b_obj);
10+
const auto sum = [&]() {
11+
return mp_obj_new_int(a + b);
12+
} ();
13+
// Prove we're being scanned for QSTRs.
14+
mp_obj_t tup[] = {sum, MP_ROM_QSTR(MP_QSTR_hellocpp)};
15+
return mp_obj_new_tuple(2, tup);
16+
}
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <examplemodule.h>
2+
3+
// Define a Python reference to the function we'll make available.
4+
// See example.cpp for the definition.
5+
STATIC MP_DEFINE_CONST_FUN_OBJ_2(cppfunc_obj, cppfunc);
6+
7+
// Define all properties of the module.
8+
// Table entries are key/value pairs of the attribute name (a string)
9+
// and the MicroPython object reference.
10+
// All identifiers and strings are written as MP_QSTR_xxx and will be
11+
// optimized to word-sized integers by the build system (interned strings).
12+
STATIC const mp_rom_map_elem_t cppexample_module_globals_table[] = {
13+
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cppexample) },
14+
{ MP_ROM_QSTR(MP_QSTR_cppfunc), MP_ROM_PTR(&cppfunc_obj) },
15+
};
16+
STATIC MP_DEFINE_CONST_DICT(cppexample_module_globals, cppexample_module_globals_table);
17+
18+
// Define module object.
19+
const mp_obj_module_t cppexample_user_cmodule = {
20+
.base = { &mp_type_module },
21+
.globals = (mp_obj_dict_t *)&cppexample_module_globals,
22+
};
23+
24+
// Register the module to make it available in Python.
25+
MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, MODULE_CPPEXAMPLE_ENABLED);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Include MicroPython API.
2+
#include "py/runtime.h"
3+
4+
// Declare the function we'll make available in Python as cppexample.cppfunc().
5+
extern mp_obj_t cppfunc(mp_obj_t a_obj, mp_obj_t b_obj);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CPPEXAMPLE_MOD_DIR := $(USERMOD_DIR)
2+
3+
# Add our source files to the respective variables.
4+
SRC_USERMOD += $(CPPEXAMPLE_MOD_DIR)/examplemodule.c
5+
SRC_USERMOD_CXX += $(CPPEXAMPLE_MOD_DIR)/example.cpp
6+
7+
# Add our module directory to the include path.
8+
CFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR)
9+
CXXFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR)
10+
11+
# We use C++ features so have to link against the standard library.
12+
LDFLAGS_USERMOD += -lstdc++

extmod/btstack/btstack.mk

Lines changed: 0 additions & 57 deletions
This file was deleted.

extmod/btstack/btstack_config.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0