forked from RobTillaart/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParPrinter.cpp
More file actions
56 lines (48 loc) · 1.06 KB
/
Copy pathParPrinter.cpp
File metadata and controls
56 lines (48 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// FILE: parprinter.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: parallel printer class that implements the Print interface
// DATE: 2013-09-30
// URL:
//
// Released to the public domain
//
#include "ParPrinter.h"
ParPrinter::ParPrinter()
{
// define pins
for (uint8_t i = 0; i < 8; i++)
{
pin[i] = 2+i;
}
}
void ParPrinter::begin()
{
pinMode(BUSY, INPUT);
pinMode(STROBE, OUTPUT);
for (uint8_t i = 0; i < 8; i++)
{
pinMode(pin[i], OUTPUT);
}
}
// write() must implement the virtual write of the Print class
size_t ParPrinter::write(uint8_t data)
{
while(digitalRead(BUSY) == HIGH);
for (uint8_t i = 0; i < 8; i++)
{
digitalWrite(pin[i], bitRead(data, i) ); // direct port access will be faster
}
digitalWrite(STROBE, LOW);
delay(2); // main time consuming part, so max 500chars/second = 10 lines.
digitalWrite(STROBE, HIGH);
while (digitalRead(BUSY) == HIGH);
return 1;
}
/*
derive CLass HP: ParPrinter
{
}
*/
// -- END OF FILE --