Skip to content

Commit ac232f2

Browse files
Merge pull request #1 from adafruit/main
update
2 parents 7970c88 + d012561 commit ac232f2

File tree

1,944 files changed

+36201
-26475
lines changed

Some content is hidden

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

1,944 files changed

+36201
-26475
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
run: |
4444
gcc --version
4545
python3 --version
46-
- name: Translations
47-
run: make check-translate
4846
- name: New boards check
4947
run: python3 -u ci_new_boards_check.py
5048
working-directory: tools
@@ -81,6 +79,7 @@ jobs:
8179
working-directory: tests
8280
- name: Print failure info
8381
run: |
82+
shopt -s nullglob;
8483
for exp in *.exp;
8584
do testbase=$(basename $exp .exp);
8685
echo -e "\nFAILURE $testbase";
@@ -313,13 +312,16 @@ jobs:
313312
- "simmel"
314313
- "snekboard"
315314
- "sparkfun_lumidrive"
315+
- "sparkfun_nrf52840_micromod"
316316
- "sparkfun_nrf52840_mini"
317+
- "sparkfun_pro_micro_rp2040"
317318
- "sparkfun_qwiic_micro_no_flash"
318319
- "sparkfun_qwiic_micro_with_flash"
319320
- "sparkfun_redboard_turbo"
320321
- "sparkfun_samd21_dev"
321322
- "sparkfun_samd21_mini"
322323
- "sparkfun_samd51_thing_plus"
324+
- "sparkfun_thing_plus_rp2040"
323325
- "spresense"
324326
- "stackrduino_m0_pro"
325327
- "stm32f411ce_blackpill"
@@ -449,6 +451,8 @@ jobs:
449451
- "espressif_kaluga_1"
450452
- "espressif_saola_1_wroom"
451453
- "espressif_saola_1_wrover"
454+
- "franzininho_wifi_wroom"
455+
- "franzininho_wifi_wrover"
452456
- "lilygo_ttgo_t8_s2_st7789"
453457
- "microdev_micro_s2"
454458
- "muselab_nanoesp32_s2"
@@ -475,7 +479,7 @@ jobs:
475479
id: idf-cache
476480
with:
477481
path: ${{ github.workspace }}/.idf_tools
478-
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210303
482+
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304
479483
- name: Clone IDF submodules
480484
run: |
481485
(cd $IDF_PATH && git submodule update --init)

.github/workflows/pre-commit.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ name: pre-commit
77
on:
88
pull_request:
99
push:
10-
branches: [main]
1110

1211
jobs:
1312
pre-commit:
@@ -16,10 +15,13 @@ jobs:
1615
- uses: actions/checkout@v1
1716
- uses: actions/setup-python@v1
1817
- name: Install deps
19-
run: sudo apt-get update && sudo apt-get install -y gettext
18+
run: |
19+
sudo apt-add-repository -y -u ppa:pybricks/ppa
20+
sudo apt-get install -y black gettext uncrustify
21+
pip3 install polib
2022
- name: Populate selected submodules
2123
run: git submodule update --init extmod/ulab
22-
- name: set PY
24+
- name: Set PY
2325
run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
2426
- uses: actions/cache@v2
2527
with:

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ repos:
1111
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/esp32s2/esp-idf-config/.*|ports/esp32s2/boards/.*/sdkconfig)'
1212
- id: trailing-whitespace
1313
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*)'
14+
- repo: local
15+
hooks:
16+
- id: translations
17+
name: Translations
18+
entry: sh -c "if ! make check-translate; then make translate; fi"
19+
types: [c]
20+
pass_filenames: false
21+
language: system
22+
- id: formatting
23+
name: Formatting
24+
entry: python3 tools/codeformat.py
25+
types_or: [c, python]
26+
language: system

BUILDING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,23 @@ Example:
8585

8686
If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register
8787
debugging with https://github.com/bnahill/PyCortexMDebug
88+
89+
# Code Quality Checks
90+
91+
We apply code quality checks using pre-commit. Install pre-commit once per system with
92+
93+
python3 -mpip install pre-commit
94+
95+
Activate it once per git clone with
96+
97+
pre-commit --install
98+
99+
Pre-commit also requires some additional programs to be installed through your package manager:
100+
101+
* Standard Unix tools such as make, find, etc
102+
* The gettext package, any modern version
103+
* uncrustify version 0.71 (0.72 is also tested)
104+
105+
Each time you create a git commit, the pre-commit quality checks will be run. You can also run them e.g., with `pre-commit run foo.c` or `pre-commit run --all` to run on all files whether modified or not.
106+
107+
Some pre-commit quality checks require your active attention to resolve, others (such as the formatting checks of uncrustify) are made automatically and must simply be incorporated into your code changes by committing them.

