You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code above, it looks as if you want to put the SPI code into the "SPI" namespace, however, used a ruby class.
This might work for your code, but I've found it to make it impossible to actually reach SPI::Driver::SPIdev without first calling SPI.new(), since that somehow makes things reachable ...
Actually, I'd be willing to take this over and clean it up a bit, if that sounds alright.
It's not a lot of code to maintain, and the bulk of the work is done by the spidev kernel module anyways.
The design was based on the i2c library https://github.com/cho45/ruby-i2c-devices with the intention that more driver classes could be added (and hopefully a better mechanism to load the most suitable one).
Similarly the intention was that calls would normally be done via the main SPI class rather than directly against a driver - although I realise the README might not be so clear on that.
I'm certainly happy to take some PRs to try and clean things up and improve them.
I've looked through some examples, and usually, stacking modules in classes is O.K. to do if the modules inside the class are some form of MixIn
However, loading and autoloading of classes with those modules in them won't properly work if a class is used, since anyclass MyClass will cause the class to be defined, even though its contents may not be declared properly.
I've found I2C to work better for my code, and my exams at Uni won't make it easy to get some time to make a PR here
But I do recommend using modules for namespacing, and then just having a:
moduleSPIdefself.newendend
Where this function returns an instance of a driver class.
ruby-spi/lib/spi/driver/spidev.rb
Line 3 in 5427336
In the code above, it looks as if you want to put the SPI code into the "SPI" namespace, however, used a ruby class.
This might work for your code, but I've found it to make it impossible to actually reach SPI::Driver::SPIdev without first calling SPI.new(), since that somehow makes things reachable ...
See code attached below:
The text was updated successfully, but these errors were encountered: