Toshiba recepian printer with arduino

Hello,

I try to hook up a Toshiba TRST-56 to a network system off me. First i want to command everything with a arduino nano and when everything works i want to switch to a nodemcu

I can print text and change the font even cut the paper. The last part is printing a image. I have try many things and diferent forum’s but it won’t print. I do not have a example so i can not test what i do wrong.

Does someone have experience?

i have use this manual but it can be the wrong:

Current code:

/*=== settings ===*/
const int chartsPerLine = 80; // max tekens per lijn;

const int nStrobe = 2; // parallel port pin# = arduino data pin#
const int data_0 = 3;
const int data_1 = 4;
const int data_2 = 5;
const int data_3 = 6;
const int data_4 = 7;
const int data_5 = 8;
const int data_6 = 9;
const int data_7 = 10;
const int nAck = 11;
const int busy = 12;

const int strobeWait = 2;   // microseconds to strobe for

const int debugBaut = 9600;


void setup() {
  Serial.begin(debugBaut);

  pinMode(nStrobe, OUTPUT);      // is active LOW
  digitalWrite(nStrobe, HIGH);   // set HIGH
  pinMode(data_0, OUTPUT);
  pinMode(data_1, OUTPUT);
  pinMode(data_2, OUTPUT);
  pinMode(data_3, OUTPUT);
  pinMode(data_4, OUTPUT);
  pinMode(data_5, OUTPUT);
  pinMode(data_6, OUTPUT);
  pinMode(data_7, OUTPUT);

  pinMode(nAck, INPUT);     // is active LOW
  pinMode(busy, INPUT); 

  pinMode(13, OUTPUT);
  pinMode(14, INPUT);   // analog pin 0 on duemilanove and uno
  digitalWrite(14, HIGH); // enable pull-up
 
  delay(1000);
 
  resetPrinter();
  
  Serial.println("Startup complete");
}

void loop() {
  /*setAlignment(1,0,0);
  writeLine("Links", 3);
  setAlignment(0,1,0);
  writeLine("Center", 3);
  setAlignment(0,0,1);
  writeLine("Rechts", 3);

  writeLine("fontsize 1", 1);
  writeLine("fontsize 2", 2);
  writeLine("fontsize 3", 3);
  writeLine("fontsize 4", 4);
  writeLine("fontsize 5", 5);
  writeLine("fontsize 6", 6);
  writeLine("fontsize 7", 7);
  writeLine("fontsize 8", 8);*/

  uploadBitmap();
  printBitmap();
  
  cutPaper();
  
  while(true) {
    
  }
}

void writeLine(String text, int fontSize) {
  setCharacterSize(fontSize);
  
  digitalWrite(13, HIGH);
  for(int cursorPosition = 0; cursorPosition < text.length(); cursorPosition++) {
    Serial.println(text[cursorPosition]);
    byte character = text[cursorPosition];
    writeByte(character);
    delay(1);
  }
  printLine();
  writeByte(13); // carriage return
  digitalWrite(13,LOW);
}

void printLine() {
  writeByte(10); // new line
}

void cutPaper() {
  writeLine("", 2);
  writeByte(29);
  writeByte(86);
  writeByte(1);
}

#define Y_MAX 96
#define X_MAX 64
void uploadBitmap() {
  int x;
  int y;
  writeByte(28);
  writeByte(113);
  writeByte(1);
  writeByte(X_MAX);
  writeByte(Y_MAX);
  for(y = 0; y < 96; y++) {
    for(x = 0; x < 64; x++) {
      writeByte(7);
   }
    delay(1);
  }
}

void printBitmap() {
    writeByte(28);
    writeByte(112);
    writeByte(1);
    writeByte(48);
    Serial.println("printBitmap");
}


void setCharacterSize(int size) {
    int data[] = {0,17,34,51,68,85,102,119};
    writeByte(29);
    writeByte(33);
    writeByte(data[size - 1]);
    Serial.print("setCharacterSize: ");
    Serial.println(data[size - 1]);
}

void drawerKick(bool a, bool b) {
  if(a == true) {
    writeByte(27);
    writeByte(112);
    writeByte(0);
    writeByte(100);
    writeByte(100);
    Serial.println("drawerKick: A");
  }

  if(b == true) {
    writeByte(27);
    writeByte(112);
    writeByte(1);
    writeByte(100);
    writeByte(100);
    Serial.println("drawerKick: B");
  }
}

void setAlignment(int left, int center, int right) {
  writeByte(27);
  writeByte(97);
  if(left == 1) {
    writeByte(0);
    Serial.println("setAlignment: Left");
  } else if(center == 1) {
    writeByte(1);
    Serial.println("setAlignment: Center");
  } else {
    writeByte(2);
    Serial.println("setAlignment: Right");
  }
}

void emptyLine() {
  Serial.println("Empty line");
  writeByte(10); // reset printer
}

void writeByte(byte inByte) {
  while(digitalRead(busy) == HIGH) {
    // wait for busy to go low
  }

  int b0 = bitRead(inByte, 0);
  int b1 = bitRead(inByte, 1);
  int b2 = bitRead(inByte, 2);
  int b3 = bitRead(inByte, 3);
  int b4 = bitRead(inByte, 4);
  int b5 = bitRead(inByte, 5);
  int b6 = bitRead(inByte, 6);
  int b7 = bitRead(inByte, 7);

  digitalWrite(data_0, b0);        // set data bit pins
  digitalWrite(data_1, b1);
  digitalWrite(data_2, b2);
  digitalWrite(data_3, b3);
  digitalWrite(data_4, b4);
  digitalWrite(data_5, b5);
  digitalWrite(data_6, b6);
  digitalWrite(data_7, b7);

  digitalWrite(nStrobe, LOW);       // strobe nStrobe to input data bits
  delayMicroseconds(strobeWait);
  digitalWrite(nStrobe, HIGH);

  while(digitalRead(busy) == HIGH) {
    // wait for busy line to go low
  }
}

void resetPrinter() {
  Serial.println("Reseting printer...");
  writeByte(27); // reset printer
  writeByte(64); // reset printer
}

If I read the manual correctly, when you upload an image into NVM, you need to specify both lower and uppoer limits for H and V before sending the data but it appears your code only sends X_MAX and Y_MAX. It you look at the formulas in the manual on page 4-54, you are defining a HUGE image - probably larger than can be handled. Something like this might be closer…

const byte FS = 28;
const int xL = 1; // lower horizontal limit
const int xH = 2;  // upper horizontal limit (0..3)
const int yL = 1;   // lower vertical limit
const int yH = 1;  // upper horizontal limit (0..1)
const long k = (xL+xH*256) * (yL+yH*256) * 8; // total number of data bytes to send
#define Y_MAX 96
#define X_MAX 64
void uploadBitmap() {
  writeByte(FS);
  writeByte('q');
  writeByte(1);
  writeByte(xL);
  writeByte(xH);
  writeByte(yL);
  writeByte(yH);
  for (int y = yL; y < yH; y++) {
    for (int x = xL; x < xH; x++) {
      writeByte(0x55);  // every other bit on
    }
    delay(1);
  }
}

Sorry, i have change the code but it cuts a empty line of the paper.