I wrote a few very simple plugins to do things that LCDSmartie couldn't easily do on its own. Personally I like a constant display on my VFD rather than swapping screens. Currently it is set up to use the first three characters of both lines to display a CPU usage graph, then the top line has case/cpu temperature or download mbps if there is downstream activity, followed by free hard drive space. the bottom line has beyondtv status and currently recording show.
Anyways, the three plugins I needed to do this have their source pasted in below. They are written in C#. A brief explanation preceeds each code snippet.
Swap
The swap plugin swaps between two or more screens at a regular interval. It's syntax is
$dll(swap,1,string1#string2#string3...#stringN,time_in_seconds-1)
Code: Select all
using System;
namespace swap
{
public class LCDSmartie
{
private Int32 i;
private Int32 hold;
private Int32 strnum;
private string[] swaplist;
public LCDSmartie()
{
i = 0;
hold = 5;
strnum = 0;
}
public string function1(string param1, string param2)
{
try
{
swaplist = param1.Split('#');
if (param2 != null)
hold = Int32.Parse(param2);
if (i == hold)
{
i = 0;
strnum++;
}
else
i++;
if (strnum == swaplist.Length)
strnum = 0;
return swaplist[strnum];
}
catch (Exception e)
{
return e.ToString();
}
}
public int GetMinRefreshInterval()
{
return 1000;
}
}
}
The scroll plugin simply scrolls specified text in a specified width. Basicly it lets you scroll part of a line. I'm aware that limbo has a similar plugin but I was unable to reach his download page so I wrote my own. It's a bit dirty, it will restart the line right after the string is finished, so if you want to pad it with spaces you have to do it manually. Syntax:
$dll(scroll,1,text_to_scroll,width)
Code: Select all
using System;
namespace scroll
{
public class LCDSmartie
{
private String scrollString;
private Int32 i;
private Int32 len;
public LCDSmartie()
{
i = 0;
len = 0;
}
// Scroll text, wrapping around at the end
public string function1(String param1, String param2)
{
try
{
this.scrollString = param1;
len = Int32.Parse(param2);
i++;
if (i >= scrollString.Length)
i = 0;
if (scrollString.Length < len)
return scrollString;
else if ((i + len) > scrollString.Length)
{
String tmp;
int j = scrollString.Length - i;
tmp = scrollString.Substring(i, j);
tmp = tmp + scrollString.Substring(0, len - j);
return tmp;
}
else
return scrollString.Substring(i, len);
}
catch (Exception e)
{
return "Error: " + e.ToString();
}
}
}
}
This very simple plugin simply compares two strings and allows for two different outputs depending on whether or not the first string = the second string. For example, If network downstream in mbit = 0.0, display temperature, otherwise display the network downstream in mbit. The syntax for this one is a bit more complicated, but pretty easy to understand.
$dll(if,1,string1#string2,display1#display2
display1 is displayed if string1 = string2, otherwise display2 is shown.
Code: Select all
using System;
namespace @if
{
public class LCDSmartie
{
// string compare, if param1a == param1b, return param2a else param2b
public string function1(string param1, string param2)
{
try
{
string[] strs = param1.Split('#');
string[] rets = param2.Split('#');
if (rets[0] == null || rets[1] == null)
return "Too few arguments";
if (strs[0] == null || strs[1] == null)
return "Too few arguments";
else if (strs[0].CompareTo(strs[1]) == 0)
return rets[0];
else
return rets[1];
}
catch (Exception e)
{
return e.ToString();
}
}
}
}