Merge branch 'master' into new-pixelbuf-api

crypto-aes
Roy Hooper 3 years ago
commit 09d4fe0324

@ -174,7 +174,7 @@ jobs:
run: |
sudo apt-get install -y gettext
pip install requests sh click setuptools awscli
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
wget https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
- name: Versions
run: |

@ -0,0 +1,82 @@
# Building CircuitPython
Welcome to CircuitPython!
This document is a quick-start guide only.
Detailed guides on how to build CircuitPython can be found in the Adafruit Learn system at
https://learn.adafruit.com/building-circuitpython/
## Setup
Please ensure you setup your build environment appropriately, as per the guide. You will need:
* Linux: https://learn.adafruit.com/building-circuitpython/linux
* MacOS: https://learn.adafruit.com/building-circuitpython/macos
* Windows Subsystem for Linux (WSL): https://learn.adafruit.com/building-circuitpython/windows-subsystem-for-linux
### Submodules
This project has a bunch of git submodules. You will need to update them regularly.
git submodule sync
git submodule update --init
### mpy-cross
As part of the build process, mpy-cross is needed to compile .py files into .mpy files.
To compile (or recompile) mpy-cross:
make -C mpy-cross
# Building
There a number of ports of CircuitPython! To build for your board, change to the appropriate ports directory and build.
Examples:
cd ports/atmel-samd
make BOARD=circuitplayground_express
cd ports/nrf
make BOARD=circuitplayground_bluefruit
If you aren't sure what boards exist, have a peek in the boards subdirectory of your port.
If you have a fast computer with many cores, consider adding `-j` to your build flags, such as `-j17` on
a 6-core 12-thread machine.
# Testing
If you are working on changes to the core language, you might find it useful to run the test suite.
The test suite in the top level `tests` directory. It needs the unix port to run.
cd ports/unix
make axtls
make micropython
Then you can run the test suite:
cd ../../tests
./run-tests
A successful run will say something like
676 tests performed (19129 individual testcases)
676 tests passed
30 tests skipped: buffered_writer builtin_help builtin_range_binop class_delattr_setattr cmd_parsetree extra_coverage framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass mpy_invalid namedtuple_asdict non_compliant resource_stream schedule sys_getsizeof urandom_extra ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_userfs
# Debugging
The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and an appropriate GDB.
Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb
If using JLink, you'll need both the `JLinkGDBServer` and `arm-none-eabi-gdb` running.
Example:
JLinkGDBServer -if SWD -device ATSAMD51J19
arm-none-eabi-gdb build-metro_m4_express/firmware.elf -iex "target extended-remote :2331"
If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register
debugging with https://github.com/bnahill/PyCortexMDebug

@ -43,6 +43,7 @@ Full Table of Contents
../README
../CONTRIBUTING
../BUILDING
../CODE_OF_CONDUCT
../license.rst

@ -1 +1 @@
Subproject commit 52d87bd7e571af66ecb57ee32b5af92531134150
Subproject commit 2000ae3a7c5d60b850c9546a16425aee279e2a36

@ -1 +1 @@
Subproject commit d87ea261c40ecbc6d893d72d337beefbea1cf932
Subproject commit 82ba9e40dfff41fdc0541636afde4936c930d86c

@ -1 +1 @@
Subproject commit a6100fb5d867c7f4980f071119bfa7e0a76e1d47
Subproject commit 5534662902a223ac8562e6f999d6359e4c17dab1

@ -1 +1 @@
Subproject commit 89faee0eb08a6855e14f117c514fecf2dd90769d
Subproject commit a23b80569f23ef109667dd8c595d319e8a30d620

@ -1 +1 @@
Subproject commit ddc74844983b35b027bd45091c7b8bb3c8d7a2d1
Subproject commit f69fc9b47fa25ba1414eb3d5c82f05013280c0d2

@ -1 +1 @@
Subproject commit b94f06d85c2678d608d904c23e9c0c4172c76b15
Subproject commit ff99d55115f81899902c2c4a84fdfbea9ae83823

@ -1 +1 @@
Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c
Subproject commit dd0fe8530a2dcc64ac95bb3e116af2158dcd7cd2

@ -1 +1 @@
Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5
Subproject commit c3c664bf4db6a36d11808dfcbb5dbf7cff1715b8

