schodet / nxt-python

NXT-Python is a python driver/interface for the Lego Mindstorms NXT robot based on NXT_python.
https://ni.srht.site/nxt-python/latest/
GNU General Public License v3.0
237 stars 74 forks source link

Adds support for HiTechnic SuperPro breakout #188

Closed jrddunbr closed 1 year ago

jrddunbr commented 2 years ago

This commit adds support for the HiTechnic SuperPro breadboardable breakout. It's no longer sold and the documentation is hard to find, but I have one of them and tested most of the functionality.

The only functionality that doesn't make sense to me is the "Strobe" functionality; it appears to be simply digital outputs, but there is not much documentation about what it does. Nothing interesting shows up on the o-scope while using this part of the device.

Also includes a demo of a bar graph doing a binary count from 0 to

  1. Looked at examples provided in PDF but some depend on board giving fast response time so decided against it. Should be relatively performant.
jrddunbr commented 2 years ago

If you have time, could you add a unit test?

Do you have examples of unit tests in this codebase that set a good example of what you want to see? I was considering an integration test by making all of the examples in the manual for the device, but decided against it for this PR. Ended up doing a few of them.

schodet commented 2 years ago

Do you have examples of unit tests in this codebase that set a good example of what you want to see? I was considering an integration test by making all of the examples in the manual for the device, but decided against it for this PR.

Yes, look at tests/test_sensors.py, there is a test for all sensors.

You can run them with python3 -m pytest

jrddunbr commented 2 years ago

This is still on my radar, I just haven't had the time this month to work this.

jrddunbr commented 2 years ago

Rebased PR on current tip. Might work on this today.

jrddunbr commented 2 years ago

So something must be broken with my implementation for the analog write functionality because it is getting the first command right (might be a fluke) and then subsequent ones cause the frequency to go into the kHz when I'm sending values under 500Hz.

Bytes were swapped. Fixed.

jrddunbr commented 2 years ago

Items left on this:

I accidentally refactored a bunch of the HiTechnic file thinking that Sphinx was not loading it properly and causing build failures, turns out it was an unrelated issue. It cleans up the comments and fixes most of the syntax errors except where it would likely break existing API functionality (this could be broken in the future if desired to make it PEP-compliant, but I didn't see a need to break it now).

schodet commented 2 years ago

This seems to work with all supported python versions: https://builds.sr.ht/~ni/job/832337