Example #1
0
        /// <summary>Render OSD labels. Can be called per frame</summary>
        public void RenderGUI()
        {
            if (isPlugged)
            {
                // channel's zero level label at the left side of screen
                label.anchoredPosition = oscSettings.GetPixelPositionClamped(chanLabelPosX, position);
                // channel's custom value labels at the right side of screen
                var valsNum = valueLabels.Count;
                for (var i = 0; i < valsNum; i++)
                {
                    var label = valueLabels[i];
                    label.anchoredPosition = oscSettings.GetPixelPositionClamped(valsLabelPosX, label.position + position);
                }
            }

            if (isDirtyConfigText)
            {
                isDirtyConfigText = false;
                oscilloscope.trigger.RequestRedraw();
                if (probe != null)
                {
                    configText.text =
                        $"{probe.name} {(autoGain ? STR_AUTO_ON : STR_AUTO_OFF)} {style}\n{(decoupling ? STR_DECOUPLING_ON : STR_DECOUPLING_OFF)} {OscFormatter.FormatValuePerDiv(gain)}\nPos:{position} divs ({OscFormatter.FormatValue(position * scale)})";
                }
                else
                {
                    configText.text = string.Empty;
                }
            }

            if (isDirtyStatusText)
            {
                isDirtyStatusText = false;
                if (probe != null)
                {
                    statusText.text = $"Vpp: {OscFormatter.FormatValue(minMax.P2P),5}";
                }
                else
                {
                    statusText.text = string.Empty;
                }
            }
        }
Example #2
0
        /// <summary>Update text at the channel's label</summary>
        public void RenderGUI()
        {
            // channel's custom time labels at the bottom side of screen
            for (var i = 0; i < timeLabels.Length; i++)
            {
                var label = timeLabels[i];
                label.anchoredPosition = oscSettings.GetPixelPositionClamped(label.position + position, timeLabelPosY);
            }

            if (isDirtyConfigText)
            {
                isDirtyConfigText = false;
                configText.text   = string.Format("In:{0} | T:{1,5} | Pos:{2,5} | Lev:{3,5} | Mode:{4,5} | Edge:{5,5} |",
                                                  channel.channelName,
                                                  OscFormatter.FormatTimePerDiv(secondsDivision),
                                                  OscFormatter.FormatTime(timeAtCenterRel),
                                                  OscFormatter.FormatValue(level * channel.Scale),
                                                  mode,
                                                  triggerEdge);
            }

            if (isDirtyStatusText)
            {
                isDirtyStatusText          = false;
                iconStateArmed.enabled     = false;
                iconStateAuto.enabled      = false;
                iconStateReady.enabled     = false;
                iconStateTriggered.enabled = false;
                iconStatePause.enabled     = false;
                switch (status)
                {
                case Status.Armed:
                    iconStateArmed.enabled = true;
                    break;

                case Status.Ready:
                    iconStateReady.enabled = true;
                    break;

                case Status.Triggered:
                    iconStateTriggered.enabled = true;
                    break;

                case Status.Auto:
                    iconStateAuto.enabled = true;
                    break;

                case Status.Stop:
                    iconStatePause.enabled = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            // -- render horizontal line of threshold but only in case of non-ext channels
            if (valueLabel != null)
            {
                var valueLabelY = level * channel.Scale + channel.Position;
                valueLabel.anchoredPosition = oscSettings.GetPixelPositionClamped(oscSettings.rectangle.xMin, valueLabelY);
            }

            for (var i = 0; i < timeLabels.Length; i++)
            {
                var label = timeLabels[i];
                var xpos  = GetGridPositionX((int)label.position);
                if (frameCount - label.frameCount < 3)
                {
                    if (xpos > oscSettings.rectangle.xMin && xpos < oscSettings.rectangle.xMax)
                    {
                        label.anchoredPosition = oscSettings.GetPixelPosition(xpos, timeLabelPosY);
                        label.visible          = true;
                    }
                    else
                    {
                        label.visible = false;
                    }
                }
                else
                {
                    label.visible = false;
                }
            }

            if (DEBUG_DISPLAY)
            {
                debugText.text = string.Format(
                    "dmaWrt: {0}\ndmaTrg: {1}\ndmaEnd: {2}\nsmpLft: {3}\nsmpRht: {4}\ndmaDrw: {5}\ndrwBeg: {6}\ndrwEnd: {7}\nsmpDiv: {8}",
                    dmaWrite,
                    dmaWriteTrggrd,
                    dmaWriteEnd,
                    numSamplesBeforeTrigger,
                    numSamplesAfterTrigger,
                    dmaDraw,
                    dmaDrawBeg,
                    dmaDrawEnd,
                    sampPerDivision);
            }
        }