Skip to content

4.1.x increase cpx stack update frozen #2407

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
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
2 changes: 1 addition & 1 deletion frozen/Adafruit_CircuitPython_CircuitPlayground
Submodule Adafruit_CircuitPython_CircuitPlayground updated 50 files
+1 −1 .travis.yml
+3 −46 README.rst
+29 −0 adafruit_circuitplayground/__init__.py
+152 −0 adafruit_circuitplayground/bluefruit.py
+1,005 −0 adafruit_circuitplayground/circuit_playground_base.py
+20 −640 adafruit_circuitplayground/express.py
+ docs/_static/microphone.jpg
+6 −0 docs/api.rst
+3 −1 docs/conf.py
+4 −4 docs/examples.rst
+48 −0 examples/advanced_examples/circuitplayground_acceleration_mapping_neopixels.py
+85 −0 examples/advanced_examples/circuitplayground_gravity_pulls_pixel.py
+132 −0 examples/advanced_examples/circuitplayground_tilting_arpeggios.py
+4 −2 examples/circuitplayground_acceleration.py
+8 −14 examples/circuitplayground_acceleration_neopixels.py
+3 −3 examples/circuitplayground_button_a.py
+5 −5 examples/circuitplayground_button_b.py
+10 −10 examples/circuitplayground_buttons_1_neopixel.py
+10 −10 examples/circuitplayground_buttons_neopixels.py
+14 −9 examples/circuitplayground_ir_receive.py
+16 −11 examples/circuitplayground_ir_transmit.py
+6 −6 examples/circuitplayground_light.py
+22 −16 examples/circuitplayground_light_neopixels.py
+5 −5 examples/circuitplayground_light_plotter.py
+4 −4 examples/circuitplayground_neopixel_0_1.py
+8 −12 examples/circuitplayground_pixels_simpletest.py
+2 −2 examples/circuitplayground_play_file.py
+5 −5 examples/circuitplayground_play_file_buttons.py
+3 −3 examples/circuitplayground_play_tone.py
+5 −5 examples/circuitplayground_play_tone_buttons.py
+2 −2 examples/circuitplayground_red_led.py
+3 −3 examples/circuitplayground_red_led_blinky.py
+2 −2 examples/circuitplayground_red_led_blnky_short.py
+3 −2 examples/circuitplayground_shake.py
+2 −2 examples/circuitplayground_slide_switch.py
+4 −4 examples/circuitplayground_slide_switch_red_led.py
+2 −2 examples/circuitplayground_slide_switch_red_led_short.py
+7 −7 examples/circuitplayground_sound_meter.py
+6 −6 examples/circuitplayground_tap_red_led.py
+4 −3 examples/circuitplayground_tapdetect.py
+7 −5 examples/circuitplayground_tapdetect_single_double.py
+10 −0 examples/circuitplayground_temperature.py
+21 −18 examples/circuitplayground_temperature_neopixels.py
+11 −0 examples/circuitplayground_temperature_plotter.py
+0 −10 examples/circuitplayground_temperture.py
+0 −11 examples/circuitplayground_temperture_plotter.py
+7 −6 examples/circuitplayground_tone.py
+20 −20 examples/circuitplayground_touch_pixel_fill_rainbow.py
+20 −20 examples/circuitplayground_touch_pixel_rainbow.py
+10 −9 examples/circuitplayground_touched.py
2 changes: 1 addition & 1 deletion frozen/Adafruit_CircuitPython_Crickit
2 changes: 1 addition & 1 deletion frozen/Adafruit_CircuitPython_DotStar
2 changes: 1 addition & 1 deletion frozen/Adafruit_CircuitPython_HID
2 changes: 1 addition & 1 deletion frozen/Adafruit_CircuitPython_NeoPixel
2 changes: 1 addition & 1 deletion frozen/circuitpython-stage
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
// Explanation of how a user got into safe mode.
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"

// Increase stack size slightly due to CPX library import nesting
#define CIRCUITPY_DEFAULT_STACK_SIZE (4632) // Must be divisible by 8 or will HardFault.

#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
// Explanation of how a user got into safe mode.
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"

// Increase stack size slightly due to CPX library import nesting
#define CIRCUITPY_DEFAULT_STACK_SIZE (4632) // Must be divisible by 8 or will HardFault.

#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)

Expand Down
15 changes: 14 additions & 1 deletion ports/atmel-samd/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#define CIRCUITPY_MCU_FAMILY samd21
#define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21"
#define SPI_FLASH_MAX_BAUDRATE 8000000
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
#define MICROPY_PY_FUNCTION_ATTRS (0)
Expand Down Expand Up @@ -69,6 +68,7 @@
#define MICROPY_PY_UJSON (1)
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
// MICROPY_PY_UERRNO_LIST - Use the default

#endif

// Turning off audioio, audiobusio, and touchio as necessary
Expand All @@ -78,6 +78,19 @@

#include "py/circuitpy_mpconfig.h"


#ifdef SAMD21
#ifndef CIRCUITPY_DEFAULT_STACK_SIZE
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
#endif
#endif

#ifdef SAMD51
#ifndef CIRCUITPY_DEFAULT_STACK_SIZE
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
#endif
#endif

