Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Made the maximum chunk height configurable with setMaxChunkHeight(int…
Browse files Browse the repository at this point in the history
… val) - defaults to 255
  • Loading branch information
ennui2342 committed Oct 19, 2013
1 parent 69ac6d7 commit fbf0be7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Adafruit_Thermal.cpp
Expand Up @@ -184,6 +184,7 @@ void Adafruit_Thermal::begin(int heatTime) {

dotPrintTime = 30000; // See comments near top of file for
dotFeedTime = 2100; // an explanation of these values.
maxChunkHeight = 255;
}

// Reset printer to default state.
Expand Down Expand Up @@ -395,10 +396,10 @@ void Adafruit_Thermal::printBitmap(
rowBytes = (w + 7) / 8; // Round up to next byte boundary
rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width

for(i=rowStart=0; rowStart < h; rowStart += 255) {
for(i=rowStart=0; rowStart < h; rowStart += maxChunkHeight) {
// Issue up to 255 rows at a time:
chunkHeight = h - rowStart;
if(chunkHeight > 255) chunkHeight = 255;
if(chunkHeight > maxChunkHeight) chunkHeight = maxChunkHeight;

writeBytes(18, 42, chunkHeight, rowBytesClipped);

Expand All @@ -419,10 +420,10 @@ void Adafruit_Thermal::printBitmap(int w, int h, Stream *stream) {
rowBytes = (w + 7) / 8; // Round up to next byte boundary
rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width

for(rowStart=0; rowStart < h; rowStart += 255) {
for(rowStart=0; rowStart < h; rowStart += maxChunkHeight) {
// Issue up to 255 rows at a time:
chunkHeight = h - rowStart;
if(chunkHeight > 255) chunkHeight = 255;
if(chunkHeight > maxChunkHeight) chunkHeight = maxChunkHeight;

writeBytes(18, 42, chunkHeight, rowBytesClipped);

Expand Down Expand Up @@ -538,6 +539,10 @@ void Adafruit_Thermal::setLineHeight(int val) {
writeBytes(27, 51, val);
}

void Adafruit_Thermal::setMaxChunkHeight(int val) {
maxChunkHeight = val;
}

////////////////////// not working?
void Adafruit_Thermal::tab() {
PRINTER_PRINT(9);
Expand Down
4 changes: 3 additions & 1 deletion Adafruit_Thermal.h
Expand Up @@ -97,6 +97,7 @@ class Adafruit_Thermal : public Print {
timeoutSet(unsigned long),
timeoutWait(),
setTimes(unsigned long, unsigned long),
setMaxChunkHeight(int val),

setCharSpacing(int spacing), // Not working
tab(); // Not working
Expand Down Expand Up @@ -127,7 +128,8 @@ class Adafruit_Thermal : public Print {
int
printMode,
_RX_Pin,
_TX_Pin;
_TX_Pin,
maxChunkHeight;
void
setPrintMode(uint8_t mask),
unsetPrintMode(uint8_t mask),
Expand Down

0 comments on commit fbf0be7

Please sign in to comment.