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; 2 days ago.

    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

            Working...
            X