Announcement

Collapse
No announcement yet.

Pin code

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

  • Pin code

    Hello,

    I would like to make a screen to enter a pin code in order to unlock the screen.
    I would like to know how to add or remove a number from a variable.

    Example:

    var code: = 1234
    var keyCode;

    Push to number x add the number to var keycode.
    Push to del delete the last number entered to keyCode.
    View code entered on the screen.
    When code = keyCode : unlock screen.
    I have tried with pustr, buffer and to() but i don't understand all.
    How to do it?


    PS : i use Gen4-uLCD-70DT in Visi mode.

    Thank you

    Code:
    #platform "Gen4-uLCD-70DT"
    
    
    // Program Skeleton 1.4 generated 08/03/2021 09:36:56
    
    #inherit "4DGL_16bitColours.fnc"
    #inherit "PrintDisk.inc"
    
    #inherit "VisualConst.inc"
    
    // var gradientRAM[29+xxx*2] := [-1,-1,-9999,0,0,xxx] ; // uncomment and replace xxx with maximum of all inherent 'media' widgets
    
    #inherit "0.1Const.inc"
    var code := "1234";
    var keyCode;
    
    func main()
    // Uncomment the following if uSD and uSD based GCI images, fonts or strings used.
    
    var hstrings ; // Handle to access uSD strings, uncomment if required
    var hFont1 ; // Handle to access uSD fonts, uncomment if required and change n to font number
    putstr("Mounting...\n");
    if (!(file_Mount()))
    while(!(file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif
    
    hFont1 := file_LoadImageControl("01C0E6~1.D01", "01C0E6~1.G01", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
    hndl := file_LoadImageControl("01C0E6~1.dat", "01C0E6~1.gci", 1);
    
    gfx_Set(SCREEN_MODE,LANDSCAPE_R) ;
    
    // Code 1.1 generated 08/03/2021 13:37:34
    gfx_BGcolour(0x65BE) ;
    gfx_Cls() ;
    touch_Set(TOUCH_ENABLE);
    
    
    // boutton1 1.0 generated 08/03/2021 11:27:08
    img_ClearAttributes(hndl, iboutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton1); // show button, only do this once
    img_SetWord(hndl, iboutton1, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton1) ;
    
    // boutton2 1.0 generated 08/03/2021 11:27:47
    img_ClearAttributes(hndl, iboutton2, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton2); // show button, only do this once
    img_SetWord(hndl, iboutton2, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton2) ;
    
    // boutton3 1.0 generated 08/03/2021 11:27:49
    img_ClearAttributes(hndl, iboutton3, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton3); // show button, only do this once
    img_SetWord(hndl, iboutton3, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton3) ;
    
    // boutton4 1.0 generated 08/03/2021 11:27:50
    img_ClearAttributes(hndl, iboutton4, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton4); // show button, only do this once
    img_SetWord(hndl, iboutton4, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton4) ;
    
    // boutton5 1.0 generated 08/03/2021 11:27:52
    img_ClearAttributes(hndl, iboutton5, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton5); // show button, only do this once
    img_SetWord(hndl, iboutton5, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton5) ;
    
    // boutton6 1.0 generated 08/03/2021 11:27:54
    img_ClearAttributes(hndl, iboutton6, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton6); // show button, only do this once
    img_SetWord(hndl, iboutton6, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton6) ;
    
    // boutton7 1.0 generated 08/03/2021 11:27:55
    img_ClearAttributes(hndl, iboutton7, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton7); // show button, only do this once
    img_SetWord(hndl, iboutton7, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton7) ;
    
    // boutton8 1.0 generated 08/03/2021 11:27:57
    img_ClearAttributes(hndl, iboutton8, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton8); // show button, only do this once
    img_SetWord(hndl, iboutton8, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton8) ;
    
    // boutton9 1.0 generated 08/03/2021 11:27:59
    img_ClearAttributes(hndl, iboutton9, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton9); // show button, only do this once
    img_SetWord(hndl, iboutton9, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton9) ;
    
    // bouttonRetour 1.0 generated 08/03/2021 11:28:00
    img_ClearAttributes(hndl, ibouttonRetour, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, ibouttonRetour); // show button, only do this once
    img_SetWord(hndl, ibouttonRetour, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,ibouttonRetour) ;
    
    // boutton0 1.0 generated 08/03/2021 11:28:02
    img_ClearAttributes(hndl, iboutton0, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iboutton0); // show button, only do this once
    img_SetWord(hndl, iboutton0, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,iboutton0) ;
    
    // bouttonOk 1.0 generated 08/03/2021 11:28:03
    img_ClearAttributes(hndl, ibouttonOk, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, ibouttonOk); // show button, only do this once
    img_SetWord(hndl, ibouttonOk, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down, or 2 total states
    img_Show(hndl,ibouttonOk) ;
    
    // Strings1 1.1 generated 08/03/2021 11:34:21
    txt_FontID(hFont1) ; // Font index correct at time of code generation
    txt_FGcolour(WHITE) ;
    txt_BGcolour(0x65BE) ;
    gfx_MoveTo(304 , 8) ;
    PrintDisk(hstrings, Strings1StartH, Strings1StartL, Strings1Size, 0) ; // where i is Message 0 - Strings1Count-1
    
    
    var code := "1234";
    var state,n;
    //print(code);
    
    txt_MoveCursor(0,0);
    
    repeat
    
    if (keyCode == code)
    endif
    
    state := touch_Get(TOUCH_STATUS);
    n := img_Touched(hndl,-1) ;
    if (state == TOUCH_PRESSED)
    
    endif
    if (state == TOUCH_RELEASED)
    
    if (n == iboutton1)
    
    endif
    
    if (n == iboutton2)
    
    endif
    
    if (n == ibouttonOk)
    
    endif
    
    
    if (n == iboutton3)
    
    endif
    
    if (n == iboutton4)
    
    endif
    
    if (n == iboutton5)
    
    endif
    
    if (n == iboutton6)
    
    endif
    
    if (n == iboutton7)
    
    endif
    
    if (n == iboutton8)
    
    endif
    
    if (n == iboutton9)
    
    endif
    
    if (n == iboutton0)
    
    endif
    
    endif
    forever
    endfunc
    Last edited by APEL; 15 March 2021, 08:51 PM.

  • #2
    Hello,

    I have made an example project related to yours. You can use it as your reference. Please check the project included in this email.

    Also, you can check the links below to learn more about the functions used in the project and some related app note.
    I hope this helps.

    Best regards
    Attached Files

    Comment


    • #3
      Perfect, thank you very much

      Comment


      • #4
        Hi,

        We're happy to help.

        If you have other inquiries, feel free to open a ticket here 4D Systems helpdesk or a new forum post.

        Have a great day!

        Best regards.

        Comment

        Working...
        X