mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.2.4 ParallelPrinter
This commit is contained in:
parent
804daaa289
commit
c6321536a7
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2021 Rob Tillaart
|
||||
Copyright (c) 2013-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: ParallelPrinter.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.3
|
||||
// VERSION: 0.2.4
|
||||
// PURPOSE: parallel printer class that implements the Print interface
|
||||
// DATE: 2013-09-30
|
||||
// URL: https://github.com/RobTillaart/ParallelPrinter
|
||||
@ -13,6 +13,7 @@
|
||||
// 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();
|
||||
// 0.2.4 2021-12-23 update library.json, license, minor edits
|
||||
|
||||
|
||||
#include "ParallelPrinter.h"
|
||||
@ -34,7 +35,7 @@ ParallelPrinter::ParallelPrinter(uint8_t STROBE, uint8_t BUSY, uint8_t OOP, uint
|
||||
pinMode(_oopPin, INPUT);
|
||||
pinMode(_busyPin, INPUT);
|
||||
pinMode(_strobePin, OUTPUT);
|
||||
|
||||
|
||||
// DATA LINES
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
@ -143,7 +144,7 @@ void ParallelPrinter::sendByte(uint8_t c)
|
||||
// BLOCK WHEN OUT OF PAPER TODO
|
||||
// while (digitalRead(_oopPin) == LOW) yield();
|
||||
// indication in hardware?
|
||||
|
||||
|
||||
Serial.write(c); // debugging
|
||||
return;
|
||||
|
||||
@ -168,3 +169,4 @@ void ParallelPrinter::sendByte(uint8_t c)
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: ParallelPrinter.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.3
|
||||
// VERSION: 0.2.4
|
||||
// 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.3"))
|
||||
#define PARALLELPRINTER_VERSION (F("0.2.4"))
|
||||
|
||||
#define FORMFEED 12
|
||||
#define LINEFEED 10
|
||||
#define FORMFEED 12
|
||||
#define LINEFEED 10
|
||||
|
||||
|
||||
class ParallelPrinter: public Print
|
||||
@ -36,7 +36,7 @@ public:
|
||||
uint8_t getLineNumber() { return _lineNr; };
|
||||
uint8_t getPageNumber() { return _pageNr; };
|
||||
uint8_t getPosition() { return _pos; };
|
||||
|
||||
|
||||
// n = 2,4,6,8
|
||||
void setTabSize(uint8_t n) { _tabSize = n; };
|
||||
uint8_t getTabSize() { return _tabSize; };
|
||||
@ -54,6 +54,7 @@ public:
|
||||
void setStrobeDelay(uint16_t n = 2000) { _strobeDelay = n; };
|
||||
uint16_t getStrobeDelay() { return _strobeDelay; };
|
||||
|
||||
|
||||
private:
|
||||
// COMMUNICATION
|
||||
uint8_t _strobePin; // inform printer new data on the line.
|
||||
@ -72,10 +73,11 @@ private:
|
||||
uint8_t _pageNr;
|
||||
uint8_t _tabSize;
|
||||
uint8_t _lineFeed;
|
||||
|
||||
|
||||
bool _printLineNumber;
|
||||
uint16_t _strobeDelay;
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -86,13 +86,18 @@ https://en.wikipedia.org/wiki/Parallel_port#Centronics
|
||||
|
||||
- update documentation
|
||||
- extend unit tests?
|
||||
- test more
|
||||
- extend simulator sketch
|
||||
- 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
|
||||
- special modes e.g. bold italic underline.
|
||||
- **write(uint8_t \* buf, uint8_t length)** should be added
|
||||
- might not really add to performance..
|
||||
- fix blocking TODO in sendByte
|
||||
|
||||
|
||||
|
||||
## Operation
|
||||
|
||||
See examples
|
||||
See examples.
|
||||
|
@ -1,11 +1,9 @@
|
||||
//
|
||||
// FILE: ParPrinter_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2020-05-26
|
||||
// (c) : MIT
|
||||
//
|
||||
|
||||
|
||||
#include "ParallelPrinter.h"
|
||||
|
||||
@ -59,7 +57,7 @@ void test3()
|
||||
for (int i = 0; i < 100; i++) PP.print("Hello World ");
|
||||
PP.printLineNumber(false);
|
||||
for (int i = 0; i < 100; i++) PP.print("Hello World ");
|
||||
|
||||
|
||||
PP.setTabSize(4);
|
||||
PP.printLineNumber(true);
|
||||
for (int i = 0; i < 100; i++) PP.print("Hello World ");
|
||||
@ -83,3 +81,4 @@ void test3()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
//
|
||||
// FILE: PrinterSimulator.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2020-06-24
|
||||
// (c) : MIT
|
||||
|
||||
|
||||
//
|
||||
// Simple parallel printer simulator, prints to serial...
|
||||
// version could be made with a shiftin register ....
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
//
|
||||
// FILE: Serial2ParPrinter.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: demo
|
||||
// DATE: 2020-05-26
|
||||
// (c) : MIT
|
||||
//
|
||||
|
||||
|
||||
#include "ParallelPrinter.h"
|
||||
|
||||
@ -32,3 +30,4 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/ParallelPrinter.git"
|
||||
},
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "ParallelPrinter.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=ParallelPrinter
|
||||
version=0.2.3
|
||||
version=0.2.4
|
||||
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.
|
||||
|
@ -38,33 +38,34 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "PARALLELPRINTER_VERSION: %s\n", (char *) PARALLELPRINTER_VERSION);
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
unittest(test_new_operator)
|
||||
{
|
||||
assertEqualINF(exp(800));
|
||||
assertEqualINF(0.0/0.0);
|
||||
assertEqualINF(42);
|
||||
|
||||
|
||||
assertEqualNAN(INFINITY - INFINITY);
|
||||
assertEqualNAN(0.0/0.0);
|
||||
assertEqualNAN(42);
|
||||
}
|
||||
*/
|
||||
|
||||
// minimal
|
||||
|
||||
// minimal
|
||||
unittest(test_constructor_basic)
|
||||
{
|
||||
fprintf(stderr, "VERSION: %s\n", PARALLELPRINTER_VERSION);
|
||||
|
||||
ParallelPrinter PP;
|
||||
|
||||
|
||||
PP.begin();
|
||||
assertEqual(80, PP.getLineLength());
|
||||
assertEqual(60, PP.getPageLength());
|
||||
@ -86,7 +87,7 @@ unittest(test_constructor_basic)
|
||||
// fprintf(stderr, "%d\n", PP.getLineNumber());
|
||||
// fprintf(stderr, "%d\n", PP.getPageNumber());
|
||||
// fprintf(stderr, "%d\n", PP.getPosition());
|
||||
|
||||
|
||||
assertEqual(3, PP.getLineNumber()); // 0 based
|
||||
assertEqual(4, PP.getPageNumber()); // 0 based
|
||||
assertEqual(11, PP.getPosition()); // 0 based
|
||||
@ -108,7 +109,7 @@ unittest(test_tabs_linefeed)
|
||||
fprintf(stderr, "0\t");
|
||||
PP.setLineFeed(0);
|
||||
assertEqual(1, PP.getLineFeed()); // minimum LF size
|
||||
|
||||
|
||||
for (int LF = 1; LF < 4; LF +=2 )
|
||||
{
|
||||
fprintf(stderr, "%d\t", LF);
|
||||
@ -128,11 +129,12 @@ unittest(test_OutOfPaper)
|
||||
// TODO
|
||||
// state->digitalPin[12] = 0;
|
||||
// assertFalse(PP.isOutOfPaper());
|
||||
//
|
||||
//
|
||||
// state->digitalPin[12] = 1;
|
||||
// assertTrue(PP.isOutOfPaper());
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
Loading…
Reference in New Issue
Block a user