Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More bitmap and DTR tweaks

  • Loading branch information...
commit c89633e8fb3193d9298ef5888768a7a686ad9dfc 1 parent e046722
@PaintYourDragon PaintYourDragon authored
Showing with 16 additions and 9 deletions.
  1. +15 −7 Adafruit_Thermal.cpp
  2. +1 −2  Adafruit_Thermal.h
View
22 Adafruit_Thermal.cpp
@@ -198,7 +198,7 @@ void Adafruit_Thermal::begin(uint8_t heatTime) {
dotPrintTime = 30000; // See comments near top of file for
dotFeedTime = 2100; // an explanation of these values.
- maxChunkHeight = 256;
+ maxChunkHeight = 255;
}
// Reset printer to default state.
@@ -443,9 +443,13 @@ void Adafruit_Thermal::printBitmap(
rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width
// Est. max rows to write at once, assuming 256 byte printer buffer.
- chunkHeightLimit = 256 / rowBytesClipped;
- if(chunkHeightLimit > maxChunkHeight) chunkHeightLimit = maxChunkHeight;
- else if(chunkHeightLimit < 1) chunkHeightLimit = 1;
+ if(dtrEnabled) {
+ chunkHeightLimit = 255; // Buffer doesn't matter, handshake!
+ } else {
+ chunkHeightLimit = 256 / rowBytesClipped;
+ if(chunkHeightLimit > maxChunkHeight) chunkHeightLimit = maxChunkHeight;
+ else if(chunkHeightLimit < 1) chunkHeightLimit = 1;
+ }
for(i=rowStart=0; rowStart < h; rowStart += chunkHeightLimit) {
// Issue up to chunkHeightLimit rows at a time:
@@ -474,9 +478,13 @@ void Adafruit_Thermal::printBitmap(int w, int h, Stream *fromStream) {
rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width
// Est. max rows to write at once, assuming 256 byte printer buffer.
- chunkHeightLimit = 256 / rowBytesClipped;
- if(chunkHeightLimit > maxChunkHeight) chunkHeightLimit = maxChunkHeight;
- else if(chunkHeightLimit < 1) chunkHeightLimit = 1;
+ if(dtrEnabled) {
+ chunkHeightLimit = 255; // Buffer doesn't matter, handshake!
+ } else {
+ chunkHeightLimit = 256 / rowBytesClipped;
+ if(chunkHeightLimit > maxChunkHeight) chunkHeightLimit = maxChunkHeight;
+ else if(chunkHeightLimit < 1) chunkHeightLimit = 1;
+ }
for(rowStart=0; rowStart < h; rowStart += chunkHeightLimit) {
// Issue up to chunkHeightLimit rows at a time:
View
3  Adafruit_Thermal.h
@@ -186,11 +186,10 @@ class Adafruit_Thermal : public Print {
charHeight, // Height of characters, in 'dots'
lineSpacing, // Inter-line spacing (not line height), in dots
barcodeHeight, // Barcode height in dots, not including text
+ maxChunkHeight,
dtrPin; // DTR handshaking pin (experimental)
boolean
dtrEnabled; // True if DTR pin set & printer initialized
- int
- maxChunkHeight;
unsigned long
resumeTime, // Wait until micros() exceeds this before sending byte
dotPrintTime, // Time to print a single dot line, in microseconds
Please sign in to comment.
Something went wrong with that request. Please try again.