#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT];
Expand Down
39 changes: 19 additions & 20 deletions py/makeqstrdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,10 @@ def compute_huffman_coding(translations, qstrs, compression_filename):
# go through each qstr and print it out
for _, _, qstr in qstrs.values():
all_strings.append(qstr)
all_strings_concat = "".join(all_strings).encode("utf-8")
all_strings_concat = "".join(all_strings)
counts = collections.Counter(all_strings_concat)
# add other values
for i in range(256):
if i not in counts:
counts[i] = 0
cb = huffman.codebook(counts.items())
values = bytearray()
values = []
length_count = {}
renumbered = 0
last_l = None
Expand All @@ -124,26 +120,27 @@ def compute_huffman_coding(translations, qstrs, compression_filename):
if last_l:
renumbered <<= (l - last_l)
canonical[ch] = '{0:0{width}b}'.format(renumbered, width=l)
if chr(ch) in C_ESCAPES:
s = C_ESCAPES[chr(ch)]
else:
s = chr(ch)
print("//", ch, s, counts[ch], canonical[ch], renumbered)
s = C_ESCAPES.get(ch, ch)
print("//", ord(ch), s, counts[ch], canonical[ch], renumbered)
renumbered += 1
last_l = l
lengths = bytearray()
for i in range(1, max(length_count) + 1):
print("// length count", length_count)
for i in range(1, max(length_count) + 2):
lengths.append(length_count.get(i, 0))
print("// values", values, "lengths", len(lengths), lengths)
print("// estimated total memory size", len(lengths) + 2*len(values) + sum(len(cb[u]) for u in all_strings_concat))
print("//", values, lengths)
values_type = "uint16_t" if max(ord(u) for u in values) > 255 else "uint8_t"
with open(compression_filename, "w") as f:
f.write("const uint8_t lengths[] = {{ {} }};\n".format(", ".join(map(str, lengths))))
f.write("const uint8_t values[256] = {{ {} }};\n".format(", ".join(map(str, values))))
f.write("const {} values[] = {{ {} }};\n".format(values_type, ", ".join(str(ord(u)) for u in values)))
return values, lengths

def decompress(encoding_table, length, encoded):
values, lengths = encoding_table
#print(l, encoded)
dec = bytearray(length)
dec = []
this_byte = 0
this_bit = 7
b = encoded[this_byte]
Expand Down Expand Up @@ -173,14 +170,14 @@ def decompress(encoding_table, length, encoded):
searched_length += lengths[bit_length]

v = values[searched_length + bits - max_code]
dec[i] = v
return dec
dec.append(v)
return ''.join(dec)

def compress(encoding_table, decompressed):
if not isinstance(decompressed, bytes):
if not isinstance(decompressed, str):
raise TypeError()
values, lengths = encoding_table
enc = bytearray(len(decompressed))
enc = bytearray(len(decompressed) * 3)
#print(decompressed)
#print(lengths)
current_bit = 7
Expand Down Expand Up @@ -227,6 +224,8 @@ def compress(encoding_table, decompressed):
current_bit -= 1
if current_bit != 7:
current_byte += 1
if current_byte > len(decompressed):
print("Note: compression increased length", repr(decompressed), len(decompressed), current_byte, file=sys.stderr)
return enc[:current_byte]

def qstr_escape(qst):
Expand Down Expand Up @@ -345,9 +344,9 @@ def print_qstr_data(encoding_table, qcfgs, qstrs, i18ns):
total_text_compressed_size = 0
for original, translation in i18ns:
translation_encoded = translation.encode("utf-8")
compressed = compress(encoding_table, translation_encoded)
compressed = compress(encoding_table, translation)
total_text_compressed_size += len(compressed)
decompressed = decompress(encoding_table, len(translation_encoded), compressed).decode("utf-8")
decompressed = decompress(encoding_table, len(translation_encoded), compressed)
for c in C_ESCAPES:
decompressed = decompressed.replace(c, C_ESCAPES[c])
print("TRANSLATION(\"{}\", {}, {{ {} }}) // {}".format(original, len(translation_encoded)+1, ", ".join(["0x{:02x}".format(x) for x in compressed]), decompressed))
Expand Down
31 changes: 18 additions & 13 deletions supervisor/shared/rgb_led_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ static digitalio_digitalinout_obj_t status_neopixel;

#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
uint8_t rgb_status_brightness = 255;
static uint8_t status_apa102_color[12] = {0, 0, 0, 0, 0xff, 0, 0, 0};

#define APA102_BUFFER_LENGTH 12
static uint8_t status_apa102_color[APA102_BUFFER_LENGTH] = {0, 0, 0, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0xff, 0xff};

#ifdef CIRCUITPY_BITBANG_APA102
#include "shared-bindings/bitbangio/SPI.h"
#include "shared-module/bitbangio/types.h"
Expand Down Expand Up @@ -104,10 +107,12 @@ void rgb_led_status_init() {
apa102_sck_in_use = false;
#ifdef CIRCUITPY_BITBANG_APA102
shared_module_bitbangio_spi_try_lock(&status_apa102);
shared_module_bitbangio_spi_configure(&status_apa102, 100000, 0, 1, 8);
// Use 1MHz for clock rate. Some APA102's are spec'd 800kHz-1200kHz,
// though many can run much faster. bitbang will probably run slower.
shared_module_bitbangio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
#else
common_hal_busio_spi_try_lock(&status_apa102);
common_hal_busio_spi_configure(&status_apa102, 100000, 0, 1, 8);
common_hal_busio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
#endif
#endif

Expand All @@ -120,7 +125,7 @@ void rgb_led_status_init() {
common_hal_pulseio_pwmout_never_reset(&rgb_status_r);
}
}

if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_G)) {
pwmout_result_t green_result = common_hal_pulseio_pwmout_construct(&rgb_status_g, CP_RGB_STATUS_G, 0, 50000, false);

Expand Down Expand Up @@ -186,9 +191,9 @@ void new_status_color(uint32_t rgb) {
status_apa102_color[7] = (rgb_adjusted >> 16) & 0xff;

#ifdef CIRCUITPY_BITBANG_APA102
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 8);
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
#else
common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8);
common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
#endif
#endif

Expand Down Expand Up @@ -229,20 +234,20 @@ void temp_status_color(uint32_t rgb) {
if (apa102_mosi_in_use || apa102_sck_in_use) {
return;
}
uint8_t colors[12] = {0, 0, 0, 0, 0xff, rgb_adjusted & 0xff, (rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, 0x0, 0x0, 0x0, 0x0};
uint8_t colors[APA102_BUFFER_LENGTH] = {0, 0, 0, 0, 0xff, rgb_adjusted & 0xff, (rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, 0xff, 0xff, 0xff, 0xff};
#ifdef CIRCUITPY_BITBANG_APA102
shared_module_bitbangio_spi_write(&status_apa102, colors, 12);
shared_module_bitbangio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
#else
common_hal_busio_spi_write(&status_apa102, colors, 12);
common_hal_busio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
#endif
#endif
#if defined(CP_RGB_STATUS_LED)
uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
uint8_t blue_u8 = rgb_adjusted & 0xFF;

uint16_t temp_status_color_rgb[3] = {0};

#if defined(CP_RGB_STATUS_INVERTED_PWM)
temp_status_color_rgb[0] = (1 << 16) - 1 - ((uint16_t) (red_u8 << 8) + red_u8);
temp_status_color_rgb[1] = (1 << 16) - 1 - ((uint16_t) (green_u8 << 8) + green_u8);
Expand All @@ -265,9 +270,9 @@ void clear_temp_status() {
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
#ifdef CIRCUITPY_BITBANG_APA102
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 8);
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
#else
common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8);
common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
#endif
#endif
#if defined(CP_RGB_STATUS_LED)
Expand Down
20 changes: 18 additions & 2 deletions supervisor/shared/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,28 @@ void serial_write_compressed(const compressed_string_t* compressed) {
serial_write(decompressed);
}

STATIC int put_utf8(char *buf, int u) {
if(u <= 0x7f) {
*buf = u;
return 1;
} else if(u <= 0x07ff) {
*buf++ = 0b11000000 | (u >> 6);
*buf = 0b10000000 | (u & 0b00111111);
return 2;
} else { // u <= 0xffff)
*buf++ = 0b11000000 | (u >> 12);
*buf = 0b10000000 | ((u >> 6) & 0b00111111);
*buf = 0b10000000 | (u & 0b00111111);
return 3;
}
}

char* decompress(const compressed_string_t* compressed, char* decompressed) {
uint8_t this_byte = 0;
uint8_t this_bit = 7;
uint8_t b = compressed->data[this_byte];
// Stop one early because the last byte is always NULL.
for (uint16_t i = 0; i < compressed->length - 1; i++) {
for (uint16_t i = 0; i < compressed->length - 1;) {
uint32_t bits = 0;
uint8_t bit_length = 0;
uint32_t max_code = lengths[0];
Expand All @@ -72,7 +88,7 @@ char* decompress(const compressed_string_t* compressed, char* decompressed) {
max_code = (max_code << 1) + lengths[bit_length];
searched_length += lengths[bit_length];
}
decompressed[i] = values[searched_length + bits - max_code];
i += put_utf8(decompressed + i, values[searched_length + bits - max_code]);
}

decompressed[compressed->length-1] = '\0';
Expand Down
3 changes: 2 additions & 1 deletion tools/build_memory_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
space = M_PATTERN.sub(M_REPLACE, space)
regions[region] = eval(space)

ram_region = regions["RAM"]
free_flash = regions["FLASH"] - text - data
free_ram = regions["RAM"] - data - bss
print(free_flash, "bytes free in flash out of", regions["FLASH"], "bytes (", regions["FLASH"] / 1024, "kb ).")
print(free_ram, "bytes free in ram for stack out of", regions["RAM"], "bytes (", regions["RAM"] / 1024, "kb ).")
print("{} bytes free in ram for stack and heap out of {} bytes ({}kB).".format(free_ram, ram_region, ram_region / 1024))
print()

# Check that we have free flash space. GCC doesn't fail when the text + data
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy