Package totalcross.io.device.printer
Class BluetoothPrinter
- java.lang.Object
-
- totalcross.io.device.printer.BluetoothPrinter
-
- Direct Known Subclasses:
CitizenPrinter,MPTPrinter
public class BluetoothPrinter extends java.lang.ObjectUsed as interface to printers that uses Bluetooth to communicate with the device. See the CitizenPrinter javadocs if you plan to use one.Note: during tests, we found that some printers require to fill their buffer to start printing. So, if you have problems printing, try the following code after you instantiate this class:
cp = new CitizenPrinter(); // or new BluetoothPrinter(); cp.write(new byte[2048]); // fill the buffer cp.newLine(); ...
-
-
Field Summary
Fields Modifier and Type Field Description static byteESCstatic byteGSstatic byteIMAGE_MODE_24_DOUBLEstatic byteIMAGE_MODE_24_SINGLEstatic byteIMAGE_MODE_8_DOUBLEstatic byteIMAGE_MODE_8_SINGLE
-
Constructor Summary
Constructors Constructor Description BluetoothPrinter()Creates a new BluetoothPrinter instance, using PortConnector.BLUETOOTH port at 57600 baud rate.BluetoothPrinter(Stream con)Creates a new BluetoothPrinter instance, using the given PortConnector as bridge to the printer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()voidescape(int command)Sends an escape command to the printer.voidescape(int command, int value1)Sends an escape command to the printer.voidescape(int command, int value1, int value2)Sends an escape command to the printer.voidgs(int command, int value1)Sends a GS command to the printer.voidgs(int command, int value1, int value2)Sends an escape command to the printer.voidnewLine()Sends a new line to the printer.voidnewLine(int count)Sends a number of new lines to the printer.voidprint(java.lang.String str)Prints the given String.voidprint(MonoImage img)Prints the given MonoImage.voidprint(MonoImage img, byte imageMode)Deprecated.Use the other print method without imageMode parameter.voidwrite(byte[] data)Sends the given raw data to the printer.voidwrite(byte[] data, int ofs, int len)Sends the given raw data to the printer.
-
-
-
Field Detail
-
ESC
public static final byte ESC
- See Also:
- Constant Field Values
-
GS
public static final byte GS
- See Also:
- Constant Field Values
-
IMAGE_MODE_8_SINGLE
public static final byte IMAGE_MODE_8_SINGLE
- See Also:
- Constant Field Values
-
IMAGE_MODE_8_DOUBLE
public static final byte IMAGE_MODE_8_DOUBLE
- See Also:
- Constant Field Values
-
IMAGE_MODE_24_SINGLE
public static final byte IMAGE_MODE_24_SINGLE
- See Also:
- Constant Field Values
-
IMAGE_MODE_24_DOUBLE
public static final byte IMAGE_MODE_24_DOUBLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BluetoothPrinter
public BluetoothPrinter() throws IOExceptionCreates a new BluetoothPrinter instance, using PortConnector.BLUETOOTH port at 57600 baud rate.- Throws:
IOException
-
BluetoothPrinter
public BluetoothPrinter(Stream con) throws IOException
Creates a new BluetoothPrinter instance, using the given PortConnector as bridge to the printer. Note that PortConnector can use any port (including infrared), however, it is not guaranteed that it will work with that port. For example, IR does not work on Palm OS devices.- Throws:
IOException
-
-
Method Detail
-
write
public void write(byte[] data) throws IOExceptionSends the given raw data to the printer.- Throws:
IOException
-
write
public void write(byte[] data, int ofs, int len) throws IOExceptionSends the given raw data to the printer.- Throws:
IOException
-
escape
public void escape(int command) throws IOExceptionSends an escape command to the printer.- Throws:
IOException
-
escape
public void escape(int command, int value1) throws IOExceptionSends an escape command to the printer.- Throws:
IOException
-
escape
public void escape(int command, int value1, int value2) throws IOExceptionSends an escape command to the printer.- Throws:
IOException
-
gs
public void gs(int command, int value1) throws IOExceptionSends a GS command to the printer.- Throws:
IOException
-
gs
public void gs(int command, int value1, int value2) throws IOExceptionSends an escape command to the printer.- Throws:
IOException
-
print
public void print(java.lang.String str) throws IOExceptionPrints the given String.- Throws:
IOException
-
print
@Deprecated public void print(MonoImage img, byte imageMode) throws ImageException, IOException
Deprecated.Use the other print method without imageMode parameter.Prints the given MonoImage.- Throws:
ImageExceptionIOException
-
print
public void print(MonoImage img) throws ImageException, IOException
Prints the given MonoImage. In the image, only black pixels are written. The maximum width is 576 pixels for single density is 192, and for double density is 384; the image is trimmed to fit these values.- Throws:
ImageExceptionIOException
-
newLine
public void newLine() throws IOExceptionSends a new line to the printer.- Throws:
IOException
-
newLine
public void newLine(int count) throws IOExceptionSends a number of new lines to the printer.- Throws:
IOException
-
close
public void close() throws IOException- Throws:
IOException
-
-