b+ Beginners Corner
#13
Build a Scrolling Text Screen
Code: (Select All)

_Title "Building a Scrolling LED Screen" ' b+ 2021-05-08

Screen _NewImage(1200, 160, 32)
_Delay .25 'give screen time to load
_ScreenMove _Middle 'and center screen

'scroll some text
Text$ = "Try scrolling me for awhile until you got it, then press a key...  "
lenText = Len(Text$)
startTextPos = 1
'put text in sign 15 chars wide in middle of screen print the message moving down 1 character evey frame
_Title "Building a Scrolling LED Screen:  Step 1 get some code to scroll your message in middle of screen."
Do
    k$ = InKey$
    Cls
    ' two pieces of text?  when get to end of text will have less than 15 chars to fill sign so get remainder from front
    len1 = lenText - startTextPos
    If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0
    ' locate at middle of screen for 15 char long sign
    _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2)
    startTextPos = startTextPos + 1
    If startTextPos > lenText Then startTextPos = 1
    _Display ' no blinking when clear screen so often
    _Limit 5 ' slow down to see scroll
Loop Until Len(k$)

' OK  now for the enLARGE M E N T  using _PutImage
' our little sign is 16 pixels high and 8 * 15 chars pixels wide = 120
Dim sign As Long
sign = _NewImage(120, 16, 32) ' we will store the print image here

'  _PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]][_SMOOTH]
'  use same pixel location to _printString as for _PutImage Source rectangle ie (sx1, sy1), -step( sign width and height)

' test screen capture with _putimage and then blowup with _putimage
'_PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15)
'Cls
'_PutImage , sign, 0 ' stretch to whole screen
'_Display

'now that that works  do it on the move

' about here I resized the screen to 1200 x 160 to make the text scalable X's 10 ie 120 x 10 wide and 16 x 10 high
_Title "Building a Scrolling LED Screen:  Step 2 Blow it up by using _PutImage twice once to capture, then to expand"
k$ = ""
Do
    k$ = InKey$
    Cls
    ' two pieces of text?  when get to end of text will have less than 15 chars to fill sign so get remainder from front
    len1 = lenText - startTextPos
    If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0
    ' locate at middle of screen for 15 char long sign
    _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2)
    _PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15)

    Cls
    _PutImage , sign, 0 ' stretch to whole screen
    _Display ' no blinking when clear screen so often
    _Limit 5 ' slow down to see scroll
    startTextPos = startTextPos + 1
    If startTextPos > lenText Then startTextPos = 1
Loop Until Len(k$)



' now for a mask just draw a grid  test grid draw here
'For x = 0 To _Width Step 10 ' verticals
'    Line (x, 0)-(x + 3, _Height), &HFF000000, BF
'Next
'For y = 0 To _Height Step 10
'    Line (0, y)-(_Width, y + 3), &HFF000000, BF
'Next

_Title "Building a Scrolling LED Screen:  Step 3 Mask or Cover the thing with a grid or grate."
' here is the whole code with all setup variables
k$ = ""
Do
    k$ = InKey$
    Cls
    ' two pieces of text?  when get to end of text will have less than 15 chars to fill sign so get remainder from front
    len1 = lenText - startTextPos
    If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0
    ' locate at middle of screen for 15 char long sign
    _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2)
    _PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15)

    Cls
    _PutImage , sign, 0 ' stretch to whole screen

    ' now for a mask just draw a grid  best to draw this and copy and layover screen as another layer
    ' here QB64 is fast evough to redarw each time
    For x = 0 To _Width Step 10 ' verticals
        Line (x, 0)-(x + 3, _Height), &HFF000000, BF
    Next
    For y = 0 To _Height Step 10
        Line (0, y)-(_Width, y + 3), &HFF000000, BF
    Next

    _Display ' no blinking when clear screen so often
    _Limit 5 ' slow down to see scroll
    startTextPos = startTextPos + 1
    If startTextPos > lenText Then startTextPos = 1
Loop Until Len(k$)



Step one is just getting text scrolling in center of screen:
   

Step 2 is enlarging text to fill screen:
   

Step 3 is adding a grid face cover to make the letters appear to be lights:
   
b = b + ...
Reply


Messages In This Thread
b+ Beginners Corner - by bplus - 05-20-2023, 06:34 PM
RE: b+ Beginners Corner - by vince - 05-20-2023, 06:47 PM
RE: b+ Beginners Corner - by bplus - 05-20-2023, 07:11 PM
RE: b+ Beginners Corner - by PhilOfPerth - 05-26-2023, 12:12 AM
RE: b+ Beginners Corner - by bplus - 05-26-2023, 04:11 PM
RE: b+ Beginners Corner - by PhilOfPerth - 05-26-2023, 11:18 PM
RE: b+ Beginners Corner - by mnrvovrfc - 05-27-2023, 12:15 AM
RE: b+ Beginners Corner - by PhilOfPerth - 05-27-2023, 02:27 AM
RE: b+ Beginners Corner - by bplus - 05-29-2023, 12:07 AM
RE: b+ Beginners Corner - by bplus - 05-29-2023, 01:37 AM
RE: b+ Beginners Corner - by mnrvovrfc - 05-29-2023, 02:29 AM
RE: b+ Beginners Corner - by bplus - 05-30-2023, 04:17 PM
RE: b+ Beginners Corner - by bplus - 06-15-2023, 03:06 PM
RE: b+ Beginners Corner - by GareBear - 06-15-2023, 07:50 PM
RE: b+ Beginners Corner - by bplus - 06-15-2023, 10:42 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 02:46 PM
RE: b+ Beginners Corner - by CharlieJV - 06-23-2023, 03:26 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 08:28 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-23-2023, 09:45 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 09:56 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-24-2023, 02:47 AM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 10:02 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 02:35 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 02:52 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 07:48 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-24-2023, 08:02 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 08:40 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-24-2023, 10:07 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 09:08 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 09:12 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-24-2023, 11:44 PM
RE: b+ Beginners Corner - by bplus - 06-25-2023, 02:27 PM
RE: b+ Beginners Corner - by OldMoses - 06-25-2023, 05:49 PM
RE: b+ Beginners Corner - by bplus - 06-25-2023, 06:40 PM
RE: b+ Beginners Corner - by OldMoses - 06-25-2023, 08:03 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 01:14 AM
RE: b+ Beginners Corner - by mnrvovrfc - 06-26-2023, 02:26 AM
RE: b+ Beginners Corner - by Ultraman - 06-26-2023, 11:29 AM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 12:17 PM
RE: b+ Beginners Corner - by Ultraman - 06-26-2023, 12:21 PM
RE: b+ Beginners Corner - by Dimster - 06-26-2023, 02:38 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 03:32 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 04:48 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 01:29 AM
RE: b+ Beginners Corner - by OldMoses - 06-27-2023, 11:49 AM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 12:40 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-27-2023, 02:12 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 03:22 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-27-2023, 05:21 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 05:48 PM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 03:20 AM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 02:54 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-28-2023, 07:07 PM
RE: b+ Beginners Corner - by Dimster - 06-28-2023, 09:50 PM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 10:27 PM



Users browsing this thread: 20 Guest(s)