Announcement

Collapse
No announcement yet.

Visi and Serial communication not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Thanks much better, now just

    Error: 'numx' not found (line 106 file:SerialTest.4Dg)
    Error: context error for unknown 'numx' (line 109 file:SerialTest.4Dg)
    2 errors
    0 warnings
    2 notices

    Error at line 106 which is 3rd line down on the last 'paste code' for the LedDigits object (last line shown below). It is the same code as the other two further up, can't understand why this one fails but the other 2 don't?

    // Leddigits1 1.0 generated 22/05/2020 13:58:10
    img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once
    ledDigitsDisplay(numx, iLeddigits1+1, 85, 4, 3, 30, 0) ;

    ----------------------------------------------------------------------------------------
    Full code below:

    #platform "Gen4-uLCD-43DT"

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "SerialTestConst.inc"
    #inherit "ledDigitsDisplay.inc"


    var values[10];
    var gotMessage := 0;
    var tempMessage[15];
    var tMcount;
    var combuf[100];

    func main()
    var hstrings ; // Handle to access uSD strings, uncomment if required
    var hFontx ; // Handle to access uSD fonts, uncomment if required and change n to font number
    // Uncomment the following if uSD images, fonts or strings used.

    putstr("Mounting...\n");
    if (!(file_Mount()))
    while(!(file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif
    gfx_TransparentColour(0x0020); // uncomment if transparency required, please understand why and when you need to use this
    gfx_Transparency(ON); // uncomment if transparency required, as generally there is a performance hit when using it

    //hFontn := file_LoadImageControl("SERIAL~1.dan", "SERIAL~1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
    // hstrings := file_Open("SERIAL~1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
    hndl := file_LoadImageControl("SERIAL~1.dat", "SERIAL~1.gci", 1);


    var numx :=0;

    // Leddigits1 1.0 generated 3/3/2020 3:05:59 PM
    img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once


    // Leddigits1 1.0 generated 22/05/2020 14:57:52
    img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once
    ledDigitsDisplay(numx, iLeddigits1+1, 85, 3, 1, 40, 0) ;


    gfx_Set(SCREEN_MODE,LANDSCAPE) ;
    gfx_Cls();


    // Leddigits1 1.0 generated 22/05/2020 14:57:42
    img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once
    ledDigitsDisplay(numx, iLeddigits1+1, 85, 3, 1, 40, 0) ;


    com_SetBaud(COM0, 11520);
    com_Init(combuf, 100, 0);


    repeat

    getSerial(); // Get any serial and check for message

    forever
    endfunc


    func getSerial()

    var recbyte, n;


    while(com_Count() > 0)

    recbyte := serin();

    if(recbyte == 69) gotMessage := 1; // check for "E" and set message complete flag
    if(gotMessage != 1) // if message not complete keep building
    tempMessage[tMcount] := recbyte;
    tMcount ++;
    endif
    wend

    if(gotMessage == 1)
    gotMessage := 0;
    //var n;
    var multiplier;
    var tempval;
    tempval := 0;
    multiplier := 1;
    for(n := tMcount-1; n >= 0; n--)
    if(tempMessage[n] > 47 && tempMessage[n] < 58)
    tempval := tempval + ((tempMessage[n] - 48) * multiplier);
    multiplier := multiplier *10;
    endif
    next
    if(tempMessage[0] == 97) values[0] := tempval; // if message starts with 'a' 97 being ASCII for a
    // add morechecks here in the same format eg 'b600\r\n'
    tMcount := 0;

    // Leddigits1 1.0 generated 22/05/2020 14:57:29
    img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once
    ledDigitsDisplay(numx, iLeddigits1+1, 85, 3, 1, 40, 0) ;


    endif

    endfunc
    Last edited by Doris; 22 May 2020, 11:59 PM.

    Comment


    • #17
      Hi,

      The last one should have tempval instead of numx. I didn't notice it earlier

      Comment


      • #18
        Excellent Paul, that works a treat - thank you again for your help today. I ultimately want the screen to display the dynamic text that appears on the Arduino serial, any tips on what changes might be required to print characters?

        Comment


        • #19
          Hi,

          I'm glad it worked out in the end. When you start a project from new or you receive a complete project then the issues you had today won't happen.

          I will look for an example or prepare an example for you. In the meantime you may find the 4DGL Reference Manual

          https://4dsystems.com.au/mwdownloads...ad/link/id/17/

          and the Diablo Internal Functions Manual

          https://4dsystems.com.au/mwdownloads...d/link/id/719/

          usefful in explaining the commands available in the 4DGL language

          Best regards

          Paul

          Comment


          • #20
            Great stuff Paul, thank you. Am reading the 4DGL manual but an example from you would be really helpful.

            Comment


            • #21
              Hi Paul. Still struggling to get strings displayed. Are you able to post an example please?

              Comment


              • #22
                Hi,

                Sorry for the delay, yes I will prepare an example for you today.

                Best regards

                Paul

                Comment


                • #23
                  Hi Doris,

                  This is a simple example to receive a string from the Arduino.

                  It will store the incoming string in a string array named inputString and then display it on the screen. There is some example Arduino code to send the string to the display.

                  Hope this helps

                  Best regards

                  Paul
                  Attached Files

                  Comment


                  • #24
                    Hi Paul,

                    I am a newbie to 4D and I must admit I am impressed with the level of support that you provide.
                    I have recently purchased a Gen4-uLCD-70DCT-CLB display (Diablo 16) and am trying to understand the relationship between the IDE environments, namely VISI, GENIE etc.
                    My requirement is to have a display panel that sends very simple information to a 3rd party host (not arduino) and then to poll the serial port for commands send from the host.

                    Whilst the design of the Display was very easy, I am trying to work out where I can put the code for all the serial port handling and then functionality like set a button to an on state after receipt from the host etc. etc.

                    Am I wrong to assume that the PRO license will still require code to make this happen or is there some magic behind the event handling that I am not aware of?

                    I am convinced that once on the correct path I will have no issues with programming this but I would appreciate some pointing in the right direction.

                    Kind Regards,
                    Mick

                    Comment


                    • #25
                      Hi Mick

                      Welcome to the forum.

                      Visi-Genie is our codeless Serial environment so all the necessary code for handling Serial is already generated when you upload your project and no code is needed on the display side.

                      The Pro version of Workshop allows you to add code to Visi-Genie to further extend the capabilities of Genie but isn't necessary to get a Visi-Genie application running. The Pro version of Workshop also has a smart widget editor allowing you to easily create your own widgets.

                      We do have some libraries for popular micro-controllers which can be found here

                      https://github.com/4dsystems

                      The host will poll the display using the Visi-Genie protocol and you can find more details here

                      https://4dsystems.com.au/mwdownloads...ad/link/id/26/
                      https://4dsystems.com.au/mwdownloads...ad/link/id/27/

                      All the coding would be done on the host using these commands or the above libraries if your Micro-controller is supported.

                      There are plenty of appnotes that may also help

                      https://4dsystems.com.au/blog/app-notes?p=1

                      Best regards

                      Paul

                      Comment


                      • Mick Burian
                        Mick Burian commented
                        Editing a comment
                        The Microprocessor used is Freescale MC9S08SH8

                    • #26
                      Hi Paul,

                      I am struggling to know where to insert the code to handle the serial polling. Do you have an example? The links you provided are just to the manuals themselves and no example.
                      I have attached a Use Case of the basic functionality I would like to achieve.
                      Note. The screen was generated by VISI-GENIE.
                      Attached Files

                      Comment


                      • #27
                        Hi Mick,

                        There will be no code inserted on the display, the code will be on the host as the host is the controller sending serial commands to perform an action or to retreive data from the display. Would you be able to tell me what your host will be ?

                        Best regards

                        Paul

                        Comment


                        • Mick Burian
                          Mick Burian commented
                          Editing a comment
                          The host is Freescale MC9S08SH8

                      • #28
                        Paul,

                        Do you have a small example of this anywhere?

                        Comment


                        • Mick Burian
                          Mick Burian commented
                          Editing a comment
                          the host is Freescale MC9S08SH8

                      • #29
                        Hi Mick,

                        Thanks for the info on the micro controller that you are using.

                        Unfortunately I don't have a ready made example to run but will have a look in detail on the programming environment to see how this can be done.

                        In the meantime to get a better understanding of how the display works and the serial data that is sent to and from the display you can ust the GTX tool. You will need to have the display connected to Workshop and your project loaded. Next click on the Tools tab and then GTX. In the right hand panel you can see the serial commands sent to the display and the responses that the display sends.

                        Best regards

                        Paul

                        Comment


                        • Mick Burian
                          Mick Burian commented
                          Editing a comment
                          Hi Paul

                          I have been trying to use GTX but no matter what I enter and query or set I dont get any changes on the display

                      • #30
                        So to start... a very primitive command to send to the display would be to change the frequency from 1180 to 1181........can you tell me how to use GTX to do that?
                        Attached Files

                        Comment

                        Working...
                        X