@ -1 +1 @@
Subproject commit e413c9efa303d70de019a91aa415384fe80ca78f
Subproject commit 7a05b177a43b368fea1d60ca344fe4ae9902a432

@ -13,9 +13,10 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C"
# Turn off features and optimizations for Crickit build to make room for additional frozen libs.
LONGINT_IMPL = NONE
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_PIXELBUF = 0
SUPEROPT_GC = 0
CFLAGS_INLINE_LIMIT = 55

@ -43,3 +43,5 @@
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
#define MICROPY_PY_URE 0

@ -138,6 +138,7 @@ SRC_NRFX = $(addprefix nrfx/,\
drivers/src/nrfx_uarte.c \
drivers/src/nrfx_gpiote.c \
drivers/src/nrfx_rtc.c \
drivers/src/nrfx_nvmc.c \
)
ifdef EXTERNAL_FLASH_DEVICES
@ -167,7 +168,6 @@ SRC_C += \
lib/utils/pyexec.c \
lib/utils/stdout_helpers.c \
lib/utils/sys_stdio_mphal.c \
nrfx/hal/nrf_nvmc.c \
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
peripherals/nrf/cache.c \
peripherals/nrf/clocks.c \

@ -36,12 +36,12 @@
void analogin_init(void) {
// Calibrate the ADC once, on startup.
nrf_saadc_enable();
nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE);
nrf_saadc_task_trigger(NRF_SAADC_TASK_CALIBRATEOFFSET);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_CALIBRATEDONE) == 0) { }
nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE);
nrf_saadc_disable();
nrf_saadc_enable(NRF_SAADC);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE) == 0) { }
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
nrf_saadc_disable(NRF_SAADC);
}
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) {
@ -81,34 +81,33 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
.reference = NRF_SAADC_REFERENCE_VDD4,
.acq_time = NRF_SAADC_ACQTIME_3US,
.mode = NRF_SAADC_MODE_SINGLE_ENDED,
.burst = NRF_SAADC_BURST_DISABLED,
.pin_p = self->pin->adc_channel,
.pin_n = self->pin->adc_channel,
.burst = NRF_SAADC_BURST_DISABLED
};
nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_14BIT);
nrf_saadc_oversample_set(NRF_SAADC_OVERSAMPLE_DISABLED);
nrf_saadc_enable();
nrf_saadc_resolution_set(NRF_SAADC, NRF_SAADC_RESOLUTION_14BIT);
nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED);
nrf_saadc_enable(NRF_SAADC);
for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; i++)
nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
for (uint32_t i = 0; i < SAADC_CH_NUM; i++)
nrf_saadc_channel_input_set(NRF_SAADC, i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
nrf_saadc_channel_init(CHANNEL_NO, &config);
nrf_saadc_buffer_init(&value, 1);
nrf_saadc_channel_init(NRF_SAADC, CHANNEL_NO, &config);
nrf_saadc_channel_input_set(NRF_SAADC, CHANNEL_NO, self->pin->adc_channel, self->pin->adc_channel);
nrf_saadc_buffer_init(NRF_SAADC, &value, 1);
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED) == 0);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_END) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END) == 0);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED) == 0);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
nrf_saadc_disable();
nrf_saadc_disable(NRF_SAADC);
if (value < 0)
value = 0;

@ -225,10 +225,6 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self,
self->loop = loop;
uint32_t sample_rate = audiosample_sample_rate(sample);
uint32_t max_sample_rate = 62500;
if (sample_rate > max_sample_rate) {
mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate);
}
self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8;
uint32_t max_buffer_length;

