示例#1
0
        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);
            }
        }
示例#2
0
        //Definition 1 ist Linie, 0 ist Boden
        private long ReadSensors()
        {
            long result = 0;

            for (int i = 0; i < Sensors.Length; i++)
            {
                if (WiringPiLib.DigitalRead(Sensors[i]) > 0)
                {
                    result = result | ((long)1 << i);
                }
            }

            if (InvertSensorInput)
            {
                result = result ^ 0xffffffff;
            }

            WriteResult(result);

            return(result);
        }
示例#3
0
        public void ReadWrite()
        {
            while (true)
            {
                for (int rowIndex = 0; rowIndex < Rows.Length; rowIndex++)
                {
                    wiringPiLib.DigitalWrite(Rows [rowIndex], 1);

                    for (int colIndex = 0; colIndex < Cols.Length; colIndex++)
                    {
                        if (wiringPiLib.DigitalRead(Cols [colIndex]) == 1)
                        {
                            //Console.WriteLine ("Reihe " + rowIndex + "Spalte " + colIndex + " gerueckt.");
                            Console.WriteLine(Chars [rowIndex][colIndex]);
                            while (wiringPiLib.DigitalRead(Cols [colIndex]) == 1)
                            {
                                Thread.Sleep(10);
                            }
                        }
                    }
                    wiringPiLib.DigitalWrite(Rows [rowIndex], 0);
                }
            }
        }