README.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Specifically useful documentation when starting out:
5151
- `CircuitPython Essentials <https://learn.adafruit.com/circuitpython-essentials>`__
5252
- `Example Code <https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/CircuitPython_Essentials>`__
5353

54+
Code Search
55+
------------
56+
GitHub doesn't currently support code search on forks. Therefore, CircuitPython doesn't have code search through GitHub because it is a fork of MicroPython. Luckily, `SourceGraph <https://sourcegraph.com/github.com/adafruit/circuitpython>`_ has free code search for public repos like CircuitPython. So, visit `sourcegraph.com/github.com/adafruit/circuitpython <https://sourcegraph.com/github.com/adafruit/circuitpython>`_ to search the CircuitPython codebase online.
57+
5458
Contributing
5559
------------
5660

@@ -113,10 +117,9 @@ Behavior
113117
- ``code.py`` (or ``main.py``) is run after every reload until it
114118
finishes or is interrupted. After it is done running, the vm and
115119
hardware is reinitialized. **This means you cannot read state from**
116-
``code.py`` **in the REPL anymore.** CircuitPython's goal for this
120+
``code.py`` **in the REPL anymore, as the REPL is a fresh vm.** CircuitPython's goal for this
117121
change includes reducing confusion about pins and memory being used.
118-
- After ``code.py`` the REPL can be entered by pressing any key. It no
119-
longer shares state with ``code.py`` so it is a fresh vm.
122+
- After the main code is finished the REPL can be entered by pressing any key.
120123
- Autoreload state will be maintained across reload.
121124
- Adds a safe mode that does not run user code after a hard crash or
122125
brown out. The hope is that this will make it easier to fix code that
@@ -126,8 +129,7 @@ Behavior
126129
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
127130
- Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with
128131
``supervisor.disable_autoreload()``)
129-
- Entering the REPL after the main code is finished requires a key press which enters the REPL and
130-
disables autoreload.
132+
- Autoreload is disabled while the REPL is active.
131133
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,
132134
``main.txt``
133135
- Boot is one of these: ``settings.txt``, ``settings.py``, ``boot.py``,
@@ -209,6 +211,7 @@ esp32s2 beta
209211
litex alpha
210212
mimxrt10xx alpha
211213
nrf stable
214+
raspberrypi beta
212215
stm ``F4`` stable | ``others`` beta
213216
unix alpha
214217
================ ============================================================

devices/ble_hci/common-hal/_bleio/Adapter.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
5353
#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION))
54-
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME) * (RESOLUTION)) / 1000000)
54+
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000)
5555
// 0.625 msecs (625 usecs)
5656
#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625)
5757
// Microseconds is the base unit. The macros above know that.
@@ -63,7 +63,7 @@
6363

6464
// TODO make this settable from Python.
6565
#define DEFAULT_TX_POWER 0 // 0 dBm
66-
#define MAX_ANONYMOUS_ADV_TIMEOUT_SECS (60*15)
66+
#define MAX_ANONYMOUS_ADV_TIMEOUT_SECS (60 * 15)
6767
#define MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS (180)
6868

6969
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
@@ -289,7 +289,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
289289

290290
// Get version information.
291291
if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version,
292-
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
292+
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
293293
mp_raise_bleio_BluetoothError(translate("Could not read HCI version"));
294294
}
295295
// Get supported features.
@@ -414,11 +414,11 @@ bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_addre
414414
return hci_le_set_random_address(bufinfo.buf) == HCI_OK;
415415
}
416416

417-
mp_obj_str_t* common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) {
417+
mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) {
418418
return self->name;
419419
}
420420