@ -133,9 +133,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *
mp_raise_RuntimeError(translate("SDA or SCL needs a pull up"));
}
nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG;
config.scl = scl->number;
config.sda = sda->number;
nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(scl->number, sda->number);
// change freq. only if it's less than the default 400K
if (frequency < 100000) {
config.frequency = NRF_TWIM_FREQ_100K;
@ -248,8 +247,10 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const u
// break into MAX_XFER_LEN transaction
while ( len ) {
const size_t xact_len = MIN(len, I2C_MAX_XFER_LEN);
nrfx_twim_xfer_desc_t xfer_desc = NRFX_TWIM_XFER_DESC_TX(addr, (uint8_t*) data, xact_len);
uint32_t const flags = (stopBit ? 0 : NRFX_TWIM_FLAG_TX_NO_STOP);
if ( NRFX_SUCCESS != (err = nrfx_twim_tx(&self->twim_peripheral->twim, addr, data, xact_len, !stopBit)) ) {
if ( NRFX_SUCCESS != (err = nrfx_twim_xfer(&self->twim_peripheral->twim, &xfer_desc, flags)) ) {
break;
}
@ -274,8 +275,9 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t
// break into MAX_XFER_LEN transaction
while ( len ) {
const size_t xact_len = MIN(len, I2C_MAX_XFER_LEN);
nrfx_twim_xfer_desc_t xfer_desc = NRFX_TWIM_XFER_DESC_RX(addr, data, xact_len);
if ( NRFX_SUCCESS != (err = nrfx_twim_rx(&self->twim_peripheral->twim, addr, data, xact_len)) ) {
if ( NRFX_SUCCESS != (err = nrfx_twim_xfer(&self->twim_peripheral->twim, &xfer_desc, 0)) ) {
break;
}

@ -135,7 +135,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
mp_raise_ValueError(translate("All SPI peripherals are in use"));
}
nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG;
nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG(NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED,
NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED);
config.frequency = NRF_SPIM_FREQ_8M;
config.sck_pin = clock->number;

@ -163,10 +163,12 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self,
.pselcts = NRF_UARTE_PSEL_DISCONNECTED,
.pselrts = NRF_UARTE_PSEL_DISCONNECTED,
.p_context = self,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED,
.baudrate = get_nrf_baud(baudrate),
.interrupt_priority = 7
.interrupt_priority = 7,
.hal_cfg = {
.hwfc = NRF_UARTE_HWFC_DISABLED,
.parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED
}
};
nrfx_uarte_uninit(self->uarte);

@ -75,35 +75,34 @@ float common_hal_mcu_processor_get_voltage(void) {
.reference = NRF_SAADC_REFERENCE_INTERNAL,
.acq_time = NRF_SAADC_ACQTIME_10US,
.mode = NRF_SAADC_MODE_SINGLE_ENDED,
.burst = NRF_SAADC_BURST_DISABLED,
.pin_p = NRF_SAADC_INPUT_VDD,
.pin_n = NRF_SAADC_INPUT_VDD,
.burst = NRF_SAADC_BURST_DISABLED
};
nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_14BIT);
nrf_saadc_oversample_set(NRF_SAADC_OVERSAMPLE_DISABLED);
nrf_saadc_enable();
nrf_saadc_resolution_set(NRF_SAADC, NRF_SAADC_RESOLUTION_14BIT);
nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED);
nrf_saadc_enable(NRF_SAADC);
for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; i++) {
nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
for (uint32_t i = 0; i < SAADC_CH_NUM; i++) {
nrf_saadc_channel_input_set(NRF_SAADC, i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
}
nrf_saadc_channel_init(0, &config);
nrf_saadc_buffer_init(&value, 1);
nrf_saadc_channel_init(NRF_SAADC, 0, &config);
nrf_saadc_channel_input_set(NRF_SAADC, 0, NRF_SAADC_INPUT_VDD, NRF_SAADC_INPUT_VDD);
nrf_saadc_buffer_init(NRF_SAADC, &value, 1);
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0) { }
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED) == 0) { }
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_END) == 0) { }
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END) == 0) { }
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0) { }
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED) == 0) { }
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
nrf_saadc_disable();
nrf_saadc_disable(NRF_SAADC);
if (value < 0) {
value = 0;

@ -70,17 +70,17 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) {
return NRF_SUCCESS == sd_rand_application_vector_get(buffer, length);
#endif
nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
nrf_rng_task_trigger(NRF_RNG_TASK_START);
nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY);
nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_START);
for (uint32_t i = 0; i < length; i++) {
while (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) == 0);
nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
while (nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY) == 0);
nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY);
buffer[i] = nrf_rng_random_value_get();
buffer[i] = nrf_rng_random_value_get(NRF_RNG);
}
nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_STOP);
return true;
}

@ -112,7 +112,7 @@ void pulsein_reset(void) {
if ( nrfx_gpiote_is_init() ) {
nrfx_gpiote_uninit();
}
nrfx_gpiote_init();
nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY);
memset(_objs, 0, sizeof(_objs));
}

