You need to assign your own Widget ID
I think it is getting close, but I have a problem. I have two threads running, one that samples temperature every second and
writes it to the canvas, the other waits for buttons to be touched and increments a value (setpoint) and writes it to the canvas.
The string writes to the canvas do not show up unless a button is pushed. I tried to get around this by putting in a "canvas.execute()".
If I put in a "canvas.execute()" in the temperature sampling loop it causes the program to hang until a touch is registered on
the canvas at which point an endless bunch of touches are detected even though there was only one. The two code blocks are below:
static void MainLoop()
{
while (running)
{
Thread.Sleep(1000);
now = DateTime.Now.Ticks;
t1 = new DateTime(now);
t2 = new SystemTime();
_colorValues[_colorIndex] = (byte)(255 * _potentiometer.GetValue());
UpdateLedColor();
canvas.DrawRectangleFilled(50, 25, 120, 60, (ushort)BasicColor.White);
canvas.DrawString(50, 30, (ushort)BasicColor.Black, VerdanaBold14.ID, _thermometer.Read().ToString().Substring(0,5));
// canvas.Execute();
Debug.Print("Temp: " + _thermometer.Read().ToString().Substring(0,5));
Debug.Print("Light: " + _lightsensor.Read().ToString());
Debug.Print("Time: " + t1.ToString());
Debug.Print("UpSp: " + UpSp.ToString());
Debug.Print("LSp: " + LSp.ToString());
Debug.Print("Tick: " + tick.ToString());
}
canvas.Reboot();
Thread.Sleep(1000);
canvas.Dispose();
}
static void ButtonLoop()
{
while (running)
{
canvas.ActivateWidgets(true);
canvas.RenderWidgets();
canvas.Execute();
canvas.TouchscreenWaitForEvent();
canvas.RenderWidgets(Render.All);
canvas.Execute();
tick = tick + 1;
}
}
I have not been able to figure out how to write strings to the canvas and get them to show up. The buttons seem to work ok, unless I put a canvas.execute() in the
temperature sampling loop.