Example #1
0
 /// <summary>Mark channel selected</summary>
 public void SelectTriggerChannel()
 {
     if (selectedChannel != null)
     {
         selectedChannel.ledSelected.State = false;
     }
     selectedChannel = null;
     oscilloscope.trigger.ledSelected.State = true;
     updateHelp = true;
 }
Example #2
0
        /// <summary>
        /// Draw waveform. Argument's units are grid divisions (GD)
        /// </summary>
        /// <param name="channel">Channel</param>
        /// <param name="smpBeg">Index of first sample</param>
        /// <param name="smpEnd">Index of last sample</param>
        /// <param name="pxStart">Start pixel</param>
        /// <param name="pxPerSample">Pixels per sample</param>
        /// <param name="color">Waveform color</param>
        public void PlotFloatLogic(
            OscChannel channel,
            int smpBeg,
            int smpEnd,
            float pxStart,
            float pxPerSample,
            Color color)
        {
            // do not render empty buffer
            const int CHAR_OFFSET_Y = -10;
            const int CHAR_OFFSET_X = -66;
            var       position      = channel.Position;
            var       texCenterY    = oscSettings.textureCenter.y;
            var       pixPerDivs    = oscSettings.pixelsPerDivision;
            var       topY          = Mathf.RoundToInt((position + channel.Scale) * pixPerDivs + texCenterY);
            var       botY          = Mathf.RoundToInt(position * pixPerDivs + texCenterY);
            // first sample position
            var fpx = pxStart;
            var x1  = Mathf.RoundToInt(pxStart - pxPerSample);
            var v1  = (int)(channel.GetFloat(smpBeg - 1) - position);

            // iterate over all samples (starts from sample 2)
            for (var i = smpBeg; i <= smpEnd; i++)
            {
                var x2 = Mathf.RoundToInt(fpx);
                var v2 = (int)(channel.GetFloat(i) - position);
                if (v1 == v2)
                {
                    if (i != smpEnd)
                    {
                        v1   = v2;
                        fpx += pxPerSample;
                        continue;                         // skip
                    }
                    else
                    {
                        // horizontal lines
                        OscUtils.PlotLine(screenTexture, x1, topY, x2 - 1, topY, color);
                        OscUtils.PlotLine(screenTexture, x1, botY, x2 - 1, botY, color);
                        return;
                    }
                }
                // horizontal lines
                OscUtils.PlotLine(screenTexture, x1, topY, x2 - 2, topY, color);
                OscUtils.PlotLine(screenTexture, x1, botY, x2 - 2, botY, color);
                // cross over lines
                OscUtils.PlotLine(screenTexture, x2 - 2, topY, x2, botY, color);
                OscUtils.PlotLine(screenTexture, x2 - 2, botY, x2, topY, color);
                // display value (previous value)
                OscFont.DrawText(screenTexture, v1.ToString("x8"), x2 + CHAR_OFFSET_X, botY + CHAR_OFFSET_Y, color);
                x1   = x2;
                v1   = v2;
                fpx += pxPerSample;
            }
        }
Example #3
0
        /// <summary>
        /// Draw waveform. Argument's units are grid divisions (GD)
        /// </summary>
        /// <param name="channel">Channel</param>
        /// <param name="smpBeg">Index of first sample</param>
        /// <param name="smpEnd">Index of last sample</param>
        /// <param name="pxStart">Start pixel</param>
        /// <param name="pxPerSample">Pixels per sample</param>
        /// <param name="color">Waveform color</param>
        public void PlotVector2(
            OscChannel channel,
            int smpBeg,
            int smpEnd,
            float pxStart,
            float pxPerSample,
            Color color)
        {
            // do not render empty buffer
            var texCenterY = oscSettings.textureCenter.y;
            var pixPerDivs = oscSettings.pixelsPerDivision;
            // first sample position
            var fpx    = pxStart;
            var x1     = Mathf.RoundToInt(pxStart - pxPerSample);
            var sample = channel.GetVector2(smpBeg - 1);
            var y1a    = Mathf.RoundToInt(sample.x * pixPerDivs + texCenterY);
            var y1b    = Mathf.RoundToInt(sample.y * pixPerDivs + texCenterY);

            // iterate over all samples (starts from sample 2)
            for (var i = smpBeg; i <= smpEnd; i++)
            {
                var x2 = Mathf.RoundToInt(fpx);
                sample = channel.GetVector2(i);
                var y2a = Mathf.RoundToInt(sample.x * pixPerDivs + texCenterY);
                var y2b = Mathf.RoundToInt(sample.y * pixPerDivs + texCenterY);
                // first line at the sample 2
                var dx = Math.Abs(x1 - x2);

                var dya = Math.Abs(y1a - y2a);
                if (dx > 1 || dya > 1)
                {
                    OscUtils.PlotLine(screenTexture, x1, y1a, x2, y2a, colorX);
                }
                else
                {
                    screenTexture.SetPixel(x2, y2a, colorX);
                }

                var dyb = Math.Abs(y1b - y2b);
                if (dx > 1 || dyb > 1)
                {
                    OscUtils.PlotLine(screenTexture, x1, y1b, x2, y2b, colorY);
                }
                else
                {
                    screenTexture.SetPixel(x2, y2b, colorY);
                }

                x1   = x2;
                y1a  = y2a;
                y1b  = y2b;
                fpx += pxPerSample;
            }
        }
