void Initializer() { WiringPiLib = new WirinPiWrapper(); WiringPiLib.WiringPiSetupGpio(); WiringPiLib.PinMode(SHUTDOWNPIN, PinType.INPUT); WiringPiLib.PullUpDnControl(SHUTDOWNPIN, PullUpType.PUD_UP); WiringPiLib.PinMode(ACTIVPIN, PinType.INPUT); WiringPiLib.PullUpDnControl(ACTIVPIN, PullUpType.PUD_DOWN); for (int i = 0; i < Sensors.Length; i++) { WiringPiLib.PinMode(Sensors [i], PinType.INPUT); WiringPiLib.PullUpDnControl(Sensors[i], PullUpType.PUD_DOWN); } SleepBetweenActions = Int32.Parse(ConfigurationManager.AppSettings ["Hund_SleepBetweenActions"]); int pwmRange = Int32.Parse(ConfigurationManager.AppSettings ["Hund_PWM_Range"]); int servohertz = Int32.Parse(ConfigurationManager.AppSettings ["HundServohertz"]); int servoMaximalAusschlagGrad = Int32.Parse(ConfigurationManager.AppSettings ["HundServoMaximalAusschlagGrad"]); int hundServoMilliSecLeft = Int32.Parse(ConfigurationManager.AppSettings ["HundServoMicroSecLeft"]); int hundServoMilliSecRight = Int32.Parse(ConfigurationManager.AppSettings ["HundServoMicroSecRight"]); InvertSensorInput = bool.Parse(ConfigurationManager.AppSettings ["HundInvertSensorInput"]); NonPlausibleWaitTimerMilliSec = Int32.Parse(ConfigurationManager.AppSettings ["HundNonPlausibleWaitTimerMilliSec"]); LenkDeltaInGrad = float.Parse(ConfigurationManager.AppSettings ["HundLenkDeltainGrad"]); LenkServo = new Servo(PWMServoPin, servohertz, pwmRange, servoMaximalAusschlagGrad, WiringPiLib, hundServoMilliSecLeft, hundServoMilliSecRight); }
public FolienTastatur() { wiringPiLib.WiringPiSetupGpio(); for (int i = 0; i < Rows.Length; i++) { wiringPiLib.PinMode(Rows [i], PinType.OUTPUT); wiringPiLib.DigitalWrite(Rows [i], 0); wiringPiLib.PinMode(Cols [i], PinType.INPUT); wiringPiLib.PullUpDnControl(Cols[i], PullUpType.PUD_DOWN); } }
private static void Kompass() { int TasterPin = 26; WirinPiWrapper wiringPiLib = new WirinPiWrapper(); wiringPiLib.WiringPiSetupGpio(); wiringPiLib.PinMode(TasterPin, PinType.INPUT); //37 liest am Taster, um die Nadel manuell zu bewegen ISchrittmotor schrittMotor = new Schrittmotor(wiringPiLib, 19, 13, 6, 5); schrittMotor.Run(1); KompassHMC6343 kompass = new KompassHMC6343(wiringPiLib); KompassDisplay display = new KompassDisplay(schrittMotor); while (true) { while (wiringPiLib.DigitalRead(TasterPin) == 1) { Console.WriteLine("Calibrate"); display.Calibrate(); } double heading = kompass.ReadHeading(); Console.WriteLine("Heading: " + heading); //display.ShowClassic (heading); display.ShowNavigation(heading); } }
public Servo(int pwmPin, int hertz, int pwmRange, int maximalAusschlagGrad, WirinPiWrapper wiringPiLib, int microSecLeft, int microSecRight) { WiringPiLib = wiringPiLib; PwmRange = (uint)pwmRange; //pwmFrequency in Hz = 19.2e6 Hz / pwmClock / pwmRange. int PwmClock = 19200000 / pwmRange / hertz; WiringPiLib.PinMode(pwmPin, PinType.PWM_OUTPUT); WiringPiLib.PwmSetClock(PwmClock); WiringPiLib.PwmSetMode(PwmType.PWM_MODE_MS); //Servos likes mark / Space approach WiringPiLib.PwmSetRange(PwmRange); PwmPin = pwmPin; MaximalAusschlagGrad = maximalAusschlagGrad; MicroSecLeft = microSecLeft; MicroSecRange = microSecRight - MicroSecLeft; PeriodeMicroSecs = 1000000 / hertz; Position = 1; SetPosition(0); }
public Schrittmotor(WirinPiWrapper wiringPiLib, int in1, int in2, int in3, int in4) { WiringPiLib = wiringPiLib; In1 = in1; In2 = in2; In3 = in3; In4 = in4; wiringPiLib.PinMode(in1, PinType.OUTPUT); wiringPiLib.PinMode(in2, PinType.OUTPUT); wiringPiLib.PinMode(in3, PinType.OUTPUT); wiringPiLib.PinMode(in4, PinType.OUTPUT); Ausschalten(); LoadMotorstateOnRestart(); }