Skip to content

Commit 184d8ef

Browse files
authored
Merge pull request #9467 from jepler/merge-91x-main
Merge 9.1.x to main
2 parents bd83418 + d335a10 commit 184d8ef

File tree

7 files changed

+77
-30
lines changed

7 files changed

+77
-30
lines changed

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
autoapi_python_class_content = "both"
111111
autoapi_python_use_implicit_namespaces = True
112112
autoapi_root = "shared-bindings"
113+
autoapi_file_patterns = ["*.pyi"]
113114

114115
# Suppress cache warnings to prevent "unpickable" [sic] warning
115116
# about autoapi_prepare_jinja_env() from sphinx >= 7.3.0.

ports/espressif/common-hal/countio/Counter.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self,
2020

2121
pcnt_unit_config_t unit_config = {
2222
// Set counter limit
23-
.low_limit = -1,
23+
.low_limit = INT16_MIN,
2424
.high_limit = INT16_MAX
2525
};
26-
// The pulse count driver automatically counts roll overs.
26+
// Enable PCNT internal accumulator to count overflows.
2727
unit_config.flags.accum_count = true;
2828

2929
// initialize PCNT
3030
CHECK_ESP_RESULT(pcnt_new_unit(&unit_config, &self->unit));
3131

32+
// Set watchpoints at limis, to auto-accumulate overflows.
33+
pcnt_unit_add_watch_point(self->unit, INT16_MIN);
34+
pcnt_unit_add_watch_point(self->unit, INT16_MAX);
35+
3236
self->pin = pin->number;
3337
pcnt_chan_config_t channel_config = {
3438
.edge_gpio_num = self->pin,

ports/espressif/common-hal/frequencyio/FrequencyIn.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ static IRAM_ATTR bool timer_interrupt_handler(gptimer_handle_t timer,
3030
static esp_err_t init_pcnt(frequencyio_frequencyin_obj_t *self) {
3131
pcnt_unit_config_t unit_config = {
3232
// Set counter limit
33-
.low_limit = -INT16_MAX + 1,
33+
.low_limit = INT16_MIN,
3434
.high_limit = INT16_MAX
3535
};
36-
// The pulse count driver automatically counts roll overs.
36+
// Enable PCNT internal accumulator to count overflows.
3737
unit_config.flags.accum_count = true;
3838

3939
// initialize PCNT
@@ -42,6 +42,10 @@ static esp_err_t init_pcnt(frequencyio_frequencyin_obj_t *self) {
4242
return result;
4343
}
4444

45+
// Set watchpoints at limis, to auto-accumulate overflows.
46+
pcnt_unit_add_watch_point(self->internal_data->unit, INT16_MIN);
47+
pcnt_unit_add_watch_point(self->internal_data->unit, INT16_MAX);
48+
4549
pcnt_chan_config_t channel_config = {
4650
.edge_gpio_num = self->pin,
4751
.level_gpio_num = -1

ports/espressif/common-hal/rotaryio/IncrementalEncoder.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
2323
// in CircuitPython.
2424
pcnt_unit_config_t unit_config = {
2525
// Set counter limit
26-
.low_limit = -INT16_MAX,
26+
.low_limit = INT16_MIN,
2727
.high_limit = INT16_MAX
2828
};
29-
// The pulse count driver automatically counts roll overs.
29+
// Enable PCNT internal accumulator to count overflows.
3030
unit_config.flags.accum_count = true;
3131

3232
// initialize PCNT
3333
CHECK_ESP_RESULT(pcnt_new_unit(&unit_config, &self->unit));
3434

35+
// Set watchpoints at limits, to auto-accumulate overflows.
36+
pcnt_unit_add_watch_point(self->unit, INT16_MIN);
37+
pcnt_unit_add_watch_point(self->unit, INT16_MAX);
38+
3539
pcnt_chan_config_t channel_a_config = {
3640
.edge_gpio_num = pin_a->number,
3741
.level_gpio_num = pin_b->number

ports/nordic/common-hal/_bleio/__init__.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ void common_hal_bleio_init(void) {
7878
}
7979

8080
void bleio_user_reset() {
81-
// Stop any user scanning or advertising.
82-
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
83-
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
81+
if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
82+
// Stop any user scanning or advertising.
83+
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
84+
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
85+
}
8486

8587
ble_drv_remove_heap_handlers();
8688

ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,32 +146,33 @@ static int _set_vid(void) {
146146
vid_setting = value;
147147
/*
148148
Voltage Divider with 3.3V: (1241 * V)
149-
10K/ 15K = 1.98V = 2458
150-
15K/ 10K = 1.32V = 1638
151-
15K/4.7K = 0.79V = 980
152-
15K/ 2K = 1.32V = 482
153-
15K/ 1K = 1.32V = 256
149+
10K/ 15K = 1.98V = 2458 GT 2000 = TBD
150+
15K/ 10K = 1.32V = 1638 GT 1200 = Explorer with SSD1681 BW
151+
15K/4.7K = 0.79V = 980 GT 600 = Explorer with SSD1681 BWR
152+
15K/ 2K = 0.39V = 482 GT 300 = Explorer with SSD1608 BW
153+
100K/ 10K = 0.30V = 372 ditto
154+
15K/ 1K = 0.21V = 256 GT 150 = DCNextGen with SSD1681 BWR
154155
Note: extreme values (using 100K or greater) will not create a strong enough current for the ADC to read accurately
155156
Note: we do not get a usable value when the voltage divider is missing
156157
*/
157158

158159
// TODO change to min/max to tighten up the ranges (requires sampling of the initial boards)
159160
if (value > 2800) {
160-
vid_setting = 9;
161+
vid_setting = 9; // invalid
161162
} else if (value > 2000) {
162-
vid_setting = 5;
163+
vid_setting = 5; // future
163164
} else if (value > 1200) {
164-
vid_setting = 4;
165+
vid_setting = 4; // Explorer SSD1681 BW
165166
} else if (value > 600) {
166-
vid_setting = 3;
167+
vid_setting = 3; // Explorer SSD1681 BWR
167168
} else if (value > 300) {
168-
vid_setting = 2;
169+
vid_setting = 2; // Explorer SSD1608 BW
169170
} else if (value > 150) {
170-
vid_setting = 1;
171+
vid_setting = 1; // DCNextGen SSD1681 BWR
171172
} else {
172-
vid_setting = 0;
173-
}
173+
vid_setting = 0; // invalid
174174

175+
}
175176
return vid_setting;
176177
}
177178

@@ -227,8 +228,29 @@ void board_init(void) {
227228
display = &allocate_display()->epaper_display;
228229
display->base.type = &epaperdisplay_epaperdisplay_type;
229230

230-
// VID codes: 1 = tricolor ePaper (BWR), 2 = monochrome ePaper (BW), other codes are TBD
231+
// default to no rotation
232+
int rotation = 0;
231233
if (vid_setting == 1) {
234+
// DCNextGen SSD1681 BWR rotated 270
235+
rotation = 270;
236+
}
237+
238+
// default to BWR refresh rates
239+
float refresh_time = 15.0;
240+
float seconds_per_frame = 20.0;
241+
if ((vid_setting == 2) || (vid_setting == 4)) {
242+
// BW displays have faster refresh rates
243+
refresh_time = 1.0;
244+
seconds_per_frame = 5.0;
245+
}
246+
247+
// VID 1, 3, and 4 = SSD1681 display driver
248+
// VID 2 = SSD1608 display driver
249+
250+
// VID codes: see above
251+
if ((vid_setting == 1) || // DCNextGen SSD1681 BWR rotated 270
252+
(vid_setting == 3) || // Explorer SSD1681 BW rotated 0
253+
(vid_setting == 4)) { // Explorer SSD1681 BWR rotated 0
232254
common_hal_epaperdisplay_epaperdisplay_construct(
233255
display,
234256
bus,
@@ -241,7 +263,7 @@ void board_init(void) {
241263
HEIGHT + 0x60, // ram_height RAM is actually only 200 bits high but we use 296 to match the 9 bits
242264
0, // colstart
243265
0, // rowstart
244-
270, // rotation
266+
rotation, // rotation
245267
SSD_SET_RAMXPOS, // set_column_window_command
246268
SSD_SET_RAMYPOS, // set_row_window_command
247269
SSD_SET_RAMXCOUNT, // set_current_column_command
@@ -252,16 +274,16 @@ void board_init(void) {
252274
false, // color_bits_inverted
253275
0xFF0000, // highlight_color (RED for tri-color display)
254276
_refresh_sequence_ssd1681, sizeof(_refresh_sequence_ssd1681), // refresh_display_command
255-
15.0, // refresh_time
277+
refresh_time, // refresh_time
256278
&pin_GPIO9, // DEFAULT_SPI_BUS_BUSY, // busy_pin
257279
true, // busy_state
258-
20.0, // seconds_per_frame (does not seem the user can change this)
280+
seconds_per_frame, // seconds_per_frame (does not seem the user can change this)
259281
true, // always_toggle_chip_select
260282
false, // not grayscale
261283
false, // not acep
262284
false, // not two_byte_sequence_length
263285
true); // address_little_endian
264-
} else if (vid_setting == 2) {
286+
} else if (vid_setting == 2) { // Explorer SSD1608 BW
265287
common_hal_epaperdisplay_epaperdisplay_construct(
266288
display,
267289
bus,
@@ -274,7 +296,7 @@ void board_init(void) {
274296
HEIGHT /* + 0x60 */, // ram_height RAM is actually only 200 bits high but we use 296 to match the 9 bits
275297
0, // colstart
276298
0, // rowstart
277-
0, // rotation
299+
rotation, // rotation
278300
SSD_SET_RAMXPOS, // set_column_window_command
279301
SSD_SET_RAMYPOS, // set_row_window_command
280302
SSD_SET_RAMXCOUNT, // set_current_column_command
@@ -285,10 +307,10 @@ void board_init(void) {
285307
false, // color_bits_inverted
286308
0x000000, // highlight_color (RED for tri-color display)
287309
_refresh_sequence_ssd1608, sizeof(_refresh_sequence_ssd1608), // refresh_display_command
288-
1.0, // refresh_time
310+
refresh_time, // refresh_time
289311
&pin_GPIO9, // DEFAULT_SPI_BUS_BUSY, // busy_pin
290312
true, // busy_state
291-
5.0, // seconds_per_frame (does not seem the user can change this)
313+
seconds_per_frame, // seconds_per_frame (does not seem the user can change this)
292314
true, // always_toggle_chip_select
293315
false, // not grayscale
294316
false, // not acep

py/modsys.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
#include "extmod/modplatform.h"
4040
#include "genhdr/mpversion.h"
4141

42+
// CIRCUITPY-CHANGE
43+
#if CIRCUITPY_WARNINGS
44+
#include "shared-module/warnings/__init__.h"
45+
#endif
46+
4247
#if MICROPY_PY_SYS_SETTRACE
4348
#include "py/objmodule.h"
4449
#include "py/profile.h"
@@ -134,6 +139,11 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
134139
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
135140

136141
STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
142+
// CIRCUITPY-CHANGE
143+
#if CIRCUITPY_WARNINGS
144+
warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_print_exception, MP_QSTR_sys, MP_QSTR_traceback);
145+
#endif
146+
137147
#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
138148
void *stream_obj = &mp_sys_stdout_obj;
139149
if (n_args > 1) {

0 commit comments

Comments
 (0)