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

Add RPi (non-pulseio) support #18

Merged
merged 5 commits into from
Oct 23, 2018
Merged

Add RPi (non-pulseio) support #18

merged 5 commits into from
Oct 23, 2018

Conversation

jerryneedell
Copy link

@jerryneedell jerryneedell commented Oct 17, 2018

This replaces PR #14 - it reconciles the changes with the current master with a few additional changes from the original PR from @ladyada
1)Main fix was to correct a bug in the pulseio code that had the relational test for the delay waiting for pulses inverted. This broke the pulseio version -- OK now
2)Attempted to make the non-pulseio more like the pulseio in its treatment of the incoming string of transitions - only use the last 81 transitions received. There are still a lot of errors when running on a Raspberry Pi, but this seems to help a bit - still > 10% failed readings
2) changed timeout waiting for pulses on non-pulseio to .25 sec (was .1) to match pulseio version. No apparent impact.

To look at the memory impact I ran the test code from @brennen to look at gc.mem_free at various points with the new code and with the current master code.

It looks like the new code consumes ~500bytes additional RAM if I am interpreting this correctly.
Is that OK?

new version
Adafruit CircuitPython 4.0.0-alpha.1-99-g293345119 on 2018-10-12; Adafruit Trinket M0 with samd21e18
>>> import dht_brennen
before import: 19472
after import: 16736
before init: 16736
after init: 16656
before sensor read: 16656
Temp: 67.5 F Humidity: 69.1%
after sensor read: 16064
before sensor read: 16640
Temp: 67.5 F Humidity: 69.1%
after sensor read: 16560

Here is the same test with the current master - (no RPi code )

current master
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.1-99-g293345119 on 2018-10-12; Adafruit Trinket M0 with samd21e18
>>>
>>> import dht_brennen
before import: 19472
after import: 17104
before init: 17104
after init: 17024
before sensor read: 17024
Temp: 67.8 F Humidity: 66.2%
after sensor read: 16432
before sensor read: 17008
Temp: 67.8 F Humidity: 64.1%
after sensor read: 16432
before sensor read: 17008
Temp: 67.8 F Humidity: 64.1%
after sensor read: 16432
before sensor read: 17008
Temp: 67.8 F Humidity: 64.2%

@ladyada
Copy link
Member

ladyada commented Oct 17, 2018

just to check, did you mpycross before importing and taking the gc memory readings?

@jerryneedell
Copy link
Author

@ladyada yes -- both readings were with .mpy file

@jerryneedell
Copy link
Author

I tested thsi on a trinket_M0 and on a Raspberry Pi 3B + -- Note: I cannot test the "led" example since I don't have that hardware.

@ladyada
Copy link
Member

ladyada commented Oct 17, 2018

@jerryneedell - thank you!

@tannewt is 500 bytes ok?

@tannewt
Copy link
Member

tannewt commented Oct 18, 2018

I think its fine for now. How about moving it into a private function? That way if I ever do lazy bytecode loading it'll stay out of memory.

Are there plans to add pulseio support to Blinka? We should remove it at that time.

@jerryneedell
Copy link
Author

jerryneedell commented Oct 18, 2018

How do I move it to a private function?
do you mean create two functions - one for pulseio one for non-pulseio and make them private then call the one wanted for each case?
Sorry -- still not fully comfortable in Python...

@ladyada
Copy link
Member

ladyada commented Oct 18, 2018

pulseio for blinka is a long ways away

@tannewt
Copy link
Member

tannewt commented Oct 18, 2018

@jerryneedell yup! and by private I mean named with a starting underscore.

@jerryneedell
Copy link
Author

Ok. I’ll try it and post it for your review. Hopefully this weekend.

@jerryneedell
Copy link
Author

@tannewt Is this what you are looking for re: private functions?

@jerryneedell
Copy link
Author

@tannewt does this need more work?

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! Exactly. Thank you!

@tannewt tannewt merged commit 5dbcca1 into adafruit:master Oct 23, 2018
tannewt pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 24, 2018
Updating https://github.com/adafruit/Adafruit_CircuitPython_DHT to 3.2.1 from 3.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#18 from jerryneedell/jerryn_fix_pr_14
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#17 from jerryneedell/jerryn_None
  > ignore the board module imports in .pylintrc

Updating https://github.com/adafruit/Adafruit_CircuitPython_Slideshow to 1.0.1 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Slideshow#8 from kattni/folder-fix
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

Successfully merging this pull request may close these issues.

None yet

3 participants