Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Information on Nwazet Display Go! module


  • Please log in to reply
34 replies to this topic

#1 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 12 April 2012 - 01:50 AM

I came across a few questions on the Nwazet Display Module for the Netduino Go!: 1. Does the display need to be calibrated before usage? 2. Are pictures other than bitmaps supported? 3. Is it possible to display serial video, say mJpeg or H.264 at a relatively low frame rate? I am sure that most will want to get this display, the display test program has a lot of stuff in it, I am still working my way through it. Thanks for a great module, Chuck

#2 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 12 April 2012 - 02:24 AM

I may have found the answer to the re-calibration. It looks like a manual calibration is done each time you re-boot if an SD card or other storage is not available to store the calibration data. When I watched the output window the following was displayed, "SD Card or file I/O error: manual calibration required."

#3 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 12 April 2012 - 06:19 AM

Yup :) I indicated that in the source code. This is a fact of life with touchscreens but only needs to be done (correctly) once. Cheers. -Fabien. PS: please note that calibration is only needed when using the touchscreen. It's not required if you only want to write to the display.

#4 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 12 April 2012 - 06:26 AM

Are pictures other than bitmaps supported?




Yes: raw 16-bit / pixel bitmaps.


3. Is it possible to display serial video, say mJpeg or H.264 at a relatively low frame rate?




If you can convert mpeg frames or H.264 frame to raw 16-bit bit streams, you can, even though the frame rate will be limited by the bandwidth provided by SPI as well as the size of the (8KB) buffer currently used. Nothing prevents you from tuning the firmware for your application (Ah! The beauty of OSS Posted Image!)

Cheers,
-Fabien.

#5 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 13 April 2012 - 03:31 AM

Has anyone written Visual Basic code to use with the Nwazet Display module.

I want to be able to send temperatures and information to the display instead of the output screen.

I have start to port pieces from C# (NwazetDisplayModule program) to Visual Basic but have run into problems declaring and using the Font to be used.

My code so far is:
Imports System
Imports System.IO
Imports System.Threading
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoGo
Imports Nwazet.Go.Helpers
Imports Nwazet.Go.Fonts
Imports Nwazet.Go.Imaging
Imports Nwazet.Go.Display.TouchScreen

Namespace Basic_go_display

    Public Module Module1
    Dim ColorBackground As Integer = BasicColor.Black
    Dim lastTouchX As Integer
    Dim lastTouchY As Integer

    Public ReadOnly CornerStyle As VirtualCanvas.RoundedCornerStyle = 
      VirtualCanvas.RoundedCornerStyle.All

    Public Sub Main()
      Dim canvas = New VirtualCanvas(AddressOf TouchEventHandler, AddressOf WidgetClickedHandler)
      Debug.Print(Resources.GetString(Resources.StringResources.String1))
      Debug.EnableGCMessages(True)
      Debug.Print("Available RAM: " + Debug.GC(True).ToString() + " bytes.")
      Debug.EnableGCMessages(False)
      canvas.Initialize(GoSockets.Socket5)
      canvas.TouchscreenCalibration()
      BasicTouchEventTest(canvas)
      canvas.Reboot()
      canvas.Dispose()
    End Sub

    Public Sub TouchEventHandler(ByVal touchEvent As TouchEvent)
      Debug.Print("------------TouchEventHandler------------")
      Debug.Print("X: " & touchEvent.X.ToString)
      Debug.Print("Y: " & touchEvent.Y.ToString)
      Debug.Print("Pressure: " & touchEvent.Pressure.ToString)
      lastTouchX = touchEvent.X
      lastTouchY = touchEvent.Y
    End Sub

    Public Sub WidgetClickedHandler(ByVal widget As Widget, ByVal touchEvent As TouchEvent)
    End Sub

    Public Sub BasicTouchEventTest(ByVal canvas As VirtualCanvas)
      Dim message = "Josh Clean the Kitchen!"
      Dim fontInfo As Font = New VerdanaBold14.GetFontInfo
      Dim stringLength As UShort = fontInfo.GetStringWidth(message)
      canvas.SetOrientation(VirtualCanvas.Orientation.Landscape)
      canvas.DrawFill(CUShort(ColorBackground))
      canvas.DrawString(CUShort(canvas.Width - stringLength) / 2, canvas.Height / 2, CUShort
        (BasicColor.Blue), fontInfo.ID, message)
      canvas.TouchscreenWaitForEvent()
      canvas.DrawCircleFilled(lastTouchX, lastTouchY, 4, CUShort(BasicColor.Red))
      canvas.Execute()
      canvas.SetOrientation(VirtualCanvas.Orientation.Portrait)
      Thread.Sleep(1000)
    End Sub
  End Module
End Namespace
I am getting the following errors (3 currently):

1 Value of type 'Basic_go_display.VerdanaBold14.GetFontInfo' cannot be converted to 'Microsoft.SPOT.Font'.
Program.vb 48 30 Basic go display
3 'ID' is not a member of 'Microsoft.SPOT.Font'. Program.vb 52 112 Basic go display
2 'GetStringWidth' is not a member of 'Microsoft.SPOT.Font'. Program.vb 49 36 Basic go display

I have visual basic code using the Onboard Button, Button Module, RGB Led Module, Potentiometer Module.
It is still pretty basic (no pun intended) but the button cycles through 7 colors and off with the
Pot controlling the brightness of the LED.

Imports System.Threading
Imports NetduinoGo
Imports SecretLabs.NETMF.Hardware.NetduinoGo
Imports GoBus

Module Module1

    Sub Main()
    Dim Led As RgbLed = New RgbLed
    Dim PB As Button = New Button
    'Dim PB As InputPort = New InputPort(Pins.Button, True, Port.ResistorMode.Disabled)'Onboard
      'Button
    Dim Pot As Potentiometer = New Potentiometer
    Dim i As Integer = 0
    Dim ColorValue As Byte

    While True
      ColorValue = CByte(255 * Pot.GetValue)
      If PB.ButtonState Then
        i = i + 1
        If i > 7 Then
          i = 0
        End If
        Thread.Sleep(250)' prevents button bounce between colors
      End If
      Thread.Sleep(100)' slows sample rate of the poteniometer.
      Select Case i
        Case 0
          Led.SetColor(0, 0, 0) ' off
        Case 1
          Led.SetColor(ColorValue, 0, 0) ' red
        Case 2
          Led.SetColor(0, ColorValue, 0) ' green
        Case 3
          Led.SetColor(0, 0, ColorValue) ' blue
        Case 4
          Led.SetColor(ColorValue, ColorValue, 0) ' yellow
        Case 5
          Led.SetColor(0, ColorValue, ColorValue) ' cyan
        Case 6
          Led.SetColor(ColorValue, 0, ColorValue) ' purple
        Case 7
          Led.SetColor(ColorValue, ColorValue, ColorValue) ' white
      End Select
    End While
  End Sub
End Module
Thanks for any help,
Chuck

#6 emg

emg

    Advanced Member

  • Members
  • PipPipPip
  • 129 posts

Posted 13 April 2012 - 08:29 AM

Not yet, still waiting for my screen to arrive. I've had to resort to writing some functions in C# as their VB equivalent is missing (try decoding a NTP time byte string in VB only!) BTW, can you fix your code /code tags in your post, it scrolls off the right of my screen!

#7 Bertrand Le Roy

Bertrand Le Roy

    New Member

  • Members
  • Pip
  • 7 posts

Posted 14 April 2012 - 12:28 AM

I don't think the errors you are seeing have anything to do with your using VB. You are more likely missing references.

#8 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 14 April 2012 - 12:41 AM

I don't think the errors you are seeing have anything to do with your using VB. You are more likely missing references.


I belive that you are correct, I still haven't found the location in the C# files that contain the font definitions, it looks like the calls are going to Microsoft.SPOT.Font instead of where it is supposed to go.

I will keep looking for it.

Thanks Bertrand,

Chuck

#9 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 14 April 2012 - 12:55 AM

Carb, So you know, I'm not using anything that has to do with Micorsoft.SPOT.Font. The font definitions in the C# code are only used to track the variables sizes of the characters in each font. The actual fonts are in the display's firmware. This makes things very efficient for display as the C# code only passes a font ID to reference a given font when needed. Hope it helps. -Fabien.

#10 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 14 April 2012 - 02:19 AM

Carb,

So you know, I'm not using anything that has to do with Micorsoft.SPOT.Font.
The font definitions in the C# code are only used to track the variables sizes of the characters in each font.
The actual fonts are in the display's firmware. This makes things very efficient for display as the C# code only passes a font ID to reference a given font when needed.

Hope it helps.

-Fabien.

Thanks Fabien,

I got it to work, some of the problem I had after I got the code right was with the referrence path for the .PE files. I took the file names that my program couldn't find, searched for them on the drive. I picked the file that was used by your program, Checked the Properties, and Put that path into the Reference Path (C:/...debug/) at first I included the /le. When I looked at the error it had C:/.../le/LE/ so I went back to c:/.../Debug/.

The code that works is:
Imports System
Imports System.IO
Imports System.Threading
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoGo
Imports Nwazet.Go.Helpers
Imports Nwazet.Go.Fonts
Imports Nwazet.Go.Imaging
Imports Nwazet.Go.Display.TouchScreen

Namespace Basic_go_display

    Public Module Module1
    Public ReadOnly ColorBackground As UShort = CUShort(BasicColor.Blue)
    Dim lastTouchX As Integer
    Dim lastTouchY As Integer

    Public Sub Main()
      Dim canvas = New VirtualCanvas(AddressOf TouchEventHandler, AddressOf WidgetClickedHandler)
      Debug.Print(Resources.GetString(Resources.StringResources.String1))
      Debug.EnableGCMessages(True)
      Debug.Print("Available RAM: " + Debug.GC(True).ToString() + " bytes.")
      Debug.EnableGCMessages(False)
      canvas.Initialize(GoSockets.Socket5)
      canvas.TouchscreenCalibration()
      BasicTouchEventTest(canvas)
      canvas.Reboot()
      canvas.Dispose()
    End Sub

    Public Sub TouchEventHandler(ByVal touchEvent As TouchEvent)
      Debug.Print("------------TouchEventHandler------------")
      Debug.Print("X: " & touchEvent.X.ToString)
      Debug.Print("Y: " & touchEvent.Y.ToString)
      Debug.Print("Pressure: " & touchEvent.Pressure.ToString)
      lastTouchX = touchEvent.X
      lastTouchY = touchEvent.Y
    End Sub

    Public Sub WidgetClickedHandler(ByVal widget As Widget, ByVal touchEvent As TouchEvent)
    End Sub

    Public Sub BasicTouchEventTest(ByVal canvas As VirtualCanvas)
      Dim message = "Josh Clean the Kitchen!"
      Dim fontInfo = New Verdana14().GetFontInfo()
      Dim stringLength = fontInfo.GetStringWidth(message)
      canvas.SetOrientation(VirtualCanvas.Orientation.Landscape)
      canvas.DrawFill(CUShort(ColorBackground))
      canvas.DrawString(CUShort((canvas.Width - stringLength) / 2), CUShort(canvas.Height / 2), CUShort(BasicColor.White), fontInfo.ID, message)
      canvas.TouchscreenWaitForEvent()
      canvas.Execute()
      canvas.SetOrientation(VirtualCanvas.Orientation.Portrait)
    End Sub
  End Module
End Namespace
I got a lot of help in the code translation from this link http://converter.telerik.com/
It will convert from C# to VB.Net or VB.Net to C#. It saved me a lot of reading and headaches.

I still have some warnings of a possible overflow without an exception, but for what I am doing it should not occur.

Thanks for the help,
Chuck

#11 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 15 April 2012 - 04:26 PM

Good morning Fabien,

I came up with another question. :rolleyes:

Currently I am using canvas.Initialize(GoSockets.Socket4) to Initialize the Nwazet Display Module. Is there a way to Initialize the display without specifing the socket to be used?

I want to be able to plug in the display module and let the Netduino Go main board find the display module.

Thanks,
Chuck

