Package totalcross.io.device.printer
Class CitizenPrinter
- java.lang.Object
-
- totalcross.io.device.printer.BluetoothPrinter
-
- totalcross.io.device.printer.CitizenPrinter
-
public class CitizenPrinter extends BluetoothPrinter
This class extends BluetoothPrinter to send special Citizen-like commands to the printer. Tested with Citizen CMP-10 thermal printer.Instructions of how to setup the devices to work with the printer.
- First, run the self-test: turning the printer off, and pressing the LF + ON button at the same time and then releasing the LF button.
- Write down the last 2 bytes (4 letters) of the ADDRESS (e.g.: A4 08)
- Discover the "Citizen Systems" printer with the PDA.
- When asked for the PIN (password), write the last 4 letters of the address in UPPER CASE (e.g.: A408); if it fails, write it in lower case (e.g.: a408).
- That's it. On some devices, you can choose to always use this printer as default Bluetooth device.
-
-
Field Summary
-
Fields inherited from class totalcross.io.device.printer.BluetoothPrinter
ESC, GS, IMAGE_MODE_24_DOUBLE, IMAGE_MODE_24_SINGLE, IMAGE_MODE_8_DOUBLE, IMAGE_MODE_8_SINGLE
-
-
Constructor Summary
Constructors Constructor Description CitizenPrinter()Creates a new CitizenPrinter instance, using PortConnector.BLUETOOTH port at 57600 baud rate.CitizenPrinter(PortConnector con)Creates a new CitizenPrinter instance, using the given PortConnector as bridge to the printer.CitizenPrinter(Stream con)Creates a new CitizenPrinter instance, using the given Stream as bridge to the printer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbold(boolean on)Sets bold state.voiddoubleLineHeight()Double-space line height.voidsetDensity(int n)Sets the font density, between 0 and 5.voidsetFont(boolean fontA, boolean bold, boolean doubleWidth, boolean doubleHeight, boolean underline)Sets the current font based on the given attributes.voidsetHorizontalAlignment(int v)Sets the horizontal text alignment.voidsetLineHeight(int n)User-defined line height (n / 203 inches height).voidsetRotation1800(boolean on)Enables 180-degree rotation.voidsetRotation90(boolean on)Enables 90-degree rotation.voidsetSpaceWidth(int w)Sets the space character width, between 0 and 32.voidsetXPos(int x)Sets the absolute position to start printing.voidsingleLineHeight()Single-space line height.voidturnOff()Turns off the printer.
-
-
-
Constructor Detail
-
CitizenPrinter
public CitizenPrinter() throws IOExceptionCreates a new CitizenPrinter instance, using PortConnector.BLUETOOTH port at 57600 baud rate.- Throws:
IOException
-
CitizenPrinter
public CitizenPrinter(PortConnector con) throws IOException
Creates a new CitizenPrinter 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
-
CitizenPrinter
public CitizenPrinter(Stream con) throws IOException
Creates a new CitizenPrinter instance, using the given Stream as bridge to the printer.- Throws:
IOException
-
-
Method Detail
-
setFont
public void setFont(boolean fontA, boolean bold, boolean doubleWidth, boolean doubleHeight, boolean underline) throws IOExceptionSets the current font based on the given attributes.- Throws:
IOException
-
setSpaceWidth
public void setSpaceWidth(int w) throws IOExceptionSets the space character width, between 0 and 32.- Throws:
IOException
-
setXPos
public void setXPos(int x) throws IOExceptionSets the absolute position to start printing.- Throws:
IOException
-
turnOff
public void turnOff() throws IOExceptionTurns off the printer.- Throws:
IOException
-
doubleLineHeight
public void doubleLineHeight() throws IOExceptionDouble-space line height.- Throws:
IOException
-
singleLineHeight
public void singleLineHeight() throws IOExceptionSingle-space line height.- Throws:
IOException
-
setLineHeight
public void setLineHeight(int n) throws IOExceptionUser-defined line height (n / 203 inches height).- Throws:
IOException
-
bold
public void bold(boolean on) throws IOExceptionSets bold state.- Throws:
IOException
-
setRotation90
public void setRotation90(boolean on) throws IOExceptionEnables 90-degree rotation.- Throws:
IOException
-
setRotation1800
public void setRotation1800(boolean on) throws IOExceptionEnables 180-degree rotation.- Throws:
IOException
-
setDensity
public void setDensity(int n) throws IOExceptionSets the font density, between 0 and 5.- Throws:
IOException
-
setHorizontalAlignment
public void setHorizontalAlignment(int v) throws IOExceptionSets the horizontal text alignment. Use Control.LEFT, Control.CENTER, Control.RIGHT.- Throws:
IOException
-
-