@ -59,8 +59,8 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) {
}
void rtc_init(void) {
if (!nrf_clock_lf_is_running()) {
nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);
if (!nrf_clock_lf_is_running(NRF_CLOCK)) {
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART);
}
nrfx_rtc_counter_clear(&rtc_instance);
nrfx_rtc_init(&rtc_instance, &rtc_config, rtc_handler);

@ -1 +1 @@
Subproject commit 3d268263be2390ab760f75a3da72689ef13031a4
Subproject commit 3f55e49eb11e6db0da1da09e189bb094222702c9

@ -3,7 +3,7 @@
// Power
#define NRFX_POWER_ENABLED 1
#define NRFX_POWER_CONFIG_IRQ_PRIORITY 7
#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7
// NOTE: THIS WORKAROUND CAUSES BLE CODE TO CRASH.
// It doesn't work with the SoftDevice.
@ -116,4 +116,7 @@
#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 7
// NVM controller
#define NRFX_NVMC_ENABLED 1
#endif // NRFX_CONFIG_H__

@ -25,7 +25,7 @@
*/
#include "nrfx.h"
#include "nrf_nvmc.h"
#include "nrfx_nvmc.h"
void nrf_peripherals_power_init(void) {
// Set GPIO reference voltage to 3.3V if it isn't already. REGOUT0 will get reset to 0xfffffff
@ -33,7 +33,7 @@ void nrf_peripherals_power_init(void) {
// This matters only when "high voltage mode" is enabled, which is true on the PCA10059,
// and might be true on other boards.
if (NRF_UICR->REGOUT0 == 0xffffffff) {
nrf_nvmc_write_word((uint32_t) &NRF_UICR->REGOUT0, UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos);
nrfx_nvmc_word_write((uint32_t) &NRF_UICR->REGOUT0, UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos);
// Must reset to make enable change.
NVIC_SystemReset();
}

@ -30,7 +30,7 @@
#include <stdio.h>
#include <string.h>
#include "nrf_nvmc.h"
#include "nrfx_nvmc.h"
#define FLASH_PAGE_SIZE (4096)
@ -90,7 +90,7 @@ bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) {
}
#endif
nrf_nvmc_page_erase(page_addr);
nrf_nvmc_write_bytes(page_addr, data, FLASH_PAGE_SIZE);
nrfx_nvmc_page_erase(page_addr);
nrfx_nvmc_bytes_write(page_addr, data, FLASH_PAGE_SIZE);
return true;
}

@ -193,7 +193,9 @@ typedef long mp_off_t;
#define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD)
// Opposite setting is deliberate.
#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD)
#ifndef MICROPY_PY_URE
#define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD)
#endif
#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD)
#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD)
#define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD)

@ -394,11 +394,18 @@ STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) {
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation);
STATIC mp_obj_t displayio_display_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) {
displayio_display_obj_t *self = native_display(self_in);
common_hal_displayio_display_set_rotation(self, mp_obj_get_int(value));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_rotation_obj, displayio_display_obj_set_rotation);
const mp_obj_property_t displayio_display_rotation_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&displayio_display_get_rotation_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&displayio_display_set_rotation_obj,
(mp_obj_t)&mp_const_none_obj},
};

@ -58,6 +58,7 @@ void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self
uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self);
void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, int rotation);
bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t* self);
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness);

@ -33,11 +33,11 @@
#include "shared-bindings/random/__init__.h"
#include "supervisor/shared/translate.h"
//| :mod:`random` --- psuedo-random numbers and choices
//| :mod:`random` --- pseudo-random numbers and choices
//| ========================================================
//|
//| .. module:: random
//| :synopsis: psuedo-random numbers and choices
//| :synopsis: pseudo-random numbers and choices
//| :platform: SAMD21, ESP8266
//|
//| The `random` module is a strict subset of the CPython `cpython:random`

