Sub Process_Globals
Dim Printer1 As EscPosPrinter
Dim Version As Double = 2.0 ' Demo program version
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
Activity.AddMenuItem("Connect", "mnuConnect")
Activity.AddMenuItem("Disconnect", "mnuDisconnect")
If FirstTime Then
Printer1.Initialize(Me, "Printer1")
DisableButtons
End If
Activity.Title = Activity.Title & " v" & NumberFormat2(Version, 0, 1, 1, False)
End Sub
Sub Printer1_Connected (Success As Boolean)
If Success Then
ToastMessageShow("Connected successfully", False)
EnableButtons
Else
Msgbox(Printer1.ConnectedErrorMsg, "Error connecting.")
End If
End Sub
Sub btnText_Click
Printer1.Reset
Printer1.WriteString(Printer1.REVERSE)
Printer1.WriteString("Reversed text" & CRLF)
Printer1.WriteString(Printer1.UNREVERSE)
Printer1.WriteString(Printer1.INVERT)
Printer1.WriteString("Normal text £££ " & Chr(99) & CRLF)
Printer1.WriteString(Printer1.UNINVERT)
Printer1.WriteString(Printer1.ULINE1 & "Underline 1 " & Printer1.ULINE2 & "Underline 2 " & Printer1.ULINE0 & "Normal" & CRLF)
Printer1.WriteString("None " & Printer1.BOLD & "Bold " & Printer1.NOBOLD & "None " & CRLF)
Printer1.WriteString("Single " & Printer1.HIGH & "High " & Printer1.WIDE & "Wide " & Printer1.HIGHWIDE & "Both" & Printer1.SINGLE & CRLF)
Printer1.LineSpacing = 15
Printer1.WriteString("Line space half follows" & CRLF)
Printer1.LineSpacing = 45
Printer1.WriteString("Line space one and a half follows" & CRLF)
Printer1.LineSpacing = 60
Printer1.WriteString("Line space two follows" & CRLF)
Printer1.WriteString("Ended" & CRLF)
Printer1.LineSpacing = 20
Printer1.CharacterFont = 0
Printer1.WriteString("Character font = 0, inset line follows" & CRLF)
Printer1.CharacterFont = 1
Printer1.LeftInset = 100
Printer1.WriteString("Character font = 1" & CRLF)
Printer1.WriteString("Character font = 1, inset self-cancelled" & CRLF)
Printer1.LeftMargin = 100
Printer1.WriteString("Character font = 1, left margin set" & CRLF)
Printer1.WriteString("Character font = 1" & CRLF)
Printer1.WriteString("Character font = 1" & CRLF)
Printer1.WriteString(Printer1.DEFAULTS)
Dim tabs() As Int = Array As Int(8,16,24,32)
Printer1.TabPositions = tabs
Printer1.WriteString("The following numbers are tabbed across the line" & CRLF)
Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4" & Printer1.HT & CRLF)
Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4")
Printer1.PrintAndFeedPaper(0) ' note no CRLF at end of line above
Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4" & CRLF)
Printer1.RelativePrintPosn = 120
Printer1.WriteString("First")
Printer1.RelativePrintPosn = 120 ' as dcoumented should push the next text further right but only works at start of line
Printer1.WriteString("Second" & CRLF)
Printer1.WriteString(Printer1.DEFAULTS & CRLF)
Printer1.WriteString("Text ended" & CRLF & CRLF)
End Sub
Sub btnQrCode_Click
' On my printer small QR codes don't seem to be able to be decoded and larger ones look obviously wrong :(
Printer1.Reset
Printer1.HRIfont = 1
Printer1.Justify = 1
Printer1.WriteQRCode(0, "M", 6, "Thanks for using our thermal printer!")
Printer1.WriteQRCode(0, "M", 4, "Thanks for using our thermal printer! Thanks for using our thermal printer! Thanks for using our thermal printer!")
End Sub