using System;
using System.Threading;
using System.IO.Ports;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace Domino___Serial {
public class Program {
static int counter = 0;
public static void Main() {
SerialPort UART = new SerialPort("COM1", 57600);
UART.Open();
while (true) {
string comanda = "Counter: " + (counter++) + "\r";
byte[] buffer = Encoding.UTF8.GetBytes(comanda);
UART.Write(buffer, 0, buffer.Length);
// Sleep for 0 milliseconds
Thread.Sleep(00);
}
}
}
}
I’m a bit sad at how slow it runs - it was a lot faster on the Arduino (see here: Life on TV with Arduino and TellyMate - YouTube). Maybe I’m doing something obviously wrong in the code - I’ve only been writing C# a couple of days so it’s quite possible.
Now I think the bottleneck is the 57k6 serial connection to the TellyMate shield. I’ve done some optimization of how the characters are transferred but there might be more to be had.
Just looking at your src, maybe the drawing routine could be adapted to do a whole row at a time or alternativly do a clear screen & home - before the draw and just ignore drawing blank spaces.
I [italic]think[/italic] the current limiting factor speedwise is how fast you can send characters to the TellyMate shield - it’s official top speed is 57600 baud, which is 5760 characters a second. The grid is 38x25 which is 950 characters, therefore if they all change (so you have to display each one) the theoretical maximum refresh rate is 6 frames a second. Plus you have to send some control characters which adds even more bytes. Luckily in a typical Life generation far fewer than 100% of the cells change - this gives us some wiggle room for optimisations.
I hadn’t thought of CLS then only draw the non-blank cells - I’ll have to give it some thought.