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

Implementation using fills up heap #2

Open
pavarott opened this issue Jan 3, 2022 · 2 comments
Open

Implementation using fills up heap #2

pavarott opened this issue Jan 3, 2022 · 2 comments

Comments

@pavarott
Copy link

pavarott commented Jan 3, 2022

Hi your implementation works great except that it fills the heap.
I'm using your library in a while loop and if I check the memory it uses all the heap and breakdown after 30 minutes

@skgsergio
Copy link
Owner

I cant get right now the sensor and a board for testing. Anyway, I tested this in the past in a continous loop and didn't face any issues, can you paste your code?

@pavarott
Copy link
Author

pavarott commented Jan 3, 2022

import pyb
from pyb import Pin
# for the ultrasonic sensor
import time
import ultrasonic
import micropython
# after boot and import
micropython.mem_info()

# ultrasonic init
trigger = pyb.Pin.board.A1
echo = pyb.Pin.board.A2
sensor = ultrasonic.Ultrasonic(trigger, echo)
dist = 0 
micropython.mem_info()


while True:
    time.sleep(0.1)
    try:
        dist = sensor.distance_in_cm()
        #print("Dist = {}".format(dist))

    except ultrasonic.MeasurementTimeout as e:
        print("{}".format(e))
    micropython.mem_info()



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

No branches or pull requests

2 participants