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

Nwazet Display Module


  • Please log in to reply
10 replies to this topic

#1 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 09 May 2012 - 07:13 PM

I tried posting this question into another thread a few weeks ago but I'm afraid it got lost.

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


#2 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 09 May 2012 - 07:57 PM

Hi,

Regarding your questions:

#1: Yup, in general, it will work but you might see slight variations between a wide sample set of displays
#2: We have a firmware update planned to enable this scenario (once Secret Labs releases the ability to reflash modules in the field)
#3: Interesting finding. I have not noticed that. Please file a bug on our BitBucket repository with a repro snippet and I'll investigate. In the meantime, this is something that's handled on the C# side, so you could fix it and contribute the fix back ;)


Thanks,
-Fabien.

#3 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 09 May 2012 - 08:16 PM

On the #2, do you have a timeframe? I'm unfortunately under a time crunch. On the #3, I wasn't aware it was in the code, I may be able to track it down and get it fixed. For my current project I just put an offset in and it took care of things. Hopefully I'll have some time next week to take a look.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 May 2012 - 08:53 PM

Hi NXTwoThou,

On the #2, do you have a timeframe? I'm unfortunately under a time crunch.

We have an alpha reflashing app for Netduino Go today, to reflash the STM32-based modules like the Nwazet Touch Display and Shield Base. It works consistently--but it requires the use of a Gadgeteer USB Serial module to stream the flash from the PC.

We hope to have a reflashing app which doesn't require any of that within the next week or so. We're making quite a few updates to Netduino Go and the Shield Base...but perhaps we can ship part early.

Chris

#5 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 09 May 2012 - 11:28 PM

@NXT

On the #2, do you have a timeframe? I'm unfortunately under a time crunch




This is a simple addition to the existing touch display firmware and to the C# API.
I can make it available sometime next week in source and binary form.


-Fabien.

#6 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 10 May 2012 - 02:45 PM

Awesome Fabien! Thanks so much! Is it going to require the Gadgeteer USB Serial module?

#7 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 10 May 2012 - 02:52 PM

Awesome Fabien! Thanks so much! Is it going to require the Gadgeteer USB Serial module?

I used this setup to reflash modules:

http://forums.netdui...o-hacker-board/

so a gadgeteer USB serial module is not really required.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#8 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 10 May 2012 - 04:35 PM

Unfortunately my electronics skills are very limited and so as cool as that looks Stefan, currently it scares the crap out of me. :)

#9 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 11 May 2012 - 12:20 AM

@NXT

To simplify module flashing, I would strongly suggest purchasing a 3.3v FTDI cable, a couple breakout sockets and some M/F and F/F jumper wires.
This article will help you understand the recommendation: http://fabienroyer.w...ng-out-sockets/

I use a variant on this breakout method for flashing the touch display module firmware using ST's Flash Loader demo application (command line version).

Cheers,
-Fabien.

#10 kweeks

kweeks

    New Member

  • Members
  • Pip
  • 1 posts

Posted 08 April 2013 - 02:25 PM

NXTwoThou

 

Did you ever get a response to question #1 and have you figured out the calibration code matrix issue. If you have a working version would you mind posting it. there i very little info regarding this and your work would be helpful to many.

 

Thanks,



#11 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 11 April 2013 - 09:24 PM

We bought 6 displays and that matrix I built from one calibration seemed to work fine for all of them.  Just uncomment the byte[] calib=null line, then put a breakpoint at b.GetBuffer, after you get the buffer, watch calib and copy the values out and replace the byte[33] at the top with it.  If you have a SD card module, you could just write out that byte[] to a file and load it back up if it exists.

 

        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 };            //byte[] calib = null; // comment out previous line and uncomment this and run in debug mode            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);                    // stop here in debug mode and copy the contents of calib                }            }        }





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.