Announcement

Collapse
No announcement yet.

Dynamic Text Options

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

  • Dynamic Text Options

    I am using Extended Graphics for my design environment but cannot find a method for creating dynamic text.
    I can create custom fonts and use those, but that is not exactly what I am wanting to do, unless there is no other way.

    In that environment you can create string objects, which allows for a choice of font and allows for basic formatting (width. height and text alignment) which is what I would like to use.
    I believe that this can be done using Magic Code, but I do not have a Pro license, nor am I using the ViSi Genie environment.

    Is there a way of updating a string object programmatically using the Diablo serial library?

    If so, an example showing how to do this would be greatly appreciated.

  • #2
    Hi SkiFreak,

    The fastest way to implement this using the Diablo serial library is by using the text move cursor function to print at a location.

    Display.txt_MoveCursor(line,column);
    Display.print();

    To erase the contents you can print spaces as values or draw a black rectangle over the string you've written.

    Comment


    • #3
      Yes, that would work, but it does not answer my question.
      Using the serial commands you can manipulate a movie object (display a specific frame).

      What I want to know is if you can do a similar thing and programmatically change the contents of a string object.

      Comment


      • #4
        Hi,

        In the Diablo serial library it really is easier to use the commands as Jerson mentioned. The Serial library in the Extended graphics library can be very flexible so you can change all to availble options of the text before printing eg foreground and background colours

        If you need fonts of different sizes then it simply is a case of creating more and switching to the font that you need.

        All you can do in a strings object programmatically is change the text.

        Best regards

        Paul

        Comment


        • #5
          Yeah, that is what i want to do... change the text of a string object programmatically.
          What I would like to know is how to do that.

          Can you give me a code example?
          Last edited by SkiFreak; 11 August 2020, 05:38 PM.

          Comment


          • #6
            Hi,

            You actually don't need to target the string object display on screen once it was displayed initially, you only just need to know its location on screen so that you can overwrite the string directly.
            Here's a snippet of code taken from the Arduino GoldeloxBigDemo example. In here the string located at Line 5, Column 3 has its text updated depending on the joystick direction.

            Code:
            {
            Display.txt_MoveCursor(5,3) ;
            switch (i)
            {
            case RELEASED :
            Display.putstr("Released") ;
            break ;
            case UP :
            Display.putstr("   Up   ") ;
            break ;
            case LEFT :
            Display.putstr("   Left  ") ;
            break ;
            case DOWN :
            Display.putstr("   Down ") ;
            break ;
            case RIGHT :
            Display.putstr("   Right ") ;
            break ;
            case FIRE :
            Display.putstr("   Fire ") ;
            break ;
            }
            }
            I hope this helps,
            Best Regards

            Comment


            • #7
              Correct me if I am wrong here, but this is not updating the actual string object, rather, it is overwriting the text in the string object.

              When defining a sting object you can set basic formatting, like the font, font weight, text box size, transparency and alignment etc.
              If you are simply overwriting the text in the string object, by using putstr(), you need to do as you have shown in the example above, that being to use spaces to align and cover the previously displayed text.

              So, back to my original question...
              Is it possible to update the text in the actual string object programmatically, and in doing so, maintain the chosen formatting of that string object?

              Comment


              • #8
                In the Serial SPE environment, the string object just works like this: Setup font style > Setup cursor > Write String; you can see this when you paste code for strings on the code editor as show below.

                Click image for larger version

Name:	String.PNG
Views:	31
Size:	207.6 KB
ID:	73106

                There is really no object to point to in the display side so you are free to dynamically replace text anywhere on the screen. Once the font settings are set initially, it will be retained for all the succeeding string writes unless changed, so it is safe to maintain the pattern above if you have different font styles for different strings.
                Attached Files

                Comment


                • #9
                  Can someone explain the parameters of the PrintDisk function, as I have not found this documented anywhere.

                  Comment


                  • #10
                    Hi,

                    The printdisk basic parameters are as follows:

                    Code:
                    func PrintDisk(display, hndl, offset,, msglen, msgid)
                    
                    display - object identifier for C++ (usually Display is used) 
                    hndl - handle to access string file stored in uSD card (Use file_open to access)
                    offset - offset of string in the file
                    msglen - string length
                    msgid - string ID
                    The parameters for this is automatically generated when you paste its code into the code editor.

                    I hope this helps,
                    Last edited by Jerson; 17 August 2020, 11:19 AM.

                    Comment

                    Working...
                    X