0.2.3 ParallelPrinter

This commit is contained in:
rob tillaart 2021-11-11 13:38:49 +01:00
parent 3f286ae8ab
commit 25b312f379
11 changed files with 98 additions and 57 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,7 +1,7 @@
//
// FILE: ParallelPrinter.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.2
// VERSION: 0.2.3
// PURPOSE: parallel printer class that implements the Print interface
// DATE: 2013-09-30
// URL: https://github.com/RobTillaart/ParallelPrinter
@ -9,8 +9,11 @@
// HISTORY
// 0.1.0 2013-09-30 initial release
// 0.2.0 2020-05-26 refactor, examples
// 0.2.1 2021-01-04 arduino-CI + unit test
// 0.2.1 2021-01-04 Arduino-CI + unit test
// 0.2.2 2021-01-14 update readme, add linefeed(), add keywords.txt
// 0.2.3 2021-11-11 update Arduino-CI, readme,md
// add isBusy();
#include "ParallelPrinter.h"

View File

@ -2,7 +2,7 @@
//
// FILE: ParallelPrinter.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.2
// VERSION: 0.2.3
// PURPOSE: parallel printer class that implements the Print interface
// DATE: 2013-09-30
// URL: https://github.com/RobTillaart/ParallelPrinter
@ -11,10 +11,10 @@
#include "Arduino.h"
#define PARALLELPRINTER_VERSION (F("0.2.2"))
#define PARALLELPRINTER_VERSION (F("0.2.3"))
#define FORMFEED 12
#define LINEFEED 10
#define FORMFEED 12
#define LINEFEED 10
class ParallelPrinter: public Print
@ -47,7 +47,8 @@ public:
void printLineNumber(bool b) { _printLineNumber = b; };
void formfeed() { write(FORMFEED); };
void linefeed() { write(LINEFEED); };
bool isOutOfPaper() { return digitalRead(_oopPin) == LOW; };
bool isOutOfPaper() { return digitalRead(_busyPin) == LOW; };
bool isBusy() { return digitalRead(_oopPin) == HIGH; };
// n = typical 2000; use with care
void setStrobeDelay(uint16_t n = 2000) { _strobeDelay = n; };
@ -76,4 +77,5 @@ private:
uint16_t _strobeDelay;
};
// -- END OF FILE --

View File

