Skip to content
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

MemoryError on Metro M0 Express #36

Open
caternuson opened this issue Mar 29, 2019 · 12 comments
Open

MemoryError on Metro M0 Express #36

caternuson opened this issue Mar 29, 2019 · 12 comments
Assignees
Labels

Comments

@caternuson
Copy link
Contributor

Re:
https://forums.adafruit.com/viewtopic.php?f=63&t=149682

Can recreate with following:

Adafruit CircuitPython 3.1.2 on 2019-01-07; Adafruit Metro M0 Express with samd21g18
>>> import board, busio
>>> import adafruit_character_lcd.character_lcd_i2c as character_lcd
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> lcd = character_lcd.Character_LCD_I2C(i2c, 20, 4)
>>> lcd.message = "Hello\nCircuitPython"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_character_lcd/character_lcd.py", line 338, in message
MemoryError: memory allocation failed, allocating 160 bytes
>>> 

But seems to work on M4:

Adafruit CircuitPython 3.1.2 on 2019-01-07; Adafruit Metro M4 Express with samd51j19
>>> import board, busio
>>> import adafruit_character_lcd.character_lcd_i2c as character_lcd
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> lcd = character_lcd.Character_LCD_I2C(i2c, 20, 4)
>>> lcd.message = "Hello\nCircuitPython"
>>> 
@ladyada
Copy link
Member

ladyada commented Mar 29, 2019

try 4.x - if that is still not fitting then yeah this library could be slimmed down, i see a lot of inefficiencies. let me know if you want to take that on

@caternuson
Copy link
Contributor Author

similar with 4.x:

Adafruit CircuitPython 4.0.0-beta.5 on 2019-03-17; Adafruit Metro M0 Express with samd21g18
>>> import board, busio
>>> import adafruit_character_lcd.character_lcd_i2c as character_lcd
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> lcd = character_lcd.Character_LCD_I2C(i2c, 20, 4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_character_lcd/character_lcd_i2c.py", line 74, in __init__
  File "adafruit_mcp230xx.py", line 31, in <module>
MemoryError: 
>>> 

@kattni - you up for this?

@ladyada
Copy link
Member

ladyada commented Mar 29, 2019

i think @kattni's pretty booked, this might be better for you to take on

@dhalbert
Copy link
Contributor

I have a different library that has similar functionality, where the interface is factored out of the user API: https://github.com/dhalbert/CircuitPython_LCD. It was written before this one; they come from different source bases. The current library takes the parallel interface as the base and then adapts other interfaces to that. The minimal branch in my library is actually the one I've been using. It removes RTL and a bunch of other lesser-used features to save memory.

@caternuson
Copy link
Contributor Author

@dhalbert Question about your library - how would it support usage of bare displays which would require the parallel interface? For example:
https://www.adafruit.com/product/181
and this hardware setup:
https://learn.adafruit.com/character-lcds/python-circuitpython

@kattni
Copy link
Contributor

kattni commented Jun 3, 2019

Tested on Metro M0. Memory fails with the RGB LCD I2C shield and the I2C RGB simpletest.

code.py output:
Traceback (most recent call last):
  File "code.py", line 15, in <module>
  File "adafruit_character_lcd/character_lcd_rgb_i2c.py", line 86, in __init__
  File "adafruit_mcp230xx/mcp23017.py", line 34, in <module>
MemoryError: memory allocation failed, allocating 64 bytes

Works properly on Metro M4.

@caternuson
Copy link
Contributor Author

Ugh...confusing results...
@kattni Can you check again please? Or let me know of any HW differences with your setup.

Finally getting back to this. Had to order up the RGB shield kit HW. I've now got the following:

Using CP 4.0.1 with bundle release from 20190620 and running this example:
https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/examples/charlcd_i2c_rgb_simpletest.py
saved as code.py. It seems to work for me:

Adafruit CircuitPython 4.0.1 on 2019-05-22; Adafruit Metro M0 Express with samd21g18
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:

lcd_test

@kattni
Copy link
Contributor

kattni commented May 4, 2020

@caternuson I don't have the hardware here to test this here, but can you test it on 5.x? If you don't experience the issue, we'll close it.

@caternuson
Copy link
Contributor Author

@kattni :(

Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit Metro M0 Express with samd21g18
>>>
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 5, in <module>
  File "adafruit_character_lcd/character_lcd_rgb_i2c.py", line 58, in <module>
MemoryError:



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

@kattni
Copy link
Contributor

kattni commented May 11, 2020

@caternuson Bummer. Alright. You were looking into this last, and couldn't replicate it. It appears that you are now able to. It seems the last thing was you needing more information from Dan. Is that accurate? Is this still something you're willing/able to look into?

@caternuson caternuson self-assigned this May 12, 2020
@caternuson
Copy link
Contributor Author

@kattni I self assigned and will take a look.

@evaherrada evaherrada added the bug label Jun 30, 2020
@pkoppstein
Copy link

Any progress on this? I ran into the problem with a Feather M0 Express with libraries from
adafruit-circuitpython-bundle-5.x-mpy-20200709

Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit Feather M0 Express with samd21g18
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "adafruit_character_lcd/character_lcd_i2c.py", line 47, in <module>
  File "adafruit_character_lcd/character_lcd.py", line 118, in <module>
MemoryError: memory allocation failed, allocating 96 bytes
>>> 

Workarounds for using an LCD with I2C backpack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants