Exemple #1
0
        public void initOscilloscope(Oscilloscope _oscilloscope, int _channels, int _FIFOdepth)
        {
            inputs = new FIFO[_channels];
            for (int i = 0; i < _channels; i++)
            {
                inputs[i] = new FIFO(_FIFOdepth);
            }
            lines        = new OscilloscopeLine[_channels];
            osciFIFO     = new OsciFIFO[_channels];
            inputsActive = new Boolean[_channels];
            yScale       = new YScale[_channels];
            for (int i = 0; i < _channels; i++)
            {
                lines[i] = new OscilloscopeLine(oscilloscopeScreen);
                switch (i % 4)
                {
                case 0: lines[i].color = Color.Red; break;

                case 1: lines[1].color = Color.Green; break;

                case 2: lines[2].color = Color.Cyan; break;

                case 3: lines[3].color = Color.Magenta; break;
                }
                osciFIFO[i] = new OsciFIFO(_oscilloscope.owner.sampleRate / 2);
                yScale[i]   = YScale.Div100m;
            }
            FIFOdepth       = _FIFOdepth;
            oscilloscope    = _oscilloscope;
            timer.Interval  = 100;       // ms
            timer.Tick     += Timer_Tick;
            channels        = _channels; // Triggers start
            selectedChannel = 0;

            timeScale = TimeScale.Div1ms;
            OsciHorzScale.SelectedIndex = (int)timeScale;


            triggerMode             = TriggerMode.Auto;
            OsciTriggerAuto.Checked = true;
            triggerFromChannel      = 0;
            triggerLevel            = 0;
            trigSlope = TrigSlope.Rising;

            for (int i = 0; i < channels; i++)
            {
                lines[i].yScale = getYScale(i);
            }

            xOffset = 0;
            oscilloscopeScreen.initOscilloscopeScreen(this, channels, lines);
            UpdateChannelScales();

            OsciChannelSelectA.Checked = true;
            selectChannel(selectedChannel);
            OsciVertScale.SelectedIndex = (int)yScale[selectedChannel];

            OsciChannelOnA.Checked = lines[0].show;
            OsciChannelOnB.Checked = lines[1].show;
            OsciChannelOnC.Checked = lines[2].show;
            OsciChannelOnD.Checked = lines[3].show;

            XYDisplay.Checked = false;
            xydisplay         = false;

            EnGrid.Checked = true;
            drawGrid       = true;

            timer.Enabled = true;
        }
Exemple #2
0
        public OscilloscopeWin()
        {
            InitializeComponent();
            channels     = 0;
            oscilloscope = null;
            FormClosing += OscilloscopeWin_FormClosing;
            CanClose     = false;
            timer        = new Timer();

            selectedChannel = -1;


            OsciChannelSelectA.Checked         = true;
            OsciChannelSelectA.CheckedChanged += OsciChannelSelect_CheckedChanged;
            OsciChannelSelectB.CheckedChanged += OsciChannelSelect_CheckedChanged;
            OsciChannelSelectC.CheckedChanged += OsciChannelSelect_CheckedChanged;
            OsciChannelSelectD.CheckedChanged += OsciChannelSelect_CheckedChanged;

            OsciChannelTriggerA.Checked         = true;
            OsciChannelTriggerA.CheckedChanged += OsciChannelTrigger_CheckedChanged;
            OsciChannelTriggerB.CheckedChanged += OsciChannelTrigger_CheckedChanged;
            OsciChannelTriggerC.CheckedChanged += OsciChannelTrigger_CheckedChanged;
            OsciChannelTriggerD.CheckedChanged += OsciChannelTrigger_CheckedChanged;

            OsciTriggerStop.Checked           = true;
            OsciTriggerStop.CheckedChanged   += OsciTriggerMode_CheckedChanged;
            OsciTriggerSingle.CheckedChanged += OsciTriggerMode_CheckedChanged;
            OsciTriggerNormal.CheckedChanged += OsciTriggerMode_CheckedChanged;
            OsciTriggerAuto.CheckedChanged   += OsciTriggerMode_CheckedChanged;

            foreach (TimeScale tsv in Enum.GetValues(typeof(TimeScale)))
            {
                OsciHorzScale.Items.Add(getTimeScaleString(tsv));
            }

            OsciHorzScale.SelectedIndexChanged += OsciHorzScale_SelectedIndexChanged;
            OsciHorzScale.SelectedIndex         = (int)timeScale;

            OsciHorzScaleP.Click += OsciHorzScaleP_Click;
            OsciHorzScaleM.Click += OsciHorzScaleM_Click;

            foreach (YScale ysv in Enum.GetValues(typeof(YScale)))
            {
                OsciVertScale.Items.Add(getYScaleString(ysv));
            }

            OsciVertScale.SelectedIndexChanged += OsciVertScale_SelectedIndexChanged;

            OsciVertScaleP.Click += OsciVertScaleP_Click;
            OsciVertScaleM.Click += OsciVertScaleM_Click;

            OsciVertAC.CheckedChanged     += OsciVertAC_CheckedChanged;
            OsciVertTrigAC.CheckedChanged += OsciVertTrigAC_CheckedChanged;

            OsciVertOfs.ValueChanged += OsciVertOfs_ValueChanged;
            OsciVertOfs0.Click       += OsciVertOfs0_Click;
            OsciVertOfsP.Click       += OsciVertOfsP_Click;
            OsciVertOfsM.Click       += OsciVertOfsM_Click;
            OsciVertOfsPP.Click      += OsciVertOfsPP_Click;
            OsciVertOfsMM.Click      += OsciVertOfsMM_Click;

            OsciVertTrig.ValueChanged += OsciVertTrig_ValueChanged;
            OsciVertTrig0.Click       += OsciVertTrig0_Click;
            OsciVertTrigP.Click       += OsciVertTrigP_Click;
            OsciVertTrigM.Click       += OsciVertTrigM_Click;
            OsciVertTrigPP.Click      += OsciVertTrigPP_Click;
            OsciVertTrigMM.Click      += OsciVertTrigMM_Click;

            OsciChannelOnA.CheckedChanged += OsciChannelOnA_CheckedChanged;
            OsciChannelOnB.CheckedChanged += OsciChannelOnB_CheckedChanged;
            OsciChannelOnC.CheckedChanged += OsciChannelOnC_CheckedChanged;
            OsciChannelOnD.CheckedChanged += OsciChannelOnD_CheckedChanged;

            XYDisplay.CheckedChanged += XYDisplay_CheckedChanged;
            EnGrid.CheckedChanged    += EnGrid_CheckedChanged;

            OsciDecay.ValueChanged += OsciDecay_ValueChanged;

            OsciVertTrigSlope.Items.Add(getTrigSlopeName((TrigSlope)0));
            OsciVertTrigSlope.Items.Add(getTrigSlopeName((TrigSlope)1));
            OsciVertTrigSlope.SelectedIndex         = (int)trigSlope;
            OsciVertTrigSlope.SelectedIndexChanged += OsciVertTrigSlope_SelectedIndexChanged;
        }