Sub Process_Globals
Public Serial1 As Serial
Private timer As Timer
' Private wifi As ESP8266WiFi
Private dmd As DMD
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'example of connecting to a local network
' If wifi.Connect2("SSID", "PASSWORD") Then
' Log("Connected to network")
' Else
' Log("Failed to connect to network")
' End If
' dmd.DISPLAYS_ACROSS = 1
' dmd.DISPLAYS_DOWN = 1
dmd.Initialize(dmd.DISPLAYS_ACROSS,dmd.DISPLAYS_DOWN)
timer.Initialize("ScanDMD",100)
' timer.Enabled = True
'//clear/init the dmd pixels held in RAM
dmd.clearScreen(1 ) '//True is normal (all pixels off), False is negative (all pixels on)
AddLooper("myloop")
AddLooper("scanSPI")
End Sub
Sub scanDMD
Log("scanDMD run")
dmd.scanDisplayBySPI
End Sub
Sub scanSPI
Log("scanSPI")
dmd.scanDisplayBySPI
End Sub
Sub DelayMS(TimeMS As Int)
For t = 0 To TimeMS
Delay (1)
dmd.scanDisplayBySPI
Next
End Sub
'/*--------------------------------------------------------------------------------------
' Loop
' Arduino architecture main Loop
'--------------------------------------------------------------------------------------*/
Sub myloop
Dim b As Byte
'// 10 x 14 font clock, including demo of Or And NOR modes For pixels so that the flashing colon can be overlayed
dmd.clearScreen( 1 )
dmd.selectFont(01)
dmd.drawChar( 0, 3, "1", dmd.GRAPHICS_NORMAL ) ': scanDMD
dmd.scanDisplayBySPI
dmd.drawChar( 7, 3, "2", dmd.GRAPHICS_NORMAL ) ': scanDMD
dmd.scanDisplayBySPI
dmd.drawChar( 17, 3, "3", dmd.GRAPHICS_NORMAL ) ': scanDMD
dmd.scanDisplayBySPI
dmd.drawChar( 25, 3, "4", dmd.GRAPHICS_NORMAL ) ': scanDMD
dmd.scanDisplayBySPI
dmd.drawChar( 15, 3, ":", dmd.GRAPHICS_OR ) ': scanDMD '// clock colon overlay on
' dmd.scanDisplayBySPI
DelayMS( 1000 )
dmd.drawChar( 15, 3, ":", dmd.GRAPHICS_NOR ) ': scanDMD '// clock colon overlay off
' dmd.scanDisplayBySPI
DelayMS( 1000 )
dmd.drawChar( 15, 3, ":", dmd.GRAPHICS_OR ) ': scanDMD '// clock colon overlay on
' dmd.scanDisplayBySPI
DelayMS( 1000 )
dmd.drawChar( 15, 3, ":", dmd.GRAPHICS_NOR ) ': scanDMD '// clock colon overlay off
' dmd.scanDisplayBySPI
DelayMS( 1000 )
dmd.drawChar( 15, 3, ":", dmd.GRAPHICS_OR ) ': scanDMD '// clock colon overlay on
' dmd.scanDisplayBySPI
DelayMS( 1000 )
dmd.drawMarquee("HiLOGIX Technologies",20,(32*dmd.DISPLAYS_ACROSS)-1,0)
dmd.scanDisplayBySPI
Dim start As ULong =Millis()
Dim time As ULong =start
Dim ret As bool =False
Do While Not(ret)
If ((time+50) < Millis) Then
ret=dmd.stepMarquee(-1,0)
time=Millis
End If
scanSPI
Loop
'// half the pixels on
dmd.drawTestPattern( dmd.PATTERN_ALT_0 )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
'// the other half on
dmd.drawTestPattern( dmd.PATTERN_ALT_1 )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
'// display some text
dmd.clearScreen( 1 )
dmd.selectFont(00)
For x=0 To dmd.DISPLAYS_ACROSS-1
For y=0 To dmd.DISPLAYS_DOWN-1
dmd.drawString( 2+(32*x), 1+(16*y), "freet", 5, dmd.GRAPHICS_NORMAL )
dmd.scanDisplayBySPI
dmd.drawString( 2+(32*x), 9+(16*y), "ronic", 5, dmd.GRAPHICS_NORMAL )
dmd.scanDisplayBySPI
Next
Next
DelayMS( 5000 )
'// draw a border rectangle around the outside of the display
dmd.clearScreen( 1 )
dmd.drawBox( 0, 0, (32*dmd.DISPLAYS_ACROSS)-1, (16*dmd.DISPLAYS_DOWN)-1, dmd.GRAPHICS_NORMAL )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
For y=0 To dmd.DISPLAYS_DOWN-1
For x=0 To dmd.DISPLAYS_ACROSS-1
'// draw an X
Dim ix As Int =32*x
Dim iy As Int =16*y
dmd.drawLine( 0+ix, 0+iy, 11+ix, 15+iy, dmd.GRAPHICS_NORMAL )
' dmd.scanDisplayBySPI
dmd.drawLine( 0+ix, 15+iy, 11+ix, 0+iy, dmd.GRAPHICS_NORMAL )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
'// draw a circle
dmd.drawCircle( 16+ix, 8+iy, 5, dmd.GRAPHICS_NORMAL )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
'// draw a filled box
dmd.drawFilledBox( 24+ix, 3+iy, 29+ix, 13+iy, dmd.GRAPHICS_NORMAL )
' dmd.scanDisplayBySPI
DelayMS( 1000 )
Next
Next
'// stripe chaser
Dim b_str As String
For b = 0 To 20-1
b_str = NumberFormat(Bit.And(b,1),0,0)
dmd.drawTestPattern(b_str+dmd.PATTERN_STRIPE_0 )
' dmd.scanDisplayBySPI
DelayMS( 300 )
Next
DelayMS( 500 )
End Sub
#if C
//exemple for 4 fonts
#include <SystemFont5x7.h>
#include <Arial_black_16.h>
#include <Arial_Black_16_ISO_8859_1.h>
#include <Arial14.h>
const uint8_t * B4R::B4RDMD::myfonts[]= {
System5x7, // => setfont(00)
Arial_Black_16, // => setfont(01)
Arial_Black_16_ISO_8859_1, // => setfont(02)
Arial_14 // => setfont(03)
};
#End If