OpenAccess printer and log functions

This is one of many sub-articles to describe the function of my OpenAccess.  I started putting it in one article, but it is really not useful like that.

The dot matrix printer uses these pins:

//dot matrix printer stuff
const int dataPins[] = {
const int strobePin = 39;//active low
const int busyPin = 49;//active low

It is initialized here:

void printer_init()
for (int i = 0; i < sizeof(dataPins) / sizeof(dataPins[0]); ++i)
pinMode(dataPins[i], OUTPUT);
pinMode(strobePin, OUTPUT);
pinMode(busyPin, INPUT);
digitalWrite(strobePin, HIGH);

The printer is actually called in this printing function here, which is blocking:

void printing(char buffer)//blocking? only if BusyPin is ever high?
//Write out our buffer
for (int j = 0; j < sizeof(dataPins) / sizeof(dataPins[0]); ++j)
digitalWrite(dataPins[j], (buffer & (1 << j)));
//buffer = 0x00;

//Block and wait for the printer to be ready
while (digitalRead(busyPin));

//Tell the printer to write out the data
digitalWrite(strobePin, LOW);
digitalWrite(strobePin, HIGH);
delay(10);//not needed?
//Reset the data lines
for (int j = 0; j < sizeof(dataPins) / sizeof(dataPins[0]); ++j)
digitalWrite(dataPins[j], LOW);

That function is called in these ones that act like serial print() and println() statements:

void printer(String printable)
//if (printable.length() != 0)
for(int i=0;i<printable.length();i++)//change to not call .length every time
//else {
//Serial.println(“No arguments”);
void printerln(String printable)

Those functions are called at the same time as serial’s print functions as log functions so the computer and printer can log stuff together:

void logging(String tolog)//wrapper
void loggingln(String tolog)//wrapper

Those functions are called absolutely everywhere, very useful for logging things verbosely.

// uses printer
//format: PRINT;<string>
void SCmd_print()
char *arg;
arg =;
if (arg != NULL)

That function is the serial wrapper that just uses the printer, great for testing or taking manual control of the system.

This is a derivative of the dot matrix printer driver I used before and part of the OpenAccess project.


One Response to “OpenAccess printer and log functions”

  1. OpenAccess 3.0 replacement software | Evan's Techie-Blog Says:

    […] printer and log functions […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: