fix
This commit is contained in:
parent
3af4096084
commit
10fa7a0d18
|
@ -38,22 +38,29 @@ ParallelPrinter::ParallelPrinter(uint8_t STROBE, uint8_t BUSY, uint8_t OOP, uint
|
|||
_pin[i] = p[i];
|
||||
pinMode(_pin[i], OUTPUT);
|
||||
}
|
||||
setLineLength(80);
|
||||
setPageLength(60);
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void ParallelPrinter::begin(uint8_t lineLength, uint8_t pageLength)
|
||||
{
|
||||
_pos = 0;
|
||||
_lineNr = 0;
|
||||
_pageNr = 0;
|
||||
_tabSize = 2;
|
||||
_lineFeed = 1;
|
||||
_strobeDelay = 2000;
|
||||
_printLineNumber = false;
|
||||
setLineLength(lineLength);
|
||||
setPageLength(pageLength);
|
||||
reset();
|
||||
}
|
||||
|
||||
// page size parameters.
|
||||
_lineLength = lineLength;
|
||||
_pageLength = pageLength;
|
||||
|
||||
void ParallelPrinter::reset()
|
||||
{
|
||||
_pos = 0;
|
||||
_lineNr = 0;
|
||||
_pageNr = 0;
|
||||
_tabSize = 2;
|
||||
_lineFeed = 1;
|
||||
_strobeDelay = 2000;
|
||||
_printLineNumber = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,10 +21,15 @@ public:
|
|||
ParallelPrinter(uint8_t STROBE, uint8_t BUSY, uint8_t OOP, uint8_t * dataPins );
|
||||
|
||||
void begin(uint8_t lineLength = 80, uint8_t pageLength = 60);
|
||||
void reset();
|
||||
size_t write(uint8_t c);
|
||||
|
||||
void setLineLength(uint8_t lineLength = 80) { _lineLength = lineLength; };
|
||||
uint8_t getLineLength() { return _lineLength; };
|
||||
|
||||
void setPageLength(uint8_t pageLength = 60) { _pageLength = pageLength; };
|
||||
uint8_t getPageLength() { return _pageLength; };
|
||||
|
||||
uint8_t getLineNumber() { return _lineNr; };
|
||||
uint8_t getPageNumber() { return _pageNr; };
|
||||
uint8_t getPosition() { return _pageNr; };
|
||||
|
|
|
@ -69,14 +69,15 @@ unittest(test_constructor_basic)
|
|||
fprintf(stderr, "VERSION: %s\n", PARALLELPRINTER_VERSION);
|
||||
|
||||
ParallelPrinter PP;
|
||||
|
||||
assertEqual(0, PP.getLineLength());
|
||||
assertEqual(0, PP.getPageLength());
|
||||
|
||||
PP.begin();
|
||||
assertEqual(80, PP.getLineLength());
|
||||
assertEqual(60, PP.getPageLength());
|
||||
assertEqual(0, PP.getLineNumber());
|
||||
assertEqual(0, PP.getPageNumber());
|
||||
assertEqual(0, PP.getPosition());
|
||||
assertEqual(0, PP.getTabSize());
|
||||
assertEqual(0, PP.getLineFeed());
|
||||
assertEqual(2, PP.getTabSize());
|
||||
assertEqual(1, PP.getLineFeed());
|
||||
|
||||
PP.formfeed();
|
||||
PP.println("This is a test");
|
||||
|
@ -89,18 +90,25 @@ unittest(test_constructor_basic)
|
|||
|
||||
unittest(test_tabs_linefeed)
|
||||
{
|
||||
fprintf(stderr, "VERSION: %s\n", PARALLELPRINTER_VERSION);
|
||||
|
||||
ParallelPrinter PP;
|
||||
|
||||
for (int tab = 0; tab < 10; tab +=2 )
|
||||
fprintf(stderr, "0\t");
|
||||
PP.setTabSize(0);
|
||||
assertEqual(2, PP.getTabSize()); // minimum tab size
|
||||
|
||||
for (int tab = 2; tab < 10; tab +=2 )
|
||||
{
|
||||
fprintf(stderr, "%d\t", tab);
|
||||
PP.setTabSize(tab);
|
||||
assertEqual(tab, PP.getTabSize());
|
||||
}
|
||||
|
||||
for (int LF = 0; LF < 10; LF +=2 )
|
||||
|
||||
fprintf(stderr, "0\t");
|
||||
PP.setLineFeed(0);
|
||||
assertEqual(1, PP.getLineFeed()); // minimum LF size
|
||||
|
||||
for (int LF = 0; LF < 4; LF +=2 )
|
||||
{
|
||||
fprintf(stderr, "%d\t", LF);
|
||||
PP.setLineFeed(LF);
|
||||
|
|
Reference in New Issue