Skip to content

Merge 9.1.x to main #9467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
autoapi_python_class_content = "both"
autoapi_python_use_implicit_namespaces = True
autoapi_root = "shared-bindings"
autoapi_file_patterns = ["*.pyi"]

# Suppress cache warnings to prevent "unpickable" [sic] warning
# about autoapi_prepare_jinja_env() from sphinx >= 7.3.0.
Expand Down
8 changes: 6 additions & 2 deletions ports/espressif/common-hal/countio/Counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self,

pcnt_unit_config_t unit_config = {
// Set counter limit
.low_limit = -1,
.low_limit = INT16_MIN,
.high_limit = INT16_MAX
};
// The pulse count driver automatically counts roll overs.
// Enable PCNT internal accumulator to count overflows.
unit_config.flags.accum_count = true;

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

// Set watchpoints at limis, to auto-accumulate overflows.
pcnt_unit_add_watch_point(self->unit, INT16_MIN);
pcnt_unit_add_watch_point(self->unit, INT16_MAX);

self->pin = pin->number;
pcnt_chan_config_t channel_config = {
.edge_gpio_num = self->pin,
Expand Down
8 changes: 6 additions & 2 deletions ports/espressif/common-hal/frequencyio/FrequencyIn.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static IRAM_ATTR bool timer_interrupt_handler(gptimer_handle_t timer,
static esp_err_t init_pcnt(frequencyio_frequencyin_obj_t *self) {
pcnt_unit_config_t unit_config = {
// Set counter limit
.low_limit = -INT16_MAX + 1,
.low_limit = INT16_MIN,
.high_limit = INT16_MAX
};
// The pulse count driver automatically counts roll overs.
// Enable PCNT internal accumulator to count overflows.
unit_config.flags.accum_count = true;

// initialize PCNT
Expand All @@ -42,6 +42,10 @@ static esp_err_t init_pcnt(frequencyio_frequencyin_obj_t *self) {
return result;
}

// Set watchpoints at limis, to auto-accumulate overflows.
pcnt_unit_add_watch_point(self->internal_data->unit, INT16_MIN);
pcnt_unit_add_watch_point(self->internal_data->unit, INT16_MAX);

pcnt_chan_config_t channel_config = {
.edge_gpio_num = self->pin,
.level_gpio_num = -1
Expand Down
8 changes: 6 additions & 2 deletions ports/espressif/common-hal/rotaryio/IncrementalEncoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
// in CircuitPython.
pcnt_unit_config_t unit_config = {
// Set counter limit
.low_limit = -INT16_MAX,
.low_limit = INT16_MIN,
.high_limit = INT16_MAX
};
// The pulse count driver automatically counts roll overs.
// Enable PCNT internal accumulator to count overflows.
unit_config.flags.accum_count = true;

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

// Set watchpoints at limits, to auto-accumulate overflows.
pcnt_unit_add_watch_point(self->unit, INT16_MIN);
pcnt_unit_add_watch_point(self->unit, INT16_MAX);

pcnt_chan_config_t channel_a_config = {
.edge_gpio_num = pin_a->number,
.level_gpio_num = pin_b->number
Expand Down
8 changes: 5 additions & 3 deletions ports/nordic/common-hal/_bleio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ void common_hal_bleio_init(void) {
}

void bleio_user_reset() {
// Stop any user scanning or advertising.
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
// Stop any user scanning or advertising.
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
}

ble_drv_remove_heap_handlers();

Expand Down
64 changes: 43 additions & 21 deletions ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,33 @@ static int _set_vid(void) {
vid_setting = value;
/*
Voltage Divider with 3.3V: (1241 * V)
10K/ 15K = 1.98V = 2458
15K/ 10K = 1.32V = 1638
15K/4.7K = 0.79V = 980
15K/ 2K = 1.32V = 482
15K/ 1K = 1.32V = 256
10K/ 15K = 1.98V = 2458 GT 2000 = TBD
15K/ 10K = 1.32V = 1638 GT 1200 = Explorer with SSD1681 BW
15K/4.7K = 0.79V = 980 GT 600 = Explorer with SSD1681 BWR
15K/ 2K = 0.39V = 482 GT 300 = Explorer with SSD1608 BW
100K/ 10K = 0.30V = 372 ditto
15K/ 1K = 0.21V = 256 GT 150 = DCNextGen with SSD1681 BWR
Note: extreme values (using 100K or greater) will not create a strong enough current for the ADC to read accurately
Note: we do not get a usable value when the voltage divider is missing
*/

// TODO change to min/max to tighten up the ranges (requires sampling of the initial boards)
if (value > 2800) {
vid_setting = 9;
vid_setting = 9; // invalid
} else if (value > 2000) {
vid_setting = 5;
vid_setting = 5; // future
} else if (value > 1200) {
vid_setting = 4;
vid_setting = 4; // Explorer SSD1681 BW
} else if (value > 600) {
vid_setting = 3;
vid_setting = 3; // Explorer SSD1681 BWR
} else if (value > 300) {
vid_setting = 2;
vid_setting = 2; // Explorer SSD1608 BW
} else if (value > 150) {
vid_setting = 1;
vid_setting = 1; // DCNextGen SSD1681 BWR
} else {
vid_setting = 0;
}
vid_setting = 0; // invalid

}
return vid_setting;
}

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

// VID codes: 1 = tricolor ePaper (BWR), 2 = monochrome ePaper (BW), other codes are TBD
// default to no rotation
int rotation = 0;
if (vid_setting == 1) {
// DCNextGen SSD1681 BWR rotated 270
rotation = 270;
}

// default to BWR refresh rates
float refresh_time = 15.0;
float seconds_per_frame = 20.0;
if ((vid_setting == 2) || (vid_setting == 4)) {
// BW displays have faster refresh rates
refresh_time = 1.0;
seconds_per_frame = 5.0;
}

// VID 1, 3, and 4 = SSD1681 display driver
// VID 2 = SSD1608 display driver

// VID codes: see above
if ((vid_setting == 1) || // DCNextGen SSD1681 BWR rotated 270
(vid_setting == 3) || // Explorer SSD1681 BW rotated 0
(vid_setting == 4)) { // Explorer SSD1681 BWR rotated 0
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
Expand All @@ -241,7 +263,7 @@ void board_init(void) {
HEIGHT + 0x60, // ram_height RAM is actually only 200 bits high but we use 296 to match the 9 bits
0, // colstart
0, // rowstart
270, // rotation
rotation, // rotation
SSD_SET_RAMXPOS, // set_column_window_command
SSD_SET_RAMYPOS, // set_row_window_command
SSD_SET_RAMXCOUNT, // set_current_column_command
Expand All @@ -252,16 +274,16 @@ void board_init(void) {
false, // color_bits_inverted
0xFF0000, // highlight_color (RED for tri-color display)
_refresh_sequence_ssd1681, sizeof(_refresh_sequence_ssd1681), // refresh_display_command
15.0, // refresh_time
refresh_time, // refresh_time
&pin_GPIO9, // DEFAULT_SPI_BUS_BUSY, // busy_pin
true, // busy_state
20.0, // seconds_per_frame (does not seem the user can change this)
seconds_per_frame, // seconds_per_frame (does not seem the user can change this)
true, // always_toggle_chip_select
false, // not grayscale
false, // not acep
false, // not two_byte_sequence_length
true); // address_little_endian
} else if (vid_setting == 2) {
} else if (vid_setting == 2) { // Explorer SSD1608 BW
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
Expand All @@ -274,7 +296,7 @@ void board_init(void) {
HEIGHT /* + 0x60 */, // ram_height RAM is actually only 200 bits high but we use 296 to match the 9 bits
0, // colstart
0, // rowstart
0, // rotation
rotation, // rotation
SSD_SET_RAMXPOS, // set_column_window_command
SSD_SET_RAMYPOS, // set_row_window_command
SSD_SET_RAMXCOUNT, // set_current_column_command
Expand All @@ -285,10 +307,10 @@ void board_init(void) {
false, // color_bits_inverted
0x000000, // highlight_color (RED for tri-color display)
_refresh_sequence_ssd1608, sizeof(_refresh_sequence_ssd1608), // refresh_display_command
1.0, // refresh_time
refresh_time, // refresh_time
&pin_GPIO9, // DEFAULT_SPI_BUS_BUSY, // busy_pin
true, // busy_state
5.0, // seconds_per_frame (does not seem the user can change this)
seconds_per_frame, // seconds_per_frame (does not seem the user can change this)
true, // always_toggle_chip_select
false, // not grayscale
false, // not acep
Expand Down
10 changes: 10 additions & 0 deletions py/modsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
#include "extmod/modplatform.h"
#include "genhdr/mpversion.h"

// CIRCUITPY-CHANGE
#if CIRCUITPY_WARNINGS
#include "shared-module/warnings/__init__.h"
#endif

#if MICROPY_PY_SYS_SETTRACE
#include "py/objmodule.h"
#include "py/profile.h"
Expand Down Expand Up @@ -134,6 +139,11 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);

STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
// CIRCUITPY-CHANGE
#if CIRCUITPY_WARNINGS
warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_print_exception, MP_QSTR_sys, MP_QSTR_traceback);
#endif

#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
void *stream_obj = &mp_sys_stdout_obj;
if (n_args > 1) {
Expand Down