Example #1
0
        /// <summary>
        /// Initializes members and creates drawable shapes.
        /// Sets the write timer interval.
        /// </summary>
        private void Init()
        {
            // Initialize ControllerSettings
            Settings = new ControllerSettings
            {
                AltitudeControlActivated = false,
                Inverted  = ControllerActivity.Inverted,
                TrimYaw   = 0,
                TrimPitch = 0,
                TrimRoll  = 0
            };

            SetOnTouchListener(this);
            SetBackgroundColor(Color.White);

            // Get screen resolution
            ScreenWidth  = Resources.DisplayMetrics.WidthPixels;
            ScreenHeight = Resources.DisplayMetrics.HeightPixels;

            InitShapes();
            InitJoysticks();

            this.SetBackgroundResource(Resource.Drawable.bg);

            // Initialize timer
            mWriteTimer           = new System.Timers.Timer();
            mWriteTimer.Interval  = 50;
            mWriteTimer.AutoReset = true;
            mWriteTimer.Elapsed  += Write;
            mWriteTimer.Start();
        }
Example #2
0
        public ControllerView(IntPtr handle) : base(handle)
        {
            CGRect screenSize = UIScreen.MainScreen.Bounds;

            SCREEN_WIDTH  = (float)screenSize.Height;
            SCREEN_HEIGHT = (float)screenSize.Width;

            UserInteractionEnabled = true;
            MultipleTouchEnabled   = true;

            Settings                          = ControllerSettings.Instance;
            Settings.Inverted                 = false;
            Settings.LoggingActivated         = false;
            Settings.AltitudeControlActivated = false;
            Settings.TrimYaw                  = 0;
            Settings.TrimPitch                = 0;
            Settings.TrimRoll                 = 0;
            Settings.MinYaw                   = -15;
            Settings.MaxYaw                   = 15;
            Settings.MinPitch                 = -20;
            Settings.MaxPitch                 = 20;
            Settings.MinRoll                  = -20;
            Settings.MaxRoll                  = 20;

            mWriteTimer           = new System.Timers.Timer();
            mWriteTimer.Interval  = 50;           //10
            mWriteTimer.AutoReset = true;
            mWriteTimer.Elapsed  += Write;
            mWriteTimer.Start();

            InitJoysticks();
        }