Fez Hydra - Accessing to modules from classes other than Program

I am developing an application using FezHydra board. Is there any sample code or example that shows how to access the button on board (Reset Button) from program. I would like to use it as an interrupt port.

Also, when I add modules to the board using the designer, I can access them from Program class. However, when I want to access them from other classes, I pass them as arguments from the Program class. I am not sure if this the right way of accessing modules from other classes or I should use a specific namespace for this purpose.

Thanks

Hi, the Reset Button on the board resets the board. You are not going to be able to use it for user input. Sorry.

1 Like

@ Blue Hair Bob - Thanks for your answer.

How about my second question? Let’s say I have added Rs232 module with the name of “[em]rs232[/em]” to the board using the designer. I am able to acess it in [em]Program [/em]class by calling [em]rs232[/em]. However, what is the best way to access it in another class, say Class [em]A[/em]. Is passing it as an argument to class [em]A [/em]the only way?

@ Afshin - you can also define public methods in the Program class that will call required methods of the module(s) instance and use that instead. Passing module instances as parameter will work too. There are different design patterns for that.

It is whatever convenient for you.

1 Like

Thanks @ andre.m and @ Architect for the hints.

Yes, both work. I think having public methods in Program class is more convenient and easier to manage.

For the reset button question.

If you were hoping to use it as a generic button then it is not possible as Bob had already indicated.

If you want to catch the Reset event, then this might be possible. There is a class and an event you can subscribed to. I haven’t tried it though.