Internal.Command
The basic building block.
batch : List Internal.Attribute -> List Command -> Command
This let's you group multiple commands and add attributes to them.
You can think of it as a div
in html.
batch []
[ writeLine "Hello!"
, batch [ bold ] [ writeLine "I am bold!" ]
]
writeLine : String -> Command
Write the given string and insert a newline.
none : Command
Do nothing.
write : String -> Command
Write the given text.
newline : Command
Insert a newline.
initialize : Command
Prepare to print.
You should always include this as your first command for a ticket.
cut : Command
Cut the paper.
encodeToBytes : Command -> Bytes
Return the command as bytes.
This is probably what you need to send to the printer.
encodeToInts : Command -> List Basics.Int
Return the command as a list of ints, one for each byte.
This is useful to send through a port.
encodeToJson : Command -> Json.Encode.Value
Return the command as json. It will be an array of numbers, one for each byte.
This is useful to send through a port.
encodeToBase64 : Command -> String
Return the command as a base64 encoded string.
raw : List Basics.Int -> Command
This function lets you implement your own custom command. This is useful if you want to add a command not included in this library.
For example, the initialize command is defined as:
{-
ASCII : ESC @
HEX : 1B 40
DECIMAL : 27 64
-}
So you could implement using hex it by writing:
raw [ 0x1B, 0x40 ]
or using decimal:
raw [ 27, 64 ]
Note: For a list of ESCPOS commands you should check your printer documentation.