/// <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; } } }
/// <summary>Set position. But before test for minimum and maximum value</summary> /// <param name="value">Vertical position</param> private void SetPosition(float value) { // compute minimum maximum for horizontal position var halfScreen = sampPerScreen / 2; var maxPosition = (BUFFER_HALF_SIZE - halfScreen) * divsPerSample; // calculate actual position position = Mathf.Clamp(value, -maxPosition, maxPosition); // calculate relative position sampAtCenterRel = Mathf.RoundToInt(position * sampPerDivision); timeAtCenterRel = position * secondsDivision; // caclulate samples before and after trigger numSamplesBeforeTrigger = Mathf.RoundToInt((int)halfScreen + sampAtCenterRel); numSamplesAfterTrigger = Mathf.RoundToInt((int)halfScreen - sampAtCenterRel); isDirtyConfigText = isDirtyStatusText = true; timeCursor.anchoredPosition = oscSettings.GetPixelPositionClamped(position, oscSettings.rectangle.yMin); RequestRedraw(); /* request redraw */ }