#12 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 16 April 2012 - 12:36 AM

Hi Charles,

Is there a way to Initialize the display without specifing the socket to be used?



Nope: to initialize a module you must have a socket associated with it.


I want to be able to plug in the display module and let the Netduino Go main board find the display module.




That's a different thing: you could send an SPI query identical to the one used in canvas.Initialize() to retrieve the module's ID and take it from there if it corresponds to the display.


What is the scenario for doing this?

#13 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 16 April 2012 - 12:55 AM

Hi Charles,




Nope: to initialize a module you must have a socket associated with it.





That's a different thing: you could send an SPI query identical to the one used in canvas.Initialize() to retrieve the module's ID and take it from there if it corresponds to the display.


What is the scenario for doing this?

Thanks for the reply Fabien,

It is not a particular problem, I just thought that with the exception of the Shield Base (only while still in beta) you could plug any module into any of the sockets.

But if I understand you correctly you need to hard code the LCD display module to a given socket.

I looked for a way to have it figure out which socket it was plugged into but could not find one.

Chuck

#14 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 16 April 2012 - 03:25 AM

Hi Chuck, Sorry that I wasn't clear. Nothing is hard-coded. you can plug the display into any socket you like. You just need to specify which one it is in the initialization call. -Fabien.

#15 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 19 April 2012 - 07:09 PM

Hi Fabien, Is there a way do change the brightness of the screen? I don't see any methods in your source code that would expose this feature. In any case, I've been having a blast with it. Cheers, Steve

#16 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 21 April 2012 - 05:38 PM

Hi Steve,

There isn't one in this revision of the module and here's why: the ILI9341 IC driver of the display I'm using does have a PWM backlight control circuit that is configurable through software commands (Write Display Brightness (51h) page 141 of the datasheet). The manufacturer of the display omitted to connect it to the backlight Posted Image I discovered this when the module board was already in production as I was focusing on the finishing touches of the driver. At that point, it was too late to change the design. The display manufacturer recognized the omission and did say that they would correct the mistake in a future revision of the display.

-Fabien.

#17 EricMeyer

EricMeyer

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationAllen, Texas

Posted 21 April 2012 - 06:45 PM

You need to update your example code for those of us without a SD card. (Especially since SD modules aren't available yet ... grin) The existing demo worked to a point and then crashed when trying to unmount a SD card that it had never successfully mounted. I commented out that line and was able to run the rest of the tests. -Eric

#18 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 21 April 2012 - 07:33 PM

Hi Eric,

SD cards modules aren't available yet but it's easy to connect one Posted Image
http://fabienroyer.w...ng-out-sockets/
http://fabienroyer.w...-to-a-netduino/

I'm surprised to hear that the demo 'crashes' because the 2 places where the SD is referenced use a try / catch :


        public static void BmpImageTest(VirtualCanvas canvas) {
            try {
                var sd = new SDCardReader();
                sd.Initialize(GoSockets.Socket8);
                DisplayBmpPicture(canvas, @"Nwazet\03.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\05.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\09.bmp");
                canvas.SetOrientation(Orientation.Landscape);
                DisplayBmpPicture(canvas, @"Nwazet\00.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\01.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\02.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\04.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\06.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\07.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\08.bmp");
                sd.Dispose();
            }catch(Exception e){
                Debug.Print(e.Message);
                Debug.Print("You need an SD card loaded with the demo photos to run this part of the demo.");
            }
        }


Here's the output when running w/o an SD card reader


Available RAM: 88380 bytes.
A first chance exception of type 'System.IO.IOException' occurred in SecretLabs.NETMF.IO.dll
SD Card or file I/O error: manual calibration required.
A first chance exception of type 'System.ApplicationException' occurred in Nwazet.Go.SD.dll
socket already bound
You need an SD card loaded with the demo photos to run this part of the demo.
<...>

Which specific line did you comment out? I'll gladly update the demo code if I can repro the issue.

Cheers,
-Fabien.

#19 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 27 April 2012 - 04:40 PM

Is it possible to design your own fonts? Looking at the fonts in the display project, I can see the descriptor contains two integers representing the address and the width in pixels, but where are the actual bit maps defined? For one of my readouts I'd like to have a large 100-120pt font, maybe even like an old 7 seg display style. I'm just not seeing where the bitmap arrays are.

#20 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 27 April 2012 - 05:33 PM

Just got mine in late yesterday and had some initial questions. I'm sure I'll find more as I dig deeper.

1) If I do a touch calib in debug mode and capture the calibration matrix, can it be "good enough" for other displays? I bought two and tested this and at least with these two, the calibration profiles seem to work.

