Announcement

Collapse
No announcement yet.

Button not shown on screen

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

  • Button not shown on screen

    Hi,

    The screen doesnt show the fancy button " iWinbutton1" , why ?

    Please see code below:

    "

    #platform "uLCD-43PT"

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "DiExMonitorConst.inc"

    #inherit "PrintDiskGoldelox.inc"

    #inherit "LedDigitsDisplayGoldelox.inc"

    var combuf[24]; // 24 vars = 48 bytes
    var combuffer[1]; // 24 vars = 48 bytes
    var page ;


    func main()
    var chr,char, e, e2, n, frame, state;
    var numx, dir, colr, redo, numt, Wbs1, x, y ;

    e := 0;
    e2 := 0;

    gfx_Set(SCREEN_MODE,LANDSCAPE) ;
    gfx_Set(CONTRAST,5) ;
    txt_Set(TEXT_OPACITY, OPAQUE);
    numx := 0 ;

    // Uncomment the following if uSD images used.
    // putstr("Mounting...\n");
    if (!(disk:=file_Mount()))
    while(!(disk :=file_Mount()))
    // putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif

    gfx_TransparentColour(0x0020);
    gfx_Transparency(ON);

    pin_Set(OUTPUT, AUDIO_ENABLE);
    pin_HI(AUDIO_ENABLE);

    hndl := file_LoadImageControl("DIEXMO~1.dat", "DIEXMO~1.gci", 1);


    if(file_Exists("bl16k.wav"))
    snd_BufSize(3);
    snd_Volume(127);
    file_PlayWAV("bl16k.wav");
    while(snd_Playing());
    else
    putstr("bl16k.wav not found");
    endif

    if(file_Exists("intro1.wav"))
    snd_BufSize(3);
    snd_Volume(127);
    file_PlayWAV("intro1.wav");
    while(snd_Playing());
    else
    putstr("intro1.wav not found");
    endif

    // gfx_Set(OUTLINE_COLOUR, DARKOLIVEGREEN); // set outline colour, gfx_Cls() will draw outline
    // gfx_Cls();


    // Image5 1.0 generated 25/08/2014 16:45:23
    //img_Show(hndl,iImage5) ;

    repeat

    hndl := file_LoadImageControl("FANCYB~1.dat", "FANCYB~1.gci", 1);
    Wbs1 := 0 ; // up, set to non zero (specifically 2) when down

    // Winbutton1 generated 20/12/2011 3:55:28 PM

    img_SetWord(hndl, iWinbutton1, IMAGE_FLAGS, (img_GetWord(hndl, iWinbutton1, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iWinbutton1); // show button, only do this once

    touch_Set(TOUCH_ENABLE); // enable the touch screen



    state := touch_Get(TOUCH_STATUS); // get touchscreen status
    n := img_Touched(hndl,-1) ;

    //-----------------------------------------------------------------------------------------
    if(state == TOUCH_PRESSED) // if there's a press
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    if (n == iWinbutton1)
    img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, Wbs1+1); // where state is 0 for up, 1 for down, 2 for 'on' up and 3 for 'on' down
    img_Show(hndl,iWinbutton1) ;
    endif
    endif

    //-----------------------------------------------------------------------------------------
    if(state == TOUCH_RELEASED) // if there's a release
    if (n == iWinbutton1)
    if (Wbs1) Wbs1 := 0 ; else Wbs1 := 2 ; // toggle status
    img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, Wbs1); // where state is 0 for up, 1 for down, 2 for 'on' up and 3 for 'on' down
    img_Show(hndl,iWinbutton1) ;
    endif
    endif

    //-----------------------------------------------------------------------------------------
    if(state == TOUCH_MOVING) // if it's moving
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    endif

    // gfx_Cls();

    repeat


    // setbaud(BAUD_9600); // 9600 baud comms
    com_SetBaud(COM1,960);

    com1_Init(combuf, 48, 0); // set up a comms circular buffer, use the entire buffer, no sync character

    repeat

    sys_SetTimer(TIMER0, 2000); // set delay so we stay in next loop for 5 seconds

    // wait for a while gathering bytes
    // and continuously displaying the count
    // of characters in the buffer.
    //// repeat
    // Video1 1.0 generated 16/11/2013 18:32:51

    // txt_MoveCursor(2,1); // reset cursor to line 3, column 2
    // print("Buffered ", [DEC2Z] ( com_Count() )); // show count of chars in buffer


    until (! sys_GetTimer(TIMER0)); // loop until TIME_OUT register is 0

    /*
    if (com_Full())
    txt_MoveCursor(3,1); // reset cursor to line 5, column 2
    print("Buffer Full ", (++e) ); // print error count
    endif

    if (com_Error())
    txt_MoveCursor(4,1); // reset cursor to line 7, column 2
    print("Comms Error ", (++e2) ); // print error count
    endif
    */
    // now dump whatever we got to the terminal
    while ( (char := serin1()) >= 0)
    // txt_Set(TEXT_COLOUR, RED);
    gfx_MoveTo(0,0);
    // print("\n'",[CHR]char,"' is ");
    to(COM1); putch(char); // send buffered chars to com port
    //wend


    /*
    txt_Set(FONT_ID, 0);
    txt_MoveCursor(0,1); // reset cursor to line 1, column 2
    putstr("Serial Echo\n9600 baud");
    */


    switch

    case (char == 'A')

    // Image2 1.0 generated 22/08/2014 09:47:02
    img_Show(hndl,iImage2) ;

    // if(file_Exists("WF2.wav"))
    snd_BufSize(3);
    snd_Volume(127);
    file_PlayWAV("WF16k.wav");
    while(snd_Playing());
    // else
    // putstr("WF2.wav not found");
    //endif

    pause(7000);
    case (char == 'B')

    touch_DetectRegion(0, 0, 240, 320);
    //touch_DetectRegion(110,150,130,170); // 20x20 square centre screen
    if(touch_Get(TOUCH_STATUS) == TOUCH_PRESSED)
    state := touch_Get(TOUCH_STATUS);
    gfx_Cls();
    if(state == TOUCH_RELEASED)
    txt_MoveCursor(3,1);
    print("There is a Touch!");
    img_Show(hndl,iImage3) ;

    pause(7000);
    endif
    gfx_Cls();
    pause(1000);
    endif
    // Image3 1.0 generated 22/08/2014 09:47:16

    // putstr(" THREE");
    // com_Init(combuffer, 2, 0); // reset buffer

    case (char == 'C')

    // Image4 1.0 generated 22/08/2014 09:47:47
    img_Show(hndl,iImage4);
    // media_Imge(0, 3) ;// show image
    pause(1000);

    snd_BufSize(3);
    snd_Volume(127);
    file_PlayWAV("Bubble16k.wav"); //WF16k.wav");
    while(snd_Playing());

    case (char == 'D')

    for (frame := 0; frame <= 47; frame++)



    pause(1);
    next
    pause(7000);



    case (char == 'P')

    gfx_Cls() ;

    default:

    endswitch
    txt_MoveCursor(3,1);
    print("Buffered ", ( com1_Count() )); // show count of chars in buffer
    wend
    pause(1000);


    until ( com1_Full() || com1_Error() ); // reset if error occurred

    forever


    endfunc"

    Thanks,
    Eyall

  • #2
    At last i figured out the problem: i copy/pasteby mistake the 'hndl' from the FANCYBUTTON example code

    Comment

    Working...
    X