Main Site Documentation

Gadgeteer Display N18


#1

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

Thank you in advance


#2

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


#3

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


#4

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:


#5

Ok,
I took the Code from

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

and the new one from

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.


#6

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);


#7

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


#8

the

Display.ShowOnScreen();

command does not exist in Gus’ library…


#9

…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!


#10

…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?


#11

…is no one able to answer?


#12

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


#13

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??


#14

You can use this if you want:


DisplayN18 is done.


#15

Thank you!


#16

And here’s how to fish :slight_smile:

Look at the https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/using-constructors “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.


#17

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.


#18

Why do you need to pass in the Board?


#19

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


#20

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.