Gadgeteer Display N18

Is there any sample Code for this Display?
I got my Reaper running on TinyCLR already.

Thank you in advance

It is the same display used here http://old.ghielectronics.com/downloads/BrainPad/BrainPad.cs

I’m sorry, but it seems that I am too stupid to change the old Code to TinyCLR.
I tried to extract the Display - Class but I found no way to change the definitions for SPI und OutputPort.
I also tried the TinyCLR Brainpad routines but they seem to use another Port.
As I am a fulltime working teacher I have too limited time to dig deeper.
I would be very thankful if you would publish classes for the Gadgeteer - Modules including the displays.
May be you did so already, and I did not find them.
By the way, Can I use the Brainpad code also for the old Brainpad?

Thank you in advance

Let me try to help http://docs.ghielectronics.com/tinyclr/tutorials/spi.html

Yes the new everything works on everything old, including the BrainPad :nerd:

Ok,
I took the Code from

http://old.ghielectronics.com/downloads/BrainPad/BrainPad.cs

and the new one from

https://github.com/ghi-electronics/TinyCLR-Accessories/tree/master/AdafruitDisplayShield

and combined them as far as I could…
I did the following ( FEZ-Reaper with Display at Socket 8):

public static class Display
    {
        /*
        private static SPI spi;
        private static OutputPort controlPin;
        private static OutputPort resetPin;
        private static OutputPort backlightPin;
        */
        static GpioPin controlPin = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.FEZReaper.GpioPin.Socket8.Pin5);
        static GpioPin resetPin = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.FEZReaper.GpioPin.Socket8.Pin3);
        static GpioPin backlightPin = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.FEZReaper.GpioPin.Socket8.Pin4);

        private static SpiDevice spi;


and later:

controlPin.SetDriveMode(GpioPinDriveMode.Output);

            //  var settings = new SpiConnectionSettings(ChipSelect);
            var settings = new SpiConnectionSettings(FEZReaper.GpioPin.Socket8.Pin5);

            settings.Mode = SpiMode.Mode3;
            settings.ClockFrequency = 4000;
            settings.DataBitLength = 8;
            //var aqs = SpiDevice.GetDeviceSelector("SPI1");
            spi = SpiDevice.FromId(FEZReaper.SpiBus.Socket8, settings);

            Reset();

My main routine is:

using System;
using System.Collections;
using System.Text;
using System.Threading;
using GHIElectronics.TinyCLR.Pins;

using Gadgeteer.DisplayN18;

namespace DisplayN18_01
{
class Program
{
static void Main()
{
Display.Clear();
Display.TurnOn();
//Display;// DisplayShield;
int i = 0;
Display.DrawLargeText(20, 30, “TinyCLR OS”, Color.Green);
while (true)
{
Display.DrawText(30, 60, "Count: " + i++, Color.Magenta);
Thread.Sleep(10);
}
}
}
}

So far it is compiled, downloaded and started with out any problem, except that there is nothing to see on the display.
I hope you have some more suggestions for me.

Hello mflume,
I don’t see anywhere in the code where you actually tell the screen to display, like this:

Display.ShowOnScreen();

this would come after you Display.DrawText();

and before the
Thread.Sleep(10);

Hm…
this is an example from Gus.
:wink:
I#ll try your hint. Thank you.

the

Display.ShowOnScreen();

command does not exist in Gus’ library…

1 Like

…I got it!

the line:

var settings = new SpiConnectionSettings(FEZReaper.GpioPin.Socket8.Pin5);

must be:

var settings = new SpiConnectionSettings(FEZReaper.GpioPin.Socket8.Pin6);

now it works!

…next question:
is there a way to pass the used board to the “Display” - Construktor so that I can use the same library for different boards (Reaper, Cerberus, Spider, etc) and different sockets?

…is no one able to answer?

The answer is yes you can. The driver was made for the BrainPad but you can completely change to for your needs.

I hoped to get an answer how.
:frowning2:
As far as I found out there is no way to send the board and port to the constructor as parameter.
Or am I wrong??

You can use this if you want:

DisplayN18 is done.

1 Like

Thank you!

And here’s how to fish :slight_smile:

Look at the Using Constructors - C# Programming Guide | Microsoft Learn “Employee” class on this page. It has two constructors defined, one that takes only a salary, one that takes a salary and a number of weeks. You’d want to do the same; add a constructor that takes the needed objects like SPI channel and pins for CS, backlight, control etc.

sorry, it maybe that I am misunderstood. I would like to have a Constructor like this:

    Display (FEZBoard board, FEZBoard.Port port)

so that I can make an instance like:

Display display = new Display (FEZReaper,port8)

Until now I found no way to do so. In my implementation and the ones I found here I always have to change the Display class if I want to change board and / or Port.
As with the Module the pins are fixed, there is no need to change the pins.

Why do you need to pass in the Board?

rule #1 code for restricted embedded devices should be as small as possible

We use different boards in different classrooms. At least it would be neccessary to change the Port (which would include the board).
For my pupils - as they are absolute beginners . it is too difficult to change this in the sourcecode of the display - class.
This is also true for endless parameters like:

GpioPin resetPin = GpioController.GetDefault().OpenPin(
GHIElectronics.TinyCLR.Pins.FEZReaper.GpioPin.Socket8.Pin3);

I could make a class for each board we use but not for the port.