Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems that you can't print bitmap data directly with printer.write(). The printer expects some special bytes to turn on bitmap printing mode as you can see in the printBitmap() method. (writeBytes(18, 42, chunkHeight, rowBytesClipped))</p> <pre><code>void Adafruit_Thermal::printBitmap( int w, int h, const uint8_t *bitmap, bool fromProgMem) { int rowBytes, rowBytesClipped, rowStart, chunkHeight, x, y, i; rowBytes = (w + 7) / 8; // Round up to next byte boundary rowBytesClipped = (rowBytes &gt;= 48) ? 48 : rowBytes; // 384 pixels max width for(i=rowStart=0; rowStart &lt; h; rowStart += 255) { // Issue up to 255 rows at a time: chunkHeight = h - rowStart; if(chunkHeight &gt; 255) chunkHeight = 255; writeBytes(18, 42, chunkHeight, rowBytesClipped); for(y=0; y &lt; chunkHeight; y++) { for(x=0; x &lt; rowBytesClipped; x++, i++) { PRINTER_PRINT(fromProgMem ? pgm_read_byte(bitmap + i) : *(bitmap+i)); } i += rowBytes - rowBytesClipped; } timeoutSet(chunkHeight * dotPrintTime); } prevByte = '\n'; } </code></pre> <p>Your sketch will need to understand the data coming from the PHP and know when to send individual characters as bytes with printer.write() and when to send bytes as an image with printer.printBitmap(). This way the printer is receiving the proper commands to prep it for printing the appropriate data. You will need to construct some metadata around what you want to print in PHP and send that to the Arduino. A JSON format might look like this:</p> <pre><code>{"reciept": [ { "type": "text", "style": "bold", "value": "Thank you for your purchase" }, { "type": "bitmap", "pos": "center", "value": ".... binary data ..." } ]} </code></pre> <p>Now your Arduino sketch will understand when to send bytes individually as text and when to send a lot of data as a bitmap.</p> <p>A more compact format might use line feeds as a break between segments:</p> <pre><code>F|bold T|Thank you for shopping with us\r P|Center B|...binary data (with \r escaped)... \r </code></pre> <p>Or, you can send the amount of data with each segment to avoid escaping binary data much like the Content-Length header of HTTP</p> <pre><code>F4|boldT32|Thank you for shopping with us\rP6|CenterB3000|...binary data... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload