Announcement

Collapse
No announcement yet.

baud rate/comms speed problem with uLCD-32PTU

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

  • baud rate/comms speed problem with uLCD-32PTU

    Hi,

    I am trying to create games with arduino and display them on uLCD-32PTU serial display.
    We are having problems when we move on game and have to clear the screen.
    After clearing the screen it takes too long for arduino to write (in this case) my maze back.

    I think the problem is with baud rate being set to 9600
    but i can't find a way to change it

    I've tried to start arduino and screen with baud rate 115200 and also tried to change it with Display.setbaudWait(13); //13 being 115200baud rate according to picaso data sheet.

    I am using:

    uLCD-32PTU (Picaso serial)
    Arduino mega 2560 / UNO
    4d Arduino Adaptor Shield II

    I am not using 4d Workshop and i do not have microSD card.

    this is my testing code

    Code:
    #define DisplaySerial Serial
    
    //-------Picaso DISPLAYS-------
    
    #include <Picaso_Const4D.h>
    #include <Picaso_Serial_4DLib.h>
    //use Serial0 to communicate with the display.
    Picaso_Serial_4DLib Display(&DisplaySerial);
    
    //---------END-----------------
    
    int xAxis=0;
    int yAxis=0;
    
    
    void setup() {
    
      Serial.begin(9600);
    
      //For handling errors
    
      randomSeed(analogRead(0));
      //5 second timeout on all commands  
      Display.TimeLimit4D   = 5000 ;
    
     DisplaySerial.begin(9600) ;
     Serial.flush();
     Display.setbaudWait(13);
    
     //Serial.flush();
     //Serial.begin(115200);
     delay(3000);
    
      //--------------------------------Optional reset routine-----------------------------------
      //Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
      //If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
      //If using jumper wires, reverse the logic states below.
      //Refer to the accompanying application note for important information.
      pinMode(4, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(4, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(4, 0);  // unReset the Display via D4
      //-----------------------------------------END---------------------------------------------
    
      delay (5000); //let the display start up  
    
    
      Display.gfx_ScreenMode(LANDSCAPE);
    
      Display.gfx_Cls();            //clear the screen
       Display.gfx_MoveTo (100 , 100); // siirtää tekstin aloitus kohdan (x-axis(320), y-axis(240))
    
    
    }
    
    void loop()
    {
      xAxis = random(270);
      yAxis = random(200);
      Display.gfx_MoveTo (xAxis , yAxis);
      Display.println(" /)_/)");
      Display.println("( o.o )");
      Display.println(" > ^ <");
    
      delay(0);
      Display.gfx_Cls();
    
    }
    thank you
    Last edited by AddictedTuna; 22 November 2019, 06:26 PM.

  • #2
    Hi,

    Welcome to the forum,

    The setBaudWait may not be working correctly if the display is being reset after the command has been sent. If the display is being reset then the it will revert back to the 9600 baud.

    Clearing the screen isn't the quickest way to animate movement and it is better to just remove / redraw the area that has been changed or replaced. I have changed your code to show just removal of the last printed.

    Code:
    #define DisplaySerial Serial
    
    //-------Picaso DISPLAYS-------
    
    #include <Picaso_Const4D.h>
    #include <Picaso_Serial_4DLib.h>
    //use Serial0 to communicate with the display.
    Picaso_Serial_4DLib Display(&DisplaySerial);
    
    //---------END-----------------
    
    int xAxis=0;
    int yAxis=0;
    int oldx;
    int oldy;
    
    void setup() {
    
      Serial.begin(9600);
    
      //For handling errors
    
      randomSeed(analogRead(0));
      //5 second timeout on all commands  
      Display.TimeLimit4D   = 5000 ;
    
     //DisplaySerial.begin(9600) ;
     //Serial.flush();
     //Display.setbaudWait(13);
    
     //Serial.flush();
     //Serial.begin(115200);
     //delay(3000);
    
      //--------------------------------Optional reset routine-----------------------------------
      //Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
      //If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
      //If using jumper wires, reverse the logic states below.
      //Refer to the accompanying application note for important information.
      pinMode(4, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(4, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(4, 0);  // unReset the Display via D4
      //-----------------------------------------END---------------------------------------------
    
      delay (5000); //let the display start up  
    
      DisplaySerial.begin(9600) ;
      Display.setbaudWait(13);
    
     //Serial.flush();
    
      DisplaySerial.begin(115200);
      delay(3000);
    
      Display.gfx_ScreenMode(LANDSCAPE);
    
      Display.gfx_Cls();            //clear the screen
       Display.gfx_MoveTo (100 , 100); // siirtää tekstin aloitus kohdan (x-axis(320), y-axis(240))
    
    
    }
    
    void loop()
    {
      xAxis = random(270);
      yAxis = random(200);
      Display.gfx_MoveTo (oldx , oldy);
      Display.println("      ");
      Display.println("       ");
      Display.println("      ");
      Display.gfx_MoveTo (xAxis , yAxis);
      Display.println(" /)_/)");
      Display.println("( o.o )");
      Display.println(" > ^ <");
      oldx = xAxis;
      oldy = yAxis;
      delay(1);
      //Display.gfx_Cls();
    
    }
    A faster way again would be to draw a filled rectangle to erase the area that was previously printed.

    I hope this helps

    Best regards

    Paul

    Comment


    • AddictedTuna
      AddictedTuna commented
      Editing a comment
      everything you fixed works perfectly!

      thank you very much!
Working...
X