private static void CalibrateTouchScreen()
        {
            byte[] calib=new byte[33]{0	,0	,3	,0	,33	,0	,5	,229	,192	,0	,0	,1	,128	,174	,6	,50	,80	,255	,255	,133	,0	,0	,7	,133	,128	,148	,104	,208	,64	,255	,177	,35	,14	}; // change to =null or new byte[0] to get initial calibration
            if (calib != null && calib.Length > 0)
            {
                BasicTypeDeSerializerContext b = new BasicTypeDeSerializerContext(calib);
                var matrix = new CalibrationMatrix();
                matrix.Get(B);
                Screen.SetTouchscreenCalibrationMatrix(matrix);
            }
            else
            {
                Screen.TouchscreenCalibration();
                var matrix = Screen.GetTouchscreenCalibrationMatrix();
                if (matrix != null)
                {
                    BasicTypeSerializerContext b = new BasicTypeSerializerContext();
                    matrix.Put(B);
                    int x;
                    calib = b.GetBuffer(out x);                   
                    // break point here in debug mode and view calib
                }
            }
        }

2) How do you poll for a touch event so you don't block your main thread? I tried
Screen.TouchscreenWaitForEvent();                
Screen.Execute(Synchronicity.Asynchronous);
Which seems to work the very first time, but doesn't get any touch events after that.
static int CenterX=240/2;
static int CenterY=320/2;
static int CirleRadius=240/4;
static BasicColor BottomColor=BasicColor.White;
static BasicColor TopColor=BasicColor.Green;
private static void ScreenTouched(object o, TouchEvent e)
{
if(BottomColor==BasicColor.White)
  BottomColor=BasicColor.Blue;
else
  BottomColor=BasicColor.White;
Screen.DrawCircleFilled(CenterX, CenterY+CircleRadius, CircleRadius, (ushort)BottomColor);
}
public static void Main()
{            
Screen.Initialize(GoSockets.Socket1);
CalibrateTouchScreen();
Screen.SetOrientation(Orientation.Portrait);
Screen.DrawFill((ushort)BasicColor.Black);
Screen.Execute();
while(true)
  {
  Screen.TouchscreenWaitForEvent();
  Screen.Execute(Synchronicity.Asynchronous); // if I get rid of Asynchronous, it blocks here
  if(TopColor==BasicColor.Green)
    TopColor=BasicColor.Red;
  else
    TopColor=BasicColor.Green;
  Screen.DrawCircleFilled(CenterX, CenterY-CircleRadius, CircleRadius, (ushort)TopColor);
  Screen.Execute();
  }
}
3) GetStringWidth may be broken on different fonts. Verdana9 seems to be offset 20 pixels too far to the left when I try this, but Verdana14 works perfectly.
Screen.SetOrientation(Orientation.Portrait);
Screen.DrawFill((ushort)BasicColor.Black);
string Message="Center Test";
int ScreenWidth=240;
FontInfo TextFont = new Verdana9().GetFontInfo();
Screen.DrawString((ScreenWidth / 2) - (TextFont.GetStringWidth(Message) / 2), 0, (ushort)BasicColor.Red, TextFont.ID, Message);
TextFont = new Verdana14().GetFontInfo();
Screen.DrawString((ScreenWidth / 2) - (TextFont.GetStringWidth(Message) / 2), 100, (ushort)BasicColor.White, TextFont.ID, Message);


..I'm sure I'll come up with some other questions, but that's all I have before lunch. Adoring how simple it is to make really cool stuff. :)

Edited by Stefan, 27 April 2012 - 05:53 PM.
Added [code] tags





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.