Announcement

Collapse
No announcement yet.

Scrolling text

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

  • Scrolling text

    Hi,

    How could be a horizontal scrolling text be made in 4D?

    (GoldenOX)

    Greets,
    Gino

  • #2


    Hi,I have had the same problem. My solution is to save the sceen memory to the sd card. With copyScreen2uSD(x, y, width, height); and then refresh the screen with copy uSD2Screen(x, y, width, height);
    The time for the refresh is approx. 900 ms. For my application it is enough !
    Maybe somebody has a better solution ? But remember the limited variable space on this platform
    Goldelox

    Have fun
    With best regards
    Sigi



    Comment


    • #3


      With the command:gfx_MoveTo(x, y); it is possible to create a scroll text. Just increment X.
      The the number of character can be max twice the characters you get horizontal. More characters just make the tail overwrite the head.


      In the end I got it from the BigDEMO sample.


      Greets,

      Gino

      Comment


      • #4


        Hi,
        Of course !!
        But I understood you, if you print on the last line, that they lines before are scrolling up.
        If you are the last line, the new line will be always printed on the last line and the lines before will be scroll up. Sorry, english is not my mother language, but I hope that you understand what I mean.
        If you are happy with your solution, than it is ok for you.
        Cheers
        Sigi

        Comment


        • #5


          Here is a way to scroll text which works pretty well for me. I would like to clean up the code (suggestions welcome) and you will see in the code there are two notes about features I wish to impliment.

          In the mean time, it is a pretty usable bit of code:

          HTML Code:
           #platform "uOLED-32028-P1T" 
          /*************************************************
          * Filename: Scroll_Text.4dg
          * Created: 19/02/2010
          * Author: Pro AV
          * Description: Scroll Text subroutine
          **************************************************/
          #constant SCROLL_SPEED 20 //Milliseconds the scroll text pauses before moving
          var text_x; //current scroll position
          
          /*------------------------------------------------*/
          /*Scroll /text/ at /text_y/ left by 1 pixel------------*/
          /*------------------------------------------------*/
          func Scroll_Text(var text, var text_y)
          var EOL; //End Of Line
          /* There must be a better way to do this */
          EOL := -str_Length(text)*24; //The right edge of the text (Font 4 is 12 pixels per char)
          // EOL := gfx_Get(RIGHT_POS);
          if(text_x < EOL) //check if the text has moved off the edge of left the screen
          text_x := gfx_Get(X_RES); //Start the text on the right screen edge
          else
          text_x := text_x - 1; //Move 1 pixel left each time the routine is called
          endif
          
          gfx_Set(CLIPPING, OFF);
          gfx_MoveTo(text_x, text_y);
          //The next two lines can be changed to multiply the text size by the last number EOL length will have to be changed to match...
          txt_Set(TEXT_OPACITY, OPAQUE); //Opaque text will overwrite previous text
          txt_Set(TEXT_HEIGHT, 2); //Double height.
          txt_Set(TEXT_WIDTH, 2); //Double width
          /* I need to figure out a way to make it only display the text on the screen (not off the edge) */
          to(GFX); putstr(text); //Display the text
          endfunc
          
          /*------------------------------------------------*/
          /*MAIN CODE-------------------------------------*/
          /*------------------------------------------------*/
          func main()
          repeat
          if(sys_GetTimer(TIMER1) == 0) //Timer 1 is the scroll timer... 
          sys_SetTimer(TIMER1, SCROLL_SPEED);
          // This Should be read from a file at the start of the program in another subroutine (Read_Text_File)
          Scroll_Text("Scrolling Text", 10);
          endif
          forever
          endfunc

          Feel free to use this as you will.

          P.S. Somehow the "CODE" tag seems to mess up some of the symbols. I will attach a .zip of the file too.

          Attached files Scroll_Text.zip (1.1 KB)

          Comment

          Working...
          X