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

Commit

Permalink
Heat+density settings changed to avoid paper jams
Browse files Browse the repository at this point in the history
  • Loading branch information
PaintYourDragon committed May 2, 2012
1 parent ee7a94d commit 7db15af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
53 changes: 34 additions & 19 deletions Adafruit_Thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ Adafruit_Thermal::Adafruit_Thermal(int RX_Pin, int TX_Pin) {
_TX_Pin = TX_Pin;
}

void Adafruit_Thermal::begin() {
begin(150);
}

// heatTime - 80 is default from page 23 of datasheet. Controls speed of printing and darkness
void Adafruit_Thermal::begin(int heatTime) {
_printer = new SERIAL_IMPL(_RX_Pin, _TX_Pin);
_printer->begin(19200);
Expand All @@ -47,19 +42,39 @@ void Adafruit_Thermal::begin(int heatTime) {

reset();

heatInterval = 50; //2 is default from page 23 of datasheet. Controls speed of printing and darkness
printDensity = 15; //Not sure what the defaut is. Testing shows the max helps darken text. From page 23.
printBreakTime = 15; //Not sure what the defaut is. Testing shows the max helps darken text. From page 23.

writeBytes(27, 55);
writeBytes(7); //Default 64 dots = 8*('7'+1)
writeBytes(heatTime); //Default 80 or 800us
writeBytes(heatInterval); //Default 2 or 20us

//Modify the print density and timeout
writeBytes(18, 35);
int printSetting = (printDensity<<4) | printBreakTime;
writeBytes(printSetting); //Combination of printDensity and printBreakTime
// Description of print settings from page 23 of the manual:
// ESC 7 n1 n2 n3 Setting Control Parameter Command
// Decimal: 27 55 n1 n2 n3
// Set "max heating dots", "heating time", "heating interval"
// n1 = 0-255 Max printing dots, Unit (8dots), Default: 7 (64 dots)
// n2 = 3-255 Heating time, Unit (10us), Default: 80 (800us)
// n3 = 0-255 Heating interval, Unit (10us), Default: 2 (20us)
// The more max heating dots, the more peak current will cost
// when printing, the faster printing speed. The max heating
// dots is 8*(n1+1). The more heating time, the more density,
// but the slower printing speed. If heating time is too short,
// blank page may occur. The more heating interval, the more
// clear, but the slower printing speed.

writeBytes(27, 55); // Esc 7 (print settings)
writeBytes(20); // Heating dots (20=balance of darkness vs no jams)
writeBytes(heatTime); // Library default = 255 (max)
writeBytes(250); // Heat interval (500 uS = slower, but darker)

// Description of print density from page 23 of the manual:
// DC2 # n Set printing density
// Decimal: 18 35 n
// D4..D0 of n is used to set the printing density. Density is
// 50% + 5% * n(D4-D0) printing density.
// D7..D5 of n is used to set the printing break time. Break time
// is n(D7-D5)*250us.
// (Unsure of the default value for either -- not documented)

const int
printDensity = 14, // 120% (? can go higher, text is darker but fuzzy)
printBreakTime = 4; // 500 uS
writeBytes(18, 35); // DC2 # (print density)
writeBytes((printBreakTime << 5) | printDensity);
}

// reset printer
Expand Down Expand Up @@ -137,7 +152,7 @@ void Adafruit_Thermal::printBarcode(char * text, uint8_t type) {
delay(500);
PRINTER_PRINT(c); // Terminator must follow delay. ???

delay(3000); //For some reason we can't immediately have line feeds here
delay(3000); // For some reason we can't immediately have line feeds here
feed(2);
}

Expand Down
8 changes: 1 addition & 7 deletions Adafruit_Thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class Adafruit_Thermal : public Print {
public:

Adafruit_Thermal(int RX_Pin, int TX_Pin); // constructor
void begin();
void begin(int heatTime);
void begin(int heatTime=255);
void reset();
void setDefault();
void test();
Expand Down Expand Up @@ -119,11 +118,6 @@ class Adafruit_Thermal : public Print {

int _RX_Pin;
int _TX_Pin;

int heatTime;
int heatInterval;
char printDensity;
char printBreakTime;
};

#endif

1 comment on commit 7db15af

@lazyatom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find there's quite a bit of variation from printer to printer (even those with the same firmware!) regarding how high the heat can be set before jams will occur. Different papers obviously factor in too. It can be quite frustrating! :)

Please sign in to comment.