예제 #1
0
파일: GyroBoy.cs 프로젝트: rotkiv42/EV3
        // verified except the interrupting balance loop
        public void errors(float avg_pwr)
        {
            nowOutOfBound = (Math.Abs(avg_pwr) > 100f);

            // read cur_err

            if (nowOutOfBound && prevOutOfBound)
            {
                outOfBoundCount++;
            }
            else
            {
                outOfBoundCount = 0;
            }

            if (outOfBoundCount > 20)
            {
                Thread.Sleep(100);
                ev3.offMotorA();
                ev3.offMotorD();

                // diplay ERROR

                ev3.sound(50, 800, 100);
                ev3.sound(50, 600, 100);
                ev3.sound(50, 300, 100);

                // B+C
//				ev3.offMotorB ();
//				ev3.offMotorC ();

                // interrupt balance loop

                Thread.Sleep(4000);
                // stop
            }
            else
            {
                prevOutOfBound = nowOutOfBound;
            }
        }