@ Darko - Well, I’ve tried sofar to start it with just a CerbuinoBee (168MHz) and the result is somewhat, well there is room for improvement.
My next try is to let the LED Matrix be controlled by the Arduino with just 16 MHz. I’ve seen it working with a Teensy, RPi, Arduino, even an STM32F401 but all with compiled code.
So I recon RLP has to be called to the resque, ehm, dunno, never done before …
The code is pretty simple, maybe to … any performance tips are more than welcome …
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;
namespace conPortTest1
{
public class Program
{
// Define port easy readers
// Data
static OutputPort Red1 = new OutputPort(LedMatrix.Data.RedOne, false);
static OutputPort Red2 = new OutputPort(LedMatrix.Data.RedTwo, false);
static OutputPort Green1 = new OutputPort(LedMatrix.Data.GreenOne, false);
static OutputPort Green2 = new OutputPort(LedMatrix.Data.GreenTwo, false);
static OutputPort Blue1 = new OutputPort(LedMatrix.Data.BlueOne, false);
static OutputPort Blue2 = new OutputPort(LedMatrix.Data.BlueTwo, false);
// Row selectors
static OutputPort Row1 = new OutputPort(LedMatrix.Rows.First, false);
static OutputPort Row2 = new OutputPort(LedMatrix.Rows.Second, false);
static OutputPort Row3 = new OutputPort(LedMatrix.Rows.Third, false);
static OutputPort Row4 = new OutputPort(LedMatrix.Rows.Fourth, false);
// Controls
static OutputPort CLK = new OutputPort(LedMatrix.Control.Clock, false);
static OutputPort LAT = new OutputPort(LedMatrix.Control.Latch, false);
static OutputPort OE = new OutputPort(LedMatrix.Control.OutputEnable, false);
// Arrays to put the RGB info into
static Int32[] RedBuffer = new Int32[32];
static Int32[] GreenBuffer = new Int32[32];
static Int32[] BlueBuffer = new Int32[32];
// Working vars
static Int32 _Data1;
static Int32 _Data2;
static Int32 _Data3;
static Int32 _Data4;
static Int32 _Data5;
static Int32 _Data6;
// Some test data to display
#region TestData
static Int32[] DemoDataRed = new Int32[32]
{
0x00000000,
0x00000000,
0x22FBE8BE,
0x22808DA0,
0x00000000,
0x2AE088B8,
0x268088A0,
0x00000000,
0x22F888A0,
0x00000000,
0x00000000,
0x00000000,
0x02113810,
0x15114454,
0x0E114038,
0x3B9138EE,
0x0E110438,
0x150A4454,
0x02043810,
0x00000000,
0x00000000,
0x00000000,
0x0E000000,
0x11000000,
0x01000000,
0x02000000,
0x04000000,
0x08000000,
0x1F000000,
0x00000000,
0x00000000,
0x00000000
};
static Int32[] DemoDataGreen = new Int32[32]
{
0x00000000,
0x00000000,
0x00000000,
0x22808DA0,
0x00000000,
0x00000000,
0x268088A0,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x02000010,
0x15000054,
0x0E000038,
0x3B8000EE,
0x0E000038,
0x15000054,
0x02000010,
0x00000000,
0x00000000,
0x00000000,
0x001C1000,
0x00223000,
0x00225000,
0x00221000,
0x00221000,
0x00221000,
0x001C7C00,
0x00000000,
0x00000000,
0x00000000
};
static Int32[] DemoDataBlue = new Int32[32]
{
0x00000000,
0x00000000,
0x00000000,
0x22808DA0,
0x32808AA0,
0x00000000,
0x268088A0,
0x228088A0,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00113800,
0x00114400,
0x00114000,
0x00113800,
0x00110400,
0x000A4400,
0x00043800,
0x00000000,
0x00000000,
0x00000000,
0x000000FC,
0x00000080,
0x00000080,
0x000000F8,
0x00000004,
0x00000084,
0x00000078,
0x00000000,
0x00000000,
0x00000000
};
#endregion
public static void Main()
{
Debug.Print(Resources.GetString(Resources.StringResources.String1));
// Fill the buffers
for (int i = 0; i < RedBuffer.Length; i++)
{
RedBuffer[i] = DemoDataRed[i];
GreenBuffer[i] = DemoDataGreen[i];
BlueBuffer[i] = DemoDataBlue[i];
}
// Copy the data from the buufer to the matrix
//while (true != false)
//{
loop:
// For all rows
for (int idy = 0; idy < 16; idy++)
{
// Copy the the first and the 16th row to
// the one and two data channels per color
_Data1 = RedBuffer[idy];
_Data2 = RedBuffer[idy + 16];
_Data3 = GreenBuffer[idy];
_Data4 = GreenBuffer[idy + 16];
_Data5 = BlueBuffer[idy];
_Data6 = BlueBuffer[idy + 16];
// Now shift the bits into the data channels last bit first
// Get bit 31 down to bit 0
int q = 0;
int tmp = 0;
for (int idx = 0; idx < 32; idx++)
{
q = 1;
q = q << (31 - idx);
tmp = RedBuffer[idy] & q;
Red1.Write((_Data1 & q) != 0 ? true : false);
Red2.Write((_Data2 & q) != 0 ? true : false);
Green1.Write((_Data3 & q) != 0 ? true : false);
Green2.Write((_Data4 & q) != 0 ? true : false);
Blue1.Write((_Data5 & q) != 0 ? true : false);
Blue2.Write((_Data6 & q) != 0 ? true : false);
// Force a falling edge
CLK.Write(true);
CLK.Write(false);
}
// Set the appropriate row active
Row1.Write((idy & 0x01) != 0 ? true : false);
Row2.Write((idy & 0x02) != 0 ? true : false);
Row3.Write((idy & 0x04) != 0 ? true : false);
Row4.Write((idy & 0x08) != 0 ? true : false);
// Latch the info through
LAT.Write(true);
LAT.Write(false);
// Wait for a bit and do an output enable cycle
OE.Write(false);
Thread.Sleep(1);
OE.Write(true);
}
goto loop;
//}
}
}
}