https://github.com/gdsports/usbprinter_uhs2
USB Printer driver for USB Host Shield 2.0 Library
https://github.com/gdsports/usbprinter_uhs2
arduino esc-pos point-of-sale pos printer receipt-printer thermal-printer usb usb-host
Last synced: about 1 month ago
JSON representation
USB Printer driver for USB Host Shield 2.0 Library
- Host: GitHub
- URL: https://github.com/gdsports/usbprinter_uhs2
- Owner: gdsports
- License: mit
- Created: 2019-06-29T02:32:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T08:03:24.000Z (almost 6 years ago)
- Last Synced: 2025-03-23T21:35:42.125Z (about 2 months ago)
- Topics: arduino, esc-pos, point-of-sale, pos, printer, receipt-printer, thermal-printer, usb, usb-host
- Language: C++
- Size: 12.7 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# USBPrinter driver for USB Host Shield 2.0 Library
This driver is designed to work for small USB thermal printers. Do not expect
this to work for laser or inkjet printers because they require complex software
support.This has been tested with USB Host Shield Library 2.0 with one required patch
and the ESC POS Printer library on a Uno.https://github.com/felis/USB_Host_Shield_2.0
Required patch not merged yet
https://github.com/felis/USB_Host_Shield_2.0/pull/473
https://github.com/gdsports/ESC_POS_Printer
Sample program that prints "Hello Printer" in large letters.
```
#include "USBPrinter.h" // https://github.com/gdsports/USBPrinter_uhs2
#include "ESC_POS_Printer.h" // https://github.com/gdsports/ESC_POS_Printerclass PrinterOper : public USBPrinterAsyncOper
{
public:
uint8_t OnInit(USBPrinter *pPrinter);
};uint8_t PrinterOper::OnInit(USBPrinter *pPrinter)
{
Serial.println(F("USB Printer OnInit"));
Serial.print(F("Bidirectional="));
Serial.println(pPrinter->isBidirectional());
return 0;
}USB myusb;
PrinterOper AsyncOper;
USBPrinter uprinter(&myusb, &AsyncOper);
ESC_POS_Printer printer(&uprinter);void setup() {
Serial.begin(115200);
while (!Serial && millis() < 3000) delay(1);if (myusb.Init()) {
Serial.println(F("USB host failed to initialize"));
while (1) delay(1);
}Serial.println(F("USB Host init OK"));
}void loop() {
myusb.Task();// Make sure USB printer found and ready
if (uprinter.isReady()) {
printer.begin();
Serial.println(F("Init ESC POS printer"));printer.setSize('L'); // L for large
printer.println(F("Hello Printer"));
printer.feed(2);// Do this one time to avoid wasting paper
while (1) delay(1);
}
}
```The ESC POS library send printer ESC/POS commands for different font sizes,
graphics mode, etc. It is based on the Adafruit Thermal printer library but
modified to work with USB thermal receipt printers. Note different thermal
printers from even if from the same manufacturers implement different subsets
of the ESC POS commands. You will have to find the ones that work on your
printer.## Related
The following driver works on SAMD board with USB OTG ports such as Arduino Zero and MKR family.
https://github.com/gdsports/USBPrinter_uhls
The following driver works on Teensy 3.6 boards.
https://github.com/gdsports/USBPrinter_t36