/dev/ttyUSB0
. In this case, the customer’s display acts as a slave device, and the control protocol programmed in the controller of the display itself is used to control and display information on the display screen. There are several different information transfer protocols for controlling the customer display, but all of them are de facto based on the Epson ESC / POS command format.ESC @
command: $ echo -n -e \\x1B\\x40 > /dev/ttyUSB0
$ echo -n -e Hello, world!\\n > /dev/ttyUSB0
ESC tn
command, where n
is the code page number. Example: $ echo -n -e \\x1B\\x74\\x07 > /dev/ttyUSB0 $ echo -n -e \\x87\\xA4\\xE0\\xA0\\xA2\\xE1\\xE2\\xA2\\xE3\\xA9\\x2C\\x20\\x95\\xA0\\xA1\\xE0\\x21\\n > /dev/ttyUSB0
ESC & snm [a (p1..pa)]*mn
to load the missing characters into the display RAM. This command is also suitable for us to load currency symbols into memory for subsequent display on sales. The command for programming the characters ESC &
contains arguments that can be divided into two parts, the first is constant, the second is variable.s
, n
and m
, where: s
is the number of bytes in the row of the matrix characters, in our example, the value is 1; n
- byte space in the code page for programming the first character; m
- byte space for programming the last character, and if one character is programmed, then n=m
.a p1...pa
, where the number of blocks depends on the number of programmable characters. Each block starts with a value, it is the number of vertical columns in the matrix of the symbol, in our example it can be in the range from 1 to 5. After the value of a
, the status values of the diodes of each are byte-encoded in p1
, p2
, p3
, p4
and p5
column of the matrix symbol, where the most significant bit is the top row of the diodes, and the least significant is the bottom one $ echo -n -e \\x1b\\x26\\x01\\x24\\x24\\x05\\x50\\x50\\x5f\\x50\\x50 > /dev/ttyUSB0
ESC % n
, where the value of n
one or zero depending on whether the loaded characters are included or not: $ echo -n -e \\x1b\\x25\\x01 > /dev/ttyUSB0
$ echo -n -e 1500$ > /dev/ttyUSB0
udev
rules for automatically launching a bash script when connecting the customer display to the Raspberry Pi. The udevadm
command udevadm
vendor code and model of our display. $ udevadm info -q all -n /dev/ttyUSB0 | grep -E -i -w '.*VENDOR_ID.*|.*MODEL_ID.*'
E: ID_MODEL_ID=2303 E: ID_VENDOR_ID=067b
90-init-vfd-display.rules
: $ sudo nano /etc/udev/rules.d/90-init-vfd-display.rules
ACTION=="add", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", RUN+="/usr/local/bin/init-vfd-display.sh"
$ sudo nano /usr/local/bin/init-vfd-display.sh
#!/bin/bash sleep 20 echo -n -e \\x1B\\x40 > /dev/ttyUSB0 echo -n -e \\x1B\\x74\\x07 > /dev/ttyUSB0 echo -n -e \\x1B\\x26\\x01\\x24\\x24\\x05\\x50\\x50\\x5F\\x50\\x50 > /dev/ttyUSB0 sleep 3
$ sudo chmod +x /usr/local/bin/init-vfd-display.sh $ sudo udevadm control --reload-rules $ sudo udevadm trigger --action=add $ sudo service udev restart
$ echo -n -e 1$ =\\x1B\\x25\\x01 181,95$ \\x1B\\x25\\x00 > /dev/ttyUSB0
udev
service in it to automatically execute the script loading the characters into the customer display. As a fixing material, I propose to program the symbols of two more currencies from the Unicode table, the Russian ruble and the Ukrainian hryvnia, according to the matrices in the figures, and you can already do the euro sign yourself.Source: https://habr.com/ru/post/235105/
All Articles