Android TSC Bluetooth/Ethernet 函式庫使用說明 1. openport(a) Bluetooth openport(a) 說明 : 指定電腦端的輸出埠 a: 字串型別直接指定 Bluetooth MacAdress, 如 00:19:0E:A0:04:E1 Ethernet openport(a,b) 說明 : 指定電腦端的輸出埠 a: 字串型別輸入 IP Address, 如 : 192.168.1.50 b: 字串型別輸入連接埠, 如 : 9100 2. closeport() 說明 : 關閉指定的電腦端輸出埠 3. setup(a,b,c,d,e,f,g) 說明 : 設定標籤的寬度 高度 列印速度 列印濃度 感應器類別 gap/black mark 垂直間距 gap/black mark 偏移距離 ) a: 字串型別, 設定標籤寬度, 單位 mm b: 字串型別, 設定標籤高度, 單位 mm c: 字串型別, 設定列印速度,( 列印速度隨機型不同而有不同的選項 ) 1.0: 每秒 1.0 吋列印速度 1.5: 每秒 1.5 吋列印速度 2.0: 每秒 2.0 吋列印速度 3.0: 每秒 3.0 吋列印速度 4.0: 每秒 4.0 吋列印速度 6.0: 每秒 6.0 吋列印速度 8.0: 每秒 8.0 吋列印速度 10.0: 每秒 10.0 吋列印速度
d: 字串型別, 設定列印濃度, 0~15, 數字愈大列印結果愈黑 e: 字串型別, 設定使用感應器類別 0 表示使用垂直間距感測器 (gap sensor) 1 表示使用黑標感測器 (black mark sensor) f: 字串型別, 設定 gap/black mark 垂直間距高度, 單位 : mm g: 字串型別, 設定 gap/black mark 偏移距離, 單位 : mm, 此參數若使用一般標籤時均設為 0 4. clearbuffer() 說明 : 清除 5. barcode(a,b,c,d,e,f,g,h,i) 說明 : 使用條碼機內建條碼列印 a: 字串型別, 條碼 X 方向起始點, 以點 (point) 表示 (200 DPI,1 點 =1/8 mm, 300 DPI,1 點 b: 字串型別, 條碼 Y 方向起始點, 以點 (point) 表示 (200 DPI,1 點 =1/8 mm, 300 DPI,1 點 c: 字串型別, 128 Code 128, switching code subset A, B, C automatically 128M Code 128, switching code subset A, B, C manually. EAN128 Code 128, switching code subset A, B, C automatically 25 Interleaved 2 of 5 25C Interleaved 2 of 5 with check digits 39 Code 39 39C Code 39 with check digits 93 Code 93 EAN13 EAN 13 EAN13+2 EAN 13 with 2 digits add-on EAN13+5 EAN 13 with 5 digits add-on EAN8 EAN 8 EAN8+2 EAN 8 with 2 digits add-on EAN8+5 EAN 8 with 5 digits add-on CODA Codabar POST Postnet UPCA UPC-A
UPCA+2 UPC-A with 2 digits add-on UPCA+5 UPC-A with 5 digits add-on UPCE UPC-E UPCE+2 UPC-E with 2 digits add-on UPCE+5 UPC-E with 5 digits add-on d: 字串型別, 設定條碼高度, 高度以點來表示 e: 字串型別, 設定是否列印條碼碼文 0: 不列印碼文 1: 列印碼文 f: 字串型別, 設定條碼旋轉角度 0: 旋轉 0 度 90: 旋轉 90 度 180: 旋轉 180 度 270: 旋轉 270 度 g: 字串型別, 設定條碼窄 bar 比例因子, 請參考 TSPL 使用手冊 h: 字串型別, 設定條碼寬 bar 比例因子, 請參考 TSPL 使用手冊 I: 字串型別, 條碼內容 6. printerfont(a,b,c,d,e,f,g) 說明 : 使用條碼機內建文字列印 a: 字串型別, 文字 X 方向起始點, 以點 (point) 表示 (200 DPI,1 點 =1/8 mm, 300 DPI,1 點 b: 字串型別, 文字 Y 方向起始點, 以點 (point) 表示 (200 DPI,1 點 =1/8 mm, 300 DPI,1 點 c: 字串型別, 內建字型名稱, 共 12 種 1: 8*/12 dots 2: 12*20 dots 3: 16*24 dots 4: 24*32 dots 5: 32*48 dots TST24.BF2: 繁體中文 24*24 ( 客制化字型 ) TST16.BF2: 繁體中文 16*16 ( 客制化字型 ) TTT24.BF2: 繁體中文 24*24 ( 電信碼 ) ( 客制化字型 ) TSS24.BF2: 簡體中文 24*24 ( 客制化字型 ) TSS16.BF2: 簡體中文 16*16 ( 客制化字型 ) K: 韓文 24*24 ( 客制化字型 ) L: 韓文 16*16 ( 客制化字型 ) d: 字串型別, 設定文字旋轉角度 0: 旋轉 0 度 90: 旋轉 90 度
180: 旋轉 180 度 270: 旋轉 270 度 e: 字串型別, 設定文字 X 方向放大倍率,1~8 f: 字串型別, 設定文字 X 方向放大倍率,1~8 g: 字串型別, 列印文字內容 7. sendcommand(command) 說明 : 送內建指令到條碼印表機 詳細指令請參考 TSPL 8. printlabel(a,b) 說明 : 列印標籤內容 a: 字串型別, 設定列印標籤式數 (set) b: 字串型別, 設定列印標籤份數 (copy) 9. downloadpcx(a) 說明 : 下載單色 PCX 格式圖檔至印表機 10. downloadbmp(a) 說明 : 下載單色 BMP 格式圖檔至印表機 11. downloadttf(a) 說明 : 下載 True Type Font 字型至印表機 12. formfeed() 說明 : 跳頁, 該函式需在 setup 後使用
13. nobackfeed() 說明 : 設定紙張不回吐 14. sendfile(a) 說明 : 傳送 txt 檔案至印表機 15. status() 說明 : 回傳印表機狀態 需用字串變數接收回傳的訊息
Android 藍芽範例 import com.example.tscdll.tscactivity; public class MainActivity extends Activity { TSCActivity TscDll = new TSCActivity(); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); TscDll.openport("00:19:0E:A0:04:E1"); TscDll.downloadpcx("UL.PCX"); TscDll.downloadbmp("Triangle.bmp"); TscDll.downloadttf("ARIAL.TTF"); TscDll.setup(70, 110, 4, 4, 0, 0, 0); TscDll.clearbuffer(); TscDll.sendcommand("SET TEAR ON\n"); TscDll.sendcommand("SET COUNTER @1 1\n"); TscDll.sendcommand("@1 = \"0001\"\n"); TscDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n"); TscDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n"); TscDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n"); TscDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n"); TscDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789"); TscDll.printerfont(100, 250, "3", 0, 1, 1, "987654321"); String status = TscDll.status(); text1.settext(status); TscDll.printlabel(2, 1); TscDll.sendfile("zpl.txt"); TscDll.closeport(); 需先掛載以下程式碼於 AndroidMainfest.xml <uses-permission android:name="android.permission.bluetooth_admin" /> <uses-permission android:name="android.permission.bluetooth" /> <uses-permission android:name="android.permission.write_external_storage"/>
Android Ethernet 範例 import com.example.tscwifidll.tscwifiactivity; public class MainActivity extends Activity { TscWifiActivity TscEthernetDll = new TscWifiActivity(); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); TscEthernetDll.openport("192.168.1.58", 9100); TscEthernetDll.downloadpcx("UL.PCX"); TscEthernetDll.downloadbmp("Triangle.bmp"); TscEthernetDll.downloadttf("ARIAL.TTF"); TscEthernetDll.setup(70, 110, 4, 4, 0, 0, 0); TscEthernetDll.clearbuffer(); TscEthernetDll.sendcommand("SET TEAR ON\n"); TscEthernetDll.sendcommand("SET COUNTER @1 1\n"); TscEthernetDll.sendcommand("@1 = \"0001\"\n"); TscEthernetDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n"); TscEthernetDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n"); TscEthernetDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n"); TscEthernetDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n"); TscEthernetDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789"); TscEthernetDll.printerfont(100, 250, "3", 0, 1, 1, "987654321"); String status = TscEthernetDll.status(); text1.settext(status); TscEthernetDll.printlabel(2, 1); TscEthernetDll.sendfile("zpl.txt"); TscEthernetDll.closeport(); 需先掛載以下程式碼於 AndroidMainfest.xml <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.write_external_storage"/>