Пример #1
0
        public void Initialize(DataRate ouputDataRate                = DataRate._95Hz,
                               AxisSelection axisSelection           = AxisSelection.All,
                               PowerMode powerMode                   = PowerMode.Active,
                               HighPassFilterMode hpMode             = HighPassFilterMode.Normal,
                               HighPassConfiguration hpConfiguration = HighPassConfiguration.HPConf0,
                               Scale scale         = Scale._0250,
                               LowPass2Mode lpMode = LowPass2Mode.Bypassed)
        {
            // we are setting the 5 control registers in a single SPI write operation
            // by taking advantage on the consecutive write capability
            byte[] configBuffer = new byte[5];

            // control register 1
            configBuffer[0]  = (byte)axisSelection;
            configBuffer[0] |= (byte)powerMode;
            configBuffer[0] |= (byte)ouputDataRate;

            // control register 2
            if (hpMode != HighPassFilterMode.Bypassed)
            {
                configBuffer[1] = (byte)hpConfiguration;
            }

            // control register 3 skipped

            // control register 4
            configBuffer[3] = (byte)scale;
            // TDB
            // block auto-update
            // endianess

            // control register 5
            if (hpMode != HighPassFilterMode.Bypassed)
            {
                // high pass filter enabled
                configBuffer[4] = 0x10;

                if (lpMode != LowPass2Mode.Bypassed)
                {
                    configBuffer[4] |= 0x08 | 0x02;
                }
                else
                {
                    configBuffer[4] |= 0x04 | 0x01;
                }
            }

            WriteOperation(ControlRegister1, configBuffer);
        }
Пример #2
0
        public void doZoomAll(AxisSelection mode = AxisSelection.Both)
        {
            try
            {
                if (view != null)
                {
                    double zoom = 1;

                    switch (mode)
                    {
                    case AxisSelection.Both:
                        zoom = Math.Min(view.ScreenSpaceBounds.Width / view.WorldSpaceBounds.Width,
                                        view.ScreenSpaceBounds.Height / view.WorldSpaceBounds.Height);
                        break;

                    case AxisSelection.Vertical:
                        zoom = view.ScreenSpaceBounds.Height / view.WorldSpaceBounds.Height;
                        break;

                    case AxisSelection.Horizontal:
                        zoom = view.ScreenSpaceBounds.Width / view.WorldSpaceBounds.Width;
                        break;
                    }

                    if (zoomLevels.Any(D => D < zoom))
                    {
                        zoom = zoomLevels.Last(D => D < zoom);
                    }
                    view.Zoom = zoom;

                    view.TransposeToAllignPoints(view.WorldSpaceBounds.Middle,
                                                 view.ScreenSpaceBounds.Middle().AsPoint(),
                                                 mode);

                    DoViewChangeTasks();
                    picMain.Refresh();
                }
            }
            catch
            {
            }
        }
Пример #3
0
        public static void TransposeToAllignPoints(this IView2D view, Point2D world, Point screen, AxisSelection mode = AxisSelection.Both)
        {
            Point2D screenPosWS = view.ScreenSpace2WorldSpace(screen.X, screen.Y);

            //nudge the screen so the mouse is zooming in on a point;
            Point2D nudge = screenPosWS - world;

            nudge *= view.Zoom;

            switch (mode)
            {
            case AxisSelection.Both:
                view.TransformX += nudge.X;
                view.TransformY += nudge.Y;
                break;

            case AxisSelection.Vertical:
                view.TransformY += nudge.Y;
                break;

            case AxisSelection.Horizontal:
                view.TransformX += nudge.X;
                break;
            }
        }