@ -308,10 +308,27 @@ STATIC void _refresh_display(displayio_display_obj_t* self) {
displayio_display_core_finish_refresh(&self->core);
}
void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, int rotation){
bool transposed = (self->core.rotation == 90 || self->core.rotation == 270);
bool will_transposed = (rotation == 90 || rotation == 270);
if(transposed != will_transposed) {
int tmp = self->core.width;
self->core.width = self->core.height;
self->core.height = tmp;
}
displayio_display_core_set_rotation(&self->core, rotation);
supervisor_stop_terminal();
supervisor_start_terminal(self->core.width, self->core.height);
if (self->core.current_group != NULL) {
displayio_group_update_transform(self->core.current_group, &self->core.transform);
}
}
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self){
return self->core.rotation;
}
bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) {
if (!self->auto_refresh && !self->first_manual_refresh) {
uint64_t current_time = supervisor_ticks_ms64();

@ -86,6 +86,15 @@ void displayio_display_core_construct(displayio_display_core_t* self,
self->height = height;
self->ram_width = ram_width;
self->ram_height = ram_height;
displayio_display_core_set_rotation(self, rotation);
}
void displayio_display_core_set_rotation( displayio_display_core_t* self,
int rotation) {
int height = self->height;
int width = self->width;
rotation = rotation % 360;
self->rotation = rotation;
self->transform.x = 0;

@ -68,6 +68,8 @@ uint16_t displayio_display_core_get_height(displayio_display_core_t* self);
void displayio_display_core_set_dither(displayio_display_core_t* self, bool dither);
bool displayio_display_core_get_dither(displayio_display_core_t* self);
void displayio_display_core_set_rotation(displayio_display_core_t* self, int rotation);
bool displayio_display_core_bus_free(displayio_display_core_t *self);
bool displayio_display_core_begin_transaction(displayio_display_core_t* self);
void displayio_display_core_end_transaction(displayio_display_core_t* self);

@ -81,6 +81,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
grid->pixel_width = width_in_tiles * grid->tile_width;
grid->pixel_height = height_in_tiles * grid->tile_height;
grid->tiles = tiles;
grid->full_change = true;
common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font);
}

@ -87,10 +87,12 @@ void usb_background(void) {
// Invoked when device is mounted
void tud_mount_cb(void) {
usb_msc_mount();
}
// Invoked when device is unmounted
void tud_umount_cb(void) {
usb_msc_umount();
}
// Invoked when usb bus is suspended

@ -41,6 +41,18 @@
static bool ejected[1];
void usb_msc_mount(void) {
// Reset the ejection tracking every time we're plugged into USB. This allows for us to battery
// power the device, eject, unplug and plug it back in to get the drive.
for (uint8_t i = 0; i < sizeof(ejected); i++) {
ejected[i] = false;
}
}
void usb_msc_umount(void) {
}
// The root FS is always at the end of the list.
static fs_user_mount_t* get_vfs(int lun) {
// TODO(tannewt): Return the mount which matches the lun where 0 is the end
@ -198,19 +210,34 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) {
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) {
if (lun > 1) {
return false;
}
fs_user_mount_t* current_mount = get_vfs(lun);
if (current_mount == NULL) {
return false;
}
if (load_eject) {
if (lun > 1) {
return false;
} else {
fs_user_mount_t* current_mount = get_vfs(lun);
if (current_mount == NULL) {
return false;
}
if (!start) {
// Eject but first flush.
if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
return false;
} else {
ejected[lun] = true;
}
} else {
// We can only load if it hasn't been ejected.
return !ejected[lun];
}
} else {
if (!start) {
// Stop the unit but don't eject.
if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
return false;
}
} else {
// Start the unit, but only if not ejected.
return !ejected[lun];
}
}

@ -41,4 +41,8 @@ void init_usb_hardware(void);
bool usb_enabled(void);
void usb_init(void);
// Propagate plug/unplug events to the MSC logic.
void usb_msc_mount(void);
void usb_msc_umount(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_USB_H

@ -48,18 +48,19 @@ for c in sample_characters:
all_characters += c
if args.extra_characters:
all_characters.extend(args.extra_characters)
all_characters = "".join(sorted(set(all_characters)))
filtered_characters = all_characters
# Try to pre-load all of the glyphs. Misses will still be slow later.
f.load_glyphs(set(all_characters))
f.load_glyphs(set(ord(c) for c in all_characters))
# Get each glyph.
for c in all_characters:
g = f.get_glyph(ord(c))
if not g:
for c in set(all_characters):
if ord(c) not in f._glyphs:
print("Font missing character:", c, ord(c))
filtered_characters = filtered_characters.replace(c, "")
continue
g = f.get_glyph(ord(c))
if g["shift"][1] != 0:
raise RuntimeError("y shift")

Loading…
Cancel
Save