adkron / grovepi

Use the GrovePi in Elixir
Apache License 2.0
47 stars 9 forks source link

Pivotpi #30

Closed axelclark closed 6 years ago

axelclark commented 7 years ago

Here is the PivotPi module to interact with the PivotPi. I also included a demo project that cycles through the servos and LEDs.

I used this Python project as a template: https://github.com/DexterInd/PivotPi/tree/master/Software/Python

Let me know if you have any questions or see any issues.

axelclark commented 6 years ago

Thanks for the feedback! I'll work on making the updates.

axelclark commented 6 years ago

I made updates based on both of your feedback. Let me know if you have questions or any other suggestions.

For testing, I will need to update GrovePi.Board and GrovePi.I2C since those modules do not currently support testing with Board.i2c_write_device/2.

EDIT: I did test this on my PivotPi

axelclark commented 6 years ago

I've spent some time looking at testing. With the current I2C module and the setup used for the tests of the current modules used to write to a board (Buzzer, Digital), the prefix must be passed into the tests.

I've been poking around trying to figure out how I can get it to work when I'm using Board.i2c_write_device and GrovePi.I2C.write_device, but I don't have a good idea about how to do it.

I did find that in Elixir 1.5.0 and up there is a new ExUnit.Callback function start_supervisor that may eliminate some of the setup currently used for the tests. It guarantees the GenServer will be stopped and started between tests, so I2C.reset shouldn't be needed in the setup.

adkron commented 6 years ago

Axel

I’ve been working on things his week. I’ve been looking at changing the sensors to be started with a module and a pin or i2c address. This means we can inject the module that is the board for testing.

Amos King Binary Noggin

On Oct 13, 2017, at 19:40, Axel Clark notifications@github.com wrote:

I've spent some time looking at testing. With the current I2C module and the setup used for the tests of the current modules used to write to a board (Buzzer, Digital), the prefix must be passed into the tests.

I've been poking around trying to figure out how I can get it to work when I'm using Board.i2c_write_device and GrovePi.I2C.write_device, but I don't have a good idea about how to do it.

I did find that in Elixir 1.5.0 and up there is a new ExUnit.Callback function start_supervisor that may eliminate some of the setup currently used for the tests. It guarantees the GenServer will be stopped and started between tests, so I2C.reset shouldn't be needed in the setup.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

axelclark commented 6 years ago

It wasn't working then I finally got the test to work. GrovePi.PivotPi.PCA9685.start() writes to the device 9 times. The test itself is ugly at the moment, but it is passing with Elixir 1.5.0 and higher.

adkron commented 6 years ago

Yes, there is quite a bit of nasty there. I need to work on how we are doing testing, and I'm currently trying to do that.

Can you update the Elixir version in the .travis.yml? If it passes I say we merge and work this out as we get the new testing in place. I hope the new testing will have a much lower barrier of entry also. The hardest part will be when we need to send multiple messages in a sequence like you are doing.

axelclark commented 6 years ago

I updated the .travis.yml and it looks like it is passing.

adkron commented 6 years ago

:robot: good work. Thanks for the trouble. Lets see what we can figure out to make our testing better and our barrier of entry for commits lower while keeping quality high.