# HG changeset patch # User StephaneLenclud # Date 1365971921 -7200 # Node ID 06369ace500d3544c8f351f602d301f6cc75a877 # Parent f590956d32348c8ac6a3d91ce37a9b107af8d5c4 Better formatting FrontView lines. Now cycling through each FrontView sensor every 2 seconds. Fixing character conversion when sending VFD text. Using special FrontView characters for Celsius and Farenheit. diff -r f590956d3234 -r 06369ace500d GUI/SensorFrontView.cs --- a/GUI/SensorFrontView.cs Sat Apr 13 00:43:25 2013 +0200 +++ b/GUI/SensorFrontView.cs Sun Apr 14 22:38:41 2013 +0200 @@ -155,31 +155,36 @@ string format = ""; switch (sensor.SensorType) { - case SensorType.Voltage: format = "{0}: {1:F2} V"; break; - case SensorType.Clock: format = "{0}: {1:F0} MHz"; break; - case SensorType.Load: format = "{0}: {1:F1} %"; break; - case SensorType.Temperature: format = "{0}: {1:F1} °C"; break; - case SensorType.Fan: format = "{0}: {1:F0} RPM"; break; - case SensorType.Flow: format = "{0}: {1:F0} L/h"; break; - case SensorType.Control: format = "{0}: {1:F1} %"; break; - case SensorType.Level: format = "{0}: {1:F1} %"; break; - case SensorType.Power: format = "{0}: {1:F0} W"; break; - case SensorType.Data: format = "{0}: {1:F0} GB"; break; - case SensorType.Factor: format = "{0}: {1:F3} GB"; break; + case SensorType.Voltage: format = "{0:F2}V"; break; + case SensorType.Clock: format = "{0:F0}MHz"; break; + case SensorType.Load: format = "{0:F1}%"; break; + //iMON VFD escape sequence for Celsius + case SensorType.Temperature: format = "{0:F0}\x001A"; break; + case SensorType.Fan: format = "{0:F0}RPM"; break; + case SensorType.Flow: format = "{0:F0}L/h"; break; + case SensorType.Control: format = "{0:F1}%"; break; + case SensorType.Level: format = "{0:F1}%"; break; + case SensorType.Power: format = "{0:F0}W"; break; + case SensorType.Data: format = "{0:F0}GB"; break; + case SensorType.Factor: format = "{0:F3}GB"; break; } - string formattedValue = string.Format(format, sensor.Name, sensor.Value); + string formattedValue = string.Format(format, sensor.Value); if (sensor.SensorType == SensorType.Temperature && unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) { - format = "{0}: {1:F1} °F"; - formattedValue = string.Format(format, sensor.Name, - UnitManager.CelsiusToFahrenheit(sensor.Value)); + //iMON VFD escape sequence for Fahrenheit + format = "{0:F0}\x001B"; + formattedValue = string.Format(format, UnitManager.CelsiusToFahrenheit(sensor.Value)); } - iFirstLine = sensor.Hardware.Name; + //iFirstLine = sensor.Hardware.Name; + //iSecondLine = sensor.Name+ ":" + formattedValue; + + iFirstLine = sensor.Name; iSecondLine = formattedValue; + } } } diff -r f590956d3234 -r 06369ace500d GUI/SoundGraphDisplay.cs --- a/GUI/SoundGraphDisplay.cs Sat Apr 13 00:43:25 2013 +0200 +++ b/GUI/SoundGraphDisplay.cs Sun Apr 14 22:38:41 2013 +0200 @@ -36,7 +36,8 @@ private List list = new List(); private SoundGraph.Server iServer; - private int nextSensorToDisplay=0; + private int iNextSensorToDisplay=0; + private int iTickCounter=0; public SoundGraphDisplay(IComputer computer, PersistentSettings settings, @@ -112,7 +113,7 @@ public void Redraw() { - //TODO: construct our two lines of texts, scroll or alternate sensors + //Update all sensors from our front view foreach (SensorFrontView sensor in list) { sensor.Update(); @@ -122,18 +123,22 @@ //Alternate between sensors if (list.Count > 0) { - SetText(list[nextSensorToDisplay].iFirstLine, list[nextSensorToDisplay].iSecondLine); - nextSensorToDisplay++; + //Display current sensor on our FrontView display + SetText(list[iNextSensorToDisplay].iFirstLine, list[iNextSensorToDisplay].iSecondLine); + iTickCounter++; + if (iTickCounter==2) //Move to the next sensor only every second tick + { + iTickCounter = 0; + iNextSensorToDisplay++; + } } - if (nextSensorToDisplay == list.Count) + if (iNextSensorToDisplay == list.Count) { //Go back to first sensor - nextSensorToDisplay = 0; + iNextSensorToDisplay = 0; } - - // } @@ -157,7 +162,7 @@ list.Add(new SensorFrontView(this, sensor, balloonTip, settings, unitManager)); //UpdateMainIconVisibilty(); settings.SetValue(new Identifier(sensor.Identifier, "FrontView").ToString(), true); - nextSensorToDisplay = 0; + iNextSensorToDisplay = 0; } } @@ -165,7 +170,7 @@ public void Remove(ISensor sensor) { Remove(sensor, true); - nextSensorToDisplay = 0; + iNextSensorToDisplay = 0; } private void Remove(ISensor sensor, bool deleteConfig) diff -r f590956d3234 -r 06369ace500d GUI/SoundGraphServer.cs --- a/GUI/SoundGraphServer.cs Sat Apr 13 00:43:25 2013 +0200 +++ b/GUI/SoundGraphServer.cs Sun Apr 14 22:38:41 2013 +0200 @@ -365,15 +365,23 @@ */ public void SendMessage(string message) { + byte[] m8 = new byte[message.Length]; + int i = 0; + foreach (char c in message) + { + m8[i]=System.Convert.ToByte(c); + i++; + } - ASCIIEncoding encoder = new ASCIIEncoding(); - byte[] messageBuffer = encoder.GetBytes(message); + //ASCIIEncoding encoder = new ASCIIEncoding(); + //byte[] messageBuffer = encoder.GetBytes(message); - if (iStreamOutbound != null && iStreamOutbound.CanWrite) - { - iStreamOutbound.Write(messageBuffer, 0, messageBuffer.Length); - iStreamOutbound.Flush(); - } + if (iStreamOutbound != null && iStreamOutbound.CanWrite) + { + //iStreamOutbound.Write(messageBuffer, 0, messageBuffer.Length); + iStreamOutbound.Write(m8, 0, message.Length); + iStreamOutbound.Flush(); + } }