Skip to content

Commit

Permalink
GUI update
Browse files Browse the repository at this point in the history
GUI no longer displays on editor if Nebula is not connected
  • Loading branch information
peperonyy committed Jun 28, 2023
1 parent 7da3af0 commit 66ff883
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions Nebula-UnitySoftware/Assets/Scripts/Nebula/NebulaGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,45 @@ public class NebulaGUI : MonoBehaviour

void OnGUI()
{
//Calculate change aspects
float resX = (float)(Screen.width) / DesignWidth;
float resY = (float)(Screen.height) / DesignHeight;
//Set matrix
GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(resX, resY, 1));
if (!manualOverride) dutyCyclef = NebulaManager.currentDutyCycle;
GUI.Box(new Rect(10, 10, 250, 150), "Nebula manual activation");

if (!NebulaManager.nebulaIsDiffusing)
{
if (GUI.Button(new Rect(20, 40, 200, 20), "Start left atomization"))
{
manualOverride = true;
NebulaManager.nebulaIsDiffusing = true;
NebulaManager.SendData("L");
NebulaManager.SendData("C" + manualPWMfreq.ToString() + "; " + manualDC);
StartCoroutine(ManualDiffusion());
}
}
else
if (NebulaManager.nebulaSerial.IsOpen)
{
if (!manualOverride) GUI.Label(new Rect(25, 90, 150, 30), "Current duty cyle : " + NebulaManager.currentDutyCycle.ToString() + "%");
else GUI.Label(new Rect(25, 90, 150, 30), "Duty cyle : " + NebulaManager.currentDutyCycle.ToString() +"%");
dutyCyclef = GUI.HorizontalSlider(new Rect(25, 110, 100, 30), dutyCyclef, minManualDutyCycle, maxManualDutyCycle);
manualDC = (int)Mathf.Round(this.dutyCyclef);
//Calculate change aspects
float resX = (float)(Screen.width) / DesignWidth;
float resY = (float)(Screen.height) / DesignHeight;
//Set matrix
GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(resX, resY, 1));
if (!manualOverride) dutyCyclef = NebulaManager.currentDutyCycle;
GUI.Box(new Rect(10, 10, 250, 150), "Nebula manual activation");

if (GUI.Button(new Rect(20, 40, 200, 20), "Stop Atomization"))
if (!NebulaManager.nebulaIsDiffusing)
{
if (NebulaManager.nebulaIsDiffusing)
if (GUI.Button(new Rect(20, 40, 200, 20), "Start left atomization"))
{
manualOverride = true;
NebulaManager.SendData("S");
NebulaManager.nebulaIsDiffusing = true;
NebulaManager.SendData("L");
NebulaManager.SendData("C" + manualPWMfreq.ToString() + "; " + manualDC);
StartCoroutine(ManualDiffusion());
}
}
else
{
if (!manualOverride) GUI.Label(new Rect(25, 90, 150, 30), "Current duty cyle : " + NebulaManager.currentDutyCycle.ToString() + "%");
else GUI.Label(new Rect(25, 90, 150, 30), "Duty cyle : " + NebulaManager.currentDutyCycle.ToString() + "%");
dutyCyclef = GUI.HorizontalSlider(new Rect(25, 110, 100, 30), dutyCyclef, minManualDutyCycle, maxManualDutyCycle);
manualDC = (int)Mathf.Round(this.dutyCyclef);

if (GUI.Button(new Rect(20, 40, 200, 20), "Stop Atomization"))
{
if (NebulaManager.nebulaIsDiffusing)
{
manualOverride = true;
NebulaManager.SendData("S");
NebulaManager.nebulaIsDiffusing = false;
}
else manualOverride = !manualOverride;
NebulaManager.nebulaIsDiffusing = false;
}
else manualOverride = !manualOverride;
NebulaManager.nebulaIsDiffusing = false;
}
}
}
Expand Down

0 comments on commit 66ff883

Please sign in to comment.