Implementing FrontView support for packed mode and time display.
authorlenclud@WUE-9BW295J.ad.garmin.com
Thu, 18 Apr 2013 16:05:47 +0200
changeset 4005bc1000c7e1a
parent 399 580df602ff73
child 401 70d865489ff3
Implementing FrontView support for packed mode and time display.
GUI/MainForm.cs
GUI/SoundGraphDisplay.cs
     1.1 --- a/GUI/MainForm.cs	Wed Apr 17 17:09:21 2013 +0200
     1.2 +++ b/GUI/MainForm.cs	Thu Apr 18 16:05:47 2013 +0200
     1.3 @@ -532,7 +532,7 @@
     1.4  
     1.5        if (soundGraphDisplay != null)
     1.6        {
     1.7 -          soundGraphDisplay.Redraw();
     1.8 +          soundGraphDisplay.Redraw(frontViewPacked.Value,frontViewDisplayTime.Value);
     1.9            /*
    1.10            displayTick=!displayTick;
    1.11            if (displayTick)
     2.1 --- a/GUI/SoundGraphDisplay.cs	Wed Apr 17 17:09:21 2013 +0200
     2.2 +++ b/GUI/SoundGraphDisplay.cs	Thu Apr 18 16:05:47 2013 +0200
     2.3 @@ -111,25 +111,97 @@
     2.4  
     2.5          }
     2.6  
     2.7 -        public void Redraw()
     2.8 +        public void Redraw(bool aPacked, bool aDisplayTime)
     2.9          {
    2.10 +            string packedFirstLine=""; //We have 16 chars per line on our VFD
    2.11 +            string packedSecondLine="";
    2.12 +            int count = 0;
    2.13 +
    2.14              //Update all sensors from our front view
    2.15              foreach (SensorFrontView sensor in list)
    2.16              {
    2.17 +                count++;
    2.18                  sensor.Update();
    2.19 +
    2.20 +                if (aPacked)
    2.21 +                {
    2.22 +                    string packedText = "";
    2.23 +                    packedText = sensor.iFirstLine.Substring(0, 3) + ":" + sensor.iSecondLine;
    2.24 +                    if (count == 1)
    2.25 +                    {
    2.26 +                        packedFirstLine = packedText;
    2.27 +                    }
    2.28 +                    else if (count == 2)
    2.29 +                    {
    2.30 +                        //Add enough spaces
    2.31 +                        while (packedFirstLine.Length + packedText.Length < 16)
    2.32 +                        {
    2.33 +                            packedFirstLine += " ";
    2.34 +                        }
    2.35 +                        packedFirstLine += packedText;
    2.36 +                    }
    2.37 +                    else if (count == 3)
    2.38 +                    {
    2.39 +                        packedSecondLine = packedText;
    2.40 +                    }
    2.41 +                    else if (count == 4)
    2.42 +                    {
    2.43 +                        //Add enough spaces
    2.44 +                        while (packedSecondLine.Length + packedText.Length < 16)
    2.45 +                        {
    2.46 +                            packedSecondLine += " ";
    2.47 +                        }
    2.48 +                        packedSecondLine += packedText;
    2.49 +                    }
    2.50 +
    2.51 +
    2.52 +                }
    2.53                  //SetText(sensor.iFirstLine, sensor.iSecondLine);
    2.54              }
    2.55  
    2.56              //Alternate between sensors 
    2.57              if (list.Count > 0)
    2.58              {
    2.59 -                //Display current sensor on our FrontView display
    2.60 -                SetText(list[iNextSensorToDisplay].iFirstLine, list[iNextSensorToDisplay].iSecondLine);
    2.61 -                iTickCounter++;
    2.62 -                if (iTickCounter==2) //Move to the next sensor only every second tick
    2.63 +                if (aPacked)
    2.64                  {
    2.65 -                    iTickCounter = 0;
    2.66 -                    iNextSensorToDisplay++;
    2.67 +                    //string packedLine = "";
    2.68 +                    iTickCounter++;
    2.69 +                    if (iTickCounter == 2) //Move to the next sensor only every second tick
    2.70 +                    {
    2.71 +                        iTickCounter = 0;
    2.72 +                        if (iNextSensorToDisplay==1)
    2.73 +                        {
    2.74 +                            iNextSensorToDisplay=0;
    2.75 +                        }
    2.76 +                        else
    2.77 +                        {
    2.78 +                            iNextSensorToDisplay=1;
    2.79 +                        }
    2.80 +                    }
    2.81 +
    2.82 +                    if (aDisplayTime)
    2.83 +                    {
    2.84 +                        string time = DateTime.Now.ToShortTimeString();
    2.85 +                        SetText(time, (iNextSensorToDisplay == 1 && packedSecondLine.Length > 0 ? packedSecondLine : packedFirstLine));
    2.86 +                    }
    2.87 +                    else
    2.88 +                    {
    2.89 +                        //Display packed sensors on our FrontView display
    2.90 +                        SetText(packedFirstLine, packedSecondLine);
    2.91 +                    }
    2.92 +
    2.93 +
    2.94 +                }
    2.95 +                else
    2.96 +                {
    2.97 +                    //Display current sensor on our FrontView display
    2.98 +                    SetText(list[iNextSensorToDisplay].iFirstLine, list[iNextSensorToDisplay].iSecondLine);
    2.99 +                    iTickCounter++;
   2.100 +                    if (iTickCounter == 2) //Move to the next sensor only every second tick
   2.101 +                    {
   2.102 +                        iTickCounter = 0;
   2.103 +                        iNextSensorToDisplay++;
   2.104 +                    }
   2.105                  }
   2.106              }
   2.107