totalcross.io.device.printer
Class CitizenPrinter

totalcross.lang.Object
  extended by totalcross.io.device.printer.BluetoothPrinter
      extended by 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.

  1. 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.
  2. Write down the last 2 bytes (4 letters) of the ADDRESS (E.G.: A4 08)
  3. Discover the "Citizen Systems" printer with the PDA.
  4. 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).
  5. That's it. In some devices, you can choose to always use this printer as default bluetooth device.
You can add other commands by looking at this reference.


Field Summary
 
Fields inherited from class totalcross.io.device.printer.BluetoothPrinter
IMAGE_MODE_24_DOUBLE, IMAGE_MODE_24_SINGLE, IMAGE_MODE_8_DOUBLE, IMAGE_MODE_8_SINGLE
 
Constructor Summary
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.
 
Method Summary
 void bold(boolean on)
          Set bold state.
 void doubleLineHeight()
          Double-space line height.
 void setDensity(int n)
          Set font density, between 0 and 5.
 void setFont(boolean fontA, boolean bold, boolean doubleWidth, boolean doubleHeight, boolean underline)
          Sets the current font based on the following attributes.
 void setHorizontalAlignment(int v)
          Sets the horizontal text alignment.
 void setLineHeight(int n)
          User-defined line height (n / 203 inches height).
 void setRotation1800(boolean on)
          Enables 180-degree rotation.
 void setRotation90(boolean on)
          Enables 90-degree rotation.
 void setSpaceWidth(int w)
          Sets the space character width, between 0 and 32.
 void setXPos(int x)
          Sets the absolute position to start printing.
 void singleLineHeight()
          Single-space line height.
 void turnOff()
          Turns off the printer.
 
Methods inherited from class totalcross.io.device.printer.BluetoothPrinter
close, escape, escape, escape, newLine, print, print, write
 
Methods inherited from class totalcross.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CitizenPrinter

public CitizenPrinter()
               throws IOException
Creates 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 the 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

setFont

public void setFont(boolean fontA,
                    boolean bold,
                    boolean doubleWidth,
                    boolean doubleHeight,
                    boolean underline)
             throws IOException
Sets the current font based on the following attributes.

Throws:
IOException

setSpaceWidth

public void setSpaceWidth(int w)
                   throws IOException
Sets the space character width, between 0 and 32.

Throws:
IOException

setXPos

public void setXPos(int x)
             throws IOException
Sets the absolute position to start printing.

Throws:
IOException

turnOff

public void turnOff()
             throws IOException
Turns off the printer.

Throws:
IOException

doubleLineHeight

public void doubleLineHeight()
                      throws IOException
Double-space line height.

Throws:
IOException

singleLineHeight

public void singleLineHeight()
                      throws IOException
Single-space line height.

Throws:
IOException

setLineHeight

public void setLineHeight(int n)
                   throws IOException
User-defined line height (n / 203 inches height).

Throws:
IOException

bold

public void bold(boolean on)
          throws IOException
Set bold state.

Throws:
IOException

setRotation90

public void setRotation90(boolean on)
                   throws IOException
Enables 90-degree rotation.

Throws:
IOException

setRotation1800

public void setRotation1800(boolean on)
                     throws IOException
Enables 180-degree rotation.

Throws:
IOException

setDensity

public void setDensity(int n)
                throws IOException
Set font density, between 0 and 5.

Throws:
IOException

setHorizontalAlignment

public void setHorizontalAlignment(int v)
                            throws IOException
Sets the horizontal text alignment. Use Control.LEFT, Control.CENTER, Control.RIGHT.

Throws:
IOException