Go Down

Topic: Thermal printer isn't Printing Images (Read 4 times) previous topic - next topic

Retroplayer

I will need to look over the library some more. I haven't had the time, unfortunately. The datasheet is not really great at explaining the various modes, etc... but I am not sure that you are accessing the modes properly.

BTW, you can change the adafruit library directly. It has the main structure that you want, you just have to modify the parts that are different.

Nauman048


Looking at the datasheet and looking at the adafruit library, it doesn't look like the library is directly compatible with your board. To get into bitmap mode, you need to send a specific command. The reason it works with everything else is because the printer is set at defaults at power up and accepts your text.

Page 14 of the datasheet describes how to use the bitmap mode. You have to send ESC (27) then * (42) then a mode of 8 or 24 dots, and then your actual bitmap information. I don't see the library sending all those commands.


I have got another code which is not using any specific Library. Its simply working on POS Commands... I used to send bitmap commands under //bitmap routine if you see.
The output is same yet...:(
The code is in next reply.


Nauman048

#22
Feb 12, 2013, 11:04 am Last Edit: Feb 13, 2013, 06:57 pm by Coding Badly Reason: 1
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial Thermal(2, 3);

int zero=0;

int heatTime = 80;
int heatInterval = 255;
char printDensity = 15;
char printBreakTime = 15;

static PROGMEM prog_uchar my_data [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};//I am skipping the data but the format is same..
void setup()
{
 Serial.begin(57600); // for debug info to serial monitor
 Thermal.begin(115200); // to write to our new printer
 initPrinter();
}

void initPrinter()
{
 //Modify the print speed and heat
 Thermal.write(27);
 Thermal.write(55);
 Thermal.write(7); //Default 64 dots = 8*('7'+1)
 Thermal.write(heatTime); //Default 80 or 800us
 Thermal.write(heatInterval); //Default 2 or 20us
 //Modify the print density and timeout
 Thermal.write(18);
 Thermal.write(35);
 int printSetting = (printDensity<<4) | printBreakTime;
 Thermal.write(printSetting); //Combination of printDensity and printBreakTime
 Serial.println();
 Serial.println("Printer ready");
}

void loop()
{
 // underline - one pixel
 Thermal.write(27);
 Thermal.write(45);  
 Thermal.write(1);
 Thermal.println("Underline - thin");
 Thermal.println("01234567890123456789012345678901");    
 Thermal.write(10);

 // underline - two pixels
 Thermal.write(27);    
 Thermal.write(45);
 Thermal.write(2);    
 Thermal.println("Underline - thick");
 Thermal.println("01234567890123456789012345678901");    
 Thermal.write(10);  

 // turn off underline
 Thermal.write(27);    
 Thermal.write(45);
 Thermal.write(zero);
 delay(3000);
 Thermal.write(10);  

 // bold text on
 Thermal.write(27);    
 Thermal.write(32);
 Thermal.write(1);
 Thermal.println(" #### Bold text #### ");
 Thermal.println("01234567890123456789012345678901");    
 delay(3000);  

 // bold text off
 Thermal.write(27);    
 Thermal.write(32);
 Thermal.write(zero);
 Thermal.write(10); //Sends the LF to the printer, advances the paper
 delay(3000);  

 // height/width enlarge
 Thermal.write(29);    
 Thermal.write(33);
 Thermal.write(255);
 Thermal.println("ABCDEF");
 Thermal.println("012345");
 delay(3000);  

 // back to normal
 Thermal.write(29);    
 Thermal.write(33);
 Thermal.write(zero);
 delay(3000);
 
 Thermal.write(10);
 Thermal.println("Back to normal...");
// Bitmap routine
 Thermal.write(27);
 Thermal.write(42);
 Thermal.write(1);
 Thermal.write(250);
 Thermal.write(2);
   for(int i=0; i<1024; i++)
   {
   Thermal.write(adalogo_data[i]);
   }
 Thermal.write(29);
 Thermal.write(47);
 Thermal.write(1);
 Thermal.println("Image ...");
 

 Thermal.write(10);
 Thermal.write(10);  
 do { } while (1>0); // do nothing
}



Moderator edit: [code] [/code] tags added.

Nauman048


BTW, you can change the adafruit library directly. It has the main structure that you want, you just have to modify the parts that are different.


I have modified it according to the datasheet of printer. One more thing I have done is that I have made private functions accessable publically. Then I tried sending commands as in datasheet. I could see the commands working fine. Even the bitmap command also runs but couldn't produce a bitmap unfortunately.. :(

Nauman048


Go Up