Share My Creation Bluetooth TSPL Printer Class

在过去的几周里,我一直在测试不干胶标签打印机。我在互联网上找到了很多信息,只有ESC / POS相关信息。没有这样的TSPL打印源代码。后来,我要求印刷供应商转到tspl指令文件。经过不断的实验,整理出以下代码,希望能为有需要的朋友提供参考!
以上英文来自翻译软件!
熟食店.png
 

Attachments

  • TSPL.zip
    13.7 KB · Views: 422
Last edited:
@cxbs Your TsplPrinter class is very helpful! Thank you very much.

I have changed a minor codes to make it async:
Use InputListAsync instead:
' Ask the user to connect to a printer and return whether she tried or not
' If True then a subsequent Connected event will indicate success or failure
Public Sub Connect As ResumableSub
    Dim PairedDevices As Map
    PairedDevices = Serial1.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        l.Add(PairedDevices.GetKeyAt(i))
    Next
    InputListAsync(l, "Choose a printer", 0, False) 'show list with paired devices
    Wait For InputList_Result (Index As Int)
    If Index <> DialogResponse.CANCEL Then
        Log("Selected place: " & l.Get(Index))
        Serial1.Connect(PairedDevices.Get(l.Get(Index))) 'convert the name to mac address
        Return True
    End If
    Return False
End Sub

Moreover, could you provide the tspl instruction file for me to learn tspl language?
 

cxbs

Active Member
Licensed User
Longtime User

Attachments

  • 得力打印机标签编程手册 TSPL v1.0.8.part2.rar
    242.4 KB · Views: 144
  • 得力打印机标签编程手册 TSPL v1.0.8.part1.rar
    500 KB · Views: 143
Last edited:

cxbs

Active Member
Licensed User
Longtime User
Hi! can you please send an example of the print commands code?



You can find an example of a Bluetooth connection where you can send a TSPL command and wait for the printer to return a message or wait for the printer to respond once the connection is successful!
 

Tico.13

Member
You can find an example of a Bluetooth connection where you can send a TSPL command and wait for the printer to return a message or wait for the printer to respond once the connection is successful!
Thanks for your creation, the printer connect successfully but when i hit the button print doesnt print.
 

cxbs

Active Member
Licensed User
Longtime User
Thanks for your creation, the printer connect successfully but when i hit the button print doesnt print.


After establishing a connection with Bluetooth printing, you can send the following commands for printing. Please note that different printers support different command formats!

B4X:
Private Sub but1_Click
    Starter.Printer2.Size(60,40)
    Starter.Printer2.GAP(2,0)
    Starter.Printer2.DENSITY2(7)
    Starter.Printer2.REFERENCE(0,0)
    Starter.Printer2.CLS

    Dim a As String
    a= 1 & ":Test" & DateTime.Date(DateTime.Now) & " " &  DateTime.Time(DateTime.Now)
    Starter.Printer2.TEXT(50,7,"TSS24.BF2",0,1,1,0,a)
    Starter.Printer2.BOX(100,100,400,280,1,10)
    Starter.Printer2.PRINT(1,0)
    Starter.Printer2.EOP
End Sub
 

Tico.13

Member
After establishing a connection with Bluetooth printing, you can send the following commands for printing. Please note that different printers support different command formats!

B4X:
Private Sub but1_Click
    Starter.Printer2.Size(60,40)
    Starter.Printer2.GAP(2,0)
    Starter.Printer2.DENSITY2(7)
    Starter.Printer2.REFERENCE(0,0)
    Starter.Printer2.CLS

    Dim a As String
    a= 1 & ":Test" & DateTime.Date(DateTime.Now) & " " &  DateTime.Time(DateTime.Now)
    Starter.Printer2.TEXT(50,7,"TSS24.BF2",0,1,1,0,a)
    Starter.Printer2.BOX(100,100,400,280,1,10)
    Starter.Printer2.PRINT(1,0)
    Starter.Printer2.EOP
End Sub
Thanks for your answer

When i use Starter.Printer2.Size(60,40) log says unknow member: printer2.

What im missing or not doing?
 

cxbs

Active Member
Licensed User
Longtime User
Thanks for your answer

When i use Starter.Printer2.Size(60,40) log says unknow member: printer2.

What im missing or not doing?
Please download the TSPL.zip document I uploaded earlier (which can be found on the top floor), extract it and run it. It is recommended to install it on your phone for testing. Open the Bluetooth device on your phone, search for and select the Bluetooth printer to connect to, and press the print button after successful connection. If the printer does not respond, it may be because your printer does not support this command. Please try changing the printer!

I have recorded a demonstration for your reference!

Please rename TSPL.rar to TSPL.z01 to decompress!
Please rename TSPL.txt to TSPL.z02 to decompress!
Last UnZip TSPL.ZIP
 

Attachments

  • TSPL.rar
    512 KB · Views: 43
  • TSPL.zip
    279 KB · Views: 49
  • TSPL.txt
    512 KB · Views: 46
Last edited:
Top