Menu

Nexion Displays

Anobium
2018-02-18
2020-03-07
1 2 3 4 > >> (Page 1 of 4)
  • Anobium

    Anobium - 2018-02-18

    This thread is to discuss the Nexion support within Great Cow BASIC.

     
  • stan cartwright

    stan cartwright - 2018-02-18

    following from map and Anobiums nextion video demo.
    I remember sending various displays to the house and you sorting some to gcb.
    one was serial nextion which I guessed you used as the basic device.
    Nextion displays look good but using is like using mplabx or avr ide ie not easy imho
    I followed the picaxe thread about using these. Didn't help me as device need setiing sd card from a win ide . bit complicated.
    The idea is you use serprint blah,blah to do say an oscilloscope. sort of. or cicles, you know, as a task but no joy for me.
    The idea could be done with gcb but dunno why. Any thoughts?
    I mean copy nextion
    The reason I like gcb is it's fast and this shows when using graphic displays. the idea of letting the display hardware do the stuff with commands like nextion via serial...dunno. Not as fast as using a display with gcb but lots of things it seem it can do.
    There is a sd card read for parallell glcd in old forum post which may be the include.display bit map.
    This is my thoughts about make a gcb nextion clone but any thoughts about using a nextion in gcb sure would be useful.

     

    Last edit: stan cartwright 2018-02-18
  • stan cartwright

    stan cartwright - 2018-02-18

    Anobium, does gcb need nextion display like picaxe users? This not anti picaxe just thoughts about nextion smart displays. Do they dumb down diplays or make it complicated and why bother.do you need one.

     
  • Anobium

    Anobium - 2018-02-19

    Lots of questions, Stan.


    I have received many devices(and bits of electronics) in the mail, and do most days. You did send a number of GLCDs and I have been working throught them all at a steady pace. Without your sending the GLCDs we would not have a number of the drivers we do today. Thank you.


    ...which I guessed you used as the basic device

    The new driver will not be used as a basic device. Great Cow BASIC and the Nextion IDE will work together to create a very compelling solution.


    Nextion displays look good but using is like using mplabx or avr ide ie not easy imho

    The Nextion IDE is pretty, and pretty hard to get to grips with. I will do a video when I get a moment to try and make it easier to understand. There are a few tricks and YouTube videos that help but mostly I found them confusing - I read the manual in the end.


    I followed the picaxe thread about using these. Didn't help me as device need setiing sd card from a win ide . bit complicated.

    The SD card is not essential. It is not clear on how to use the SD card and why you would use it. But, essentially.... the Nextion has a program of the screens and the supporting logic. This program of screens is called 'firmware'. The 'firmware' can be uploaded to the Nextion display via the SD Card or sent to the Nextion display via the serial connection. I have not (yet) seen how to access the SD Card from the 'firmware' during the RunTime/Normal operation of the Nextion display. I will update this statement if I find how to do this.


    The idea is you use serprint blah,blah to do say an oscilloscope. sort of. or cicles, you know, as a task but no joy for me.

    The Great Cow BASIC GLCD driver is intended this very simple. All the standard GLCD commands are there plus a host specfic to Nextion.

    Example code from the Great Cow BASIC GLCD library. GLCD primatives.

    box 0,0,GLCD_WIDTH-1, GLCD_HEIGHT-1, TFT_YELLOW
    box GLCD_WIDTH-5, GLCD_HEIGHT-5,GLCD_WIDTH-1, GLCD_HEIGHT-1, TFT_WHITE
    
    Circle( GLCD_WIDTH/2, GLCD_HEIGHT/2, 50, TFT_WHITE )            ;center
    FilledCircle( GLCD_WIDTH/2, GLCD_HEIGHT/2, 25, TFT_DARKGREY  )
    
    line 0,  GLCD_HEIGHT-1 , GLCD_WIDTH/2 +100,  (GLCD_HEIGHT /2) - 50, TFT_CYAN
    line  0, (GLCD_HEIGHT /2) - 50, GLCD_WIDTH/2 +100, (GLCD_HEIGHT /2) - 50, TFT_CYAN
    
    filledbox 2,GLCD_HEIGHT/2+10,42,GLCD_HEIGHT/2+50, TFT_RED
    

    Code for Great Cow BASIC fonts.

    GLCDCLS TFT_BLACK
    GLCDPrintString (2, 1, "GCB",TFT_WHITE )
    GLCDPrintString (56,1,"v0.98.02",TFT_YELLOW)
    GLCDPrintString (2, 18, "DrawStr",TFT_WHITE)
    

    Code for Nextion fonts.

    GLCDCLS TFT_BLACK
    ' Using additionalparameter like NextionFont0 will select the default Nextion Font
    GLCDPrintString_Nexion (2, 1, "GCB",TFT_WHITE, NextionFont0 )
    GLCDPrintString_Nexion (56,1,"v0.98.02",TFT_YELLOW)
     GLCDPrintNumber_Nexion ( 64 , 52, NumberValue )
    

    The idea could be done with gcb but dunno why. Any thoughts?
    I mean copy nextion

    No need to copy the Nextion IDE for normal usage once you have initialised the device with a few fonts. Using the Nextion fonts are a lot faster than the Great Cow BASIC fonts. We can update any Nextion screen object with ease. An example is shown below:

      GLCDUpdateObject__Nexion( "t0.txt",  "ADC_Scaled="+str(ScaledValue) )
      GLCDUpdateObject__Nexion( "z1.txt",  scaledValue )
    

    The reason I like gcb is it's fast and this shows when using graphic displays. the idea of letting the display hardware do the stuff with commands like nextion via serial...dunno. Not as fast as using a display with gcb but lots of things it seem it can do.

    You will be able to leverage the Nextion capabilites and Great Cow BASIC GLCD capabilites, so this is the best of both worlds. There are some performance issues with the serial connectivity - like Great Cow BASIC fonts work... but, you can use the Nextion Fonts so things are handled by the best performance method.


    There is a sd card read for parallell glcd in old forum post which may be the include.display bit map.

    As I am not sure how to access the Nextion SD card when in Runtime mode. I cannot comment.

    Note. The SD Card is used to upload the firmware as previously stated.


    This is my thoughts about make a gcb nextion clone but any thoughts about using a nextion in gcb sure would be useful.

    You can/could make a Great Cow BASIC Nextion clone but the business case/justification would not be very compelling.


    Does gcb need nextion display like picaxe users?

    No. You can use any of the large list of GLCD devices. The Nextion library adds to the long list of GLCD devices.


    Do they dumb down diplays or make it complicated and why bother.do you need one.

    Who is they?

    If Nextion is they. This is a standalone produce range of displays - you would have to ask Nextion.

    If Picaxe is they. Then the Nextion could be relatively simply way to added GLCD capabilities but any serial GLCD for Pixace will be highly complex compared to any other microcontroller implemention. Again, you will have to asked the Picaxe developers.

    Anobium

     

    Last edit: Anobium 2018-02-19
  • stan cartwright

    stan cartwright - 2018-02-19

    Nextion displays look nice. I loaded a demo to sd card with buttons and gauges which worked but no joy using serprint "command" with 255,255,255 at the end when using picaxe. The nextion website has an english guy running a forum but the software could do with more explanation.
    Nobody seems to have asked about them on the gcb forum..yet.

     
    • Anobium

      Anobium - 2018-02-19

      You asked on the forum. :-)

      Did I answer your questions in my last post? Took me a long time to collate and post.

       
  • stan cartwright

    stan cartwright - 2018-02-19

    I'll see what info you post. Thanks

     
  • Anobium

    Anobium - 2018-02-21

    These are the implemented library functions.

    Setup the device. Use GLCD_TYPE_NEXION320x480L and specify the Nexion fonts characteristics


    #include <glcd.h>
    #define GLCD_TYPE GLCD_TYPE_NEXION320x480L
    #define NextionFont0      0, 8, 16    'Arial 8x16
    #define NextionFont1      1, 12, 24   '24point 12x24 charset
    #define NextionFont2      2, 16, 32   '32point 16x32 charset
    

    Update objects. These happen to be value from the ADC displayed on two gauges with some suppporting text.

    adcval = ReadAD( AN4 )
    ScaledValue = scale( adcval, 0, 255, -135, 135 )
    myString = "ADC="+str(adcval)
    myString = myString +":SCD="+str(( 360 + ScaledValue ) mod 360)
    
    GLCDUpdateObject_Nexion( "t0.txt",  myString )                        'a string
    GLCDUpdateObject_Nexion( "z0.val",  ( 360 + ScaledValue ) mod 360 )   'a number, an Integer value
    GLCDUpdateObject_Nexion( "z1.val",  (180-ScaledValue) )               'a number, an Integer value
    

    To show all a demo of all the standard GLCD commands and the Nextion font handler (you can use the standard Great Cow BASIC fonts (and the OLED fonts).

    GLCDCLS TFT_BLACK
    GLCDLocateString_Nexion 1,1
    GLCDPrintDefaultFont_Nextion ( NextionFont0 )
    GLCDPrintString_Nexion ( "Great Cow BASIC " )
    GLCDLocateString_Nexion 130,1
    GLCDPrintStringLn_Nexion ( "v0.98.02" )
    
    GLCDPrint_Nexion ( 2, 18, "DrawStr",TFT_YELLOW)
    GLCDPrint_Nexion ( 2, 52, "Long:", TFT_WHITE )
    GLCDPrint_Nexion ( 2, 70, "Word:" )
    GLCDPrint_Nexion ( 2, 88, "Byte:" )
    
    GLCDPrint_Nexion ( 128, 18, "Asc:"+"  " )
    
    box 0,0,GLCD_WIDTH-1, GLCD_HEIGHT-1, TFT_YELLOW
    box GLCD_WIDTH-5, GLCD_HEIGHT-5,GLCD_WIDTH-1, GLCD_HEIGHT-1, TFT_WHITE
    
    Circle( GLCD_WIDTH/2, GLCD_HEIGHT/2, 50, TFT_WHITE )            ;center
    FilledCircle( GLCD_WIDTH/2, GLCD_HEIGHT/2, 25, TFT_DARKGREY  )
    
    line 0,  GLCD_HEIGHT-1 , GLCD_WIDTH/2 +100,  (GLCD_HEIGHT /2) - 50, TFT_CYAN
    line  0, (GLCD_HEIGHT /2) - 50, GLCD_WIDTH/2 +100, (GLCD_HEIGHT /2) - 50, TFT_CYAN
    
    filledbox 2,GLCD_HEIGHT/2+10,42,GLCD_HEIGHT/2+50, TFT_RED
    
    GLCDPrint_Nexion ( 70, GLCD_HEIGHT - 36 , "Great Cow BASIC" , TFT_WHITE, NextionFont2 )
    GLCDPrint_Nexion ( GLCD_WIDTH - 78, 2 , "Feb 2018" , TFT_WHITE, NextionFont0 )
    GLCDForeground = TFT_WHITE
    GLCDPrint_Nexion ( 100 , GLCD_HEIGHT - 60 , "Nextion Driver", NextionFont1 )
    
    DO forever
    
      GLCDPrint_Nexion ( 64 , 52, longNumber, TFT_WHITE, NextionFont0 )
      GLCDPrint_Nexion ( 124 , 52, longNumber, TFT_Yellow )
    
      'Change the colour via the global GLCD variable
      GLCDForeground = TFT_WHITE
      GLCDPrint_Nexion ( 184 , 52, longNumber )
    
      GLCDPrint_Nexion ( 64 , 70, pad( str(wordnumber),5))
      GLCDPrint_Nexion ( 64 , 88, pad( str(bytenumber),3))
    
      GLCDPrint_Nexion ( 101, 19, chr(CCount) )
      Box 98,17,117,42, TFT_WHITE   'Draw a box around the Char below
    
      GLCDPrint_Nexion ( 180, 18 , pad( str(CCount),3) )
      CCount++
      if CCount = 0 then CCount = 32
      if CCount = 128 then CCount = 32
      longNumber = longNumber + 7
      wordNumber = wordNumber + 3
      byteNumber++
    
    LOOP
    

    Essentially, standard commands with the _NEXION to ensure you are taking advantage of the Nextion capabilities. The Great Cow BASIC primitives work - things like LINE, BOX etc.

    You can read events from the screen, control the screen pages and write to the objects with ease.

    Next, to create the four channel Oscilloscope - should be relatively simple. I wonder what the frequency will be... excited.

     
  • stan cartwright

    stan cartwright - 2018-02-22

    I don't know how you managed to interface gcb with nextion commands. Impessive. In picaxe it's

    serout b.2, n9600, ( "line 0, 0, 100, 100, RED")
    serout b.2, n9600, ( "cls BLACK") ; clears the screen to black or whatever colour you choose
    serout b.2, n9600, ( "fill x, y, w, h, color) ; choose you position x,y then width then height then colour and it fills that space with a colour
    serout b.2, n9600, ( "draw 0, 0, 100, 100, RED") ; draw a red rectangle 
    serout b.2, n9600, ( "cir 100, 100, 30, RED") ; draw read circle
    serout b.2, n9600, ( "cirs 100, 100, 30, RED") ; draw a solid/filled circle
    serout b.2, n9600, ( "print ""123""") ; Prints 123 on the screen
    

    None of which worked for me :)

     
    • Anobium

      Anobium - 2018-02-22

      Oh dear it did not work. Great Cow BASIC rocks.

       

      Last edit: Anobium 2018-02-22
  • Moto Geek

    Moto Geek - 2018-02-23

    I second, third and forth dat!!!! GCB does absolutely Rock!!!! I am really pissing off my arduino type buddies, because I can actually get things done without relying on copying and pasting without a clue. and then not having to ask, "why did this not work, I copied and pasted directly from github." My usuall response is... "did you change the in/out pins to match your design??? Or something very similar. You can imagine the responses I get, like... Why do I have to do that, I copied and pasted it, it should work.." They are like the James Dean of micros, rebel without a clue. GBC all day!

    Sorry, this has nothing to do with Nextion displays, but I had to say it.

     

    Last edit: Moto Geek 2018-02-23
  • stan cartwright

    stan cartwright - 2018-02-23

    The arduino projects on github cover many devices. There's usually a demo and includes for drivers. You play with the demo. GCB is the same. How many users analyse the gcb includes? I do but find other peoples code style hard to follow. The glcd includes, seems every other word is GLCD_SOMETHING in upper case!

     
    • Anobium

      Anobium - 2018-02-23

      @Stan. Don't be complaining GLCD_NOW! :-)

       
  • stan cartwright

    stan cartwright - 2018-02-23

    moi?
    did you get the touch screen working? that would be better than wires,pull ups and switches for dev. These nextions give good in/out interface when working ok. Nice you are supporting it.

     

    Last edit: stan cartwright 2018-02-23
  • stan cartwright

    stan cartwright - 2018-02-23

    Nextion use arm 7...and a serial interface.

     
  • Anobium

    Anobium - 2018-02-24

    The segment of code show how to read the screen Touch Events.

    This will show the string value of Touch Event x an y location on the Nexion screen using the t0.txt text object.

    The send the get tch2 and get tch3 commands. Which is the get touch event locations. Then the code reads 3 dummy bytes, 2 bytes for the screen location into a Word variable then 4 dummy bytes. These dummy bytes are communication protocol header and footer bytes, see https://nextion.itead.cc/resources/documents/instruction-set/#s3 for information on the communication packet when the get command is sent to the Nextion Screen. The code then formats the string to be sent, finally sending the string to the t0.txt text object to the Nextion Display.

    So, for a Touch Event you get value like 120, 29....456.254 etc for the respective X, Y location of the Touch Event. So, you can 'do' something with the value. This could be made into a function but 'knowing' XY position of the Touch Event is more useful when handled within the Nextion display (the internal event handler).

    dim myDummyByteIn as byte
    dim myWordX, myWordY as word 
    
    'Send the request for the XPOS event location
    GLCDSendOpInstruction_Nexion( "get",  "tch2" )
        'header data
        repeat 3
        HSerReceive ( myDummyByteIn)
        end Repeat
        'Receive the real data
        HSerReceive ( [byte]myWordX )
        HSerReceive ( myWordX_H)
        'footer data
        repeat 3
        HSerReceive ( myDummyByteIn)
        end Repeat
        'myWordX is now the X pos
        myString = str(myWordX) +","
    
    'Send the request for the YPOS event location
    GLCDSendOpInstruction_Nexion( "get",  "tch3" )
        'header data
        repeat 3
        HSerReceive ( myDummyByteIn)
        end Repeat
        'Receive the real data
        HSerReceive ( [byte]myWordY)
        HSerReceive ( myWordY_H)
        'footer data
        repeat 3
        HSerReceive ( myDummyByteIn)
        end Repeat
        'myWordY is now the Y pos
        myString = myString+str(myWordY)
    
    'Update the text object
    GLCDUpdateObject_Nexion( "t0.txt", myString )
    

    I will post a video when I get time.

     
  • stan cartwright

    stan cartwright - 2018-02-24

    Anobium, you sorted that out fast. Let us know what's involved. ie what files do you put on sd card, does it need sd card. Basically out of the box what needs setting up to send serial commands and codes/format.
    I never got to control the display, just flash sd card and demo.
    As you're developing for this I'll order a small one cos they're cheap and capable in the right hands.
    Would you recommend it to gcb users yet? Was the scope feature usable or just a demo to show data display?

     
  • Anobium

    Anobium - 2018-02-24

    No recommendation for which GCLD to use. As this depends on the use case. Buying one without understanding the use case will cost you money but the other GLCD devices as very, very capable with very similar functionality.

    If the use case is a large GLCD to take advantage of the large fonts and the large GLCD real estate - then, the Nextion may make sense. The ILI9486L is larger.
    If the use case is a lot of commands then Nextion will need a microcontroller with RAM and some program memory. The SSD1331 uses very little memory.
    If the use is set of guages, then, as you have proven the standard GLCD can do this with ease.
    If cost is a constraint the Nextion is not cheap. See your own posts.
    It is all about the use case.

    See http://gcbasic.sourceforge.net/help/_glcd_overview.html for more information that should with a selection process - see the large table.

    With respect to developing with the Nexion. I used both the Nextion IDE and a serial connection. The SD Card can by used to transfer the design (the HMI file) to the Nextion display.

    I think this thread explain the commands. Use the Nextion IDE when appropiate and you can use the GLCD capabilities of Great Cow BASIC. It all depends on the use case.

    This driver will be in the next release. It is complete now but there is an issue with respect to release that I need to resolve before this code can be released.

    Anobium

     
  • Anobium

    Anobium - 2018-02-24

    When using the Nextion you will need to setup the Serial Connectivity. The library supports the following methds:

    1, Hardware USART
    2. Legacy Software Serial
    3. Optimised Software Serial

    These are example of the the three cases:


    Hardware USART for microcontroller with PPS

    'Generated by PIC PPS Tool for Great Cow Basic
    'PPS Tool version: 0.0.5.11
    'PinManager data: v1.55
    '
    'Template comment at the start of the config file
    '
    #startup InitPPS, 85
    
    Sub InitPPS
    
            'Module: EUSART
            RXPPS = 0x0016    'RC6 > RX
    
            'Module: EUSART
            RC0PPS = 0x0010    'TX > RC0
            TXPPS = 0x0010    'RC0 > TX (bi-directional)
            RC5PPS = 0x0010    'TX > RC5
            TXPPS = 0x0015    'RC5 > TX (bi-directional)
    
    End Sub
    'Template comment at the end of the config file
    #define USART_BAUD_RATE 9600
    #define USART_BLOCKING
    

    Hardware USART for microcontroller without PPS

    #define USART_BAUD_RATE 9600
    #define USART_BLOCKING
    

    **Legacy Software Serial **

        'Config Software-UART
        #define RS232Out PORTC.5
        #define RS232In  PORTC.6
    
        Dir RS232Out Out
        Dir RS232In In
    
        #define SendAHigh Set RS232Out ON
        #define SendALow Set RS232Out OFF
        #define RecAHigh Set RS232In ON
        #define RecALow Set RS232In OFF
    
        InitSer 1, r9600, 1+WaitForStart, 8, 1, none, normal
    
        #define GLCD_NEXIONSerialPrint        SerPrint 1,
        #define GLCD_NEXIONSerialSend         SerSend  1,
    

    Optimised Software Serial

    ; ----- Include library
    #include <SoftSerial.h>
    
    ; ----- Config Serial UART for sending:
    #define SER1_BAUD 9600     ; baudrate must be defined
    #define SER1_TXPORT PORTC ; I/O port (without .bit) must be defined
    #define SER1_TXPIN 5       ; portbit  must be defined
    
    #define GLCD_NEXIONSerialPrint        Ser1Print
    #define GLCD_NEXIONSerialSend         Ser1Send
    

    Summary

    The library defaults to Hardware USART. To use Software serial you must use the GLCD_NEXIONSerialPrint and the GLCD_NEXIONSerialSendconstants.

    When using Legacy Software Serial you must add the port number to the constants. For example the correct constant is SerPrint 1,

    Easy

    Anobium

     

    Last edit: Anobium 2018-02-24
  • stan cartwright

    stan cartwright - 2018-02-24

    Ok. I'm glad nextion will be supported in gcb. Hope they last for a while. They seem popular as displays go. An old idea modernised to stuff you would find hard to do with a display. The ide design looks interesting...on paper.

     
  • stan cartwright

    stan cartwright - 2018-03-17

    A nextion lcd arrived today. It's doing the "Welcome to Nextion Editor" demo.
    I'm looking how to reset.
    flashing this didn't. I don't like ilead site.

    #chip mega328p, 16
    #option
    #define USART_BAUD_RATE 9600
    #define USART_BLOCKING
    wait 500 ms
    
    HSerPrint "cls BLACK"
    HSerPrint "draw 0, 0, 100, 100, RED"
    HSerPrint "cir 100, 100, 30, RED"
    HSerPrint "print ""123"""
    end
    
     
  • stan cartwright

    stan cartwright - 2018-03-17

    Do I need nextion editor to make it blank? A while since I last used one. I tried to update it and win 10 administrator needed. That's me messing with admin with pickit3. I used this and now I'm administrator. Don't know, am I? https://www.ghacks.net/2014/11/12/how-to-enable-the-hidden-windows-10-administrator-account/ Don't mess with windows if you don't know what you're doing...like me.
    I now have latest nextion editor and sd card and card writer.
    edit the above admin doesn't work cos I tried pickit3 and still gives admin errors.
    Anyway, display looks like image, I can't remember what to do to reset it to just screen

     

    Last edit: stan cartwright 2018-03-17
1 2 3 4 > >> (Page 1 of 4)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.