We currently use the EMX module and have consistently seen slow screen refreshes on our 4.3" 480 x 272 display.
This led us to build up a quick app with a significantly less complex interface in order to benchmark the graphics performance and try to determine what could be causing things to run so slow. To our surprise the benchmark app maxes out at a meager 4 FPS. We are stumped as to what we could be doing wrong here and it doesn’t make sense that the EMX plus such a simple graphics routine is so ridiculously slow.
Anyone have any idea why this could be happening?
The test app is built to draw a couple text boxes, a rectangle that moves on every render and a quick FPS calculation. It is set to render this on a 1ms timer. Code below:
- Brian
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
namespace GraphicsDebugger
{
public class BaselineWindow : Window
{
public long tickStart, frames;
public int x, xd;
public Pen Pen;
public Brush Brush;
public DispatcherTimer Timer;
public BaselineWindow()
{
Pen = new Pen(Colors.Black);
Brush = new SolidColorBrush(Colors.Orange);
Timer = new DispatcherTimer();
Timer.Tick += Timer_Tick;
Timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
Timer.Start();
xd = 20;
tickStart = DateTime.Now.Ticks;
}
void Timer_Tick(object sender, EventArgs e)
{
Invalidate();
}
public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc)
{
base.OnRender(dc);
frames++;
dc.DrawText("Frames: " + frames.ToString(), Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 10);
long seconds = (DateTime.Now.Ticks-tickStart) / (10*1000*1000); // ticks are in 100 nanoseconds
dc.DrawText("Seconds: " + seconds, Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 50);
if (seconds > 0)
{
long fps = frames / seconds;
dc.DrawText("FPS: " + fps, Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 170);
}
if (x >= 480 - 100)
{
xd = -20;
}
if (x <= 0)
{
xd = 20;
}
x += xd;
dc.DrawRectangle(Brush, Pen, x, 120, 100, 50);
}
}
}