Here is my test code:
(Program.cs)
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using GHIElectronics.NETMF.Hardware;
namespace BSTDigitalBoard
{
public class DigitalBoard
{
//Boolean TouchCalibrationFlag = true;
public static void Main()
{
// if the target is the emulator, skip the GHI LCD initialization
if (SystemInfo.SystemID.Model != 2)
{
Configuration.LCD.Configurations lcdConfig = new Configuration.LCD.Configurations();
lcdConfig.Width = 800;
lcdConfig.Height = 480;
// Only use if needed, see documentation.
lcdConfig.PriorityEnable = true;
lcdConfig.OutputEnableIsFixed = false;
lcdConfig.OutputEnablePolarity = true;
lcdConfig.PixelPolarity = false;
lcdConfig.HorizontalSyncPolarity = false;
lcdConfig.VerticalSyncPolarity = false;
lcdConfig.HorizontalSyncPulseWidth = 150;
lcdConfig.HorizontalBackPorch = 150;
lcdConfig.HorizontalFrontPorch = 150;
lcdConfig.VerticalSyncPulseWidth = 2;
lcdConfig.VerticalBackPorch = 2;
lcdConfig.VerticalFrontPorch = 2;
lcdConfig.PixelClockDivider = 3;
// Set config
if (Configuration.LCD.Set(lcdConfig) && Configuration.Heap.SetCustomHeapSize(4 * 1024 * 1024))
PowerState.RebootDevice(false);
Configuration.LCD.SetRotation(Configuration.LCD.Rotation.Rotate_CW_90);
}
AppControl BSTApp = new AppControl();
Thread.Sleep(-1);
}
}
}
(AppControl.cs)
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
namespace BSTDigitalBoard
{
class AppControl
{
private BaseBitmap ScreenBuffer;
private Timer ScreenUpdateTimer;
TimeSpan timerspan = new TimeSpan(0, 0, 0, 0, 50);
TimerCallback ScreenUpdateTimerCallback;
Boolean ScreenFlag = false, ScreenBufferUpdate = false;
private Timer BackgroundUpdateTimer;
TimeSpan bkspan = new TimeSpan(0, 0, 0, 0, 2000);
TimerCallback BKUpdateTimerCallback;
public AppControl()
{
ScreenBuffer = new BaseBitmap();
ScreenUpdateTimerCallback = new TimerCallback(ScreenTimerCallback);
ScreenUpdateTimer = new Timer(ScreenUpdateTimerCallback, null, timerspan, timerspan);
BKUpdateTimerCallback = new TimerCallback(BKTimerCallback);
BackgroundUpdateTimer = new Timer(BKUpdateTimerCallback, null, bkspan, bkspan);
}
public void BKTimerCallback(Object sender)
{
if (ScreenFlag)
{
ScreenBuffer.SetBackground(Colors.White);
ScreenFlag = false;
}
else
{
ScreenBuffer.SetBackground(Colors.Blue);
ScreenFlag = true;
}
ScreenBufferUpdate = true;
}
public void ScreenTimerCallback(Object sender)
{
if (ScreenBufferUpdate)
{
ScreenBuffer.Buffer.Flush();
ScreenBuffer.Buffer.Dispose();
ScreenBufferUpdate = false;
}
}
}
}
(BaseBitmap.cs)
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
namespace BSTDigitalBoard
{
public class BaseBitmap
{
private const Color BlueBackground = (Color)0x8F0000;
public Bitmap Buffer;
public BaseBitmap()
{
}
public void SetBackground(Color c)
{
Buffer = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
Buffer.DrawRectangle(c,
0,
0, 0,
SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight,
0, 0,
c,
0, 0,
c,
0, 0,
Bitmap.OpacityOpaque);
}
}
}
I added the call to Dispose(), but that had no noticeable effect nor did adding the call to change the CustomHeap size.