If I create a app in UWP for example with Template 10. I use C#
I want to have the GpioController
logic in a class or somewhere that will handle all input and output business like set all pins and events.
Like an example, when a button is pressed it will send a POST request to the server, this must work in any view.
If I go to a view and I want to get the status of a pin to show like "The door is open"
Also if for an example a sensor is triggering a pin to HIGH, if i change view it cant trigger buttonPin_ValueChanged
event and or set it to LOW for any reason unless the sensor is LOW.
Even if the pins Power-on Pull is PullDown.
pin = gpio.OpenPin(12);
pin.SetDriveMode(GpioPinDriveMode.InputPullUp);
pin.Write(GpioPinValue.Low);
pin.ValueChanged += buttonPin_ValueChanged;
The power pins pull power directly from the Raspberry Pi. GND are the pins you use to ground your devices. It doesn't matter which pin you use as they are all connected to the same line.
Raspberry-gpio-python or RPi. GPIO, is a Python module to control the GPIO interface on the Raspberry Pi. It was developed by Ben Croston and released under an MIT free software license.
GPIOs up to 8: default state is 1 (HIGH, or close to 3.3V). GPIOs 9 to 27: default state is 0 (LOW, or close to 0V).
GPIO or general purpose input/output is a generic pin on an integrated circuit or computer board whose behavior (including whether it is an input or output pin) is controllable by the user at run time. ( From Wikipedia, the free encyclopedia)
You can create a GpioController
object in your initial class, and pass it as an object to other classes.
Such as:
class BaseClass {
GpioController gpio;
void createGpioController(){
gpio = new GpioController(/*Constuctor arguments here.*/);
}
void moveToNextClass(NextClass next){
//Instantiate next class with any special constructors.
next.gpio = this.gpio;
//Launch next class with same gpio member values.
}
}
class NextClass: BaseClass {
GpioController gpio; //Will be assigned by last class.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With