4.3. IDisplayCommandBuilder
added in version 1.6.0
An interface to provide functions to generate commands for the customer display control.
This interface is only for models which support a customer display.For the supporting models, refer to Supported Peripherals .
Constant
Name
Contents
International character constants
Code Page constants
Cursor Mode constants
ContrastMode constants
Method
Name
Contents
Adds data (text or command) to the command buffer.
Generates a backspace command, and then adds it to the command buffer.
Generates a horizontal tab command, and then adds it to the command buffer.
Generates a line feed command, and then adds it to the command buffer.
Generates a carriage-return command, and then adds it to the command buffer.
Generates a graphic display command, and then adds it to the command buffer.
Select command of the international character mode is generated and added to the command buffer.
Select command of the code page is generated and added to the command buffer.
Generates a command to clear the screen until the end of the line, and then adds it to the command buffer.
Generates a command to clear the screen, and then adds it to the command buffer.
Generates a command to move the cursor to the home position, and then adds it to the command buffer.
Generates a command to turn on/off the backlight, and then adds it to the command buffer.
Generates a command to move the cursor to the specified position, and then adds it to the command buffer.
Generates a command to change the cursor mode, and then adds it to the command buffer.
Generates a command to change the contrast mode, and then adds it to the command buffer.
Generates a command to register user-defined characters (SBCS), and then adds it to the command buffer.
Generates a command to register user-defined characters (DBCS), and then adds it to the command buffer.
Gets the command buffer (generated command).
Gets a command sequence with the pass-through command to the printer added at the beginning of the command buffer (generated command).
4.3.1. InternationalType
added in version 1.6.0
International character constants
Declaration
enum InternationalType { USA, France, Germany, UK, Denmark, Sweden, Italy, Spain, Japan, Norway, Denmark2, Spain2, LatinAmerica, Korea }
Constants
Name
Contents
USA
USA
France
France
Germany
Germany
UK
UK
Denmark
Denmark
Sweden
Sweden
Italy
Italy
Spain
Spain
Japan
Japan
Norway
Norway
Denmark2
Denmark ||
Spain2
Spain ||
LatinAmerica
Latin America
Korea
Korea
4.3.2. CodePageType
added in version 1.6.0
Code Page constants
Declaration
enum CodePageType { CP437, Katakana, CP850, CP860, CP863, CP865, CP1252, CP866, CP852, CP858, Japanese, SimplifiedChinese, TraditionalChinese, Hangul }
Constants
Name
Contents
CP437
CodePage437 (USA, Std. Europe)
Katakana
Katakana
CP850
PC850 (Multilingual)
CP860
PC860 (Portuguese)
CP863
PC863 (Canadian-French)
CP865
PC865 (Norwegian)
CP1252
WPC1252
CP866
PC866 [Cyrillic #2]
CP852
PC852 [Latin 2]
CP858
Page 19 [PC858]
Japanese
Japanese font (shift JIS)
SimplifiedChinese
Simplified Chinese (GB2312)
TraditionalChinese
Traditional Chinese (Big5)
Hangul
Hangul (KSC5601)
4.3.3. CursorMode
added in version 1.6.0
Cursor Mode constants.
Declaration
enum CursorMode { Off, Blink, On }
Constants
Name
Contents
Off
Cursor off
Blink
Cursor blinking
On
Cursor lighting
4.3.4. ContrastMode
added in version 1.6.0
Contrast mode constants.
Declaration
enum ContrastMode { Minus3, Minus2, Minus1, Default, Plus1, Plus2, Plus3 }
Constants
Name
Contents
Minus3
Contrast: -3
Minus2
Contrast: -2
Minus1
Contrast: -1
Default
Default
Plus1
Contrast: +1
Plus2
Contrast: +2
Plus3
Contrast: +3
4.3.5. append
added in version 1.6.0
Adds data (text or command) to the command buffer.
Declaration
void append(byte data); void append(byte[] data);
Parameter
Name
Contents
Type
data
Data (Text and Command)
bytebyte[]Return value
None
Examples
public static byte[] createTextPattern(int number) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern; ... builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.6. appendBackSpace
added in version 1.6.0
Generates a backspace command, and then adds it to the command buffer.
Declaration
void appendBackSpace();
Parameter
None
Return value
None
4.3.7. appendHorizontalTab
added in version 1.6.0
Generates a horizontal tab command, and then adds it to the command buffer.
Declaration
void appendHorizontalTab();
Parameter
None
Return value
None
4.3.8. appendLineFeed
added in version 1.6.0
Generates a line feed command, and then adds it to the command buffer.
Declaration
void appendLineFeed();
Parameter
None
Return value
None
4.3.9. appendCarriageReturn
added in version 1.6.0
Generates a carriage-return command, and then adds it to the command buffer.
Declaration
void appendCarriageReturn();
Parameter
None
Return value
None
4.3.10. appendBitmap
added in version 1.6.0
Generates a graphic display command, and then adds it to the command buffer.
Declaration
void appendBitmap(Bitmap bitmap, boolean diffusion);
Parameter
Name
Contents
Type
bitmap
Image you want to displaySpecify the instance of the 160 × 40 dots monochrome Bitmap class.If a different sized Bitmap is specified, it is resized to 160 × 40 dots.The Bitmap pixels are automatically converted to monochrome value.android.graphics.Bitmap
diffusion
Random dithertrue … Validfalse … Invalidboolean
Return value
None
Examples
public static byte[] createGraphicPattern(int number, Resources resources) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); // builder.appendHomePosition(); Bitmap bitmap; switch (number) { default: case 0: bitmap = BitmapFactory.decodeResource(resources, R.drawable.display_image_1); break; case 1: bitmap = BitmapFactory.decodeResource(resources, R.drawable.display_image_2); break; case 2: bitmap = BitmapFactory.decodeResource(resources, R.drawable.display_image_3); break; case 3: bitmap = BitmapFactory.decodeResource(resources, R.drawable.display_image_4); break; } builder.appendBitmap(bitmap, false); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.11. appendInternational
added in version 1.6.0
Select command of the international character mode is generated and added to the command buffer.
Declaration
void appendInternational(InternationalType internationalType);
Parameter
Name
Contents
Type
internationalType
International character constants
Return value
None
Examples
public static byte[] createCharacterSet(InternationalType internationalType, CodePageType codePageType) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); builder.appendInternational(internationalType); builder.appendCodePage(codePageType); ... switch (codePageType) { default: builder.append(pattern1); break; // CP437,Katakana,CP850,CP860,CP863,CP865,CP1252,CP866,CP852,CP858 case Japanese: builder.append(pattern2); break; case SimplifiedChinese: builder.append(pattern3); break; case TraditionalChinese: builder.append(pattern4); break; case Hangul: builder.append(pattern5); break; } return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.12. appendCodePage
added in version 1.6.0
Select command of the code page is generated and added to the command buffer.
Declaration
void appendCodePage(CodePageType codePageType);
Parameter
Name
Contents
Type
codePageType
Code Page constants
Return value
None
Examples
public static byte[] createCharacterSet(InternationalType internationalType, CodePageType codePageType) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); builder.appendInternational(internationalType); builder.appendCodePage(codePageType); ... switch (codePageType) { default: builder.append(pattern1); break; // CP437,Katakana,CP850,CP860,CP863,CP865,CP1252,CP866,CP852,CP858 case Japanese: builder.append(pattern2); break; case SimplifiedChinese: builder.append(pattern3); break; case TraditionalChinese: builder.append(pattern4); break; case Hangul: builder.append(pattern5); break; } return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.13. appendDeleteToEndOfLine
added in version 1.6.0
Generates a command to clear the screen until the end of the line, and then adds it to the command buffer.
Declaration
void appendDeleteToEndOfLine();
Parameter
None
Return value
None
4.3.14. appendClearScreen
added in version 1.6.0
Generates a command to clear the screen, and then adds it to the command buffer.
Declaration
void appendClearScreen();
Parameter
None
Return value
None
Examples
public static byte[] createTextPattern(int number) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern; ... builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.15. appendHomePosition
added in version 1.6.0
Generates a command to move the cursor to the home position, and then adds it to the command buffer.
Declaration
void appendHomePosition();
Parameter
None
Return value
None
Examples
public static byte[] createTextPattern(int number) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern; ... builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.16. appendTurnOn
added in version 1.6.0
Generates a command to turn on/off the backlight, and then adds it to the command buffer.
Declaration
void appendTurnOn(boolean turnOn);
Parameter
Name
Contents
Type
turnOn
Backlight ON/OFF
boolean
Return value
None
Examples
public static byte[] createTurnOn(boolean isTurnOn) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); ... builder.appendTurnOn(isTurnOn); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.17. appendSpecifiedPosition
added in version 1.6.0
Generates a command to move the cursor to the specified position, and then adds it to the command buffer.
Declaration
void appendSpecifiedPosition(int x, int y);
Parameter
Name
Contents
Type
x
Digit position (Leftmost digit is 1)
int
y
Line position (top line is 1)
int
Return value
None
Examples
public static byte[] createCursorMode(CursorMode mode) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern = {'S', 't', 'a', 'r', ' ', 'M', 'i', 'c', 'r', 'o', 'n', 'i', 'c', 's', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'o', 't', 'a', 'l', ' ', ':', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '2', '3', '4', '5'}; builder.append(pattern); builder.appendSpecifiedPosition(20, 2); builder.appendCursorMode(mode); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.18. appendCursorMode
added in version 1.6.0
Generates a command to change the cursor mode, and then adds it to the command buffer.
Declaration
void appendCursorMode(CursorMode cursorMode);
Parameter
Name
Contents
Type
cursorMode
Cursor Mode constants
Return value
None
Examples
public static byte[] createCursorMode(CursorMode mode) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern = {'S', 't', 'a', 'r', ' ', 'M', 'i', 'c', 'r', 'o', 'n', 'i', 'c', 's', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'o', 't', 'a', 'l', ' ', ':', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '2', '3', '4', '5'}; builder.append(pattern); builder.appendSpecifiedPosition(20, 2); builder.appendCursorMode(mode); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.19. appendContrastMode
added in version 1.6.0
Generates a command to change the contrast mode, and then adds it to the command buffer.
Declaration
void appendContrastMode(ContrastMode contrastMode);
Parameter
Name
Contents
Type
contrastMode
ContrastMode constants
Return value
None
Examples
public static byte[] createContrastMode(ContrastMode contrastMode) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); // builder.appendClearScreen(); // builder.appendCursorMode(CursorMode.Off); // builder.appendHomePosition(); // // byte[] pattern = {'S', 't', 'a', 'r', ' ', 'M', 'i', 'c', 'r', 'o', 'n', 'i', 'c', 's', ' ', ' ', ' ', ' ', ' ', ' ', // ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'S', 't', 'a', 'r', ' ', 'M', 'i', 'c', 'o', 'n', 'i', 'c', 's'}; // // builder.append(pattern); builder.appendContrastMode(contrastMode); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.20. appendUserDefinedCharacter
added in version 1.6.0
Generates a command to register user-defined characters (SBCS), and then adds it to the command buffer.
Declaration
void appendUserDefinedCharacter(int index, int code, byte[] font);
Parameter
Name
Contents
Type
index
Japanese fontFont number00h ≦ index ≦ 1Fhint
code
Character code of user-defined character20h ≦ code ≦ 7FhIf Japanese is specified with the appendCodePage method, the following range is also supported.A0h ≦ code ≦ DFhint
font
16-byte font dataRefer to the font data format of the user-defined characters.Specifying null deletes the user-defined characters of the specified font No.byte[]
Return value
None
The font data format of the user-defined characters.
Examples
public static byte[] createUserDefinedCharacter(boolean set) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); builder.appendInternational(InternationalType.USA); builder.appendCodePage(CodePageType.Japanese); if (set) { byte[] font = { (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x49, (byte) 0x7f, (byte) 0x26, (byte) 0x48, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x00 }; byte[] dbcsFont = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x20, (byte) 0x04, (byte) 0x90, (byte) 0x04, (byte) 0x90, (byte) 0x02, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xf0, (byte) 0x04, (byte) 0x80, (byte) 0x04, (byte) 0x80, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; builder.appendUserDefinedCharacter(0, 0x20, font); builder.appendUserDefinedDbcsCharacter(0, 0x8140, dbcsFont); } else { builder.appendUserDefinedCharacter(0, 0x20, null); builder.appendUserDefinedDbcsCharacter(0, 0x8140, null); } byte[] pattern = { (byte) 0x5b,(byte) 0x20,(byte) 0x20,(byte) 0x53,(byte) 0x74,(byte) 0x61,(byte) 0x72,(byte) 0x20,(byte) 0x4d,(byte) 0x69,(byte) 0x63,(byte) 0x72,(byte) 0x6f,(byte) 0x6e,(byte) 0x69,(byte) 0x63,(byte) 0x73,(byte) 0x20,(byte) 0x20,(byte) 0x5d, (byte) 0x5b,(byte) 0x81,(byte) 0x40,(byte) 0x81,(byte) 0x40,(byte) 0x83,(byte) 0x58,(byte) 0x83,(byte) 0x5e,(byte) 0x81,(byte) 0x5b,(byte) 0x90,(byte) 0xb8,(byte) 0x96,(byte) 0xa7,(byte) 0x81,(byte) 0x40,(byte) 0x81,(byte) 0x40,(byte) 0x5d, }; builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.21. appendUserDefinedDbcsCharacter
added in version 1.6.0
Generates a command to register user-defined characters (DBCS), and then adds it to the command buffer.
Declaration
void appendUserDefinedDbcsCharacter(int index, int code, byte[] font);
Parameter
Name
Contents
Type
index
Japanese fontFont number00h ≦ index ≦ 0Fhint
code
Character code of user-defined character20h ≦ code ≦ 7FhIf Japanese is specified with the appendCodePage method, the following range is also supported.80 00h ≦ code ≦ FF FFhint
font
32-byte font dataRefer to the font data format of the user-defined characters.Specifying null deletes the user-defined characters of the specified font No.byte[]
Return value
None
The font data format of the user-defined characters.
Examples
public static byte[] createUserDefinedCharacter(boolean set) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); builder.appendInternational(InternationalType.USA); builder.appendCodePage(CodePageType.Japanese); if (set) { byte[] font = { (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x49, (byte) 0x7f, (byte) 0x26, (byte) 0x48, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x00 }; byte[] dbcsFont = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x20, (byte) 0x04, (byte) 0x90, (byte) 0x04, (byte) 0x90, (byte) 0x02, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xf0, (byte) 0x04, (byte) 0x80, (byte) 0x04, (byte) 0x80, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; builder.appendUserDefinedCharacter(0, 0x20, font); builder.appendUserDefinedDbcsCharacter(0, 0x8140, dbcsFont); } else { builder.appendUserDefinedCharacter(0, 0x20, null); builder.appendUserDefinedDbcsCharacter(0, 0x8140, null); } byte[] pattern = { (byte) 0x5b,(byte) 0x20,(byte) 0x20,(byte) 0x53,(byte) 0x74,(byte) 0x61,(byte) 0x72,(byte) 0x20,(byte) 0x4d,(byte) 0x69,(byte) 0x63,(byte) 0x72,(byte) 0x6f,(byte) 0x6e,(byte) 0x69,(byte) 0x63,(byte) 0x73,(byte) 0x20,(byte) 0x20,(byte) 0x5d, (byte) 0x5b,(byte) 0x81,(byte) 0x40,(byte) 0x81,(byte) 0x40,(byte) 0x83,(byte) 0x58,(byte) 0x83,(byte) 0x5e,(byte) 0x81,(byte) 0x5b,(byte) 0x90,(byte) 0xb8,(byte) 0x96,(byte) 0xa7,(byte) 0x81,(byte) 0x40,(byte) 0x81,(byte) 0x40,(byte) 0x5d, }; builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.
4.3.22. getCommands
added in version 1.6.0
Gets the command buffer (generated command).
Declaration
byte[] getCommands();
Parameter
None
Value
Contents
Type
Command buffer (generated command)
byte[]
4.3.23. getPassThroughCommands
added in version 1.6.0
Gets a command sequence with the pass-through command to the printer added at the beginning of the command buffer (generated command).
Declaration
byte[] appendPassThroughCommands();
Parameter
None
Return value
Contents
Type
Command buffer (generated command)
byte[]
Examples
public static byte[] createTextPattern(int number) { IDisplayCommandBuilder builder = StarIoExt.createDisplayCommandBuilder(DisplayModel.SCD222); builder.appendClearScreen(); builder.appendCursorMode(CursorMode.Off); builder.appendHomePosition(); byte[] pattern; ... builder.append(pattern); return builder.getPassThroughCommands(); }
Refer to DisplayFunctions.java.