Announcement

Collapse
No announcement yet.

Gen4-IoD-28T. Buttonx. freeze. when type too fast.

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

  • Gen4-IoD-28T. Buttonx. freeze. when type too fast.

    Hello dear 4D Systems team and 4D Users!

    I getting started with IoD modules and i have an issue(and another but that fits another topic.).
    I declared six buttons and a textwindow. When i touch the buttons on the screen one after another (or one button) too fast, the whole modul get freeze.
    I use arduino 1.8.3 and version 2.4.0 of esp lbrary. I trierd to use different type of technics to make it and all of them get the same result. I tried to add some delay but no luck.
    Is there anybody who faced with this issue? Or somebody who can help me where/what i wrote badly?
    Thank You!
    Robert


    Here is the code that i made:

    #include "ESP8266WiFi.h"
    #include "GFX4d.h"
    uint8_t buttw;
    int but;
    int lastbut;
    GFX4d gfx = GFX4d();

    void setup() {
    Serial.begin(115200);
    gfx.begin();
    gfx.Cls();
    gfx.ScrollEnable(true);
    gfx.BacklightOn(true);
    gfx.Orientation(LANDSCAPE_R);
    gfx.SmoothScrollSpeed(5);
    gfx.touch_Set(TOUCH_ENABLE);
    gfx.TextColor(WHITE); gfx.Font(2); gfx.TextSize(1);
    gfx.TextWindow(0,0, 320,100, BLACK, SILVER, DARKGRAY);
    gfx.Buttonx(33, 10, 150, 40, 40, SILVER, "1", 1, BLACK);
    gfx.Buttonx(34, 60, 150, 40, 40, SILVER, "2", 1, BLACK);
    gfx.Buttonx(35, 110, 150, 40, 40, SILVER, "3", 1, BLACK);
    gfx.Buttonx(36, 160, 150, 40, 40, SILVER, "4", 1, BLACK);
    gfx.Buttonx(37, 210, 150, 40, 40, SILVER, "5", 1, BLACK);
    gfx.Buttonx(38, 260, 150, 40, 40, SILVER, "6", 1, BLACK);
    }

    void loop() {

    //1st version
    //buttw = gfx.CheckButtons();
    // if(buttw != lastbut && buttw > 0){
    // but = buttw;
    // switch(but){
    // case 33:gfx.TWcls();gfx.TWprintln("1");break;
    // case 34:gfx.TWcls();gfx.TWprintln("2");break;
    // case 35:gfx.TWcls();gfx.TWprintln("3");break;
    // case 36:gfx.TWcls();gfx.TWprintln("4");break;
    // case 37:gfx.TWcls();gfx.TWprintln("5");break;
    // case 38:gfx.TWcls();gfx.TWprintln("6");break;
    // }
    // }else{but = 0;}
    // lastbut = buttw;

    //2nd version
    //buttw = gfx.CheckButtons();
    // if(buttw != lastbut && buttw > 0&&buttw<255){Serial.println(buttw);delayMicroseconds(14000);//delay(14);
    // but = buttw;gfx.TWcls();
    // if(but == 33){
    // gfx.TWprintln("1");
    // }
    // if(but == 34){
    // gfx.TWprintln("2");
    // }
    // if(but == 35){
    // gfx.TWprintln("3");
    // }
    // if(but == 36){
    // gfx.TWprintln("4");
    // }
    // if(but == 37){
    // gfx.TWprintln("5");
    // }
    // if(but == 38){
    // gfx.TWprintln("6");
    // }
    // } else {
    // but = 0;delayMicroseconds(14000);//delay(14);
    // }
    // lastbut = buttw;

    //3rd version
    buttw = gfx.CheckButtons();
    switch(buttw){
    case 33:gfx.TWcls();gfx.TWprintln("1");break;
    case 34:gfx.TWcls();gfx.TWprintln("2");break;
    case 35:gfx.TWcls();gfx.TWprintln("3");break;
    case 36:gfx.TWcls();gfx.TWprintln("4");break;
    case 37:gfx.TWcls();gfx.TWprintln("5");break;
    case 38:gfx.TWcls();gfx.TWprintln("6");break;
    }


    yield();
    }

  • #2
    Hello,

    Welcome to the forum,

    I have seen problems with buttonx when it is being over-read. The demo in the examples section of the GFX4d, called 4Dos, has a on screen keyboard and it was necessary to include a delay of 2 millis. The keyboard in 4Dos can be quickly swiped without crashing.

    I will have a look into it as an update to GFX4d will be released within the next few days.

    Many thanks for pointing this out to us.

    Best regards

    Paul

    Comment


    • #3
      Just noticed that your first attempt does have a delay. I will test your code to see if I get the same result

      Best regards

      Paul

      Comment


      • #4
        Hi,

        Without the TWCls() it works fine. I will find out what is causing this and make sure it is fixed in the next release.

        Code:
        #include "ESP8266WiFi.h"
        #include "GFX4d.h"
        uint8_t buttw;
        int but;
        int lastbut;
        GFX4d gfx = GFX4d();
        
        void setup() {
        Serial.begin(115200);
        gfx.begin();
        gfx.Cls();
        gfx.ScrollEnable(true);
        gfx.BacklightOn(true);
        gfx.Orientation(LANDSCAPE_R);
        gfx.SmoothScrollSpeed(5);
        gfx.touch_Set(TOUCH_ENABLE);
        gfx.TextColor(WHITE); gfx.Font(2); gfx.TextSize(1);
        gfx.TextWindow(0,0, 320,100, BLACK, SILVER, DARKGRAY);
        gfx.Buttonx(33, 10, 150, 40, 40, SILVER, "1", 1, BLACK);
        gfx.Buttonx(34, 60, 150, 40, 40, SILVER, "2", 1, BLACK);
        gfx.Buttonx(35, 110, 150, 40, 40, SILVER, "3", 1, BLACK);
        gfx.Buttonx(36, 160, 150, 40, 40, SILVER, "4", 1, BLACK);
        gfx.Buttonx(37, 210, 150, 40, 40, SILVER, "5", 1, BLACK);
        gfx.Buttonx(38, 260, 150, 40, 40, SILVER, "6", 1, BLACK);
        }
        
        void loop() {
        
        //1st version
        //buttw = gfx.CheckButtons();
        // if(buttw != lastbut && buttw > 0){
        // but = buttw;
        // switch(but){
        // case 33:gfx.TWcls();gfx.TWprintln("1");break;
        // case 34:gfx.TWcls();gfx.TWprintln("2");break;
        // case 35:gfx.TWcls();gfx.TWprintln("3");break;
        // case 36:gfx.TWcls();gfx.TWprintln("4");break;
        // case 37:gfx.TWcls();gfx.TWprintln("5");break;
        // case 38:gfx.TWcls();gfx.TWprintln("6");break;
        // }
        // }else{but = 0;}
        // lastbut = buttw;
        
        //2nd version
        //buttw = gfx.CheckButtons();
        // if(buttw != lastbut && buttw > 0&&buttw<255){Serial.println(buttw);delayMicroseconds(14000);//delay(14);
        // but = buttw;gfx.TWcls();
        // if(but == 33){
        // gfx.TWprintln("1");
        // }
        // if(but == 34){
        // gfx.TWprintln("2");
        // }
        // if(but == 35){
        // gfx.TWprintln("3");
        // }
        // if(but == 36){
        // gfx.TWprintln("4");
        // }
        // if(but == 37){
        // gfx.TWprintln("5");
        // }
        // if(but == 38){
        // gfx.TWprintln("6");
        // }
        // } else {
        // but = 0;delayMicroseconds(14000);//delay(14);
        // }
        // lastbut = buttw;
        
        //3rd version
        buttw = gfx.CheckButtons();
        switch(buttw){
        case 33:gfx.TWprintln("1");break;
        case 34:gfx.TWprintln("2");break;
        case 35:gfx.TWprintln("3");break;
        case 36:gfx.TWprintln("4");break;
        case 37:gfx.TWprintln("5");break;
        case 38:gfx.TWprintln("6");break;
        }
        delay(5);
        
        yield();
        }
        Best regards

        Paul

        Comment


        • Philip51
          Philip51 commented
          Editing a comment
          Hello Paul!

          Thank You for your quick response!
          And also Thanks for the point. I got the same that You without gfx.TWcls();, after I eliminate it, freezing goes away. So now it works fine, without freezing.

          [(For Everybody! I just notice, the nex are not a good way.) Also, for get the same working of the program in the library I took public the twcurx and twcury variables and gives them a value before call gfx.TWprint() (I change gfx.TWprintln to gfx.TWprint) and it works almost the same like the original whitout freezing.]

          Maybe a TWmoveTo routine would be a good option for the TextWindow function.
          Last edited by Philip51; 30th March 2018, 05:25 AM.
      Working...
      X