Example #4
0
        private OscChannel selectedChannel; //< Channel to get messages

        public void SelectChannel(OscChannel.Name channelName)
        {
            oscilloscope.trigger.ledSelected.State = false;
            if (selectedChannel != null)
            {
                selectedChannel.ledSelected.State = false;
            }
            selectedChannel = oscilloscope.GetChannel(channelName);
            selectedChannel.ledSelected.State = true;
            updateHelp = true;
        }
Example #5
0
        // =============================================================================================================
        // Initialization
        // =============================================================================================================

        /// <summary>Create trigger with default channel</summary>
        /// <param name="oscilloscope"></param>
        public void Initialize(Oscilloscope osc, OscChannel oscChannel)
        {
            oscilloscope       = osc;
            oscSettings        = osc.oscSettings;
            oscRenderer        = osc.oscRenderer;
            textureCenterX     = oscSettings.textureCenter.x; /* Perf. Opt */
            configText.color   = color;
            valueLabel.color   = color;
            valueLabel.text    = TRIGGER_CHANNEL_NAME;
            timeCursor.color   = color;
            timeCursor.text    = TRIGGER_CHANNEL_NAME;
            ledPlugged.message = TRIGGER_CHANNEL_NAME;
            pause             = true;
            timeLabelPosY     = oscSettings.rectangle.yMin;
            debugText.enabled = DEBUG_DISPLAY;
            SetChannel(oscChannel);
            SpawnLabels();
            RenderGUI();
        }
Example #6
0
        // ============================================================================================
        // Draw time diagram on screen
        // ============================================================================================

        /// <summary>
        ///     Draw waveform. Argument's units are grid divisions (GD)
        /// </summary>
        /// <param name="channel">Channel</param>
        /// <param name="smpBeg">Index of first sample</param>
        /// <param name="smpEnd">Index of last sample</param>
        /// <param name="pxStart">Start pixel</param>
        /// <param name="pxPerSample">Pixels per sample</param>
        /// <param name="color">Waveform color</param>
        public void PlotFloat(
            OscChannel channel,
            int smpBeg,
            int smpEnd,
            float pxStart,
            float pxPerSample,
            Color color)
        {
            // do not render empty buffer
            var texCenterY = oscSettings.textureCenter.y;
            var pixPerDivs = oscSettings.pixelsPerDivision;
            // first sample position
            var fpx = pxStart;
            var x1  = Mathf.RoundToInt(pxStart - pxPerSample);
            var y1  = Mathf.RoundToInt(channel.GetFloat(smpBeg - 1) * pixPerDivs + texCenterY);

            y1 = oscSettings.ClampPixelInsideScreenY(y1);
            // iterate over all samples (starts from sample 2)
            for (var i = smpBeg; i <= smpEnd; i++)
            {
                var x2 = Mathf.RoundToInt(fpx);
                var y2 = Mathf.RoundToInt(channel.GetFloat(i) * pixPerDivs + texCenterY);
                y2 = oscSettings.ClampPixelInsideScreenY(y2);
                // first line at the sample 2
                var absDx = Math.Abs(x1 - x2);
                var absDy = Math.Abs(y1 - y2);
                if (absDx > 1 || absDy > 1)
                {
                    OscUtils.PlotLine(screenTexture, x1, y1, x2, y2, color);
                }
                else
                {
                    screenTexture.SetPixel(x2, y2, color);
                }
                x1   = x2;
                y1   = y2;
                fpx += pxPerSample;
            }
        }
Example #7
0
        // =============================================================================================================
        // Trigger's input port can be connected to any channel
        // =============================================================================================================

        /// <summary>Set channel for this trigger</summary>
        public void SetChannel(OscChannel oscChannel)
        {
            channel = oscChannel;
            OnPlugHandle();
        }