{"id":20147339,"url":"https://github.com/gdsports/usbprinter_uhs2","last_synced_at":"2025-04-09T19:35:50.978Z","repository":{"id":130716433,"uuid":"194355922","full_name":"gdsports/USBPrinter_uhs2","owner":"gdsports","description":"USB Printer driver for USB Host Shield 2.0 Library","archived":false,"fork":false,"pushed_at":"2019-07-11T08:03:24.000Z","size":13,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T21:35:42.125Z","etag":null,"topics":["arduino","esc-pos","point-of-sale","pos","printer","receipt-printer","thermal-printer","usb","usb-host"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdsports.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-29T02:32:36.000Z","updated_at":"2025-03-11T16:06:01.000Z","dependencies_parsed_at":"2023-06-01T13:00:24.636Z","dependency_job_id":null,"html_url":"https://github.com/gdsports/USBPrinter_uhs2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2FUSBPrinter_uhs2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2FUSBPrinter_uhs2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2FUSBPrinter_uhs2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2FUSBPrinter_uhs2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdsports","download_url":"https://codeload.github.com/gdsports/USBPrinter_uhs2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098369,"owners_count":21047425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","esc-pos","point-of-sale","pos","printer","receipt-printer","thermal-printer","usb","usb-host"],"created_at":"2024-11-13T22:28:40.036Z","updated_at":"2025-04-09T19:35:50.954Z","avatar_url":"https://github.com/gdsports.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USBPrinter driver for USB Host Shield 2.0 Library\n\nThis driver is designed to work for small USB thermal printers. Do not expect\nthis to work for laser or inkjet printers because they require complex software\nsupport.\n\nThis has been tested with USB Host Shield Library 2.0 with one required patch\nand the ESC POS Printer library on a Uno.\n\nhttps://github.com/felis/USB_Host_Shield_2.0\n\nRequired patch not merged yet\n\nhttps://github.com/felis/USB_Host_Shield_2.0/pull/473\n\nhttps://github.com/gdsports/ESC_POS_Printer\n\nSample program that prints \"Hello Printer\" in large letters.\n\n```\n#include \"USBPrinter.h\"         // https://github.com/gdsports/USBPrinter_uhs2\n#include \"ESC_POS_Printer.h\"    // https://github.com/gdsports/ESC_POS_Printer\n\nclass PrinterOper : public USBPrinterAsyncOper\n{\n  public:\n    uint8_t OnInit(USBPrinter *pPrinter);\n};\n\nuint8_t PrinterOper::OnInit(USBPrinter *pPrinter)\n{\n  Serial.println(F(\"USB Printer OnInit\"));\n  Serial.print(F(\"Bidirectional=\"));\n  Serial.println(pPrinter-\u003eisBidirectional());\n  return 0;\n}\n\nUSB myusb;\nPrinterOper AsyncOper;\nUSBPrinter uprinter(\u0026myusb, \u0026AsyncOper);\nESC_POS_Printer printer(\u0026uprinter);\n\nvoid setup() {\n  Serial.begin(115200);\n  while (!Serial \u0026\u0026 millis() \u003c 3000) delay(1);\n\n  if (myusb.Init()) {\n    Serial.println(F(\"USB host failed to initialize\"));\n    while (1) delay(1);\n  }\n\n  Serial.println(F(\"USB Host init OK\"));\n}\n\nvoid loop() {\n  myusb.Task();\n\n  // Make sure USB printer found and ready\n  if (uprinter.isReady()) {\n    printer.begin();\n    Serial.println(F(\"Init ESC POS printer\"));\n\n    printer.setSize('L');   // L for large\n    printer.println(F(\"Hello Printer\"));\n    printer.feed(2);\n\n    // Do this one time to avoid wasting paper\n    while (1) delay(1);\n  }\n}\n```\n\nThe ESC POS library send printer ESC/POS commands for different font sizes,\ngraphics mode, etc. It is based on the Adafruit Thermal printer library but\nmodified to work with USB thermal receipt printers. Note different thermal\nprinters from even if from the same manufacturers implement different subsets\nof the ESC POS commands. You will have to find the ones that work on your\nprinter.\n\n## Related\n\nThe following driver works on SAMD board with USB OTG ports such as Arduino Zero and MKR family.\n\nhttps://github.com/gdsports/USBPrinter_uhls\n\nThe following driver works on Teensy 3.6 boards.\n\nhttps://github.com/gdsports/USBPrinter_t36\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsports%2Fusbprinter_uhs2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdsports%2Fusbprinter_uhs2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsports%2Fusbprinter_uhs2/lists"}