Repeated communication with 2 SPI slaves
Repeated communication with 2 SPI slaves
In my laser 3d printer controller project I need to communicate with 2 SPI slaves repeatedly. The problem is that both slaves are using different polarity and phase settings. Is there any way how to re-configure existing SPI object? Does spi.init() do this? Or is the only solution to create new SPI object with different settings over and over?
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Repeated communication with 2 SPI slaves
Wow, a laser 3D printer? Sounds like a very cool project
The answer is to use spi.init(). Good luck!
Cheers,
Daniel
The answer is to use spi.init(). Good luck!
Cheers,
Daniel
Re: Repeated communication with 2 SPI slaves
Thanks, I will try that.
You can find more info regarding our project here: http://marsaltech.com/
I will update news section in next few days
You can find more info regarding our project here: http://marsaltech.com/
I will update news section in next few days
Re: Repeated communication with 2 SPI slaves
Daniel, I have another issues, hope you can help me
1. In main.py I create objectA as an instance of classA. This object represents one of HW modules of my controller.
2. Then I create objectB as an instance of classB. This object represents client to my backend server service.
3. By calling objectB.functionB() I want to start processing of some data loaded from a file and based on this data perform some actions on HW module by calling objectA.functionA().
The problem is that from "inside" of instantiated classB as objectB the object objectA is not "visible" (name not defined). Should I pass objectA (and all other objects representing HW resources) as parameters when creating objectB? Or are there any other solutions?
1. In main.py I create objectA as an instance of classA. This object represents one of HW modules of my controller.
2. Then I create objectB as an instance of classB. This object represents client to my backend server service.
3. By calling objectB.functionB() I want to start processing of some data loaded from a file and based on this data perform some actions on HW module by calling objectA.functionA().
The problem is that from "inside" of instantiated classB as objectB the object objectA is not "visible" (name not defined). Should I pass objectA (and all other objects representing HW resources) as parameters when creating objectB? Or are there any other solutions?
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: Repeated communication with 2 SPI slaves
Either that, e.g. by making it an argument to the constructor of ClassB or by having an attribute/property on the ClassB instance, which you set to the ClassA instance after instantiation of objectB, or you put both instances, objectA and objectB, in the same namespace, usually either the global one, or that of your main() function.danielm wrote:Should I pass objectA (and all other objects representing HW resources) as parameters when creating objectB?
See also:
https://en.wikipedia.org/wiki/Design_Patterns
and
http://c2.com/cgi/wiki?CategoryStructuralPatterns
Chris
Re: Repeated communication with 2 SPI slaves
Chris, thank you for your answer