Menu

Srcolling Text only 37 Bytes: Resolved

bed
2019-03-21
2019-03-24
  • bed

    bed - 2019-03-21

    I think found a little bug.
    According to the help, a string with the length of 40 characters is allowed for controllers with more than 367 bytes of RAM.
    In my project with the PIC18F25K22 and glcd1306 128x64 Pix in TEXTONLY mode and Protect_Overrun, I can only use 37 bytes without errors. With 38-40 bytes it comes to misrepresentations at the first position, but the program works, it only looks stupid.

    Code: snippet

    DIM scrolltext AS STRING
    '          "1234567890123456789012345678901234567890"
    scrolltext="U/D=Ausw M=stellt U,D gleichz=Ende .."  ; OKAY
    'scrolltext="U/D=Auswahl M=stellt U,D gleichz=Ende " ; WRONG
    
    function menuLine
            scrolltext=mid(scrolltext,2)+left(scrolltext,1,1)
            glcdPrint(0,56,scrolltext)
    wait delay
    end function
    

    RAM used:

    Chip resource usage:
    Chip Model: 18F25K22
    
    Program Memory: 8454/16384 words (51.6%)
    
    RAM: 547/1536 bytes (35.61%)
    
     
  • Anobium

    Anobium - 2019-03-21

    Use the size parameter where * 128 would size the string for you.

    DIM scrolltext AS STRING * 128 'other big number

     

    Last edit: Anobium 2019-03-21
  • bed

    bed - 2019-03-21

    No, just tried it before, this does not fix the prob. 37 is limit
    I can share two Videos. Or build an example

     
  • Theo

    Theo - 2019-03-21

    @bed
    Try this one:
    The Syntax of Left is:

    output = Left(source, count)
    

    and not

    output = Left(source, count ,count)
    

    Mfg, Theo.

     
  • bed

    bed - 2019-03-21

    Ok, thanks.
    I had copied it from my older Project...
    But
    scrolltext=mid(scrolltext,2)+left(scrolltext,1)
    Same result. :-(

     
  • Anobium

    Anobium - 2019-03-21

    I think Theo meant....as left is output = Left(source, count)

    try
    =mid(source, start, count)

     
  • bed

    bed - 2019-03-23

    This is what happens when you use foreign code without your own thoughts.
    (it has worked before )

    It remains the astonishing thing that despite ignoring the syntax of mid and left you get a very small and limited working code... Which of course you shouldn't do, because who knows when the code will fall on your face later :-)
    I have now found a less elegant method, which works fine with longer strings.

    DIM scrolltext AS STRING * 140
    '          "1234567890123456789012345678901234567890" ; 40
    scrolltext="                  Here comes a long example text which stands for a huge Description for the possibilities in a menu                  "
    DIM scroll,laenge AS BYTE
    #DEFINE maxtextdisplay 18 ' We can display a max of 18 Char in a row
    laenge=len(scrolltext)
    scroll=1 
    glcdPrint(0,0,"Scrolltxt len:")
    glcdPrint(105,0,laenge)
    do forever
    '   here is the normal main loop with button check etc.
        menuLine
    
    LOOP
    
    sub menuLine
        glcdPrint(0,56,mid(scrolltext,scroll,maxtextdisplay))
        wait delay
        scroll++
        IF scroll=laenge - maxtextdisplay THEN
            scroll=1
        END IF
    
    end sub
    

    So, the downside is using more code and an extra variable

     
  • bed

    bed - 2019-03-24

    There is always something positive in a false assumption. Last but not least, my scroll text led to an improvement 😘

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.