update 0.2.2 (#4)
This commit is contained in:
parent
e9fca01531
commit
4c7c4d06ad
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// FILE: ParallelPrinter.cpp
|
// FILE: ParallelPrinter.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.2.1
|
// VERSION: 0.2.2
|
||||||
// PURPOSE: parallel printer class that implements the Print interface
|
// PURPOSE: parallel printer class that implements the Print interface
|
||||||
// DATE: 2013-09-30
|
// DATE: 2013-09-30
|
||||||
// URL: https://github.com/RobTillaart/ParallelPrinter
|
// URL: https://github.com/RobTillaart/ParallelPrinter
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
// HISTORY
|
// HISTORY
|
||||||
// 0.1.0 2013-09-30 initial release
|
// 0.1.0 2013-09-30 initial release
|
||||||
// 0.2.0 2020-05-26 refactor, examples
|
// 0.2.0 2020-05-26 refactor, examples
|
||||||
// 0.2.1 2020-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
|
||||||
|
|
||||||
#include "ParallelPrinter.h"
|
#include "ParallelPrinter.h"
|
||||||
|
|
||||||
|
@ -67,13 +67,13 @@ void ParallelPrinter::reset()
|
||||||
// write() implements the virtual write of the Print class
|
// write() implements the virtual write of the Print class
|
||||||
size_t ParallelPrinter::write(uint8_t c)
|
size_t ParallelPrinter::write(uint8_t c)
|
||||||
{
|
{
|
||||||
if (c == '\t')
|
if (c == '\t') // TAB
|
||||||
{
|
{
|
||||||
uint8_t spaces = _tabSize - _pos % _tabSize;
|
uint8_t spaces = _tabSize - _pos % _tabSize;
|
||||||
for (uint8_t i = 0; i < spaces; i++) processSingleChar(' ');
|
for (uint8_t i = 0; i < spaces; i++) processSingleChar(' ');
|
||||||
return spaces;
|
return spaces;
|
||||||
}
|
}
|
||||||
if (c == '\n')
|
if (c == '\n') // LINEFEED
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < _lineFeed; i++)
|
for (uint8_t i = 0; i < _lineFeed; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,17 +2,20 @@
|
||||||
//
|
//
|
||||||
// FILE: ParallelPrinter.h
|
// FILE: ParallelPrinter.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.2.1
|
// VERSION: 0.2.2
|
||||||
// PURPOSE: parallel printer class that implements the Print interface
|
// PURPOSE: parallel printer class that implements the Print interface
|
||||||
// DATE: 2013-09-30
|
// DATE: 2013-09-30
|
||||||
// URL: https://github.com/RobTillaart/ParallelPrinter
|
// URL: https://github.com/RobTillaart/ParallelPrinter
|
||||||
//
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
#define PARALLELPRINTER_VERSION (F("0.2.1"))
|
|
||||||
|
#define PARALLELPRINTER_VERSION (F("0.2.2"))
|
||||||
|
|
||||||
#define FORMFEED 12
|
#define FORMFEED 12
|
||||||
|
#define LINEFEED 10
|
||||||
|
|
||||||
|
|
||||||
class ParallelPrinter: public Print
|
class ParallelPrinter: public Print
|
||||||
{
|
{
|
||||||
|
@ -43,6 +46,7 @@ public:
|
||||||
|
|
||||||
void printLineNumber(bool b) { _printLineNumber = b; };
|
void printLineNumber(bool b) { _printLineNumber = b; };
|
||||||
void formfeed() { write(FORMFEED); };
|
void formfeed() { write(FORMFEED); };
|
||||||
|
void linefeed() { write(LINEFEED); };
|
||||||
bool isOutOfPaper() { return digitalRead(_oopPin) == LOW; };
|
bool isOutOfPaper() { return digitalRead(_oopPin) == LOW; };
|
||||||
|
|
||||||
// n = typical 2000; use with care
|
// n = typical 2000; use with care
|
||||||
|
|
53
README.md
53
README.md
|
@ -5,13 +5,14 @@
|
||||||
|
|
||||||
# ParallelPrinter
|
# ParallelPrinter
|
||||||
|
|
||||||
Arduino library that implements a parallel printer - uses print interface
|
Arduino library that implements a parallel printer (driver) - implements the PRINT interface
|
||||||
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This **experimental** library defines a simple parallel printer object.
|
This library defines a parallel printer object.
|
||||||
|
|
||||||
It implements the **Print interface** to be able to print all datatypes using **print()** and **println()**
|
It implements the **Print interface** to be able to print all datatypes using **write()**, **print()** and **println()**
|
||||||
The printer writes every byte over 8 parallel lines including a **STROBE** (clock) pulse,
|
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**.
|
||||||
|
|
||||||
|
@ -22,46 +23,62 @@ Have fun!
|
||||||
|
|
||||||
**Note:** This lib is a extended redo of the ParPrinter class.
|
**Note:** This lib is a extended redo of the ParPrinter class.
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
### Constructor
|
### Constructor
|
||||||
|
|
||||||
- **ParallelPrinter()** uses default pins (10, 2, 12, \[3,4,5,6,7,8,9,10\])
|
- **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)
|
- **ParallelPrinter(strobe, busy, oop, arr)** define 3 control pins + 8 datapins (= arr)
|
||||||
- **begin(linelength, pagelength)** set line and page length parameters
|
- **begin(linelength, pagelength)** set line and page length parameters
|
||||||
|
|
||||||
|
|
||||||
### Print interface
|
### Print interface
|
||||||
- **write(c)** send a single byte to printer, implements Print interface. Therefor all **print()** and **println()** functions will work.
|
- **write(c)** send a single byte to printer, implements Print interface.
|
||||||
- **formfeed()** to eject current page.
|
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()**
|
||||||
|
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
|
|
||||||
- **setLineLength(n)** idem
|
These settings are pretty straightforward.
|
||||||
- **getLineLength()** idem
|
|
||||||
- **setPageLength()** idem
|
- **setLineLength(lineLength)** idem
|
||||||
- **getPageLength()** idem
|
- **getLineLength()** returns the current line length.
|
||||||
- **getLineNumber()** idem
|
- **setPageLength(pageLength)** idem
|
||||||
- **getPageNumber()** idem
|
- **getPageLength()** returns the current page length.
|
||||||
- **getPosition()** idem
|
- **getLineNumber()** returns current line number.
|
||||||
- **setTabSize(n)** tabs are replaced by spaces. n can be 0 or any size!
|
- **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
|
- **getTabSize()** returns tabSize set
|
||||||
- **setLineFeed(n)** n = 1,2,3 1 = default
|
- **setLineFeed(lineFeeds)** lineFeeds = 1,2,3 1 = default
|
||||||
- **getLineFeed()** returns lineFeed set
|
- **getLineFeed()** returns lineFeeds set
|
||||||
- **printLineNr(b)** true, false
|
- **printLineNr(bool)** can be set to true, false
|
||||||
|
|
||||||
|
|
||||||
### Expert mode
|
### Expert mode
|
||||||
|
|
||||||
- **isOutOfPaper()** to check paper tray before printing starts.
|
- **isOutOfPaper()** to check paper tray before printing starts.
|
||||||
- **setStrobeDelay(n = 2000)** make the strobe pulse shorter == faster printing
|
- **setStrobeDelay(n = 2000)** make the strobe pulse shorter == faster printing
|
||||||
allows tuning of performance. Default value = 2000. Time in microseconds.
|
allows tuning of performance. Default value = 2000. Time in microseconds.
|
||||||
- **getStrobeDelay()** returns value set.
|
- **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.
|
||||||
|
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
https://en.wikipedia.org/wiki/Parallel_port#Centronics
|
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
|
||||||
|
- derive e.g. an HP or an EPSON printer from this class.
|
||||||
|
|
||||||
## Operation
|
## Operation
|
||||||
|
|
||||||
See examples
|
See examples
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Syntax Coloring Map For ParallelPrinter
|
||||||
|
|
||||||
|
# Datatypes (KEYWORD1)
|
||||||
|
ParallelPrinter KEYWORD1
|
||||||
|
|
||||||
|
# Methods and Functions (KEYWORD2)
|
||||||
|
begin KEYWORD2
|
||||||
|
reset KEYWORD2
|
||||||
|
write KEYWORD2
|
||||||
|
|
||||||
|
setLineLength KEYWORD2
|
||||||
|
getLineLength KEYWORD2
|
||||||
|
setPageLength KEYWORD2
|
||||||
|
getPageLength KEYWORD2
|
||||||
|
|
||||||
|
getLineNumber KEYWORD2
|
||||||
|
getPageNumber KEYWORD2
|
||||||
|
getPosition KEYWORD2
|
||||||
|
|
||||||
|
setTabSize KEYWORD2
|
||||||
|
getTabSize KEYWORD2
|
||||||
|
setLineFeed KEYWORD2
|
||||||
|
getLineFeed KEYWORD2
|
||||||
|
|
||||||
|
printLineNumber KEYWORD2
|
||||||
|
formfeed KEYWORD2
|
||||||
|
linefeed KEYWORD2
|
||||||
|
|
||||||
|
isOutOfPaper KEYWORD2
|
||||||
|
setStrobeDelay KEYWORD2
|
||||||
|
getStrobeDelay KEYWORD2
|
||||||
|
|
||||||
|
|
||||||
|
# Instances (KEYWORD2)
|
||||||
|
|
||||||
|
# Constants (LITERAL1)
|
||||||
|
PARALLELPRINTER_VERSION LITERAL1
|
||||||
|
FORMFEED LITERAL1
|
||||||
|
LINEFEED LITERAL1
|
|
@ -15,7 +15,7 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/ParallelPrinter.git"
|
"url": "https://github.com/RobTillaart/ParallelPrinter.git"
|
||||||
},
|
},
|
||||||
"version":"0.2.1",
|
"version":"0.2.2",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*"
|
"platforms": "*"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name=ParallelPrinter
|
name=ParallelPrinter
|
||||||
version=0.2.1
|
version=0.2.2
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=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.
|
sentence=Experimental (not complete) library to connect a parallel printer to Arduino.
|
||||||
|
|
Reference in New Issue