adafruit / Adafruit_CircuitPlayground

library for Circuit Playground board
171 stars 77 forks source link

Memory allocation error on CPX #35

Closed TheKitty closed 6 years ago

TheKitty commented 6 years ago

Thank you for opening an issue on an Adafruit Arduino library repository. To improve the speed of resolution please review the following guidelines and common troubleshooting steps below before creating the issue:

If you're sure this issue is a defect in the code and checked the steps above please fill in the following fields to provide enough troubleshooting information. You may delete the guideline and text above to just leave the following details:

Program to demonstrate writing out string data via HID keyboard emulation on CPX:

Circuit Playground Express Keyboard Emulation Example

2018 for Getting Started with Circuit Playground Express

import time from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_circuitplayground.express import cpx

kbd = Keyboard() layout = KeyboardLayoutUS(kbd)

while True: if cpx.button_a:

Type your name followed by Enter (a newline).

    layout.write('Kim Possible\n')

elif cpx.button_b:
    # Type out the name of your development board
    layout.write('Circuit Playground Express\n')

time.sleep(0.1)

I can press button A and get the text out. With one press of button B, it will print partial text then through the following error

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: Traceback (most recent call last): File "code.py", line 19, in File "adafruit_hid/keyboard_layout_us.py", line 209, in write MemoryError: memory allocation failed, allocating 460 bytes

Press any key to enter the REPL. Use CTRL-D to reload.

A bit time sensitive due to getting my CPX book to publisher this month. Thanks, Mike

ladyada commented 6 years ago

yeah those are big libraries, you will have to do the HID stuff without CPX library import, and use the digitalio lib directly

https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-hid-keyboard

kattni commented 6 years ago

Closing issue. Feel free to comment further or reopen the issue if needed!