@ -1,20 +1,24 @@
[![Arduino CI](https://github.com/RobTillaart/ParallelPrinter/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/ParallelPrinter/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/ParallelPrinter/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/ParallelPrinter/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/ParallelPrinter/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/ParallelPrinter/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ParallelPrinter.svg?maxAge=3600)](https://github.com/RobTillaart/ParallelPrinter/releases)
# ParallelPrinter
Arduino library that implements a parallel printer (driver) - implements the PRINT interface
Arduino library that implements a parallel printer (driver) - implements the PRINT interface.
## Description
This library defines a parallel printer object.
It implements the **Print interface** to be able to print all datatypes using **write()**, **print()** and **println()**
It implements the **Print interface** to be able to print all data types
using **write()**, **print()** and **println()**.
The printer writes every byte over 8 parallel lines including a **STROBE** (clock) pulse,
while waiting for the connected printer not to be **BUSY** or **OUT OF PAPER**.
while waiting for the connected printer not to be **BUSY** or **OUT OF PAPER** (OOP).
This library is meant to be a starting point to make a "printer driver" for a
specific parallel printer. These can often be bought in 2nd hand stores or so.
@ -29,41 +33,45 @@ Have fun!
### Constructor
- **ParallelPrinter()** uses default pins (13, 2, 12, \[3,4,5,6,7,8,9,10\])
- **ParallelPrinter(strobe, busy, oop, arr)** define 3 control pins + 8 datapins (= arr)
- **begin(linelength, pagelength)** set line and page length parameters
- **ParallelPrinter(uint8_t strobe, uint8_t busy, uint8_t oop, uint8_t \*arr)**
define 3 control pins + 8 data pins (= arr\[8\]).
- **void begin(uint8_t lineLength, uint8_t pageLength)** set line and page length parameters
### Print interface
- **write(c)** send a single byte to printer, implements Print interface.
Therefor all **print()** and **println()** functions will work.
- **formfeed()** to eject current page or forced go to the next page.
- **linefeed()** send a linefeed. The number of actual lines is set by **setLineFeed()**
- **size_t write(uint8_t c)** send a single byte to printer, implements Print interface.
Therefore all **print()** and **println()** functions will work.
- **void formfeed()** to eject current page or forced go to the next page.
- **void linefeed()** send a linefeed.
The number of actual lines is set by **setLineFeed()**
### Config
### Configuration
These settings are pretty straightforward.
- **setLineLength(lineLength)** idem
- **getLineLength()** returns the current line length.
- **setPageLength(pageLength)** idem
- **getPageLength()** returns the current page length.
- **getLineNumber()** returns current line number.
- **getPageNumber()** returns current page number.
- **getPosition()** returns the position on a line.
- **setTabSize(tabsize)** tabs are replaced by spaces. n can be 0 or any size!
- **getTabSize()** returns tabSize set
- **setLineFeed(lineFeeds)** lineFeeds = 1,2,3 1 = default
- **getLineFeed()** returns lineFeeds set
- **printLineNr(bool)** can be set to true, false
- **void setLineLength(uint8_t lineLength)** idem
- **uint8_t getLineLength()** returns the current line length.
- **void setPageLength(uint8_t pageLength)** idem
- **uint8_t getPageLength()** returns the current page length.
- **uint8_t getLineNumber()** returns current line number.
- **uint8_t getPageNumber()** returns current page number.
- **uint8_t getPosition()** returns the position on a line.
- **uint8_t setTabSize(uint8_t tabsize)** tabs are replaced by spaces. n can be 0 or any size!
- **uint8_t getTabSize()** returns tabSize set
- **void setLineFeed(uint8_t lineFeeds)** lineFeeds = 1,2,3 1 = default.
- **uint8_t getLineFeed()** returns lineFeeds set
- **void printLineNr(bool b)** can be set to true, false.
### Expert mode
- **isOutOfPaper()** to check paper tray before printing starts.
- **setStrobeDelay(n = 2000)** make the strobe pulse shorter == faster printing
allows tuning of performance. Default value = 2000. Time in microseconds.
- **getStrobeDelay()** returns value set.
- **bool isOutOfPaper()** to check paper tray before printing starts.
- **void setStrobeDelay(uint16_t n = 2000)** allows tuning of performance.
Make the strobe pulse shorter == faster printing (printer dependant).
Default value = 2000. Time in microseconds.
- **uint16_t getStrobeDelay()** returns value set.
**Note** mechanical printers e.g. dot matrix, really do need a way to stop receiving
data as they do not have large buffers.
@ -76,8 +84,14 @@ https://en.wikipedia.org/wiki/Parallel_port#Centronics
## Future
- Make a front end of a parallel printer, that accepts the clocked bytes and print them
- update documentation
- extend unit tests?
- test more
- extend simulator sketch
- Make a front end of a parallel printer,
- Accepts the clocked bytes and print them e.g. over serial.
- derive e.g. an HP or an EPSON printer from this class.
- special modes e.g. bold italic underline
## Operation

View File

@ -23,11 +23,12 @@ void setup()
Serial.println("\ndone...");
}
void loop()
{
}
void test1()
{
Serial.println(__FUNCTION__);
@ -36,6 +37,7 @@ void test1()
delay(100);
}
void test2()
{
Serial.println(__FUNCTION__);
@ -45,6 +47,7 @@ void test2()
delay(100);
}
void test3()
{
Serial.println(__FUNCTION__);

View File

@ -6,58 +6,66 @@
// DATE: 2020-06-24
// (c) : MIT
// Simple parallel printer simulator, prints to serial...
// version could be made with a shiftin register ....
#include "Arduino.h"
uint8_t STROBE = 2;
uint8_t BUSY = 13;
uint8_t OOP = 10;
uint8_t PIN_STROBE = 2;
uint8_t PIN_BUSY = 13;
uint8_t PIN_OOP = 10;
uint8_t dataPins[] = { 3, 4, 5, 6, 7, 8, 9, 10 };
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
pinMode(STROBE, INPUT);
pinMode(OOP, OUTPUT);
pinMode(BUSY, OUTPUT); // build in LED UNO.
pinMode(PIN_STROBE, INPUT);
pinMode(PIN_OOP, OUTPUT);
pinMode(PIN_BUSY, OUTPUT); // build in LED UNO.
for (uint8_t i = 0; i < 8; i++)
{
pinMode(dataPins[i], INPUT);
}
digitalWrite(OOP, HIGH); // HIGH is OK
digitalWrite(BUSY, HIGH); // BUSY during startup
digitalWrite(PIN_OOP, HIGH); // HIGH is OK
digitalWrite(PIN_BUSY, HIGH); // BUSY during startup
delay(5000); // do startup thingies.
}
void loop()
{
handleInput();
// do other things here
}
void handleInput()
{
uint8_t x = 0;
digitalWrite(BUSY, LOW);
while (digitalRead(STROBE) == HIGH) yield();
digitalWrite(PIN_BUSY, LOW);
while (digitalRead(PIN_STROBE) == HIGH) yield();
for (int i = 0; i < 8; i++)
{
x <<= 1;
if (digitalRead(dataPins[i]) == HIGH) x += 1;
}
while (digitalRead(STROBE) == LOW) yield();
digitalWrite(BUSY, HIGH);
while (digitalRead(PIN_STROBE) == LOW) yield();
digitalWrite(PIN_BUSY, HIGH);
// process data
Serial.write(x);
}
// -- END OF FILE --

View File

@ -15,6 +15,7 @@
ParallelPrinter PP;
void setup()
{
Serial.begin(115200);
@ -23,6 +24,7 @@ void setup()
PP.begin();
}
void loop()
{
if (Serial.available()) PP.write(Serial.read());

View File

@ -1,6 +1,6 @@
# Syntax Coloring Map For ParallelPrinter
# Syntax Colouring Map For ParallelPrinter
# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
ParallelPrinter KEYWORD1
# Methods and Functions (KEYWORD2)
@ -27,6 +27,7 @@ formfeed KEYWORD2
linefeed KEYWORD2
isOutOfPaper KEYWORD2
isBusy KEYWORD2
setStrobeDelay KEYWORD2
getStrobeDelay KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ParallelPrinter.git"
},
"version": "0.2.2",
"version": "0.2.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"

View File

@ -1,5 +1,5 @@
name=ParallelPrinter
version=0.2.2
version=0.2.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Experimental (not complete) library to connect a parallel printer to Arduino.