421-
void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* name) {
421+
void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name) {
422422
self->name = mp_obj_new_str(name, strlen(name));
423423
mp_buffer_info_t bufinfo;
424424
mp_get_buffer_raise(self->name, &bufinfo, MP_BUFFER_READ);
@@ -459,7 +459,7 @@ void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* na
459459
// return true;
460460
// }
461461

462-
mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t* prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) {
462+
mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) {
463463
// TODO
464464
mp_raise_NotImplementedError(NULL);
465465
check_enabled(self);
@@ -704,7 +704,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
704704

705705
uint8_t handle[1] = { 0 };
706706
uint16_t duration_10msec[1] = { timeout * 100 };
707-
uint8_t max_ext_adv_evts[1] = { 0 };
707+
uint8_t max_ext_adv_evts[1] = { 0 };
708708
hci_check_error(
709709
hci_le_set_extended_advertising_enable(
710710
BT_HCI_LE_ADV_ENABLE,
@@ -789,11 +789,11 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
789789
} else {
790790
if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS) {
791791
mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"),
792-
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
792+
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
793793
}
794794
}
795795

796-
const uint32_t result =_common_hal_bleio_adapter_start_advertising(
796+
const uint32_t result = _common_hal_bleio_adapter_start_advertising(
797797
self, connectable, anonymous, timeout, interval,
798798
advertising_data_bufinfo->buf,
799799
advertising_data_bufinfo->len,
@@ -820,11 +820,11 @@ void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) {
820820
hci_check_error(result);
821821
}
822822

823-
//TODO startup CircuitPython advertising again.
823+
// TODO startup CircuitPython advertising again.
824824
}
825825

826826
// Note that something stopped advertising, such as a connection happening.
827-
//Don't ask the adapter to stop.
827+
// Don't ask the adapter to stop.
828828
void bleio_adapter_advertising_was_stopped(bleio_adapter_obj_t *self) {
829829
self->now_advertising = false;
830830
self->extended_advertising = false;
@@ -876,14 +876,14 @@ void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) {
876876
mp_raise_NotImplementedError(NULL);
877877
check_enabled(self);
878878

879-
//FIX bonding_erase_storage();
879+
// FIX bonding_erase_storage();
880880
}
881881

882882
uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *attribute) {
883883
check_enabled(adapter);
884884

885885
// The handle is the index of this attribute in the attributes list.
886-
uint16_t handle = (uint16_t) adapter->attributes->len;
886+
uint16_t handle = (uint16_t)adapter->attributes->len;
887887
mp_obj_list_append(adapter->attributes, attribute);
888888

889889
if (MP_OBJ_IS_TYPE(attribute, &bleio_service_type)) {
@@ -896,7 +896,7 @@ uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *att
896896
return handle;
897897
}
898898

899-
mp_obj_t* bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle) {
899+
mp_obj_t *bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle) {
900900
check_enabled(adapter);
901901

902902
if (handle == 0 || handle >= adapter->attributes->len) {
@@ -912,12 +912,12 @@ uint16_t bleio_adapter_max_attribute_handle(bleio_adapter_obj_t *adapter) {
912912
}
913913

914914

915-
void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) {
916-
gc_collect_root((void**)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t));
917-
gc_collect_root((void**)bleio_connections, sizeof(bleio_connections) / sizeof(size_t));
915+
void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter) {
916+
gc_collect_root((void **)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t));
917+
gc_collect_root((void **)bleio_connections, sizeof(bleio_connections) / sizeof(size_t));
918918
}
919919

920-
void bleio_adapter_reset(bleio_adapter_obj_t* adapter) {
920+
void bleio_adapter_reset(bleio_adapter_obj_t *adapter) {
921921

922922
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
923923
return;
@@ -939,7 +939,7 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) {
939939

940940
}
941941

942-
void bleio_adapter_background(bleio_adapter_obj_t* adapter) {
942+
void bleio_adapter_background(bleio_adapter_obj_t *adapter) {
943943
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
944944
return;
945945
}

devices/ble_hci/common-hal/_bleio/Adapter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct _bleio_adapter_obj_t {
4949
bleio_scanresults_obj_t *scan_results;
5050
mp_obj_t name;
5151
mp_obj_tuple_t *connection_objs;
52-
busio_uart_obj_t* hci_uart;
52+
busio_uart_obj_t *hci_uart;
5353
digitalio_digitalinout_obj_t *rts_digitalinout;
5454
digitalio_digitalinout_obj_t *cts_digitalinout;
5555
bool allocated; // True when in use.
@@ -72,7 +72,7 @@ typedef struct _bleio_adapter_obj_t {
7272
// Generic services characteristics.
7373
bleio_characteristic_obj_t *device_name_characteristic;
7474
bleio_characteristic_obj_t *appearance_characteristic;
75-
bleio_characteristic_obj_t * service_changed_characteristic;
75+
bleio_characteristic_obj_t *service_changed_characteristic;
7676

7777
uint16_t max_acl_buffer_len;
7878
uint16_t max_acl_num_buffers;
@@ -90,10 +90,10 @@ typedef struct _bleio_adapter_obj_t {
9090

9191
uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *attribute);
9292
void bleio_adapter_advertising_was_stopped(bleio_adapter_obj_t *self);
93-
mp_obj_t* bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle);
93+
mp_obj_t *bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle);
9494
uint16_t bleio_adapter_max_attribute_handle(bleio_adapter_obj_t *adapter);
95-
void bleio_adapter_background(bleio_adapter_obj_t* adapter);
96-
void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter);
97-
void bleio_adapter_reset(bleio_adapter_obj_t* adapter);
95+
void bleio_adapter_background(bleio_adapter_obj_t *adapter);
96+
void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter);
97+
void bleio_adapter_reset(bleio_adapter_obj_t *adapter);
9898

9999
#endif // MICROPY_INCLUDED_BLE_HCI_COMMON_HAL_ADAPTER_H

devices/ble_hci/common-hal/_bleio/Characteristic.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_character
7878
return self->service;
7979
}
8080

81-
size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t* buf, size_t len) {
81+
size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len) {
8282
// Do GATT operations only if this characteristic has been added to a registered service.
8383
if (self->handle != BLE_GATT_HANDLE_INVALID) {
84-
//FIX uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
84+
// FIX uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
8585
if (common_hal_bleio_service_get_is_remote(self->service)) {
86-
//FIX read remote chars
87-
//uint8_t rsp[MAX(len, 512)];
88-
//FIX improve att_read_req to write into our requested buffer.
86+
// FIX read remote chars
87+
// uint8_t rsp[MAX(len, 512)];
88+
// FIX improve att_read_req to write into our requested buffer.
8989
// return att_read_req(conn_handle, self->handle, rsp);
90-
return 0; //FIX
90+
return 0; // FIX
9191
} else {
9292
mp_buffer_info_t bufinfo;
9393
if (!mp_get_buffer(self->value, &bufinfo, MP_BUFFER_READ)) {
@@ -113,13 +113,13 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
113113
// Do GATT operations only if this characteristic has been added to a registered service.
114114
if (self->handle != BLE_GATT_HANDLE_INVALID) {
115115
if (common_hal_bleio_service_get_is_remote(self->service)) {
116-
//FIX uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
116+
// FIX uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
117117
if (self->props & CHAR_PROP_WRITE) {
118-
//FIX writing remote chars
119-
//uint8_t rsp[sizeof(bt_att_error_rsp)];
120-
//att_write_req(conn_handle, self->handle, bufinfo->buf, bufinfo->len, rsp);
118+
// FIX writing remote chars
119+
// uint8_t rsp[sizeof(bt_att_error_rsp)];
120+
// att_write_req(conn_handle, self->handle, bufinfo->buf, bufinfo->len, rsp);
121121
} else if (self->props & CHAR_PROP_WRITE_NO_RESPONSE) {
122-
//att_write_cmd(conn_handle, self->handle, bufinfo->buff, bufinfo->len);
122+
// att_write_cmd(conn_handle, self->handle, bufinfo->buff, bufinfo->len);
123123
} else {
124124
mp_raise_bleio_BluetoothError(translate("Characteristic not writable"));
125125
}
@@ -172,7 +172,7 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *
172172
self->service->end_handle = descriptor->handle;
173173

174174
mp_obj_list_append(MP_OBJ_FROM_PTR(self->descriptor_list),
175-
MP_OBJ_FROM_PTR(descriptor));
175+
MP_OBJ_FROM_PTR(descriptor));
176176
}
177177

178178
void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
@@ -191,8 +191,8 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self,
191191
(notify ? CCCD_NOTIFY : 0) |
192192
(indicate ? CCCD_INDICATE : 0);
193193

194-
//FIX do remote
195-
(void) cccd_value;
194+
// FIX do remote
195+
(void)cccd_value;
196196
// uint8_t rsp[sizeof(bt_att_error_rsp)];
197197
// if (att_write_req(conn_handle, self->cccd->handle, &cccd_value, sizeof(cccd_value)) == 0) {
198198
// mp_raise_bleio_BluetoothError(translate("Could not write CCCD"));

0 commit comments

Comments
 (0)