update build-CI, readme, badges, add isBusy() (#5)
* update build-CI, * update readme, badges, * add isBusy() * fixed example for ESP32pull/6/head 0.2.3
parent
ed6fed3c41
commit
a29596cc12
|
@ -2,6 +2,10 @@ compile:
|
||||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||||
platforms:
|
platforms:
|
||||||
- uno
|
- uno
|
||||||
- leonardo
|
# - due
|
||||||
- due
|
# - zero
|
||||||
- zero
|
# - leonardo
|
||||||
|
- m4
|
||||||
|
- esp32
|
||||||
|
# - esp8266
|
||||||
|
# - mega2560
|
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
arduino_ci:
|
runTest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: Arduino-CI/action@master
|
- uses: ruby/setup-ruby@v1
|
||||||
# Arduino-CI/action@v0.1.1
|
with:
|
||||||
|
ruby-version: 2.6
|
||||||
|
- run: |
|
||||||
|
gem install arduino_ci
|
||||||
|
arduino_ci.rb
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// FILE: ParallelPrinter.cpp
|
// FILE: ParallelPrinter.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.2.2
|
// VERSION: 0.2.3
|
||||||
// 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,11 @@
|
||||||
// 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 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.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"
|
#include "ParallelPrinter.h"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// FILE: ParallelPrinter.h
|
// FILE: ParallelPrinter.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.2.2
|
// VERSION: 0.2.3
|
||||||
// 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
|
||||||
|
@ -11,10 +11,10 @@
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
|
||||||
#define PARALLELPRINTER_VERSION (F("0.2.2"))
|
#define PARALLELPRINTER_VERSION (F("0.2.3"))
|
||||||
|
|
||||||
#define FORMFEED 12
|
#define FORMFEED 12
|
||||||
#define LINEFEED 10
|
#define LINEFEED 10
|
||||||
|
|
||||||
|
|
||||||
class ParallelPrinter: public Print
|
class ParallelPrinter: public Print
|
||||||
|
@ -47,7 +47,8 @@ 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); };
|
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
|
// n = typical 2000; use with care
|
||||||
void setStrobeDelay(uint16_t n = 2000) { _strobeDelay = n; };
|
void setStrobeDelay(uint16_t n = 2000) { _strobeDelay = n; };
|
||||||
|
@ -76,4 +77,5 @@ private:
|
||||||
uint16_t _strobeDelay;
|
uint16_t _strobeDelay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
|
68
README.md
68
README.md
|
@ -1,20 +1,24 @@
|
||||||
|
|
||||||
[![Arduino CI](https://github.com/RobTillaart/ParallelPrinter/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
[![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)
|
[![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)
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ParallelPrinter.svg?maxAge=3600)](https://github.com/RobTillaart/ParallelPrinter/releases)
|
||||||
|
|
||||||
|
|
||||||
# ParallelPrinter
|
# 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
|
## Description
|
||||||
|
|
||||||
This library defines a parallel printer object.
|
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,
|
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
|
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.
|
specific parallel printer. These can often be bought in 2nd hand stores or so.
|
||||||
|
@ -29,41 +33,45 @@ Have fun!
|
||||||
### Constructor
|
### Constructor
|
||||||
|
|
||||||
- **ParallelPrinter()** uses default pins (13, 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(uint8_t strobe, uint8_t busy, uint8_t oop, uint8_t \*arr)**
|
||||||
- **begin(linelength, pagelength)** set line and page length parameters
|
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
|
### Print interface
|
||||||
- **write(c)** send a single byte to printer, implements Print interface.
|
|
||||||
Therefor all **print()** and **println()** functions will work.
|
- **size_t write(uint8_t c)** send a single byte to printer, implements Print interface.
|
||||||
- **formfeed()** to eject current page or forced go to the next page.
|
Therefore all **print()** and **println()** functions will work.
|
||||||
- **linefeed()** send a linefeed. The number of actual lines is set by **setLineFeed()**
|
- **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.
|
These settings are pretty straightforward.
|
||||||
|
|
||||||
- **setLineLength(lineLength)** idem
|
- **void setLineLength(uint8_t lineLength)** idem
|
||||||
- **getLineLength()** returns the current line length.
|
- **uint8_t getLineLength()** returns the current line length.
|
||||||
- **setPageLength(pageLength)** idem
|
- **void setPageLength(uint8_t pageLength)** idem
|
||||||
- **getPageLength()** returns the current page length.
|
- **uint8_t getPageLength()** returns the current page length.
|
||||||
- **getLineNumber()** returns current line number.
|
- **uint8_t getLineNumber()** returns current line number.
|
||||||
- **getPageNumber()** returns current page number.
|
- **uint8_t getPageNumber()** returns current page number.
|
||||||
- **getPosition()** returns the position on a line.
|
- **uint8_t getPosition()** returns the position on a line.
|
||||||
- **setTabSize(tabsize)** tabs are replaced by spaces. n can be 0 or any size!
|
- **uint8_t setTabSize(uint8_t tabsize)** tabs are replaced by spaces. n can be 0 or any size!
|
||||||
- **getTabSize()** returns tabSize set
|
- **uint8_t getTabSize()** returns tabSize set
|
||||||
- **setLineFeed(lineFeeds)** lineFeeds = 1,2,3 1 = default
|
- **void setLineFeed(uint8_t lineFeeds)** lineFeeds = 1,2,3 1 = default.
|
||||||
- **getLineFeed()** returns lineFeeds set
|
- **uint8_t getLineFeed()** returns lineFeeds set
|
||||||
- **printLineNr(bool)** can be set to true, false
|
- **void printLineNr(bool b)** can be set to true, false.
|
||||||
|
|
||||||
|
|
||||||
### Expert mode
|
### Expert mode
|
||||||
|
|
||||||
- **isOutOfPaper()** to check paper tray before printing starts.
|
- **bool isOutOfPaper()** to check paper tray before printing starts.
|
||||||
- **setStrobeDelay(n = 2000)** make the strobe pulse shorter == faster printing
|
- **void setStrobeDelay(uint16_t n = 2000)** allows tuning of performance.
|
||||||
allows tuning of performance. Default value = 2000. Time in microseconds.
|
Make the strobe pulse shorter == faster printing (printer dependant).
|
||||||
- **getStrobeDelay()** returns value set.
|
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
|
**Note** mechanical printers e.g. dot matrix, really do need a way to stop receiving
|
||||||
data as they do not have large buffers.
|
data as they do not have large buffers.
|
||||||
|
@ -76,8 +84,14 @@ https://en.wikipedia.org/wiki/Parallel_port#Centronics
|
||||||
|
|
||||||
## Future
|
## 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.
|
- derive e.g. an HP or an EPSON printer from this class.
|
||||||
|
- special modes e.g. bold italic underline
|
||||||
|
|
||||||
## Operation
|
## Operation
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,12 @@ void setup()
|
||||||
Serial.println("\ndone...");
|
Serial.println("\ndone...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test1()
|
void test1()
|
||||||
{
|
{
|
||||||
Serial.println(__FUNCTION__);
|
Serial.println(__FUNCTION__);
|
||||||
|
@ -36,6 +37,7 @@ void test1()
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test2()
|
void test2()
|
||||||
{
|
{
|
||||||
Serial.println(__FUNCTION__);
|
Serial.println(__FUNCTION__);
|
||||||
|
@ -45,6 +47,7 @@ void test2()
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test3()
|
void test3()
|
||||||
{
|
{
|
||||||
Serial.println(__FUNCTION__);
|
Serial.println(__FUNCTION__);
|
||||||
|
|
|
@ -6,58 +6,66 @@
|
||||||
// DATE: 2020-06-24
|
// DATE: 2020-06-24
|
||||||
// (c) : MIT
|
// (c) : MIT
|
||||||
|
|
||||||
|
|
||||||
// Simple parallel printer simulator, prints to serial...
|
// Simple parallel printer simulator, prints to serial...
|
||||||
// version could be made with a shiftin register ....
|
// version could be made with a shiftin register ....
|
||||||
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
uint8_t STROBE = 2;
|
|
||||||
uint8_t BUSY = 13;
|
uint8_t PIN_STROBE = 2;
|
||||||
uint8_t OOP = 10;
|
uint8_t PIN_BUSY = 13;
|
||||||
|
uint8_t PIN_OOP = 10;
|
||||||
uint8_t dataPins[] = { 3, 4, 5, 6, 7, 8, 9, 10 };
|
uint8_t dataPins[] = { 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
|
|
||||||
pinMode(STROBE, INPUT);
|
pinMode(PIN_STROBE, INPUT);
|
||||||
pinMode(OOP, OUTPUT);
|
pinMode(PIN_OOP, OUTPUT);
|
||||||
pinMode(BUSY, OUTPUT); // build in LED UNO.
|
pinMode(PIN_BUSY, OUTPUT); // build in LED UNO.
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++)
|
for (uint8_t i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
pinMode(dataPins[i], INPUT);
|
pinMode(dataPins[i], INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
digitalWrite(OOP, HIGH); // HIGH is OK
|
digitalWrite(PIN_OOP, HIGH); // HIGH is OK
|
||||||
digitalWrite(BUSY, HIGH); // BUSY during startup
|
digitalWrite(PIN_BUSY, HIGH); // BUSY during startup
|
||||||
|
|
||||||
delay(5000); // do startup thingies.
|
delay(5000); // do startup thingies.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
handleInput();
|
handleInput();
|
||||||
// do other things here
|
// do other things here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void handleInput()
|
void handleInput()
|
||||||
{
|
{
|
||||||
uint8_t x = 0;
|
uint8_t x = 0;
|
||||||
|
|
||||||
digitalWrite(BUSY, LOW);
|
digitalWrite(PIN_BUSY, LOW);
|
||||||
while (digitalRead(STROBE) == HIGH) yield();
|
while (digitalRead(PIN_STROBE) == HIGH) yield();
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
x <<= 1;
|
x <<= 1;
|
||||||
if (digitalRead(dataPins[i]) == HIGH) x += 1;
|
if (digitalRead(dataPins[i]) == HIGH) x += 1;
|
||||||
}
|
}
|
||||||
while (digitalRead(STROBE) == LOW) yield();
|
while (digitalRead(PIN_STROBE) == LOW) yield();
|
||||||
digitalWrite(BUSY, HIGH);
|
digitalWrite(PIN_BUSY, HIGH);
|
||||||
|
|
||||||
// process data
|
// process data
|
||||||
Serial.write(x);
|
Serial.write(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
ParallelPrinter PP;
|
ParallelPrinter PP;
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
@ -23,6 +24,7 @@ void setup()
|
||||||
PP.begin();
|
PP.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (Serial.available()) PP.write(Serial.read());
|
if (Serial.available()) PP.write(Serial.read());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Syntax Coloring Map For ParallelPrinter
|
# Syntax Colouring Map For ParallelPrinter
|
||||||
|
|
||||||
# Datatypes (KEYWORD1)
|
# Data types (KEYWORD1)
|
||||||
ParallelPrinter KEYWORD1
|
ParallelPrinter KEYWORD1
|
||||||
|
|
||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
|
@ -27,6 +27,7 @@ formfeed KEYWORD2
|
||||||
linefeed KEYWORD2
|
linefeed KEYWORD2
|
||||||
|
|
||||||
isOutOfPaper KEYWORD2
|
isOutOfPaper KEYWORD2
|
||||||
|
isBusy KEYWORD2
|
||||||
setStrobeDelay KEYWORD2
|
setStrobeDelay KEYWORD2
|
||||||
getStrobeDelay KEYWORD2
|
getStrobeDelay KEYWORD2
|
||||||
|
|
||||||
|
|
|
@ -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.2",
|
"version": "0.2.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*"
|
"platforms": "*"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name=ParallelPrinter
|
name=ParallelPrinter
|
||||||
version=0.2.2
|
version=0.2.3
|
||||||
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.
|
||||||
|
|
Loading…
Reference in New Issue