Announcement

Collapse
No announcement yet.

Objects don't show

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

  • Objects don't show

    Hey,
    I'm trying to display 4 static texts, 2 user leds, 1 4d button, 2 rectangles, 1 circle and two strings.
    It only shows the rectangles, circle and strings.
    I don't understand why.

    This is my first project with 4d systems

    Code:
    #platform "uLCD-32PTU"
    
    // Program Skeleton 1.2 generated 27/05/2016 13:22:46
    
    #inherit "4DGL_16bitColours.fnc"
    
    #inherit "VisualConst.inc"
    
    #inherit "VisiTest2Const.inc"
    
    func main()
    
    gfx_Set(SCREEN_MODE,LANDSCAPE) ;
    
    var defX := 82;
    var defY := 2;
    
        var hstrings ; // Handle to access uSD strings, uncomment if required
        var hFontn ;   // 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
        putstr("Mounted");
        pause(250);
        gfx_Cls();
        gfx_TransparentColour(0x0020);    // uncomment if transparency required
        gfx_Transparency(ON);             // uncomment if transparency required
    
        hFontn := file_LoadImageControl("NoName1.dan", "NoName1.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("NoName1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
        hndl := file_LoadImageControl("VisiTest2.dat", "VisiTest2.gci", 1);
    
    //********User Code*************
    touch_Set(TOUCH_ENABLE);
    touch_DetectRegion(15,185,63,233);
    
    var state;
    var dead := 0;
    var oob := 0; //Out of bounds
    
    if(touch_Get(TOUCH_STATUS) == NOTOUCH)
        state := 0;
        else
            state := 1;
            dead := 1;
    endif
    
        // Calculate x and y pos
        var x := 0;
        var y := 0;
        x := defX;
        y := defY;
    
        com_SetBaud(COM0, 960); //X pos
        com_SetBaud(COM1, 960); //Y pos
    
        var charX := 0;
        var charY := 0;
        charX := serin();
        charY := serin1();
    
        if(charX >= 0 && charY >= 0)
            x := defX + charX;
            y := defY + charY;
        endif
    
        oob := pin_Read(IO1_PIN);
    
    
        // Circle1 1.0 generated 27/05/2016 15:03:05
        gfx_CircleFilled(x, y, 2, BLUE);
    
    
    //******Autogenerated code*********
    
    
        // Form1 1.1 generated 27/05/2016 14:04:43
        img_Show(hndl,iForm1) ;
    
        // Strings1 1.1 generated 27/05/2016 14:04:43
        txt_FontID(FONT3) ;
        txt_FGcolour(BLACK) ;
        txt_BGcolour(WHITE) ;
        gfx_MoveTo(80 , 0) ;
        print(" ") ;
    
    
        // Strings2 1.1 generated 31-5-2016 16:36:12
        txt_FontID(FONT3) ;
        txt_FGcolour(BLACK) ;
        txt_BGcolour(WHITE) ;
        gfx_MoveTo(200 , 0) ;
        print(" ") ;
    
    
        // Userled1 1.0 generated 27/05/2016 14:04:43
        //Userled1 = Dead/Alive led
        img_Show(hndl,iUserled1) ;  // show initialy, if required
        img_SetWord(hndl, iUserled1, IMAGE_INDEX, dead) ;      // where numx is 0 (Off) or 1 (On)
        img_Show(hndl,iUserled1) ;
    
        //  String background
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPFINE) ;
        gfx_RectangleFilled(80, 0, 320, 26, WHITE) ;
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPSOLID) ;
    
        // Rectangle1 1.0 generated 27/05/2016 14:04:43
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPFINE) ;
        gfx_RectangleFilled(0, 32, 14, 57, LIME) ;
        gfx_OutlineColour(BLACK) ;
        gfx_LinePattern(LPSOLID) ;
    
        // Rectangle2 1.0 generated 27/05/2016 14:04:43
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPFINE) ;
        gfx_RectangleFilled(0, 46, 14, 57, RED) ;
        gfx_OutlineColour(BLACK) ;
        gfx_LinePattern(LPSOLID) ;
    
        // Statictext1 1.0 generated 27/05/2016 14:04:43
        img_Show(hndl,iStatictext1) ;
        img_SetAttributes(hndl,iStatictext1,"Alive");
        img_Show(hndl,iStatictext1) ;
    
        // Statictext2 1.0 generated 27/05/2016 14:04:43
        img_Show(hndl,iStatictext2) ;
        img_SetAttributes(hndl,iStatictext2,"Dead");
        img_Show(hndl,iStatictext2) ;
    
        // 4Dbutton1 1.0 generated 27/05/2016 14:04:43
        img_ClearAttributes(hndl, i4Dbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
        img_Show(hndl, i4Dbutton1);  // show button, only do this once
        img_SetWord(hndl, i4Dbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down
        img_Show(hndl,i4Dbutton1) ;
    
        // Statictext3 1.0 generated 27/05/2016 14:04:43
        img_Show(hndl,iStatictext3) ;
        img_SetAttributes(hndl,iStatictext3,"Press if killed");
        img_Show(hndl,iStatictext3);
    
        // Userled2 1.0 generated 27/05/2016 14:04:43
        //Userled2 = OUT OF BOUNDS led
        img_Show(hndl,iUserled2) ;  // show initialy, if required
        img_SetWord(hndl, iUserled2, IMAGE_INDEX, oob) ;      // where numx is 0 (Off) or 1 (On)
        img_Show(hndl,iUserled2) ;
    
        // Statictext4 1.0 generated 27/05/2016 14:04:43
        img_Show(hndl,iStatictext4) ;
    
        // Form1 1.1 generated 27/05/2016 14:04:43
        img_Show(hndl,iForm1) ;
    
        // Border1 1.1 generated 27/05/2016 14:04:43
        // Borders are 'embedded' in the background of each form, this means even a form without a background image will have one created if it has a border.
        // Borders, Gradients and Scales are all done this way, so you only need to Paste the main form, or one of them, if several are included on a form.
        img_Show(hndl,iForm1) ;
    
        // Strings1 1.1 generated 27/05/2016 14:04:43
        txt_FontID(FONT3) ;
        txt_FGcolour(BLACK) ;
        txt_BGcolour(WHITE) ;
        gfx_MoveTo(80 , 0) ;
        print(" ") ;
    
        // Userled1 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iUserled1) ;  // show initialy, if required
        img_SetWord(hndl, iUserled1, IMAGE_INDEX, dead) ;      // where numx is 0 (Off) or 1 (On)
        img_Show(hndl,iUserled1) ;
    
        // Rectangle1 1.0 generated 27/05/2016 14:04:44
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPFINE) ;
        gfx_RectangleFilled(0, 32, 13, 43, LIME) ;
        gfx_OutlineColour(BLACK) ;
        gfx_LinePattern(LPSOLID) ;
    
        // Rectangle2 1.0 generated 27/05/2016 14:04:44
        gfx_OutlineColour(WHITE) ;
        gfx_LinePattern(LPFINE) ;
        gfx_RectangleFilled(0, 46, 14, 57, RED) ;
        gfx_OutlineColour(BLACK) ;
        gfx_LinePattern(LPSOLID) ;
    
        // Statictext1 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iStatictext1) ;
    
        // Statictext2 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iStatictext2) ;
    
        // 4Dbutton1 1.0 generated 27/05/2016 14:04:44
        img_ClearAttributes(hndl, i4Dbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
        img_Show(hndl, i4Dbutton1);  // show button, only do this once
        img_SetWord(hndl, i4Dbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down
        img_Show(hndl,i4Dbutton1) ;
    
        // Statictext3 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iStatictext3) ;
    
        // Userled2 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iUserled2) ;  // show initialy, if required
        img_SetWord(hndl, iUserled2, IMAGE_INDEX, dead) ;      // where numx is 0 (Off) or 1 (On)
        img_Show(hndl,iUserled2) ;
    
        // Statictext4 1.0 generated 27/05/2016 14:04:44
        img_Show(hndl,iStatictext4) ;
    
    
    //********End of code**********
    
        repeat
        forever
    endfunc

  • #2
    This code doesn't quite look right
    Code:
     
         hFontn := file_LoadImageControl("NoName1.dan", "NoName1.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("NoName1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required     hndl := file_LoadImageControl("VisiTest2.dat", "VisiTest2.gci", 1);
    Check the actual filenames generated in the project folder and fix the names in the above. They should be short 8.3 names as you will find in the folder. Workshop normally automatically updates them during 'save as' operations (of which the first save is one), but if you play with these names yourself, or rename the files outside Workshop it can't help you and you have to keep them correct manually.
    Mark

    Comment


    • #3
      Yes! Thank you so much!
      That made it work. A few things don't show yet, but that's because there isn't a .dan or .gcn file generated by the SaveAs operation.
      How can I find them or force generate them?

      Comment


      • #4
        The .dan and .gcn files are 'only' for fonts, the files generated will be .gc1, .da1, etc. you need to duplicate that line and change the n to the number for each one generated.
        i.e.
        Code:
         
             hFont1 := file_LoadImageControl("NoName1.da1", "NoName1.gc1", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9   
             hFont2 := file_LoadImageControl("NoName1.da2", "NoName1.gc2", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
        Mark

        Comment

        Working...
        X