0

Increase bitmap print speed thermal printer
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Increase bitmap print speed thermal printer

by Monstercrunch81 on Fri Nov 09, 2018 8:40 am

Hi,
I'm using the mini thermal printer but I'm a bit disappointed with it's speed while printing bitmap. It's even more frustrating knowing that the print speed in text mode is super fast.
This is my test: two bitmaps of the same picture, but rotated. The horizontal one takes around 7s to come up while the second one takes 11s.
Image

I tried to tweak some parameters in the library with no significant results. All my tests have resulted in a more or less 18s print.

Code: Select all | TOGGLE FULL SIZE
writeBytes(11, 120, 40);  // Heating dots, heat time, heat interval, default values
writeBytes(40, 120, 40);
writeBytes(11, 120, 5);
writeBytes(11, 60, 40);


The main 'optimisation' has been to comment this line int the Adafruit_Thermal::printBitmap function:
Code: Select all | TOGGLE FULL SIZE
//timeoutSet(chunkHeight * dotPrintTime);


Without this line commented, the print is achieved in 37s... which is way too slow!

Any idea what I could do to increase the speed even more? I'd really like to reach the text print speed in bitmap mode :)

My code:
Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>
#include <avr/pgmspace.h>
/*------------------------------------------------------------------------
  Example sketch for Adafruit Thermal Printer library for Arduino.
  Demonstrates a few text styles & layouts, bitmap printing, etc.

  IMPORTANT: DECLARATIONS DIFFER FROM PRIOR VERSIONS OF THIS LIBRARY.
  This is to support newer & more board types, especially ones that don't
  support SoftwareSerial (e.g. Arduino Due).  You can pass any Stream
  (e.g. Serial1) to the printer constructor.  See notes below.

  You may need to edit the PRINTER_FIRMWARE value in Adafruit_Thermal.h
  to match your printer (hold feed button on powerup for test page).
  ------------------------------------------------------------------------*/

#include <Adafruit_Thermal.h>
#include <SD.h>
#include "content.h"

// Here's the new syntax when using SoftwareSerial (e.g. Arduino Uno) ----
// If using hardware serial instead, comment out or remove these lines:

#include "SoftwareSerial.h"
#define TX_PIN 9 // Arduino transmit  YELLOW WIRE  labeled RX on printer
#define RX_PIN 8 // Arduino receive   GREEN WIRE   labeled TX on printer
#define SD_Pin 4

SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial);     // Pass addr to printer constructor
// Then see setup() function regarding serial & printer begin() calls.

// Here's the syntax for hardware serial (e.g. Arduino Due) --------------
// Un-comment the following line if using hardware serial:

//Adafruit_Thermal printer(&Serial1);      // Or Serial2, Serial3, etc.

// -----------------------------------------------------------------------

inline void initSD() {
  pinMode(SD_Pin, OUTPUT);
  if (!SD.begin(SD_Pin)) {
    Serial.println("SD Error");
  } else {
    Serial.println("SD Ok");
  }
}

void setup() {
  initSD();

  // This line is for compatibility with the Adafruit IotP project pack,
  // which uses pin 7 as a spare grounding point.  You only need this if
  // wired up the same way (w/3-pin header into pins 5/6/7):
  pinMode(7, OUTPUT); digitalWrite(7, LOW);

  // NOTE: SOME PRINTERS NEED 9600 BAUD instead of 19200, check test page.
  mySerial.begin(19200);  // Initialize SoftwareSerial
  //Serial1.begin(19200); // Use this instead if using hardware serial
  printer.begin();        // Init printer (same regardless of serial type)

  printer.feed(2);

  File ticketh = SD.open("ticketh", FILE_READ);
  printer.printBitmap(384, 267, dynamic_cast<Stream*>(&ticketh));
  ticketh.close();

  printer.feed(2);

  File ticketv = SD.open("ticketv", FILE_READ);
  printer.printBitmap(384, 384, dynamic_cast<Stream*>(&ticketv));
  ticketv.close();
 
  //const uint8_t test[] = {0xf0,0x01,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0e,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff};
  printer.feed(2);

  printer.sleep();      // Tell printer to sleep
  delay(3000L);         // Sleep for 3 seconds
  printer.wake();       // MUST wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
 
}

void loop() {
}


ticketv and ticketh files: https://drive.google.com/open?id=11NnNbwlT3km2YONdx_bzeaYshh0cgTKx




Thanks
Attachments
45776072_293958938111900_3083303588110270464_n.jpg
45776072_293958938111900_3083303588110270464_n.jpg (52.05 KiB) Viewed 370 times

Monstercrunch81
 
Posts: 4
Joined: Thu Dec 14, 2017 6:54 am

Please be positive and constructive with your questions and comments.