I am looking to do a Display of Analog Readings (coming from physiological readings) on the Gadgeteer
LCD panel and am wondering if anyone has done a simple oscilliscope-like display of Signal over Time, or Voltage over Time on the .Net Micro Framework or if any of you experts could outline what I need to do?
I don’t want to assign more homework than necessary to Gus or anyone else but are there any hints on how to do a labelled and maybe grid-based scope display on the T35 LCD for Gadgeteer.
class Scope
{
private Bitmap _LCD = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
private int[] _samples;
private Font font = Resources.GetFont(Resources.FontResources.small);
public Scope(uint sampleCount)
{
if (sampleCount < 10 || sampleCount > (SystemMetrics.ScreenWidth / 2))
throw new ArgumentException();
// clear
_LCD.Clear();
_LCD.Flush();
// allocate buffer for samples
// maybe it is better to use? System.Collections.Queue
_samples = new int[sampleCount];
}
public void Update(int value)
{
// shift all samples up once
for (int i = _samples.Length - 1; i > 0; i--)
{
_samples[i] = _samples[i - 1];
}
//add the new entry
_samples[0] = value;
// draw to screen
float division = SystemMetrics.ScreenWidth / _samples.Length;
int sample;
float x;
_LCD.Clear();
DrawGrid();
for (x = 0, sample = 0; sample < _samples.Length - 1; x += division, sample++)
{
//we can add scaling here if we want but this will slow it down
_LCD.DrawLine(Colors.Red, 1, (int)x, _samples[sample] + SystemMetrics.ScreenHeight / 2, (int)(x + division), _samples[sample + 1] + SystemMetrics.ScreenHeight / 2);
}
_LCD.Flush();
}
public void DrawGrid()
{
int yStep = SystemMetrics.ScreenHeight / 10;
for (int i = 0; i < 10; i++)
{
_LCD.DrawLine(Colors.Green, 1, 0, i * yStep, SystemMetrics.ScreenWidth, i * yStep);
}
int xStep = SystemMetrics.ScreenWidth / 10;
for (int i = 0; i < 10; i++)
{
_LCD.DrawLine(Colors.Green, 1, i * xStep, 0, i * xStep, SystemMetrics.ScreenHeight);
_LCD.DrawText(i.ToString(), font, Colors.Yellow, i * xStep, SystemMetrics.ScreenHeight/2);
}
}
}
Mike Dodaro in his Blog Integral Design also posted an Oscilloscope-like display for Gadgeteer along with code for posting Data to a RESTful Internet Interface
Interestingly he is also working with physiological data from SEEED Studio’s Pulse Oximeter