Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6c872ef6be | ||
|
dc6ede0453 | ||
|
ba028ae623 | ||
|
89d6f91ccc | ||
|
6e95c90401 | ||
|
44ea91d957 | ||
|
3814e97010 | ||
|
ffc66e9892 | ||
|
0698219458 | ||
|
74a6edff4d | ||
|
4dd9e0da2c | ||
|
1062e193e4 | ||
|
7f4ff9b3cc | ||
|
cfcbb3623f | ||
|
f10be55592 | ||
|
5f326ac5a3 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -32,3 +32,9 @@
|
||||
[submodule "tools/python-semver"]
|
||||
path = tools/python-semver
|
||||
url = https://github.com/k-bx/python-semver.git
|
||||
[submodule "frozen/Adafruit_CircuitPython_CircuitPlayground"]
|
||||
path = frozen/Adafruit_CircuitPython_CircuitPlayground
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground.git
|
||||
[submodule "frozen/Adafruit_CircuitPython_HID"]
|
||||
path = frozen/Adafruit_CircuitPython_HID
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_HID.git
|
||||
|
@ -48,7 +48,7 @@
|
||||
#define TC_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \defgroup asfdoc_sam0_tc_group SAM Timer/Counter (TC) Driver
|
||||
* \defgroup asfdoc_sam0_tc_group SAM Timer/Counter (TC) Driver
|
||||
*
|
||||
* This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration
|
||||
* and management of the timer modules within the device, for waveform
|
||||
@ -1146,12 +1146,14 @@ static inline void tc_enable_events(
|
||||
/* Sanity check arguments */
|
||||
Assert(module_inst);
|
||||
Assert(module_inst->hw);
|
||||
Assert(events);
|
||||
Assert(events);
|
||||
|
||||
Tc *const tc_module = module_inst->hw;
|
||||
|
||||
uint32_t event_mask = 0;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
if (events->invert_event_input == true) {
|
||||
event_mask |= TC_EVCTRL_TCINV;
|
||||
}
|
||||
@ -1171,6 +1173,7 @@ static inline void tc_enable_events(
|
||||
}
|
||||
|
||||
tc_module->COUNT8.EVCTRL.reg |= event_mask | events->event_action;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,8 @@ CHIP_VARIANT = SAMD21G18A
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
|
||||
|
@ -27,8 +27,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "main.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/storage/__init__.h"
|
||||
|
||||
extern volatile bool mp_msc_enabled;
|
||||
@ -44,3 +46,9 @@ void common_hal_storage_remount(const char* mount_path, bool readonly) {
|
||||
|
||||
flash_set_usb_writeable(readonly);
|
||||
}
|
||||
|
||||
void common_hal_storage_erase_filesystem(void) {
|
||||
init_flash_fs(false, true); // Force a re-format.
|
||||
common_hal_mcu_reset();
|
||||
// We won't actually get here, since we're resetting.
|
||||
}
|
||||
|
@ -66,6 +66,7 @@
|
||||
|
||||
#include "autoreload.h"
|
||||
#include "flash_api.h"
|
||||
#include "main.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "rgb_led_status.h"
|
||||
#include "shared_dma.h"
|
||||
@ -110,7 +111,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
|
||||
// we don't make this function static because it needs a lot of stack and we
|
||||
// want it to be executed without using stack within main() function
|
||||
void init_flash_fs(bool create_allowed) {
|
||||
void init_flash_fs(bool create_allowed, bool force_create) {
|
||||
// init the vfs object
|
||||
fs_user_mount_t *vfs_fat = &fs_user_mount_flash;
|
||||
vfs_fat->flags = 0;
|
||||
@ -119,8 +120,8 @@ void init_flash_fs(bool create_allowed) {
|
||||
// try to mount the flash
|
||||
FRESULT res = f_mount(&vfs_fat->fatfs);
|
||||
|
||||
if (res == FR_NO_FILESYSTEM && create_allowed) {
|
||||
// no filesystem so create a fresh one
|
||||
if ((res == FR_NO_FILESYSTEM && create_allowed) || force_create) {
|
||||
// No filesystem so create a fresh one, or reformat has been requested.
|
||||
|
||||
// Wait two seconds before creating. Jittery power might
|
||||
// fail before we're ready. This can happen if someone
|
||||
@ -129,10 +130,10 @@ void init_flash_fs(bool create_allowed) {
|
||||
|
||||
// Then try one more time to mount the flash in case it was late coming up.
|
||||
res = f_mount(&vfs_fat->fatfs);
|
||||
if (res == FR_NO_FILESYSTEM) {
|
||||
if (res == FR_NO_FILESYSTEM || force_create) {
|
||||
uint8_t working_buf[_MAX_SS];
|
||||
res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
|
||||
// Flush the new file system to make sure its repaired immediately.
|
||||
// Flush the new file system to make sure it's repaired immediately.
|
||||
flash_flush();
|
||||
if (res != FR_OK) {
|
||||
return;
|
||||
@ -528,6 +529,14 @@ void load_serial_number(void) {
|
||||
extern uint32_t _ezero;
|
||||
|
||||
safe_mode_t samd21_init(void) {
|
||||
|
||||
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
|
||||
// which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
|
||||
// Disable while changing level.
|
||||
SYSCTRL->BOD33.bit.ENABLE = 0;
|
||||
SYSCTRL->BOD33.bit.LEVEL = 39; // 2.77V with hysteresis off. Table 37.20 in datasheet.
|
||||
SYSCTRL->BOD33.bit.ENABLE = 1;
|
||||
|
||||
#ifdef ENABLE_MICRO_TRACE_BUFFER
|
||||
REG_MTB_POSITION = ((uint32_t) (mtb - REG_MTB_BASE)) & 0xFFFFFFF8;
|
||||
REG_MTB_FLOW = (((uint32_t) mtb - REG_MTB_BASE) + TRACE_BUFFER_SIZE_BYTES) & 0xFFFFFFF8;
|
||||
@ -683,9 +692,9 @@ int main(void) {
|
||||
// Create a new filesystem only if we're not in a safe mode.
|
||||
// A power brownout here could make it appear as if there's
|
||||
// no SPI flash filesystem, and we might erase the existing one.
|
||||
init_flash_fs(safe_mode == NO_SAFE_MODE);
|
||||
init_flash_fs(safe_mode == NO_SAFE_MODE, false);
|
||||
|
||||
// Reset everything and prep MicroPython to run boot.py.
|
||||
// Reset everything and prep to run boot.py.
|
||||
reset_samd21();
|
||||
reset_board();
|
||||
reset_mp();
|
||||
@ -694,37 +703,86 @@ int main(void) {
|
||||
autoreload_enable();
|
||||
|
||||
// By default our internal flash is readonly to local python code and
|
||||
// writeable over USB. Set it here so that boot.py can change it.
|
||||
// writable over USB.
|
||||
flash_set_usb_writeable(true);
|
||||
|
||||
// If not in safe mode, run boot before initing USB and capture output in a
|
||||
// file.
|
||||
if (safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL) {
|
||||
new_status_color(BOOT_RUNNING);
|
||||
|
||||
// Run the first of these files found at boot time (if any).
|
||||
static char const* BOOT_PY_FILENAMES[] = {
|
||||
"settings.txt",
|
||||
"settings.py",
|
||||
"boot.py",
|
||||
"boot.txt",
|
||||
};
|
||||
|
||||
// Check for existance of any of the BOOT_PY_FILENAMES.
|
||||
char const* boot_py_to_use = NULL;
|
||||
for (size_t i = 0; i < MP_ARRAY_SIZE(BOOT_PY_FILENAMES); i++) {
|
||||
if (mp_import_stat(BOOT_PY_FILENAMES[i]) == MP_IMPORT_STAT_FILE) {
|
||||
boot_py_to_use = BOOT_PY_FILENAMES[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
|
||||
// Since USB isn't up yet we can cheat and let ourselves write the boot
|
||||
// output file.
|
||||
flash_set_usb_writeable(false);
|
||||
FIL file_pointer;
|
||||
boot_output_file = &file_pointer;
|
||||
f_open(&((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs,
|
||||
boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS);
|
||||
flash_set_usb_writeable(true);
|
||||
// Write version info to boot_out.txt.
|
||||
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
|
||||
mp_hal_stdout_tx_str("\r\n");
|
||||
|
||||
// Get the base filesystem.
|
||||
FATFS *fs = &((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs;
|
||||
|
||||
char file_contents[512];
|
||||
UINT chars_read = 0;
|
||||
bool skip_boot_output = false;
|
||||
|
||||
// If there's no boot.py file that might write some changing output,
|
||||
// read the existing copy of CIRCUITPY_BOOT_OUTPUT_FILE and see if its contents
|
||||
// match the version info we would print anyway. If so, skip writing CIRCUITPY_BOOT_OUTPUT_FILE.
|
||||
// This saves wear and tear on the flash and also prevents filesystem damage if power is lost
|
||||
// during the write, which may happen due to bobbling the power connector or weak power.
|
||||
|
||||
if (!boot_py_to_use && f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) {
|
||||
f_read(boot_output_file, file_contents, 512, &chars_read);
|
||||
f_close(boot_output_file);
|
||||
skip_boot_output =
|
||||
// + 2 accounts for \r\n.
|
||||
chars_read == strlen(MICROPY_FULL_VERSION_INFO) + 2 &&
|
||||
strncmp(file_contents, MICROPY_FULL_VERSION_INFO, strlen(MICROPY_FULL_VERSION_INFO)) == 0;
|
||||
}
|
||||
|
||||
if (!skip_boot_output) {
|
||||
// Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write,
|
||||
// in case power is momentary or will fail shortly due to, say a low, battery.
|
||||
mp_hal_delay_ms(1500);
|
||||
|
||||
// USB isn't up, so we can write the file.
|
||||
flash_set_usb_writeable(false);
|
||||
f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS);
|
||||
|
||||
// Switch the filesystem back to non-writable by Python now instead of later,
|
||||
// since boot.py might change it back to writable.
|
||||
flash_set_usb_writeable(true);
|
||||
|
||||
// Write version info to boot_out.txt.
|
||||
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
|
||||
mp_hal_stdout_tx_str("\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO(tannewt): Re-add support for flashing boot error output.
|
||||
bool found_boot = maybe_run("settings.txt", NULL) ||
|
||||
maybe_run("settings.py", NULL) ||
|
||||
maybe_run("boot.py", NULL) ||
|
||||
maybe_run("boot.txt", NULL);
|
||||
(void) found_boot;
|
||||
if (boot_py_to_use) {
|
||||
maybe_run(boot_py_to_use, NULL);
|
||||
}
|
||||
|
||||
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
|
||||
f_close(boot_output_file);
|
||||
flash_flush();
|
||||
if (!skip_boot_output) {
|
||||
f_close(boot_output_file);
|
||||
flash_flush();
|
||||
}
|
||||
boot_output_file = NULL;
|
||||
#endif
|
||||
|
||||
|
30
atmel-samd/main.h
Normal file
30
atmel-samd/main.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Functions defined in main.c that are useful elsewhere.
|
||||
// Eventually they should be factored out.
|
||||
|
||||
void init_flash_fs(bool create_allowed, bool force_create);
|
3
conf.py
3
conf.py
@ -336,3 +336,6 @@ texinfo_documents = [
|
||||
intersphinx_mapping = {"cpython": ('https://docs.python.org/3/', None),
|
||||
"bus_device": ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),
|
||||
"register": ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None)}
|
||||
def setup(app):
|
||||
app.add_stylesheet("customstyle.css")
|
||||
|
||||
|
13
docs/static/customstyle.css
vendored
13
docs/static/customstyle.css
vendored
@ -10,6 +10,19 @@
|
||||
}
|
||||
|
||||
|
||||
/* custom CSS to sticky the ' viewing outdated version'
|
||||
warning
|
||||
*/
|
||||
.document > .admonition {
|
||||
position: sticky;
|
||||
top: 0px;
|
||||
background-color: salmon;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-x: unset!important;
|
||||
}
|
||||
|
||||
/* override table width restrictions */
|
||||
@media screen and (min-width: 767px) {
|
||||
|
@ -32,3 +32,7 @@
|
||||
void common_hal_storage_remount(const char* mount_path, bool readonly) {
|
||||
mp_raise_NotImplementedError("");
|
||||
}
|
||||
|
||||
void common_hal_storage_erase_filesystem() {
|
||||
mp_raise_NotImplementedError("Use esptool to erase flash and re-upload Python instead");
|
||||
}
|
||||
|
@ -73,6 +73,17 @@ SECTIONS
|
||||
_irom0_text_start = ABSOLUTE(.);
|
||||
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
||||
|
||||
/* Vendor SDK in v2.1.0-7-gb8fd588 started to build these with
|
||||
-ffunction-sections -fdata-sections, and require routing to
|
||||
irom via linker:
|
||||
https://github.com/espressif/ESP8266_NONOS_SDK/commit/b8fd588a33f0319dc135523b51655e97b483b205
|
||||
*/
|
||||
|
||||
*libcrypto.a:(.literal.* .text.*)
|
||||
*libnet80211.a:(.literal.* .text.*)
|
||||
*libwpa.a:(.literal.* .text.*)
|
||||
*libwpa2.a:(.literal.* .text.*)
|
||||
|
||||
/* we put some specific text in this section */
|
||||
|
||||
*common-hal/*.o*(.literal* .text*)
|
||||
|
@ -6,14 +6,12 @@
|
||||
// see http://esp8266-re.foogod.com/wiki/Random_Number_Generator
|
||||
#define WDEV_HWRNG ((volatile uint32_t*)0x3ff20e44)
|
||||
|
||||
void ets_delay_us();
|
||||
void ets_intr_lock(void);
|
||||
void ets_intr_unlock(void);
|
||||
void ets_isr_mask(uint32_t mask);
|
||||
void ets_isr_unmask(uint32_t mask);
|
||||
void ets_isr_attach(int irq_no, void (*handler)(void *), void *arg);
|
||||
void ets_install_putc1();
|
||||
void uart_div_modify();
|
||||
void ets_set_idle_cb(void (*handler)(void *), void *arg);
|
||||
|
||||
void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_milli_timer);
|
||||
@ -32,12 +30,6 @@ void MD5Init(MD5_CTX *context);
|
||||
void MD5Update(MD5_CTX *context, const void *data, unsigned int len);
|
||||
void MD5Final(unsigned char digest[16], MD5_CTX *context);
|
||||
|
||||
// These prototypes are for recent SDKs with "malloc tracking"
|
||||
void *pvPortMalloc(unsigned sz, const char *fname, int line);
|
||||
void *pvPortZalloc(unsigned sz, const char *fname, int line);
|
||||
void *pvPortRealloc(void *p, unsigned sz, const char *fname, int line);
|
||||
void vPortFree(void *p, const char *fname, int line);
|
||||
|
||||
uint32_t SPIRead(uint32_t offset, void *buf, uint32_t len);
|
||||
uint32_t SPIWrite(uint32_t offset, const void *buf, uint32_t len);
|
||||
uint32_t SPIEraseSector(int sector);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9a49ca04e3754be246524e57f8c1810c76be5948
|
||||
Subproject commit de2d0d33cace54532467e411128521dfc8d253c3
|
1
frozen/Adafruit_CircuitPython_CircuitPlayground
Submodule
1
frozen/Adafruit_CircuitPython_CircuitPlayground
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a669915237545638c64f89400f368a91c408cd5d
|
1
frozen/Adafruit_CircuitPython_HID
Submodule
1
frozen/Adafruit_CircuitPython_HID
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 90e4ca931a991718985e655bdcd527c1b0543f55
|
@ -1 +1 @@
|
||||
Subproject commit 74afff3ff912c9711d207671b8b9068358eaa0d2
|
||||
Subproject commit d5491cded0d12716ceb1111ca4c4431111a22df6
|
@ -1 +1 @@
|
||||
Subproject commit 8e1e5bbb86e03d539103c6d73ccac0cb27711b77
|
||||
Subproject commit e9f50cb6678a1684591ee021b95a3c4b51786fee
|
@ -1 +1 @@
|
||||
Subproject commit 6c281ed26a2b38060e6a8c37c16f3bf6345cec2d
|
||||
Subproject commit 00f4ebca6c740b76c1c464f83d514ac20b0600e1
|
@ -71,10 +71,10 @@
|
||||
//| This function is intended for internal use in the ``stage`` library
|
||||
//| and all the necessary checks are performed there.
|
||||
STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
|
||||
uint8_t x0 = mp_obj_get_int(args[0]);
|
||||
uint8_t y0 = mp_obj_get_int(args[1]);
|
||||
uint8_t x1 = mp_obj_get_int(args[2]);
|
||||
uint8_t y1 = mp_obj_get_int(args[3]);
|
||||
uint16_t x0 = mp_obj_get_int(args[0]);
|
||||
uint16_t y0 = mp_obj_get_int(args[1]);
|
||||
uint16_t x1 = mp_obj_get_int(args[2]);
|
||||
uint16_t y1 = mp_obj_get_int(args[3]);
|
||||
|
||||
size_t layers_size = 0;
|
||||
mp_obj_t *layers;
|
||||
|
@ -115,12 +115,32 @@ mp_obj_t storage_remount(mp_obj_t mount_path, mp_obj_t readonly) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(storage_remount_obj, storage_remount);
|
||||
|
||||
//| .. function:: erase_filesystem()
|
||||
//|
|
||||
//| Erase and re-create the ``CIRCUITPY`` filesystem. Then call
|
||||
//| `microcontroller.reset()` to restart CircuitPython and have the
|
||||
//| host computer remount CIRCUITPY.
|
||||
//|
|
||||
//| This function can be called from the REPL when ``CIRCUITPY``
|
||||
//| has become corrupted.
|
||||
//|
|
||||
//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and
|
||||
//| CircuitPython will restart.
|
||||
|
||||
mp_obj_t storage_erase_filesystem(void) {
|
||||
common_hal_storage_erase_filesystem();
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(storage_erase_filesystem_obj, storage_erase_filesystem);
|
||||
|
||||
|
||||
STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) },
|
||||
|
||||
//| .. class:: VfsFat(block_device)
|
||||
//|
|
||||
|
@ -34,5 +34,6 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly)
|
||||
void common_hal_storage_umount_path(const char* path);
|
||||
void common_hal_storage_umount_object(mp_obj_t vfs_obj);
|
||||
void common_hal_storage_remount(const char* path, bool readonly);
|
||||
void common_hal_storage_erase_filesystem(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
// Get the color of the pixel on the layer.
|
||||
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y) {
|
||||
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
|
||||
|
||||
// Shift by the layer's position offset.
|
||||
x -= layer->x;
|
||||
|
@ -43,6 +43,6 @@ typedef struct {
|
||||
uint8_t rotation;
|
||||
} layer_obj_t;
|
||||
|
||||
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y);
|
||||
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
// Get the color of the pixel on the text.
|
||||
uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y) {
|
||||
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
|
||||
|
||||
// Shift by the text's position offset.
|
||||
x -= text->x;
|
||||
|
@ -41,6 +41,6 @@ typedef struct {
|
||||
uint8_t width, height;
|
||||
} text_obj_t;
|
||||
|
||||
uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y);
|
||||
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT
|
||||
|
@ -31,17 +31,14 @@
|
||||
#include "shared-bindings/_stage/Text.h"
|
||||
|
||||
|
||||
bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
|
||||
bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||
mp_obj_t *layers, size_t layers_size,
|
||||
uint16_t *buffer, size_t buffer_size,
|
||||
busio_spi_obj_t *spi) {
|
||||
|
||||
// TODO(deshipu): Do a collision check of each layer with the
|
||||
// rectangle, and only process the layers that overlap with it.
|
||||
|
||||
size_t index = 0;
|
||||
for (uint8_t y = y0; y < y1; ++y) {
|
||||
for (uint8_t x = x0; x < x1; ++x) {
|
||||
for (uint16_t y = y0; y < y1; ++y) {
|
||||
for (uint16_t x = x0; x < x1; ++x) {
|
||||
for (size_t layer = 0; layer < layers_size; ++layer) {
|
||||
uint16_t c = TRANSPARENT;
|
||||
layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]);
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#define TRANSPARENT (0x1ff8)
|
||||
|
||||
bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
|
||||
bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||
mp_obj_t *layers, size_t layers_size,
|
||||
uint16_t *buffer, size_t buffer_size,
|
||||
busio_spi_obj_t *spi);
|
||||
|
Loading…
Reference in New Issue
Block a user