Managed Graphics and LED Dot Matrix Display

I have had some success in implementing the managed graphics (see Managed graphics for non-TFT displays in TinyCLR) for a 32 x 16 pixel LED display (https://www.jaycar.com.au/red-led-dot-matrix-display-for-arduino/p/XC4621) adapting the Arduino code from 32x16 Red Dot Matrix Display | Freetronics. There is not a lot of information available on this display.

As the display needs to be refreshed, the controller level code (FlushBuffer()) copies the display buffer to the device on a timer event, while the DrawTarget Flush() calls the controller’s DrawBuffer() which copies the DrawTarget buffer into the controller’s display buffer. As the display is small and uses 1 bit per pixel it is not huge memory impact. The code is designed to handle multiple panels but I have not tested this (only have one panel :grinning:).

The code needs a bit of a clean up, implement the text functions, and introduce pwm to allow brightness control.

May I suggest some additional Display DataFormats: Mono - 1 bit per pixel, and Grey - 1 byte per pixel.

The top level code is:

using System;
using System.Collections;
using System.Text;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Spi;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Pins;
using GHIElectronics.TinyCLR.Devices.Display;
using GHIElectronics.TinyCLR.Drawing;
using System.Drawing;

namespace LED32x16Test
{
    class Program
    {
        static void Main()
        {
            SpiController spi = SpiController.FromName(FEZPandaIII.SpiBus.Spi1);
            GpioController gpio = GpioController.GetDefault();
            SpiDevice spi_device = spi.GetDevice(LED32x16Controller.GetConnectionSettings(SpiChipSelectType.Gpio, FEZPandaIII.GpioPin.D20));
            LED32x16Controller ledmatrix = new LED32x16Controller(spi_device, gpio.OpenPin(FEZPandaIII.GpioPin.D21), gpio.OpenPin(FEZPandaIII.GpioPin.D22), gpio.OpenPin(FEZPandaIII.GpioPin.D23), 1, 1);

            DisplayController disp = DisplayController.FromProvider(ledmatrix);

            disp.SetConfiguration(new SpiDisplayControllerSettings { Width = 32, Height = 16 });

            IntPtr hdc = GraphicsManager.RegisterDrawTarget(new DrawTarget(disp));
            var screen = Graphics.FromHdc(hdc);

            Pen color = new Pen(Color.Red);
            ledmatrix.Enable();
            Thread.Sleep(2000);

            screen.DrawLine(color, 0, 0, 10, 0);
            screen.DrawLine(color, 0, 3, 30, 3);
            screen.DrawEllipse(color, 10, 5, 5, 5);
            screen.DrawRectangle(color, 1, 1, 20, 10);
            screen.Flush();

            Thread.Sleep(10000);

            screen.Clear(Color.Black);
            screen.Flush();

        }
    }
}
7 Likes

I have not tested the drivers with 1bbp displays but I know the team have used it with BrainPad. I am glad to hear you have success as well.

What kind of board are you using?
I’ve drawer filled with led panels, mostly driven by HT1632x chips…